diff --git a/tools/quake3/common/polylib.cpp b/tools/quake3/common/polylib.cpp index f187f6cc..cc175da5 100644 --- a/tools/quake3/common/polylib.cpp +++ b/tools/quake3/common/polylib.cpp @@ -151,13 +151,11 @@ float WindingArea( const winding_t *w ){ return total; } -MinMax WindingBounds( const winding_t *w ){ - MinMax minmax; - for ( int i = 0 ; i < w->numpoints ; i++ ) +void WindingExtendBounds( const winding_t *w, MinMax& minmax ){ + for ( int i = 0 ; i < w->numpoints ; ++i ) { minmax.extend( w->p[i] ); } - return minmax; } /* diff --git a/tools/quake3/common/polylib.h b/tools/quake3/common/polylib.h index e3ec9507..4c4b3d2a 100644 --- a/tools/quake3/common/polylib.h +++ b/tools/quake3/common/polylib.h @@ -60,7 +60,7 @@ Plane3f WindingPlane( const winding_t *w ); void RemoveColinearPoints( winding_t *w ); EPlaneSide WindingOnPlaneSide( const winding_t *w, const Plane3f& plane ); void FreeWinding( winding_t *w ); -MinMax WindingBounds( const winding_t *w ); +void WindingExtendBounds( const winding_t *w, MinMax& minmax ); void AddWindingToConvexHull( winding_t *w, winding_t **hull, const Vector3& normal ); diff --git a/tools/quake3/q3map2/brush.cpp b/tools/quake3/q3map2/brush.cpp index 242cb0f2..13c5ce17 100644 --- a/tools/quake3/q3map2/brush.cpp +++ b/tools/quake3/q3map2/brush.cpp @@ -179,11 +179,9 @@ bool BoundBrush( brush_t *brush ){ for ( int i = 0; i < brush->numsides; i++ ) { const winding_t *w = brush->sides[ i ].winding; - if ( w == NULL ) { - continue; + if ( w != NULL ) { + WindingExtendBounds( w, brush->minmax ); } - for ( int j = 0; j < w->numpoints; j++ ) - brush->minmax.extend( w->p[ j ] ); } return brush->minmax.valid() && c_worldMinmax.surrounds( brush->minmax ); @@ -291,7 +289,6 @@ bool FixWinding( winding_t *w ){ bool valid = true; int i, j, k; Vector3 vec; - float dist; /* dummy check */ @@ -311,8 +308,7 @@ bool FixWinding( winding_t *w ){ j = ( i + 1 ) % w->numpoints; /* degenerate edge? */ - dist = vector3_length( w->p[ i ] - w->p[ j ] ); - if ( dist < DEGENERATE_EPSILON ) { + if ( vector3_length( w->p[ i ] - w->p[ j ] ) < DEGENERATE_EPSILON ) { valid = false; //Sys_FPrintf( SYS_WRN | SYS_VRBflag, "WARNING: Degenerate winding edge found, fixing...\n" ); diff --git a/tools/quake3/q3map2/convert_bsp.cpp b/tools/quake3/q3map2/convert_bsp.cpp index d7bc4517..428049a3 100644 --- a/tools/quake3/q3map2/convert_bsp.cpp +++ b/tools/quake3/q3map2/convert_bsp.cpp @@ -872,12 +872,12 @@ int ConvertBSPMain( int argc, char **argv ){ else if ( striEqual( argv[ i ], "-ne" ) ) { normalEpsilon = atof( argv[ i + 1 ] ); i++; - Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon ); + Sys_Printf( "Normal epsilon set to %lf\n", normalEpsilon ); } else if ( striEqual( argv[ i ], "-de" ) ) { distanceEpsilon = atof( argv[ i + 1 ] ); i++; - Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon ); + Sys_Printf( "Distance epsilon set to %lf\n", distanceEpsilon ); } else if ( striEqual( argv[ i ], "-shaderasbitmap" ) || striEqual( argv[ i ], "-shadersasbitmap" ) ) { shadersAsBitmap = true; diff --git a/tools/quake3/q3map2/facebsp.cpp b/tools/quake3/q3map2/facebsp.cpp index 648b0f16..4ac11e10 100644 --- a/tools/quake3/q3map2/facebsp.cpp +++ b/tools/quake3/q3map2/facebsp.cpp @@ -365,25 +365,20 @@ void BuildFaceTree_r( node_t *node, face_t *list ){ tree_t *FaceBSP( face_t *list ) { tree_t *tree; face_t *face; - int i; - int count; Sys_FPrintf( SYS_VRB, "--- FaceBSP ---\n" ); tree = AllocTree(); - count = 0; + int count = 0; for ( face = list; face != NULL; face = face->next ) { + WindingExtendBounds( face->w, tree->minmax ); count++; - for ( i = 0; i < face->w->numpoints; i++ ) - { - tree->minmax.extend( face->w->p[ i ] ); - } } Sys_FPrintf( SYS_VRB, "%9d faces\n", count ); - for ( i = 0; i < nummapplanes; i++ ) + for ( int i = 0; i < nummapplanes; i++ ) { mapplanes[ i ].counter = 0; } diff --git a/tools/quake3/q3map2/light_bounce.cpp b/tools/quake3/q3map2/light_bounce.cpp index 172c20cd..435e393a 100644 --- a/tools/quake3/q3map2/light_bounce.cpp +++ b/tools/quake3/q3map2/light_bounce.cpp @@ -587,7 +587,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw splash_w = AllocWinding( rw->numVerts ); splash_w->numpoints = rw->numVerts; for ( i = 0; i < rw->numVerts; i++ ) - splash_w->p[ i ] = normal * si->backsplashDistance + rw->verts[rw->numVerts - 1 - i].xyz; + splash_w->p[ i ] = rw->verts[rw->numVerts - 1 - i].xyz + normal * si->backsplashDistance; splash->w = splash_w; splash->origin = normal * si->backsplashDistance + light->origin; diff --git a/tools/quake3/q3map2/portals.cpp b/tools/quake3/q3map2/portals.cpp index 687c9ed1..ed57263a 100644 --- a/tools/quake3/q3map2/portals.cpp +++ b/tools/quake3/q3map2/portals.cpp @@ -456,15 +456,13 @@ void SplitNodePortals( node_t *node ){ void CalcNodeBounds( node_t *node ){ portal_t *p; int s; - int i; // calc mins/maxs for both leafs and nodes node->minmax.clear(); for ( p = node->portals ; p ; p = p->next[s] ) { s = ( p->nodes[1] == node ); - for ( i = 0 ; i < p->winding->numpoints ; i++ ) - node->minmax.extend( p->winding->p[i] ); + WindingExtendBounds( p->winding, node->minmax ); } } diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index b9fcdcc1..f4ecd5bf 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -1212,7 +1212,6 @@ static void AddSurfaceFlare( mapDrawSurface_t *ds, const Vector3& entityOrigin ) */ static void SubdivideFace_r( entity_t *e, brush_t *brush, side_t *side, winding_t *w, int fogNum, float subdivisions ){ - int i; int axis; MinMax bounds; const float epsilon = 0.1; @@ -1230,8 +1229,7 @@ static void SubdivideFace_r( entity_t *e, brush_t *brush, side_t *side, winding_ } /* determine surface bounds */ - for ( i = 0; i < w->numpoints; i++ ) - bounds.extend( w->p[ i ] ); + WindingExtendBounds( w, bounds ); /* split the face */ for ( axis = 0; axis < 3; axis++ )