]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/tjunction.c
uncrustify! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / tools / quake3 / q3map2 / tjunction.c
index d728c185b2611ad93b7f4fda7008eb860680139e..50e5d7c4d1536677f0a1a70fdb41a2b766060661 100644 (file)
@@ -1,30 +1,30 @@
 /* -------------------------------------------------------------------------------
 
-Copyright (C) 1999-2007 id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
+   Copyright (C) 1999-2007 id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
 
-This file is part of GtkRadiant.
+   This file is part of GtkRadiant.
 
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-----------------------------------------------------------------------------------
+   ----------------------------------------------------------------------------------
 
-This code has been altered significantly from its original form, to support
-several games based on the Quake III Arena engine, in the form of "Q3Map2."
+   This code has been altered significantly from its original form, to support
+   several games based on the Quake III Arena engine, in the form of "Q3Map2."
 
-------------------------------------------------------------------------------- */
+   ------------------------------------------------------------------------------- */
 
 
 
@@ -40,63 +40,63 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2."
 
 
 typedef struct edgePoint_s {
-       float           intercept;
-       vec3_t          xyz;
-       struct edgePoint_s      *prev, *next;
+       float intercept;
+       vec3_t xyz;
+       struct edgePoint_s  *prev, *next;
 } edgePoint_t;
 
 typedef struct edgeLine_s {
-       vec3_t          normal1;
-       float           dist1;
-       
-       vec3_t          normal2;
-       float           dist2;
-       
-       vec3_t          origin;
-       vec3_t          dir;
-
-       edgePoint_t     chain;          // unused element of doubly linked list
+       vec3_t normal1;
+       float dist1;
+
+       vec3_t normal2;
+       float dist2;
+
+       vec3_t origin;
+       vec3_t dir;
+
+       edgePoint_t chain;      // unused element of doubly linked list
 } edgeLine_t;
 
 typedef struct {
-       float           length;
-       bspDrawVert_t   *dv[2];
+       float length;
+       bspDrawVert_t   *dv[2];
 } originalEdge_t;
 
-#define        MAX_ORIGINAL_EDGES      0x20000
-originalEdge_t originalEdges[MAX_ORIGINAL_EDGES];
-int                            numOriginalEdges;
+#define MAX_ORIGINAL_EDGES  0x20000
+originalEdge_t originalEdges[MAX_ORIGINAL_EDGES];
+int numOriginalEdges;
 
 
-#define        MAX_EDGE_LINES          0x10000
-edgeLine_t             edgeLines[MAX_EDGE_LINES];
-int                            numEdgeLines;
+#define MAX_EDGE_LINES      0x10000
+edgeLine_t edgeLines[MAX_EDGE_LINES];
+int numEdgeLines;
 
-int                            c_degenerateEdges;
-int                            c_addedVerts;
-int                            c_totalVerts;
+int c_degenerateEdges;
+int c_addedVerts;
+int c_totalVerts;
 
-int                            c_natural, c_rotate, c_cant;
+int c_natural, c_rotate, c_cant;
 
 // these should be whatever epsilon we actually expect,
