From 8fe4f6b6aa6029c9159401538e445dbe106af16b Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Sat, 29 Mar 2025 17:24:26 +0100 Subject: [PATCH] Fix another culling BS --- data | 66 +++++++++++++++++++++++++++++++++++++++++++----------- renderer.h | 15 +++++++++---- 2 files changed, 64 insertions(+), 17 deletions(-) diff --git a/data b/data index b5165f2..ae83fae 100644 --- a/data +++ b/data @@ -11,26 +11,38 @@ overall structure :-031 :fa19 :<031 :fa11 :<039I :fa11 :<621I- :f411 start roof :A&0hI| :f171 :v&7h| :^Z7hI :f211 :^@6hJ- :xZ1h :m371 big gate -:=500 :fA16 :f51k +:=500 :fz16 :f51k :=D01 :fp16 -:=X07 :f41f +:_X07 :-X02 :f41m :=X0u :f51q :=00y :f51p -:=00W :fW14 +:=30W :fT14 :=U0T :f414 +:=W0S :f414 :=W0X :=T0V :^a05- :ft11 -:^X1l :f411 :^Y1uI :f311 jump ramps +:F01 :f316 +:>00D :f513 + +:=b0W3 :fa14 + +:'W02L :f114 + +:=60I2 :f236 :^62IJ :f116 :^73IJ :f116 spectator seats +:|01z2L :f11e border left diff --git a/renderer.h b/renderer.h index bfaef08..787bd43 100644 --- a/renderer.h +++ b/renderer.h @@ -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) {