]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/map.c
try to fix FindFloatPlane bug
[xonotic/netradiant.git] / tools / quake3 / q3map2 / map.c
index b9862c51d4fe61a354b331a71a12bdcabc7204a0..f29d7d62e0016c942d65c7a7e70c30080de6553a 100644 (file)
@@ -212,7 +212,7 @@ ydnar: changed to allow a number of test points to be supplied that
 must be within an epsilon distance of the plane
 */
 
-int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) // NOTE: this has a side effect on the normal. Good or bad?
+int FindFloatPlane( vec3_t innormal, vec_t dist, int numPoints, vec3_t *points ) // NOTE: this has a side effect on the normal. Good or bad?
 
 #ifdef USE_HASHING
 
@@ -222,12 +222,14 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) /
        plane_t *p;
        vec_t   d;
        vec3_t centerofweight;
+       vec3_t normal;
 
        VectorClear(centerofweight);
        for(i = 0; i < numPoints; ++i)
                VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
        
        /* hash the plane */
+       VectorCopy(innormal, normal);
        SnapPlane( normal, &dist, centerofweight );
        hash = (PLANE_HASHES - 1) & (int) fabs( dist );
        
@@ -269,6 +271,7 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) /
 {
        int             i;
        plane_t *p;
+       vec3_t normal;
        
 
        vec3_t centerofweight;
@@ -277,6 +280,7 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) /
        for(i = 0; i < numPoints; ++i)
                VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
 
+       VectorCopy(innormal, normal);
        SnapPlane( normal, &dist, centerofweight );
        for( i = 0, p = mapplanes; i < nummapplanes; i++, p++ )
        {