From 2b7668ee330025a738b8b5f196d4142bc49872e0 Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 12 Jul 2009 17:54:07 +0000 Subject: [PATCH] possibly speed up MergeMetaTriangles, will benchmark it later git-svn-id: svn://svn.icculus.org/netradiant/trunk@385 61c419a2-8eb2-4b30-bcec-8cead039b335 --- tools/quake3/q3map2/surface_meta.c | 33 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index f0d48b3d..5e9cb984 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -1226,14 +1226,15 @@ returns the score of the triangle added #define ST_SCORE2 (2 * (ST_SCORE)) #define ADEQUATE_SCORE ((AXIS_MIN) + 1 * (VERT_SCORE)) -#define GOOD_SCORE ((AXIS_MIN) + 2 * (VERT_SCORE) + 4 * (ST_SCORE)) -#define PERFECT_SCORE ((AXIS_MIN) + + 3 * (VERT_SCORE) + (SURFACE_SCORE) + 4 * (ST_SCORE)) +#define GOOD_SCORE ((AXIS_MIN) + 2 * (VERT_SCORE) + 4 * (ST_SCORE)) +#define PERFECT_SCORE ((AXIS_MIN) + 3 * (VERT_SCORE) + (SURFACE_SCORE) + 4 * (ST_SCORE)) +#define MAX_BBOX_DISTANCE 16 static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, qboolean testAdd ) { int i, score, coincident, ai, bi, ci, oldTexRange[ 2 ]; float lmMax; - vec3_t mins, maxs; + vec3_t mins, maxs, p; qboolean inTexRange, es, et; mapDrawSurface_t old; @@ -1264,6 +1265,32 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri, if( tri->planeNum >= 0 && tri->planeNum != ds->planeNum ) return 0; } + +#if MAX_BBOX_DISTANCE > 0 + VectorCopy( mins, ds->mins ); + VectorCopy( maxs, ds->maxs ); + mins[0] -= MAX_BBOX_DISTANCE; + mins[1] -= MAX_BBOX_DISTANCE; + mins[2] -= MAX_BBOX_DISTANCE; + maxs[0] += MAX_BBOX_DISTANCE; + maxs[1] += MAX_BBOX_DISTANCE; + maxs[2] += MAX_BBOX_DISTANCE; +#define CHECK_1D(mins, v, maxs) ((mins) <= (v) && (v) <= (maxs)) +#define CHECK_3D(mins, v, maxs) (CHECK_1D((mins)[0], (v)[0], (maxs)[0]) && CHECK_1D((mins)[1], (v)[1], (maxs)[1]) && CHECK_1D((mins)[2], (v)[2], (maxs)[2])) + VectorCopy(p, metaVerts[ tri->indexes[ 0 ] ].xyz); + if(!CHECK_3D(mins, p, maxs)) + { + VectorCopy(p, metaVerts[ tri->indexes[ 1 ] ].xyz); + if(!CHECK_3D(mins, p, maxs)) + { + VectorCopy(p, metaVerts[ tri->indexes[ 2 ] ].xyz); + if(!CHECK_3D(mins, p, maxs)) + return 0; + } + } +#undef CHECK_3D +#undef CHECK_1D +#endif /* set initial score */ score = tri->surfaceNum == ds->surfaceNum ? SURFACE_SCORE : 0; -- 2.39.2