From cb169716fe81dc334a9a902ccf5bd00e0c613106 Mon Sep 17 00:00:00 2001 From: rambetter Date: Wed, 19 Jan 2011 06:41:33 +0000 Subject: [PATCH] Fixing a 45 degree model clipping problem. Introducing Q3MAP2_EXPERIMENTAL_MODEL_CLIPPING_FIX to control the new code, current value is 1 (enable the fix). This code fixes the q3map2 regression test model_clipping_45_degrees. git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@429 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- tools/quake3/q3map2/model.c | 11 +++++++++++ tools/quake3/q3map2/q3map2.h | 1 + 2 files changed, 12 insertions(+) diff --git a/tools/quake3/q3map2/model.c b/tools/quake3/q3map2/model.c index 4200368b..ef0a0489 100644 --- a/tools/quake3/q3map2/model.c +++ b/tools/quake3/q3map2/model.c @@ -431,6 +431,9 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade /* copy xyz */ VectorCopy( dv->xyz, points[ j ] ); +#if ! Q3MAP2_EXPERIMENTAL_MODEL_CLIPPING_FIX + // The code below is totally unneeded regardless of Q3MAP2_EXPERIMENTAL_MODEL_CLIPPING_FIX. + // backs is reinitialized further below. However, the extra code does not hurt anything. VectorCopy( dv->xyz, backs[ j ] ); /* find nearest axial to normal and push back points opposite */ @@ -444,6 +447,7 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade break; } } +#endif } /* make plane for triangle */ @@ -461,8 +465,15 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade /* find nearest axial to plane normal and push back points opposite */ for( k = 0; k < 3; k++ ) { +#if Q3MAP2_EXPERIMENTAL_MODEL_CLIPPING_FIX + if( fabs( plane[ k ] ) >= fabs( plane[ (k + 1) % 3 ] ) && + fabs( plane[ k ] ) >= fabs( plane[ (k + 2) % 3 ] ) ) +#else + // This code is broken for 45 degree angles where there + // is no clear winner. if( fabs( plane[ k ] ) > fabs( plane[ (k + 1) % 3 ] ) && fabs( plane[ k ] ) > fabs( plane[ (k + 2) % 3 ] ) ) +#endif { backs[ j ][ k ] += plane[ k ] < 0.0f ? 64.0f : -64.0f; break; diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 7b907365..b5b41117 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -127,6 +127,7 @@ constants #define Q3MAP2_EXPERIMENTAL_HIGH_PRECISION_MATH_FIXES 1 #define Q3MAP2_EXPERIMENTAL_SNAP_NORMAL_FIX 1 #define Q3MAP2_EXPERIMENTAL_SNAP_PLANE_FIX 1 +#define Q3MAP2_EXPERIMENTAL_MODEL_CLIPPING_FIX 1 /* general */ #define MAX_QPATH 64 -- 2.39.2