From be26ddae63f82e0ba01a7dfb802cdd9fd0d8db49 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Thu, 20 Feb 2025 17:25:53 +0100 Subject: [PATCH] Make culling a bit faster --- renderer.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/renderer.h b/renderer.h index ba66e41..d92bb18 100644 --- a/renderer.h +++ b/renderer.h @@ -590,24 +590,23 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, const S3L_Index *t2) vertices[0] = LCR_renderer.mapVerts + 3 * t1[0]; vertices[3] = LCR_renderer.mapVerts + 3 * t2[0]; - if ( // quick manhattan distance bailout condition - S3L_abs(vertices[0][0] - vertices[3][0]) + - S3L_abs(vertices[0][1] - vertices[3][1]) + - S3L_abs(vertices[0][2] - vertices[3][2]) > - (3 * LCR_RENDERER_UNIT)) + if ( // quick chebyshev distance bailout condition + S3L_abs(vertices[0][0] - vertices[3][0]) > LCR_RENDERER_UNIT || + S3L_abs(vertices[0][2] - vertices[3][2]) > LCR_RENDERER_UNIT || + S3L_abs(vertices[0][1] - vertices[3][1]) > (LCR_RENDERER_UNIT / 2)) return 0; + if ( // same vert indices? + (((t1[0] == t2[0]) || (t1[0] == t2[1]) || (t1[0] == t2[2]))) && + (((t1[1] == t2[0]) || (t1[1] == t2[1]) || (t1[1] == t2[2]))) && + (((t1[2] == t2[0]) || (t1[2] == t2[1]) || (t1[2] == t2[2])))) + return 0x03; + vertices[1] = LCR_renderer.mapVerts + 3 * t1[1]; vertices[4] = LCR_renderer.mapVerts + 3 * t2[1]; vertices[2] = LCR_renderer.mapVerts + 3 * t1[2]; vertices[5] = LCR_renderer.mapVerts + 3 * t2[2]; - if ( // same vert indices? - (((t1[0] == t2[0]) | (t1[0] == t2[1]) | (t1[0] == t2[2]))) & - (((t1[1] == t2[0]) | (t1[1] == t2[1]) | (t1[1] == t2[2]))) & - (((t1[2] == t2[0]) | (t1[2] == t2[1]) | (t1[2] == t2[2])))) - return 0x03; - uint8_t result = 0; int plane = -1;