Add animation quality

This commit is contained in:
Miloslav Ciz 2024-09-01 16:10:15 +02:00
parent 920ddc4981
commit 56904cabab
3 changed files with 21 additions and 8 deletions

View file

@ -21,6 +21,8 @@
#define LCR_MAP_SIZE_BLOCKS 64 #define LCR_MAP_SIZE_BLOCKS 64
#define LCR_ANIMATE_CAR (LCR_SETTING_CAR_ANIMATION_SUBDIVIDE != 0)
/** Maximum number of triangles of a block shape. */ /** Maximum number of triangles of a block shape. */
#define LCR_MAP_BLOCK_SHAPE_MAX_BYTES 80 #define LCR_MAP_BLOCK_SHAPE_MAX_BYTES 80

View file

@ -71,7 +71,7 @@ struct
int triUVs[6]; int triUVs[6];
uint8_t texSubsampleCount; uint8_t texSubsampleCount;
#if LCR_SETTING_ANIMATE_CAR #if LCR_ANIMATE_CAR
S3L_Unit wheelRotation; S3L_Unit wheelRotation;
S3L_Unit wheelTurn; S3L_Unit wheelTurn;
S3L_Unit wheelRotationCenters[4]; S3L_Unit wheelRotationCenters[4];
@ -735,7 +735,7 @@ uint8_t LCR_rendererInit(void)
LCR_renderer.carModel = LCR_renderer.models + 8; LCR_renderer.carModel = LCR_renderer.models + 8;
S3L_model3DInit( S3L_model3DInit(
#if LCR_SETTING_ANIMATE_CAR #if LCR_ANIMATE_CAR
LCR_renderer.animatedCarVerts LCR_renderer.animatedCarVerts
#else #else
LCR_carVertices LCR_carVertices
@ -744,7 +744,7 @@ uint8_t LCR_rendererInit(void)
LCR_carTriangles,LCR_CAR_TRIANGLE_COUNT, LCR_carTriangles,LCR_CAR_TRIANGLE_COUNT,
LCR_renderer.carModel); LCR_renderer.carModel);
#if LCR_SETTING_ANIMATE_CAR #if LCR_ANIMATE_CAR
for (int i = 0; i < LCR_CAR_VERTEX_COUNT * 3; ++i) for (int i = 0; i < LCR_CAR_VERTEX_COUNT * 3; ++i)
LCR_renderer.animatedCarVerts[i] = LCR_carVertices[i]; LCR_renderer.animatedCarVerts[i] = LCR_carVertices[i];
@ -1209,9 +1209,12 @@ void LCR_drawLevelFloor(void)
#endif #endif
} }
#if LCR_ANIMATE_CAR
void _LCR_rendererAnimateCar(void) void _LCR_rendererAnimateCar(void)
{ {
for (int i = 0; i < LCR_CAR_VERTEX_COUNT; ++i) for (int i = LCR_renderer.frame % LCR_SETTING_CAR_ANIMATION_SUBDIVIDE;
i < LCR_CAR_VERTEX_COUNT; i += LCR_SETTING_CAR_ANIMATION_SUBDIVIDE)
{
if (LCR_carVertexTypes[i] > 0) if (LCR_carVertexTypes[i] > 0)
{ {
S3L_Unit s = S3L_sin(-1 * LCR_renderer.wheelRotation), S3L_Unit s = S3L_sin(-1 * LCR_renderer.wheelRotation),
@ -1253,6 +1256,8 @@ void _LCR_rendererAnimateCar(void)
} }
} }
} }
}
#endif
void LCR_rendererDraw(void) void LCR_rendererDraw(void)
{ {
@ -1261,14 +1266,16 @@ void LCR_rendererDraw(void)
_LCR_rendererLoadMapChunks(); // TODO: call only once in a while? _LCR_rendererLoadMapChunks(); // TODO: call only once in a while?
LCR_rendererDrawSky(2, LCR_rendererDrawSky(1,
LCR_renderer.scene.camera.transform.rotation.y, LCR_renderer.scene.camera.transform.rotation.y,
-4 * LCR_renderer.scene.camera.transform.rotation.x); -4 * LCR_renderer.scene.camera.transform.rotation.x);
#if LCR_ANIMATE_CAR
LCR_renderer.wheelRotation += 5; LCR_renderer.wheelRotation += 5;
LCR_renderer.wheelTurn = S3L_sin(LCR_renderer.frame * 4); LCR_renderer.wheelTurn = S3L_sin(LCR_renderer.frame * 4);
_LCR_rendererAnimateCar(); _LCR_rendererAnimateCar();
#endif
LCR_drawLevelFloor(); LCR_drawLevelFloor();
LCR_rendererDrawLOD(); LCR_rendererDrawLOD();

View file

@ -92,8 +92,12 @@
#define LCR_SETTING_FLOOR_PARTICLE_SIZE 32 #define LCR_SETTING_FLOOR_PARTICLE_SIZE 32
#endif #endif
#ifndef LCR_SETTING_ANIMATE_CAR #ifndef LCR_SETTING_CAR_ANIMATION_SUBDIVIDE
#define LCR_SETTING_ANIMATE_CAR 1 /** How many frames will be used to complete whole animation of the car model.
0 turns off car animation completely (may be faster and smaller), 1 turns
on highest quality animation, higher values lower animation quality and
may increase performance. */
#define LCR_SETTING_CAR_ANIMATION_SUBDIVIDE 4
#endif #endif
#endif // guard #endif // guard