Fix another culling BS

This commit is contained in:
Miloslav Ciz 2025-03-29 17:24:26 +01:00
parent 252bf57e41
commit 8fe4f6b6aa
2 changed files with 64 additions and 17 deletions

View file

@ -519,8 +519,8 @@ S3L_Index _LCR_rendererAddMapVert(S3L_Unit x, S3L_Unit y, S3L_Unit z)
return LCR_renderer.mapModel.vertexCount - 1;
}
LCR_LOG0("couldn't add map vertex");
return 0;
LCR_LOG1("couldn't add vertex");
return 0;
}
void _LCR_rendererAddMapTri(S3L_Index a, S3L_Index b, S3L_Index c, uint8_t mat)
@ -538,6 +538,10 @@ void _LCR_rendererAddMapTri(S3L_Index a, S3L_Index b, S3L_Index c, uint8_t mat)
LCR_renderer.mapModel.triangleCount++;
}
else
{
LCR_LOG1("couldn't add triangle");
}
}
void _LCR_rendererSwapMapTris(unsigned int index1, unsigned int index2)
@ -894,8 +898,7 @@ uint8_t _LCR_buildMapModel(void)
for (int j = 0; j < LCR_currentMap.blockCount; ++j)
{
if (((j + 1) % LCR_SETTING_CULLING_PERIOD == 0) ||
(LCR_renderer.mapModel.triangleCount == LCR_SETTING_MAX_MAP_TRIANGLES))
if (((j + 1) % LCR_SETTING_CULLING_PERIOD == 0))
_LCR_cullHiddenMapTris();
S3L_Unit originOffset = -1 * LCR_MAP_SIZE_BLOCKS / 2 * LCR_RENDERER_UNIT;
@ -947,6 +950,10 @@ uint8_t _LCR_buildMapModel(void)
vi++;
else // 3 indices => create and add triangle
{
if (LCR_renderer.mapModel.triangleCount >=
LCR_SETTING_MAX_MAP_TRIANGLES)
_LCR_cullHiddenMapTris();
// don't add triangles completely at the boundary of the map
if (!edgeBits)
{