Run cppcheck

This commit is contained in:
Miloslav Ciz 2025-06-24 21:12:01 +02:00
parent bc55e84d5b
commit d57a07edb8
7 changed files with 25 additions and 47 deletions

View file

@ -11,15 +11,16 @@
Some comments:
- The module uses small3dlib, a tiny software rasterization library. This
module knows nothing about I/O (windows, canvases, ...), it just say where
to draw pixels and what colors they should have.
- The map 3D model is divided into 4x4x4 chunks, i.e. 64 in total, out of
which only 8 are loaded at any time, depending on where the camera is and
where it is looking. This is to save resources, we don't draw the far away
chunks or those behind the camera.
module knows nothing about I/O (windows, canvases, ...), it just says where
to draw pixels and what colors they should be.
- The map 3D model is divided into chunks 4 times in each dimension, i.e.
there are 64 chunks in total, out of which only 8 are loaded at any time,
depending on where the camera is located and where it is looking. This is to
save CPU time, we don't draw the far away chunks or those behind the camera.
- Extremely simple LOD of far away chunks is implemented: we keep an 8x8x8
bit array of where there is empty space and where there is "something", then
for far away areas with "something" we just draw some 2D rectangles.
for far away areas with "something" we just draw some 2D rectangles. This
mostly helps orientation in areas where there are no 3D models nearby.
- RENDERING IS THE BOTTLENECK OF PERFORMANCE, it takes even much more time
than physics simulation, i.e. care should be taken to make code here very
optimized, namely the _LCR_pixelFunc3D function, as it is called for every
@ -112,7 +113,7 @@ struct
S3L_Model3D models[LCR_RENDERER_MODEL_COUNT];
uint_fast16_t pixelColor; /**< Holds pixel color for _LCR_pixelFunc3D. This
is needed is texture subsampling is on. */
is needed when texture subsampling is on. */
uint32_t frame;
uint8_t loadedChunks[8]; ///< Numbers of loaded map chunks.
@ -523,7 +524,7 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
for (int i = 0; i < 6; ++i)
{
LCR_renderer.triUVs[i] = ((
(v[i / 2][i % 2 ? 1 : (type == 1 ? 2 : 0)]) *
(v[i / 2][(i % 2) ? 1 : (type == 1 ? 2 : 0)]) *
LCR_IMAGE_SIZE) / LCR_RENDERER_UNIT);
if (i % 2)
@ -1597,7 +1598,7 @@ void LCR_rendererDrawSky(int sky, S3L_Unit offsetH, S3L_Unit offsetV)
for (int ix = 0; ix < 2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
ix += LCR_SETTING_SKY_SIZE)
{
unsigned int color = LCR_getNextImagePixel();
uint_fast16_t color = LCR_getNextImagePixel();
unsigned long startIndex = pixelIndex;
for (int k = 0; k < LCR_SETTING_SKY_SIZE; ++k)
@ -1983,7 +1984,7 @@ void LCR_rendererBlitImage(uint8_t index, unsigned int x, unsigned int y,
for (int l = 0; l < LCR_IMAGE_SIZE; ++l)
{
uint16_t color = LCR_getNextImagePixel();
uint_fast16_t color = LCR_getNextImagePixel();
if (color != transparentColor)
LCR_gameDrawPixel(i,color);