-// plus SNAP_INT_TO_FLOAT 
-#define        LINE_POSITION_EPSILON   0.25
-#define        POINT_ON_LINE_EPSILON   0.25
+// plus SNAP_INT_TO_FLOAT
+#define LINE_POSITION_EPSILON   0.25
+#define POINT_ON_LINE_EPSILON   0.25
 
 /*
-====================
-InsertPointOnEdge
-====================
-*/
+   ====================
+   InsertPointOnEdge
+   ====================
+ */
 void InsertPointOnEdge( vec3_t v, edgeLine_t *e ) {
-       vec3_t          delta;
-       float           d;
-       edgePoint_t     *p, *scan;
+       vec3_t delta;
+       float d;
+       edgePoint_t *p, *scan;
 
        VectorSubtract( v, e->origin, delta );
        d = DotProduct( delta, e->dir );
 
-       p = safe_malloc( sizeof(edgePoint_t) );
+       p = safe_malloc( sizeof( edgePoint_t ) );
        p->intercept = d;
        VectorCopy( v, p->xyz );
 
@@ -111,7 +111,7 @@ void InsertPointOnEdge( vec3_t v, edgeLine_t *e ) {
                d = p->intercept - scan->intercept;
                if ( d > -LINE_POSITION_EPSILON && d < LINE_POSITION_EPSILON ) {
                        free( p );
-                       return;         // the point is already set
+                       return;     // the point is already set
                }
 
                if ( p->intercept < scan->intercept ) {
@@ -133,15 +133,15 @@ void InsertPointOnEdge( vec3_t v, edgeLine_t *e ) {
 
 
 /*
-====================
-AddEdge
-====================
-*/
+   ====================
+   AddEdge
+   ====================
+ */
 int AddEdge( vec3_t v1, vec3_t v2, qboolean createNonAxial ) {
-       int                     i;
-       edgeLine_t      *e;
-       float           d;
-       vec3_t          dir;
+       int i;
+       edgeLine_t  *e;
+       float d;
+       vec3_t dir;
 
        VectorSubtract( v2, v1, dir );
        d = VectorNormalize( dir, dir );
@@ -217,46 +217,44 @@ int AddEdge( vec3_t v1, vec3_t v2, qboolean createNonAxial ) {
 
 
 /*
-AddSurfaceEdges()
-adds a surface's edges
-*/
+   AddSurfaceEdges()
+   adds a surface's edges
+ */
+
+void AddSurfaceEdges( mapDrawSurface_t *ds ){
+       int i;
 
-void AddSurfaceEdges( mapDrawSurface_t *ds )
-{
-       int             i;
-       
 
-       for( i = 0; i < ds->numVerts; i++ )
+       for ( i = 0; i < ds->numVerts; i++ )
        {
                /* save the edge number in the lightmap field so we don't need to look it up again */
-               ds->verts[i].lightmap[ 0 ][ 0 ] = 
-                       AddEdge( ds->verts[ i ].xyz, ds->verts[ (i + 1) % ds->numVerts ].xyz, qfalse );
+               ds->verts[i].lightmap[ 0 ][ 0 ] =
+                       AddEdge( ds->verts[ i ].xyz, ds->verts[ ( i + 1 ) % ds->numVerts ].xyz, qfalse );
        }
 }
 
 
 
 /*
-ColinearEdge()
-determines if an edge is colinear
-*/
+   ColinearEdge()
+   determines if an edge is colinear
+ */
 
-qboolean ColinearEdge( vec3_t v1, vec3_t v2, vec3_t v3 )
-{
-       vec3_t  midpoint, dir, offset, on;
-       float   d;
+qboolean ColinearEdge( vec3_t v1, vec3_t v2, vec3_t v3 ){
+       vec3_t midpoint, dir, offset, on;
+       float d;
 
        VectorSubtract( v2, v1, midpoint );
        VectorSubtract( v3, v1, dir );
        d = VectorNormalize( dir, dir );
        if ( d == 0 ) {
-               return qfalse;  // degenerate
+               return qfalse;  // degenerate
        }
 
        d = DotProduct( midpoint, dir );
        VectorScale( dir, d, on );
        VectorSubtract( midpoint, on, offset );
-       d = VectorLength ( offset );
+       d = VectorLength( offset );
 
        if ( d < 0.1 ) {
                return qtrue;
@@ -268,18 +266,18 @@ qboolean ColinearEdge( vec3_t v1, vec3_t v2, vec3_t v3 )
 
 
 /*
-====================
-AddPatchEdges
+   ====================
+   AddPatchEdges
 
-Add colinear border edges, which will fix some classes of patch to
-brush tjunctions
-====================
-*/
+   Add colinear border edges, which will fix some classes of patch to
+   brush tjunctions
+   ====================
+ */
 void AddPatchEdges( mapDrawSurface_t *ds ) {
-       int             i;
-       float   *v1, *v2, *v3;
+       int i;
+       float   *v1, *v2, *v3;
 
-       for ( i = 0 ; i < ds->patchWidth - 2; i+=2 ) {
+       for ( i = 0 ; i < ds->patchWidth - 2; i += 2 ) {
                v1 = ds->verts[ i ].xyz;
                v2 = ds->verts[ i + 1 ].xyz;
                v3 = ds->verts[ i + 2 ].xyz;
@@ -299,7 +297,7 @@ void AddPatchEdges( mapDrawSurface_t *ds ) {
                }
        }
 
-       for ( i = 0 ; i < ds->patchHeight - 2 ; i+=2 ) {
+       for ( i = 0 ; i < ds->patchHeight - 2 ; i += 2 ) {
                v1 = ds->verts[ i * ds->patchWidth ].xyz;
                v2 = ds->verts[ ( i + 1 ) * ds->patchWidth ].xyz;
                v3 = ds->verts[ ( i + 2 ) * ds->patchWidth ].xyz;
@@ -324,27 +322,27 @@ void AddPatchEdges( mapDrawSurface_t *ds ) {
 
 
 /*
-====================
-FixSurfaceJunctions
-====================
-*/
-#define        MAX_SURFACE_VERTS       256
+   ====================
+   FixSurfaceJunctions
+   ====================
+ */
+#define MAX_SURFACE_VERTS   256
 void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
-       int                     i, j, k;
-       edgeLine_t      *e;
-       edgePoint_t     *p;
-       int                     originalVerts;
-       int                     counts[MAX_SURFACE_VERTS];
-       int                     originals[MAX_SURFACE_VERTS];
-       int                     firstVert[MAX_SURFACE_VERTS];
-       bspDrawVert_t   verts[MAX_SURFACE_VERTS], *v1, *v2;
-       int                     numVerts;
-       float           start, end, frac, c;
-       vec3_t          delta;
-       
-       
+       int i, j, k;
+       edgeLine_t  *e;
+       edgePoint_t *p;
+       int originalVerts;
+       int counts[MAX_SURFACE_VERTS];
+       int originals[MAX_SURFACE_VERTS];
+       int firstVert[MAX_SURFACE_VERTS];
+       bspDrawVert_t verts[MAX_SURFACE_VERTS], *v1, *v2;
+       int numVerts;
+       float start, end, frac, c;
+       vec3_t delta;
+
+
        originalVerts = ds->numVerts;
-       
+
        numVerts = 0;
        for ( i = 0 ; i < ds->numVerts ; i++ )
        {
@@ -361,14 +359,14 @@ void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
 
                // check to see if there are any t junctions before the next vert
                v1 = &ds->verts[i];
-               v2 = &ds->verts[ (i+1) % ds->numVerts ];
+               v2 = &ds->verts[ ( i + 1 ) % ds->numVerts ];
 
                j = (int)ds->verts[i].lightmap[ 0 ][ 0 ];
                if ( j == -1 ) {
-                       continue;               // degenerate edge
+                       continue;       // degenerate edge
                }
                e = &edgeLines[ j ];
-               
+
                VectorSubtract( v1->xyz, e->origin, delta );
                start = DotProduct( delta, e->dir );
 
@@ -378,52 +376,54 @@ void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
 
                if ( start < end ) {
                        p = e->chain.next;
-               } else {
+               }
+               else {
                        p = e->chain.prev;
                }
 
-               for (  ; p != &e->chain ;  ) {
+               for (  ; p != &e->chain ; ) {
                        if ( start < end ) {
                                if ( p->intercept > end - ON_EPSILON ) {
                                        break;
                                }
-                       } else {
+                       }
+                       else {
                                if ( p->intercept < end + ON_EPSILON ) {
                                        break;
                                }
                        }
 
-                       if ( 
+                       if (
                                ( start < end && p->intercept > start + ON_EPSILON ) ||
                                ( start > end && p->intercept < start - ON_EPSILON ) ) {
                                // insert this point
                                if ( numVerts == MAX_SURFACE_VERTS ) {
                                        Error( "MAX_SURFACE_VERTS" );
                                }
-                               
+
                                /* take the exact intercept point */
                                VectorCopy( p->xyz, verts[ numVerts ].xyz );
-                               
+
                                /* interpolate the texture coordinates */
                                frac = ( p->intercept - start ) / ( end - start );
                                for ( j = 0 ; j < 2 ; j++ ) {
-                                       verts[ numVerts ].st[j] = v1->st[j] + 
-                                               frac * ( v2->st[j] - v1->st[j] );
+                                       verts[ numVerts ].st[j] = v1->st[j] +
+                                                                                         frac * ( v2->st[j] - v1->st[j] );
                                }
-                               
+
                                /* copy the normal (FIXME: what about nonplanar surfaces? */
                                VectorCopy( v1->normal, verts[ numVerts ].normal );
-                               
+
                                /* ydnar: interpolate the color */
-                               for( k = 0; k < MAX_LIGHTMAPS; k++ )
+                               for ( k = 0; k < MAX_LIGHTMAPS; k++ )
                                {
-                                       for( j = 0; j < 4; j++ )
+                                       for ( j = 0; j < 4; j++ )
                                        {
-                                               c = (float) v1->color[ k ][ j ] + frac * ((float) v2->color[ k ][ j ] - (float) v1->color[ k ][ j ]);
-                                               verts[ numVerts ].color[ k ][ j ] = (byte) (c < 255.0f ? c : 255);
+                                               c = (float) v1->color[ k ][ j ] + frac * ( (float) v2->color[ k ][ j ] - (float) v1->color[ k ][ j ] );
+                                               verts[ numVerts ].color[ k ][ j ] = (byte) ( c < 255.0f ? c : 255 );
                                        }
                                }
-                               
+
                                /* next... */
                                originals[ numVerts ] = i;
                                numVerts++;
@@ -432,7 +432,8 @@ void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
 
                        if ( start < end ) {
                                p = p->next;
-                       } else {
+                       }
+                       else {
                                p = p->prev;
                        }
                }
@@ -448,11 +449,11 @@ void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
        // rotate the points so that the initial vertex is between
        // two non-subdivided edges
        for ( i = 0 ; i < numVerts ; i++ ) {
-               if ( originals[ (i+1) % numVerts ] == originals[ i ] ) {
+               if ( originals[ ( i + 1 ) % numVerts ] == originals[ i ] ) {
                        continue;
                }
-               j = (i + numVerts - 1 ) % numVerts;
-               k = (i + numVerts - 2 ) % numVerts;
+               j = ( i + numVerts - 1 ) % numVerts;
+               k = ( i + numVerts - 2 ) % numVerts;
                if ( originals[ j ] == originals[ k ] ) {
                        continue;
                }
@@ -474,20 +475,21 @@ void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
                c_cant++;
 
 /*
-               memset ( &verts[numVerts], 0, sizeof( verts[numVerts] ) );
-               for ( i = 0 ; i < numVerts ; i++ ) {
-                       for ( j = 0 ; j < 10 ; j++ ) {
-                               verts[numVerts].xyz[j] += verts[i].xyz[j];
-                       }
-               }
-               for ( j = 0 ; j < 10 ; j++ ) {
-                       verts[numVerts].xyz[j] /= numVerts;
-               }
-
-               i = numVerts;
-               numVerts++;
-*/
-       } else {
+        memset ( &verts[numVerts], 0, sizeof( verts[numVerts] ) );
+        for ( i = 0 ; i < numVerts ; i++ ) {
+            for ( j = 0 ; j < 10 ; j++ ) {
+                verts[numVerts].xyz[j] += verts[i].xyz[j];
+            }
+        }
+        for ( j = 0 ; j < 10 ; j++ ) {
+            verts[numVerts].xyz[j] /= numVerts;
+        }
+
+        i = numVerts;
+        numVerts++;
+ */
+       }
+       else {
                // just rotate the vertexes
                c_rotate++;
 
@@ -506,47 +508,48 @@ void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
 
 
 /*
-FixBrokenSurface() - ydnar
-removes nearly coincident verts from a planar winding surface
-returns qfalse if the surface is broken
-*/
+   FixBrokenSurface() - ydnar
+   removes nearly coincident verts from a planar winding surface
+   returns qfalse if the surface is broken
+ */
 
 extern void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out );
 
-#define DEGENERATE_EPSILON     0.1
+#define DEGENERATE_EPSILON  0.1
+
+int c_broken = 0;
+
+qboolean FixBrokenSurface( mapDrawSurface_t *ds ){
+       qboolean valid = qtrue;
+       bspDrawVert_t   *dv1, *dv2, avg;
+       int i, j, k;
+       float dist;
 
-int            c_broken = 0;
 
-qboolean FixBrokenSurface( mapDrawSurface_t *ds )
-{
-       qboolean        valid = qtrue;
-       bspDrawVert_t   *dv1, *dv2, avg;
-       int                     i, j, k;
-       float           dist;
-       
-       
        /* dummy check */
-       if( ds == NULL )
+       if ( ds == NULL ) {
                return qfalse;
-       if( ds->type != SURFACE_FACE )
+       }
+       if ( ds->type != SURFACE_FACE ) {
                return qfalse;
-       
+       }
+
        /* check all verts */
-       for( i = 0; i < ds->numVerts; i++ )
+       for ( i = 0; i < ds->numVerts; i++ )
        {
                /* don't remove points if winding is a triangle */
-               if( ds->numVerts == 3 )
+               if ( ds->numVerts == 3 ) {
                        return valid;
-               
+               }
+
                /* get verts */
                dv1 = &ds->verts[ i ];
-               dv2 = &ds->verts[ (i + 1) % ds->numVerts ];
-               
+               dv2 = &ds->verts[ ( i + 1 ) % ds->numVerts ];
+
                /* degenerate edge? */
                VectorSubtract( dv1->xyz, dv2->xyz, avg.xyz );
                dist = VectorLength( avg.xyz );
-               if( dist < DEGENERATE_EPSILON )
-               {
+               if ( dist < DEGENERATE_EPSILON ) {
                        valid = qfalse;
                        Sys_FPrintf( SYS_VRB, "WARNING: Degenerate T-junction edge found, fixing...\n" );
 
@@ -555,38 +558,39 @@ qboolean FixBrokenSurface( mapDrawSurface_t *ds )
                        SnapWeldVector( dv1->xyz, dv2->xyz, avg.xyz );
                        VectorAdd( dv1->normal, dv2->normal, avg.normal );
                        VectorNormalize( avg.normal, avg.normal );
-                       avg.st[ 0 ] = (dv1->st[ 0 ] + dv2->st[ 0 ]) * 0.5f;
-                       avg.st[ 1 ] = (dv1->st[ 1 ] + dv2->st[ 1 ]) * 0.5f;
-                       
+                       avg.st[ 0 ] = ( dv1->st[ 0 ] + dv2->st[ 0 ] ) * 0.5f;
+                       avg.st[ 1 ] = ( dv1->st[ 1 ] + dv2->st[ 1 ] ) * 0.5f;
+
                        /* lightmap st/colors */
-                       for( k = 0; k < MAX_LIGHTMAPS; k++ )
+                       for ( k = 0; k < MAX_LIGHTMAPS; k++ )
                        {
-                               avg.lightmap[ k ][ 0 ] = (dv1->lightmap[ k ][ 0 ] + dv2->lightmap[ k ][ 0 ]) * 0.5f;
-                               avg.lightmap[ k ][ 1 ] = (dv1->lightmap[ k ][ 1 ] + dv2->lightmap[ k ][ 1 ]) * 0.5f;
-                               for( j = 0; j < 4; j++ )
-                                       avg.color[ k ][ j ] = (int) (dv1->color[ k ][ j ] + dv2->color[ k ][ j ]) >> 1;
+                               avg.lightmap[ k ][ 0 ] = ( dv1->lightmap[ k ][ 0 ] + dv2->lightmap[ k ][ 0 ] ) * 0.5f;
+                               avg.lightmap[ k ][ 1 ] = ( dv1->lightmap[ k ][ 1 ] + dv2->lightmap[ k ][ 1 ] ) * 0.5f;
+                               for ( j = 0; j < 4; j++ )
+                                       avg.color[ k ][ j ] = (int) ( dv1->color[ k ][ j ] + dv2->color[ k ][ j ] ) >> 1;
                        }
-                       
+
                        /* ydnar: der... */
                        memcpy( dv1, &avg, sizeof( avg ) );
-                       
+
                        /* move the remaining verts */
-                       for( k = i + 2; k < ds->numVerts; k++ )
+                       for ( k = i + 2; k < ds->numVerts; k++ )
                        {
                                /* get verts */
                                dv1 = &ds->verts[ k ];
                                dv2 = &ds->verts[ k - 1 ];
-                               
+
                                /* copy */
                                memcpy( dv2, dv1, sizeof( bspDrawVert_t ) );
                        }
                        ds->numVerts--;
                }
        }
-       
+
        /* one last check and return */
-       if( ds->numVerts < 3 )
+       if ( ds->numVerts < 3 ) {
                valid = qfalse;
+       }
        return valid;
 }
 
@@ -599,15 +603,15 @@ qboolean FixBrokenSurface( mapDrawSurface_t *ds )
 
 
 /*
-================
-EdgeCompare
-================
-*/
+   ================
+   EdgeCompare
+   ================
+ */
 int EdgeCompare( const void *elem1, const void *elem2 ) {
-       float   d1, d2;
+       float d1, d2;
 
-       d1 = ((originalEdge_t *)elem1)->length;
-       d2 = ((originalEdge_t *)elem2)->length;
+       d1 = ( (originalEdge_t *)elem1 )->length;
+       d2 = ( (originalEdge_t *)elem2 )->length;
 
        if ( d1 < d2 ) {
                return -1;
@@ -621,28 +625,27 @@ int EdgeCompare( const void *elem1, const void *elem2 ) {
 
 
 /*
-FixTJunctions
-call after the surface list has been pruned
-*/
-
-void FixTJunctions( entity_t *ent )
-{
-       int                                     i;
-       mapDrawSurface_t        *ds;
-       shaderInfo_t            *si;
-       int                                     axialEdgeLines;
-       originalEdge_t          *e;
-       
-       
+   FixTJunctions
+   call after the surface list has been pruned
+ */
+
+void FixTJunctions( entity_t *ent ){
+       int i;
+       mapDrawSurface_t    *ds;
+       shaderInfo_t        *si;
+       int axialEdgeLines;
+       originalEdge_t      *e;
+
+
        /* meta mode has its own t-junction code (currently not as good as this code) */
        //%     if( meta )
-       //%             return; 
-       
+       //%             return;
+
        /* note it */
        Sys_FPrintf( SYS_VRB, "--- FixTJunctions ---\n" );
        numEdgeLines = 0;
        numOriginalEdges = 0;
-       
+
        // add all the edges
        // this actually creates axial edges, but it
        // only creates originalEdge_t structures
@@ -652,32 +655,33 @@ void FixTJunctions( entity_t *ent )
                /* get surface and early out if possible */
                ds = &mapDrawSurfs[ i ];
                si = ds->shaderInfo;
-               if( (si->compileFlags & C_NODRAW) || si->autosprite || si->notjunc || ds->numVerts == 0 )
+               if ( ( si->compileFlags & C_NODRAW ) || si->autosprite || si->notjunc || ds->numVerts == 0 ) {
                        continue;
-               
+               }
+
                /* ydnar: gs mods: handle the various types of surfaces */
-               switch( ds->type )
+               switch ( ds->type )
                {
-                       /* handle brush faces */
-                       case SURFACE_FACE:
-                               AddSurfaceEdges( ds );
-                               break;
-                       
-                       /* handle patches */
-                       case SURFACE_PATCH:
-                               AddPatchEdges( ds );
-                               break;
-                       
-                       /* fixme: make triangle surfaces t-junction */
-                       default:
-                               break;
+               /* handle brush faces */
+               case SURFACE_FACE:
+                       AddSurfaceEdges( ds );
+                       break;
+
+               /* handle patches */
+               case SURFACE_PATCH:
+                       AddPatchEdges( ds );
+                       break;
+
+               /* fixme: make triangle surfaces t-junction */
+               default:
+                       break;
                }
        }
 
        axialEdgeLines = numEdgeLines;
 
        // sort the non-axial edges by length
-       qsort( originalEdges, numOriginalEdges, sizeof(originalEdges[0]), EdgeCompare );
+       qsort( originalEdges, numOriginalEdges, sizeof( originalEdges[0] ), EdgeCompare );
 
        // add the non-axial edges, longest first
        // this gives the most accurate edge description
@@ -691,33 +695,33 @@ void FixTJunctions( entity_t *ent )
        Sys_FPrintf( SYS_VRB, "%9d degenerate edges\n", c_degenerateEdges );
 
        // insert any needed vertexes
-       for( i = ent->firstDrawSurf; i < numMapDrawSurfs ; i++ )
+       for ( i = ent->firstDrawSurf; i < numMapDrawSurfs ; i++ )
        {
                /* get surface and early out if possible */
                ds = &mapDrawSurfs[ i ];
                si = ds->shaderInfo;
-               if( (si->compileFlags & C_NODRAW) || si->autosprite || si->notjunc || ds->numVerts == 0 || ds->type != SURFACE_FACE )
+               if ( ( si->compileFlags & C_NODRAW ) || si->autosprite || si->notjunc || ds->numVerts == 0 || ds->type != SURFACE_FACE ) {
                        continue;
-               
+               }
+
                /* ydnar: gs mods: handle the various types of surfaces */
-               switch( ds->type )
+               switch ( ds->type )
                {
-                       /* handle brush faces */
-                       case SURFACE_FACE:
-                               FixSurfaceJunctions( ds );
-                               if( FixBrokenSurface( ds ) == qfalse )
-                               {
-                                       c_broken++;
-                                       ClearSurface( ds );
-                               }
-                               break;
-                       
-                       /* fixme: t-junction triangle models and patches */
-                       default:
-                               break;
+               /* handle brush faces */
+               case SURFACE_FACE:
+                       FixSurfaceJunctions( ds );
+                       if ( FixBrokenSurface( ds ) == qfalse ) {
+                               c_broken++;
+                               ClearSurface( ds );
+                       }
+                       break;
+
+               /* fixme: t-junction triangle models and patches */
+               default:
+                       break;
                }
        }
-       
+
        /* emit some statistics */
        Sys_FPrintf( SYS_VRB, "%9d verts added for T-junctions\n", c_addedVerts );
        Sys_FPrintf( SYS_VRB, "%9d total verts\n", c_totalVerts );