From 0619dfeb4e6713b3cc9c0ab1585e29234a9b4aa3 Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 22 Jul 2009 10:34:31 +0000 Subject: [PATCH] curves: optimize their order for the bbox optimization git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9067 d7cf8633-e32d-0410-b094-e92efae38249 --- curves.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/curves.c b/curves.c index 910201ad..89468381 100644 --- a/curves.c +++ b/curves.c @@ -402,18 +402,38 @@ void Q3PatchTriangleElements(int *elements, int width, int height, int firstvert int x, y, row0, row1; for (y = 0;y < height - 1;y++) { - row0 = firstvertex + (y + 0) * width; - row1 = firstvertex + (y + 1) * width; - for (x = 0;x < width - 1;x++) + if(y % 2) { - *elements++ = row0; - *elements++ = row1; - *elements++ = row0 + 1; - *elements++ = row1; - *elements++ = row1 + 1; - *elements++ = row0 + 1; - row0++; - row1++; + // swap the triangle order in odd rows as optimization for collision stride + row0 = firstvertex + (y + 0) * width + width - 2; + row1 = firstvertex + (y + 1) * width + width - 2; + for (x = 0;x < width - 1;x++) + { + *elements++ = row1; + *elements++ = row1 + 1; + *elements++ = row0 + 1; + *elements++ = row0; + *elements++ = row1; + *elements++ = row0 + 1; + row0--; + row1--; + } + } + else + { + row0 = firstvertex + (y + 0) * width; + row1 = firstvertex + (y + 1) * width; + for (x = 0;x < width - 1;x++) + { + *elements++ = row0; + *elements++ = row1; + *elements++ = row0 + 1; + *elements++ = row1; + *elements++ = row1 + 1; + *elements++ = row0 + 1; + row0++; + row1++; + } } } } -- 2.39.2