Average rotations

This commit is contained in:
Miloslav Ciz 2024-09-22 20:19:43 +02:00
parent b181256e58
commit c0aa81e79e
2 changed files with 49 additions and 32 deletions

View file

@ -98,34 +98,12 @@ 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),3);
/*
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),3);
/*
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_pixelFunc3D(S3L_PixelInfo *pixel)
@ -1184,7 +1162,7 @@ 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_rendererSmoothRot(S3L_Unit angleOld, S3L_Unit angleNew,
unsigned int amount)
{
/* We have to do the following angle correction -- even if keep angles in
@ -1428,10 +1406,10 @@ void LCR_rendererCameraFollow(void)
LCR_renderer.scene.camera.transform.translation.y /= 2;
LCR_renderer.scene.camera.transform.translation.z /= 2;
LCR_renderer.scene.camera.transform.rotation.x = _LCR_smoothRotation(
LCR_renderer.scene.camera.transform.rotation.x = _LCR_rendererSmoothRot(
transPrev.rotation.x,LCR_renderer.scene.camera.transform.rotation.x,8);
LCR_renderer.scene.camera.transform.rotation.y = _LCR_smoothRotation(
LCR_renderer.scene.camera.transform.rotation.y = _LCR_rendererSmoothRot(
transPrev.rotation.y,LCR_renderer.scene.camera.transform.rotation.y,6);
#endif
}