Do some tuning
This commit is contained in:
parent
4754b33dfe
commit
b6d28c2886
4 changed files with 70 additions and 16 deletions
37
renderer.h
37
renderer.h
|
@ -98,12 +98,32 @@ void LCR_rendererSetCarTransform(LCR_GameUnit position[3],
|
|||
LCR_renderer.carModel->transform.translation.z =
|
||||
(position[2] * LCR_RENDERER_UNIT) / LCR_GAME_UNIT;
|
||||
|
||||
// TODO: make a separate function that does the smoothing (updateCarTransform)
|
||||
LCR_renderer.carModel->transform.rotation.x =
|
||||
_LCR_smoothRotation(LCR_renderer.carModel->transform.rotation.x,
|
||||
S3L_wrap((rotation[0] * S3L_F) / LCR_GAME_UNIT,S3L_F),1);
|
||||
|
||||
|
||||
LCR_renderer.carModel->transform.rotation.y = S3L_wrap((rotation[1] *
|
||||
S3L_F) / LCR_GAME_UNIT,S3L_F); // don't smooth for faster reaction?
|
||||
/*
|
||||
LCR_renderer.carModel->transform.rotation.y =
|
||||
_LCR_smoothRotation(LCR_renderer.carModel->transform.rotation.y,
|
||||
S3L_wrap((rotation[1] * S3L_F) / LCR_GAME_UNIT,S3L_F),1);
|
||||
*/
|
||||
|
||||
LCR_renderer.carModel->transform.rotation.z =
|
||||
_LCR_smoothRotation(LCR_renderer.carModel->transform.rotation.z,
|
||||
S3L_wrap((rotation[2] * S3L_F) / LCR_GAME_UNIT,S3L_F),1);
|
||||
|
||||
/*
|
||||
LCR_renderer.carModel->transform.rotation.x = S3L_wrap((rotation[0] *
|
||||
S3L_F) / LCR_GAME_UNIT,S3L_F);
|
||||
LCR_renderer.carModel->transform.rotation.y = S3L_wrap((rotation[1] *
|
||||
S3L_F) / LCR_GAME_UNIT,S3L_F);
|
||||
LCR_renderer.carModel->transform.rotation.z = S3L_wrap((rotation[2] *
|
||||
S3L_F) / LCR_GAME_UNIT,S3L_F);
|
||||
*/
|
||||
}
|
||||
|
||||
void _LCR_pixelFuncc3D(S3L_PixelInfo *pixel)
|
||||
|
@ -1166,7 +1186,8 @@ void _LCR_rendererLoadMapChunk(uint8_t chunk, int8_t x, int8_t y, int8_t z)
|
|||
/**
|
||||
Serves for smoothing out angle change, e.g. that of camera rotation.
|
||||
*/
|
||||
S3L_Unit _LCR_smoothRotation(S3L_Unit angleOld, S3L_Unit angleNew)
|
||||
S3L_Unit _LCR_smoothRotation(S3L_Unit angleOld, S3L_Unit angleNew,
|
||||
unsigned int amount)
|
||||
{
|
||||
S3L_Unit angleDiff = angleNew - angleOld;
|
||||
|
||||
|
@ -1181,10 +1202,15 @@ S3L_Unit _LCR_smoothRotation(S3L_Unit angleOld, S3L_Unit angleNew)
|
|||
angleDiff += (angleDiff > 0) ? -1 * (S3L_F / 2) : (S3L_F / 2);
|
||||
}
|
||||
|
||||
if (angleDiffAbs > S3L_F / 4) // angle too big, rotate immediately
|
||||
if (angleDiffAbs > (3 * S3L_F) / 8) // angle too big, rotate immediately
|
||||
return angleNew;
|
||||
|
||||
return angleOld + angleDiff / 4; // smoothly interpolate
|
||||
/*
|
||||
if (angleDiffAbs < S3L_F / 32)
|
||||
return angleOld;
|
||||
*/
|
||||
|
||||
return angleOld + (angleDiff >> amount); // smoothly interpolate
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1402,6 +1428,7 @@ void LCR_rendererCameraFollow(void)
|
|||
|
||||
#if LCR_SETTING_SMOOTH_ANIMATIONS
|
||||
// now average with previous transform to smooth the animation out:
|
||||
|
||||
S3L_vec3Add(&(LCR_renderer.scene.camera.transform.translation),
|
||||
transPrev.translation);
|
||||
|
||||
|
@ -1410,10 +1437,10 @@ void LCR_rendererCameraFollow(void)
|
|||
LCR_renderer.scene.camera.transform.translation.z /= 2;
|
||||
|
||||
LCR_renderer.scene.camera.transform.rotation.x = _LCR_smoothRotation(
|
||||
transPrev.rotation.x,LCR_renderer.scene.camera.transform.rotation.x);
|
||||
transPrev.rotation.x,LCR_renderer.scene.camera.transform.rotation.x,2);
|
||||
|
||||
LCR_renderer.scene.camera.transform.rotation.y = _LCR_smoothRotation(
|
||||
transPrev.rotation.y,LCR_renderer.scene.camera.transform.rotation.y);
|
||||
transPrev.rotation.y,LCR_renderer.scene.camera.transform.rotation.y,3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue