]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Fixing a 45 degree model clipping problem.
authorrambetter <rambetter>
Wed, 19 Jan 2011 06:41:33 +0000 (06:41 +0000)
committerrambetter <rambetter>
Wed, 19 Jan 2011 06:41:33 +0000 (06:41 +0000)
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
tools/quake3/q3map2/q3map2.h

index 4200368bbddb58b7df28205e3696b4d22d13a0bf..ef0a04892f576ea2ce43a4c7b6d94218eaca4223 100644 (file)
@@ -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;
index 7b907365906613ebc791e8a025897bca6e99d26e..b5b41117d9552c77c86152e7d15a92a217609488 100644 (file)
@@ -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