From 4a368deef0c4d26324458eea8b81a4b00be75860 Mon Sep 17 00:00:00 2001 From: Garux Date: Tue, 4 Feb 2025 12:15:12 +0500 Subject: [PATCH] minor refactoring --- contrib/bobtoolz/DPatch.cpp | 4 +- contrib/bobtoolz/shapes.cpp | 2 +- libs/container/hashfunc.h | 18 +- libs/ddslib/ddslib.c | 4 +- libs/eclasslib.h | 4 +- libs/l_net/l_net.c | 2 +- libs/l_net/l_net_wins.c | 2 +- libs/math/aabb.h | 4 +- libs/mathlib.h | 26 +- libs/mathlib/m4x4.c | 4 +- libs/mathlib/mathlib.c | 2 +- libs/mathlib/ray.c | 4 +- libs/profile/file.cpp | 2 +- libs/profile/file.h | 2 +- libs/profile/profile.cpp | 2 +- libs/profile/profile.h | 2 +- libs/profile/profile2.h | 2 +- libs/render.h | 8 +- libs/str.h | 2 +- plugins/entity/light.cpp | 4 +- plugins/image/jpeg.cpp | 2 +- plugins/image/jpeg.h | 2 +- plugins/imagehl/hlw.cpp | 2 +- plugins/md3model/mdlimage.cpp | 2 +- plugins/shaders/shaders.cpp | 2 +- plugins/shaders/shaders.h | 2 +- plugins/vfspk3/vfs.cpp | 2 +- plugins/vfspk3/vfs.h | 2 +- radiant/brush_primit.h | 18 +- radiant/eclass_def.cpp | 10 +- radiant/error.cpp | 4 +- radiant/feedback.cpp | 6 +- radiant/gtkdlgs.cpp | 2 +- radiant/gtkdlgs.h | 2 +- radiant/gtkmisc.cpp | 2 +- radiant/gtkmisc.h | 2 +- radiant/patch.cpp | 150 +++--- radiant/patch.h | 20 +- radiant/points.cpp | 4 +- radiant/select.cpp | 8 +- radiant/select.h | 2 +- radiant/stacktrace.cpp | 2 +- radiant/texmanip.cpp | 8 +- radiant/texmanip.h | 2 +- radiant/textures.cpp | 4 +- radiant/watchbsp.cpp | 2 +- radiant/watchbsp.h | 2 +- radiant/xmlstuff.cpp | 2 +- radiant/xmlstuff.h | 2 +- radiant/xywindow.cpp | 33 +- tools/quake3/common/cmdlib.cpp | 8 +- tools/quake3/common/jpeg.cpp | 2 +- tools/quake3/common/md4.cpp | 62 +-- tools/quake3/common/polylib.cpp | 2 +- tools/quake3/common/qimagelib.cpp | 40 +- tools/quake3/common/vfs.cpp | 2 +- tools/quake3/common/vfs.h | 2 +- tools/quake3/q3map2/convert_map.cpp | 25 +- tools/quake3/q3map2/decals.cpp | 53 +- tools/quake3/q3map2/facebsp.cpp | 10 +- tools/quake3/q3map2/fog.cpp | 8 +- tools/quake3/q3map2/games.cpp | 14 +- tools/quake3/q3map2/help.cpp | 622 ++++++++++++------------ tools/quake3/q3map2/light_bounce.cpp | 62 ++- tools/quake3/q3map2/light_trace.cpp | 109 ++--- tools/quake3/q3map2/light_ydnar.cpp | 128 +++-- tools/quake3/q3map2/lightmaps_ydnar.cpp | 183 ++++--- tools/quake3/q3map2/map.cpp | 10 +- tools/quake3/q3map2/mesh.cpp | 39 +- tools/quake3/q3map2/patch.cpp | 3 +- tools/quake3/q3map2/surface.cpp | 26 +- tools/quake3/q3map2/surface_foliage.cpp | 25 +- tools/quake3/q3map2/surface_meta.cpp | 35 +- tools/quake3/q3map2/vis.cpp | 2 +- 74 files changed, 907 insertions(+), 968 deletions(-) diff --git a/contrib/bobtoolz/DPatch.cpp b/contrib/bobtoolz/DPatch.cpp index 148605e5..53ca9371 100644 --- a/contrib/bobtoolz/DPatch.cpp +++ b/contrib/bobtoolz/DPatch.cpp @@ -99,7 +99,7 @@ void DPatch::BuildInRadiant( scene::Node* entity ){ b->patchBrush = true; b->pPatch = Patch_Alloc(); - b->pPatch->setDims( width,height ); + b->pPatch->setDims( width, height ); for ( int x = 0; x < width; x++ ) for ( int y = 0; y < height; y++ ) @@ -167,7 +167,7 @@ void DPatch::LoadFromPatch( scene::Instance& patch ){ { for ( int y = 0; y < width; y++ ) { - float *p = brush->pPatch->ctrlAt( ROW,x,y ); + float *p = brush->pPatch->ctrlAt( ROW, x, y ); p[0] = points[x][y].xyz[0]; p[1] = points[x][y].xyz[1]; p[2] = points[x][y].xyz[2]; diff --git a/contrib/bobtoolz/shapes.cpp b/contrib/bobtoolz/shapes.cpp index 955e0daa..2c4e4500 100644 --- a/contrib/bobtoolz/shapes.cpp +++ b/contrib/bobtoolz/shapes.cpp @@ -618,7 +618,7 @@ void MakeBevel( vec3_t vMin, vec3_t vMax ){ { for ( int j = 0; j < 1; j++ ) { - PatchControl& p = matrix( i,2 - j ); + PatchControl& p = matrix( i, 2 - j ); PatchControl& q = matrix( i, j ); std::swap( p.m_vertex, q.m_vertex ); //std::swap(p.m_texcoord, q.m_texcoord); diff --git a/libs/container/hashfunc.h b/libs/container/hashfunc.h index ef8ba121..58b3dfe9 100644 --- a/libs/container/hashfunc.h +++ b/libs/container/hashfunc.h @@ -121,7 +121,7 @@ public: to choose from. I only looked at a billion or so. -------------------------------------------------------------------- */ -#define mix( a,b,c ) \ +#define mix( a, b, c ) \ { \ a -= b; a -= c; a ^= ( c >> 13 ); \ b -= c; b -= a; b ^= ( a << 8 ); \ @@ -135,7 +135,7 @@ public: } /* same, but slower, works on systems that might have 8 byte ub4's */ -#define mix2( a,b,c ) \ +#define mix2( a, b, c ) \ { \ a -= b; a -= c; a ^= ( c >> 13 ); \ b -= c; b -= a; b ^= ( a << 8 ); \ @@ -181,7 +181,7 @@ inline ub4 hash( const UB1Traits& ub1traits, const UB4x1Traits& ub4x1traits ){ - ub4 a,b,c,len; + ub4 a, b, c, len; /* Set up the internal state */ len = length; @@ -194,7 +194,7 @@ inline ub4 hash( a += ( k[0] + ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 ) + ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 ) + ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 ) ); b += ( k[4] + ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 ) + ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 ) + ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 ) ); c += ( k[8] + ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 8 ) + ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 16 ) + ( ( ub4 ) UB1Traits::as_ub1( k[11] ) << 24 ) ); - mix( a,b,c ); + mix( a, b, c ); k += 12; len -= 12; } @@ -217,7 +217,7 @@ inline ub4 hash( case 1: a += UB1Traits::as_ub1( k[0] ); /* case 0: nothing left to add */ } - mix( a,b,c ); + mix( a, b, c ); /*-------------------------------------------- report the result */ return c; } @@ -240,7 +240,7 @@ inline ub4 hash2( ub4 initval, /* the previous hash, or an arbitrary value */ const UB4Traits& ub4traits ){ - ub4 a,b,c,len; + ub4 a, b, c, len; /* Set up the internal state */ len = length; @@ -253,7 +253,7 @@ inline ub4 hash2( a += UB4Traits::as_ub4( k[0] ); b += UB4Traits::as_ub4( k[1] ); c += UB4Traits::as_ub4( k[2] ); - mix( a,b,c ); + mix( a, b, c ); k += 3; len -= 3; } @@ -267,7 +267,7 @@ inline ub4 hash2( case 1: a += UB4Traits::as_ub4( k[0] ); /* case 0: nothing left to add */ } - mix( a,b,c ); + mix( a, b, c ); /*-------------------------------------------- report the result */ return c; } @@ -284,7 +284,7 @@ inline hash_t hash_ub1_nocase( const ub1* key, std::size_t len, hash_t previous template inline hash_t hash_ub4( const ub4* key, std::size_t len, const UB4Traits& traits, hash_t previous = 0 ){ - return hash2( key,ub4( len ), previous, traits ); + return hash2( key, ub4( len ), previous, traits ); } inline ub4 hash_combine( ub4 left, ub4 right ){ diff --git a/libs/ddslib/ddslib.c b/libs/ddslib/ddslib.c index 362d538e..03b01f80 100644 --- a/libs/ddslib/ddslib.c +++ b/libs/ddslib/ddslib.c @@ -77,7 +77,7 @@ short DDSLittleShort( short src ){ } float DDSLittleFloat( float src ){ - floatSwapUnion in,out; + floatSwapUnion in, out; in.f = src; out.c[ 0 ] = in.c[ 3 ]; out.c[ 1 ] = in.c[ 2 ]; @@ -105,7 +105,7 @@ short DDSBigShort( short src ){ } float DDSBigFloat( float src ){ - floatSwapUnion in,out; + floatSwapUnion in, out; in.f = src; out.c[ 0 ] = in.c[ 3 ]; out.c[ 1 ] = in.c[ 2 ]; diff --git a/libs/eclasslib.h b/libs/eclasslib.h index a926456b..fe8d9134 100644 --- a/libs/eclasslib.h +++ b/libs/eclasslib.h @@ -267,7 +267,7 @@ inline EntityClass* Eclass_Alloc(){ memset( e->flagnames, 0, sizeof( e->flagnames ) ); memset( e->flagAttributes, 0, sizeof( e->flagAttributes ) ); - e->maxs = Vector3( -1,-1,-1 ); + e->maxs = Vector3(-1,-1,-1 ); e->mins = Vector3( 1, 1, 1 ); e->free = 0; @@ -324,7 +324,7 @@ inline EntityClass* EClass_Create_FixedSize( const char* name, const Vector3& co } const Vector3 smallbox[2] = { - Vector3( -8,-8,-8 ), + Vector3(-8,-8,-8 ), Vector3( 8, 8, 8 ), }; diff --git a/libs/l_net/l_net.c b/libs/l_net/l_net.c index eab1b5be..69c57b15 100644 --- a/libs/l_net/l_net.c +++ b/libs/l_net/l_net.c @@ -31,7 +31,7 @@ void WinPrint( const char *str, ... ){ va_list argptr; char text[4096]; - va_start( argptr,str ); + va_start( argptr, str ); vsprintf( text, str, argptr ); va_end( argptr ); diff --git a/libs/l_net/l_net_wins.c b/libs/l_net/l_net_wins.c index 964b633d..abf3676d 100644 --- a/libs/l_net/l_net_wins.c +++ b/libs/l_net/l_net_wins.c @@ -143,7 +143,7 @@ ERROR_STRUCT errlist[] = { {WSANO_DATA, "WSANO_DATA - (or WSANO_ADDRESS) - No data record of requested type" }, {-1, NULL } #else - {EACCES, "EACCES - The address is protected,user is not root"}, + {EACCES, "EACCES - The address is protected, user is not root"}, {EAGAIN, "EAGAIN - Operation on non-blocking socket that cannot return immediately"}, {EBADF, "EBADF - sockfd is not a valid descriptor"}, {EFAULT, "EFAULT - The parameter is not in a writable part of the user address space"}, diff --git a/libs/math/aabb.h b/libs/math/aabb.h index 8956b8aa..1c67d6c9 100644 --- a/libs/math/aabb.h +++ b/libs/math/aabb.h @@ -33,7 +33,7 @@ class AABB public: Vector3 origin, extents; - AABB() : origin( 0, 0, 0 ), extents( -1,-1,-1 ){ + AABB() : origin( 0, 0, 0 ), extents( -1, -1, -1 ){ } AABB( const Vector3& origin_, const Vector3& extents_ ) : origin( origin_ ), extents( extents_ ){ @@ -244,7 +244,7 @@ const Vector3 aabb_normals[6] = { Vector3( 1, 0, 0 ), Vector3( 0, 1, 0 ), Vector3( 0, 0, 1 ), - Vector3( -1, 0, 0 ), + Vector3(-1, 0, 0 ), Vector3( 0,-1, 0 ), Vector3( 0, 0,-1 ), }; diff --git a/libs/mathlib.h b/libs/mathlib.h index a8307b98..7697cecd 100644 --- a/libs/mathlib.h +++ b/libs/mathlib.h @@ -68,20 +68,20 @@ extern const vec3_t g_vec3_axis_z; #define EQUAL_EPSILON 0.001 -#define DotProduct( x,y ) ( ( x )[0] * ( y )[0] + ( x )[1] * ( y )[1] + ( x )[2] * ( y )[2] ) -#define VectorSubtract( a,b,c ) ( ( c )[0] = ( a )[0] - ( b )[0],( c )[1] = ( a )[1] - ( b )[1],( c )[2] = ( a )[2] - ( b )[2] ) -#define VectorAdd( a,b,c ) ( ( c )[0] = ( a )[0] + ( b )[0],( c )[1] = ( a )[1] + ( b )[1],( c )[2] = ( a )[2] + ( b )[2] ) -#define VectorIncrement( a,b ) ( ( b )[0] += ( a )[0],( b )[1] += ( a )[1],( b )[2] += ( a )[2] ) -#define VectorCopy( a,b ) ( ( b )[0] = ( a )[0],( b )[1] = ( a )[1],( b )[2] = ( a )[2] ) -#define VectorSet( v, a, b, c ) ( ( v )[0] = ( a ),( v )[1] = ( b ),( v )[2] = ( c ) ) -#define VectorScale( a,b,c ) ( ( c )[0] = ( b ) * ( a )[0],( c )[1] = ( b ) * ( a )[1],( c )[2] = ( b ) * ( a )[2] ) -#define VectorMid( a,b,c ) ( ( c )[0] = ( ( a )[0] + ( b )[0] ) * 0.5f,( c )[1] = ( ( a )[1] + ( b )[1] ) * 0.5f,( c )[2] = ( ( a )[2] + ( b )[2] ) * 0.5f ) -#define VectorNegate( a,b ) ( ( b )[0] = -( a )[0],( b )[1] = -( a )[1],( b )[2] = -( a )[2] ) -#define CrossProduct( a,b,c ) ( ( c )[0] = ( a )[1] * ( b )[2] - ( a )[2] * ( b )[1],( c )[1] = ( a )[2] * ( b )[0] - ( a )[0] * ( b )[2],( c )[2] = ( a )[0] * ( b )[1] - ( a )[1] * ( b )[0] ) +#define DotProduct( x, y ) ( ( x )[0] * ( y )[0] + ( x )[1] * ( y )[1] + ( x )[2] * ( y )[2] ) +#define VectorSubtract( a, b, c ) ( ( c )[0] = ( a )[0] - ( b )[0], ( c )[1] = ( a )[1] - ( b )[1], ( c )[2] = ( a )[2] - ( b )[2] ) +#define VectorAdd( a, b, c ) ( ( c )[0] = ( a )[0] + ( b )[0], ( c )[1] = ( a )[1] + ( b )[1], ( c )[2] = ( a )[2] + ( b )[2] ) +#define VectorIncrement( a, b ) ( ( b )[0] += ( a )[0], ( b )[1] += ( a )[1], ( b )[2] += ( a )[2] ) +#define VectorCopy( a, b ) ( ( b )[0] = ( a )[0], ( b )[1] = ( a )[1], ( b )[2] = ( a )[2] ) +#define VectorSet( v, a, b, c ) ( ( v )[0] = ( a ), ( v )[1] = ( b ), ( v )[2] = ( c ) ) +#define VectorScale( a, b, c ) ( ( c )[0] = ( b ) * ( a )[0], ( c )[1] = ( b ) * ( a )[1], ( c )[2] = ( b ) * ( a )[2] ) +#define VectorMid( a, b, c ) ( ( c )[0] = ( ( a )[0] + ( b )[0] ) * 0.5f, ( c )[1] = ( ( a )[1] + ( b )[1] ) * 0.5f, ( c )[2] = ( ( a )[2] + ( b )[2] ) * 0.5f ) +#define VectorNegate( a, b ) ( ( b )[0] = -( a )[0], ( b )[1] = -( a )[1], ( b )[2] = -( a )[2] ) +#define CrossProduct( a, b, c ) ( ( c )[0] = ( a )[1] * ( b )[2] - ( a )[2] * ( b )[1], ( c )[1] = ( a )[2] * ( b )[0] - ( a )[0] * ( b )[2], ( c )[2] = ( a )[0] * ( b )[1] - ( a )[1] * ( b )[0] ) #define VectorClear( x ) ( ( x )[0] = ( x )[1] = ( x )[2] = 0 ) #define VectorMax( x ) ( ( ( x )[0] > ( x )[1] ) ? ( ( ( x )[0] > ( x )[2] ) ? ( x )[0] : ( x )[2] ) : ( ( ( x )[1] > ( x )[2] ) ? ( x )[1] : ( x )[2] ) ) -#define FLOAT_SNAP( f,snap ) ( (float)( floor( ( f ) / ( snap ) + 0.5 ) * ( snap ) ) ) +#define FLOAT_SNAP( f, snap ) ( (float)( floor( ( f ) / ( snap ) + 0.5 ) * ( snap ) ) ) #define FLOAT_TO_INTEGER( f ) ( (float)( floor( ( f ) + 0.5 ) ) ) #define RGBTOGRAY( x ) ( (float)( ( x )[0] ) * 0.2989f + (float)( ( x )[1] ) * 0.5870f + (float)( ( x )[2] ) * 0.1140f ) @@ -180,7 +180,7 @@ typedef vec_t m3x3_t[9]; */ typedef vec_t m4x4_t[16]; -#define M4X4_INDEX( m,row,col ) ( m[( col << 2 ) + row] ) +#define M4X4_INDEX( m, row, col ) ( m[( col << 2 ) + row] ) typedef enum { eXYZ, eYZX, eZXY, eXZY, eYXZ, eZYX } eulerOrder_t; @@ -196,7 +196,7 @@ typedef unsigned char clipmask_t; extern const m4x4_t g_m4x4_identity; -#define M4X4_COPY( dst,src ) ( \ +#define M4X4_COPY( dst, src ) ( \ ( dst )[0] = ( src )[0], \ ( dst )[1] = ( src )[1], \ ( dst )[2] = ( src )[2], \ diff --git a/libs/mathlib/m4x4.c b/libs/mathlib/m4x4.c index cb1ad87e..9a4470b9 100644 --- a/libs/mathlib/m4x4.c +++ b/libs/mathlib/m4x4.c @@ -1667,7 +1667,7 @@ int m4x4_invert( m4x4_t matrix ){ #if 0 void m4x4_solve_ge( m4x4_t matrix, vec4_t x ){ int indx[4]; - int c,r; + int c, r; int i; int best; float scale[4]; @@ -1741,7 +1741,7 @@ void m4x4_solve_ge( m4x4_t matrix, vec4_t x ){ int matrix_solve_ge( vec_t* matrix, vec_t* aug, vec3_t x ){ int indx[N]; - int c,r; + int c, r; int i; int best; float scale[N]; diff --git a/libs/mathlib/mathlib.c b/libs/mathlib/mathlib.c index a264d326..5e3158b1 100644 --- a/libs/mathlib/mathlib.c +++ b/libs/mathlib/mathlib.c @@ -24,7 +24,7 @@ // we use memcpy and memset #include -const vec3_t vec3_origin = {0.0f,0.0f,0.0f}; +const vec3_t vec3_origin = { 0.0f, 0.0f, 0.0f }; const vec3_t g_vec3_axis_x = { 1, 0, 0, }; const vec3_t g_vec3_axis_y = { 0, 1, 0, }; diff --git a/libs/mathlib/ray.c b/libs/mathlib/ray.c index a39b48a0..543241aa 100644 --- a/libs/mathlib/ray.c +++ b/libs/mathlib/ray.c @@ -22,7 +22,7 @@ #include "mathlib.h" #include -vec3_t identity = { 0,0,0 }; +vec3_t identity = { 0, 0, 0 }; void ray_construct_for_vec3( ray_t *ray, const vec3_t origin, const vec3_t direction ){ VectorCopy( origin, ray->origin ); @@ -62,7 +62,7 @@ vec_t ray_intersect_point( const ray_t *ray, const vec3_t point, vec_t epsilon, vec_t ray_intersect_triangle( const ray_t *ray, bool bCullBack, const vec3_t vert0, const vec3_t vert1, const vec3_t vert2 ){ float edge1[3], edge2[3], tvec[3], pvec[3], qvec[3]; - float det,inv_det; + float det, inv_det; float u, v; vec_t depth = (vec_t)FLT_MAX; diff --git a/libs/profile/file.cpp b/libs/profile/file.cpp index e9a7cbd5..a219a2b3 100644 --- a/libs/profile/file.cpp +++ b/libs/profile/file.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/libs/profile/file.h b/libs/profile/file.h index e85d985c..52629e95 100644 --- a/libs/profile/file.h +++ b/libs/profile/file.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/libs/profile/profile.cpp b/libs/profile/profile.cpp index 83af032e..cd4df30b 100644 --- a/libs/profile/profile.cpp +++ b/libs/profile/profile.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/libs/profile/profile.h b/libs/profile/profile.h index 789771e3..7334138b 100644 --- a/libs/profile/profile.h +++ b/libs/profile/profile.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/libs/profile/profile2.h b/libs/profile/profile2.h index ebbb0914..2313ed29 100644 --- a/libs/profile/profile2.h +++ b/libs/profile/profile2.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/libs/render.h b/libs/render.h index 624a01a0..bdfa3874 100644 --- a/libs/render.h +++ b/libs/render.h @@ -1145,10 +1145,10 @@ inline void draw_semicircle( const std::size_t segments, const float radius, ite remap_policy::set( ( *nxpy ),-x, y, 0 ); remap_policy::set( ( *nxny ),-x,-y, 0 ); - //remap_policy::set((*pypx), y, x, 0); - //remap_policy::set((*pynx), y,-x, 0); - //remap_policy::set((*nypx),-y, x, 0); - //remap_policy::set((*nynx),-y,-x, 0); + //remap_policy::set( ( *pypx), y, x, 0 ); + //remap_policy::set( ( *pynx), y,-x, 0 ); + //remap_policy::set( ( *nypx),-y, x, 0 ); + //remap_policy::set( ( *nynx),-y,-x, 0 ); } } diff --git a/libs/str.h b/libs/str.h index c6d59827..1f301d3b 100644 --- a/libs/str.h +++ b/libs/str.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/plugins/entity/light.cpp b/plugins/entity/light.cpp index 9ef4dc0f..f6940527 100644 --- a/plugins/entity/light.cpp +++ b/plugins/entity/light.cpp @@ -557,11 +557,11 @@ void light_draw( const AABB& aabb_light, RenderStateFlags state ){ Vector3( 0, f, f ), Vector3( f, 0, f ), Vector3( 0,-f, f ), - Vector3( -f, 0, f ), + Vector3(-f, 0, f ), Vector3( 0, f,-f ), Vector3( f, 0,-f ), Vector3( 0,-f,-f ), - Vector3( -f, 0,-f ), + Vector3(-f, 0,-f ), }; #if !defined( USE_TRIANGLE_FAN ) diff --git a/plugins/image/jpeg.cpp b/plugins/image/jpeg.cpp index 2b53cf72..a55c2e1b 100644 --- a/plugins/image/jpeg.cpp +++ b/plugins/image/jpeg.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/plugins/image/jpeg.h b/plugins/image/jpeg.h index e8bfe8af..0e38024b 100644 --- a/plugins/image/jpeg.h +++ b/plugins/image/jpeg.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/plugins/imagehl/hlw.cpp b/plugins/imagehl/hlw.cpp index 5986611f..baf25128 100644 --- a/plugins/imagehl/hlw.cpp +++ b/plugins/imagehl/hlw.cpp @@ -100,7 +100,7 @@ Image* LoadHLWBuff( byte* buffer ){ lpMip = (LPWAD3_MIP)buffer; //!\todo Make endian-safe. - mipdatasize = GET_MIP_DATA_SIZE( lpMip->width,lpMip->height ); + mipdatasize = GET_MIP_DATA_SIZE( lpMip->width, lpMip->height ); palette = buffer + mipdatasize + 2; diff --git a/plugins/md3model/mdlimage.cpp b/plugins/md3model/mdlimage.cpp index cb719551..7724c6b6 100644 --- a/plugins/md3model/mdlimage.cpp +++ b/plugins/md3model/mdlimage.cpp @@ -41,7 +41,7 @@ unsigned char mdl_palette[768]; ============== */ void Texture_InitPalette( byte *pal ){ - int r,g,b; + int r, g, b; int i; int inf; byte gammatable[256]; diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index 659472db..2539dc86 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/plugins/shaders/shaders.h b/plugins/shaders/shaders.h index 02c58b89..920370c8 100644 --- a/plugins/shaders/shaders.h +++ b/plugins/shaders/shaders.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index d5ee0d0d..823ad4bc 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/plugins/vfspk3/vfs.h b/plugins/vfspk3/vfs.h index 93e1341c..3d08e6ad 100644 --- a/plugins/vfspk3/vfs.h +++ b/plugins/vfspk3/vfs.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/brush_primit.h b/radiant/brush_primit.h index 89e0fc54..34dcb0e2 100644 --- a/radiant/brush_primit.h +++ b/radiant/brush_primit.h @@ -163,18 +163,18 @@ inline void ComputeAxisBase( const BasicVector3& normal, BasicVector3comments(),pWhat ); + where = strstr( e->comments(), pWhat ); if ( !where ) { return; } @@ -170,7 +170,7 @@ void setSpecialLoad( EntityClass *e, const char* pWhat, CopiedString& p ){ pText++; } - where = strchr( pText,'\"' ); + where = strchr( pText, '\"' ); if ( where ) { p = StringRange( pText, where ); } @@ -207,7 +207,7 @@ EntityClass *Eclass_InitFromText( const char *text ){ { // grab the color, reformat as texture name - int r = sscanf( text," (%f %f %f)", &e->color[0], &e->color[1], &e->color[2] ); + int r = sscanf( text, " (%f %f %f)", &e->color[0], &e->color[1], &e->color[2] ); if ( r != 3 ) { return e; } @@ -227,8 +227,8 @@ EntityClass *Eclass_InitFromText( const char *text ){ text = COM_Parse( text ); if ( Get_COM_Token()[0] == '(' ) { // parse the size as two vectors e->fixedsize = true; - int r = sscanf( text,"%f %f %f) (%f %f %f)", &e->mins[0], &e->mins[1], &e->mins[2], - &e->maxs[0], &e->maxs[1], &e->maxs[2] ); + int r = sscanf( text, "%f %f %f) (%f %f %f)", &e->mins[0], &e->mins[1], &e->mins[2], + &e->maxs[0], &e->maxs[1], &e->maxs[2] ); if ( r != 6 ) { return 0; } diff --git a/radiant/error.cpp b/radiant/error.cpp index c6911eee..999ced77 100644 --- a/radiant/error.cpp +++ b/radiant/error.cpp @@ -57,8 +57,8 @@ void Error( const char *error, ... ){ va_list argptr; char text[4096]; - va_start( argptr,error ); - vsprintf( text, error,argptr ); + va_start( argptr, error ); + vsprintf( text, error, argptr ); va_end( argptr ); strcat( text, "\n" ); diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index e67d3d43..fe8c2018 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -131,7 +131,7 @@ void CPointMsg::DropHighlight(){ void CPointMsg::Draw2D( VIEWTYPE vt ){ NDIM1NDIM2( vt ) gl().glPointSize( 4 ); - gl().glColor3f( 1.0f,0.0f,0.0f ); + gl().glColor3f( 1.0f, 0.0f, 0.0f ); gl().glBegin( GL_POINTS ); gl().glVertex2f( pt[nDim1], pt[nDim2] ); gl().glEnd(); @@ -202,7 +202,7 @@ void CWindingMsg::Draw2D( VIEWTYPE vt ){ int i; NDIM1NDIM2( vt ) - gl().glColor3f( 1.0f,0.f,0.0f ); + gl().glColor3f( 1.0f, 0.f, 0.0f ); gl().glPointSize( 4 ); gl().glBegin( GL_POINTS ); @@ -214,7 +214,7 @@ void CWindingMsg::Draw2D( VIEWTYPE vt ){ gl().glEnable( GL_BLEND ); gl().glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); gl().glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - gl().glColor4f( 0.133f,0.4f,1.0f,0.5f ); + gl().glColor4f( 0.133f, 0.4f, 1.0f, 0.5f ); gl().glBegin( GL_POLYGON ); for ( i = 0; i < numpoints; i++ ) gl().glVertex2f( wt[i][nDim1], wt[i][nDim2] ); diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 1b877a26..4f087e5c 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/gtkdlgs.h b/radiant/gtkdlgs.h index 58144747..5f93dfd6 100644 --- a/radiant/gtkdlgs.h +++ b/radiant/gtkdlgs.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 5e25d07d..de837276 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 2fa7da03..c29a7358 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 24f5e897..11755e92 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -2772,7 +2772,7 @@ void Patch::BuildVertexArray(){ std::size_t index0 = 1; std::size_t index1 = 4; - double dot = vector3_dot( tangentX[index0],tangentY[index1] ); + double dot = vector3_dot( tangentX[index0], tangentY[index1] ); double length = vector3_length( tangentX[index0] ) * vector3_length( tangentY[index1] ); bestTangents10( nFlagsX, dot, length, index0, index1 ); @@ -2800,7 +2800,7 @@ void Patch::BuildVertexArray(){ std::size_t index0 = 5; std::size_t index1 = 5; - double dot = vector3_dot( tangentX[index0],tangentY[index1] ); + double dot = vector3_dot( tangentX[index0], tangentY[index1] ); double length = vector3_length( tangentX[index0] ) * vector3_length( tangentY[index1] ); bestTangents11( nFlagsX, dot, length, index0, index1 ); @@ -2874,7 +2874,7 @@ void Patch::BuildVertexArray(){ } -Vector3 getAverageNormal(const Vector3& normal1, const Vector3& normal2) +Vector3 getAverageNormal( const Vector3& normal1, const Vector3& normal2 ) { // Beware of normals with 0 length if ( vector3_length_squared( normal1 ) == 0 ) return normal2; @@ -2887,12 +2887,12 @@ Vector3 getAverageNormal(const Vector3& normal1, const Vector3& normal2) // Get the angle bisector if( vector3_length_squared( normal1 + normal2 ) == 0 ) return normal1; - Vector3 normal = vector3_normalised (normal1 + normal2); + Vector3 normal = vector3_normalised( normal1 + normal2 ); // Now calculate the length correction out of the angle // of the two normals /* float factor = cos(n1.angle(n2) * 0.5); */ - float factor = (float) vector3_dot( normal1, normal2 ); + float factor = vector3_dot( normal1, normal2 ); if ( factor > 1.0 ) factor = 1; if ( factor < -1.0 ) factor = -1; factor = acos( factor ); @@ -2901,7 +2901,7 @@ Vector3 getAverageNormal(const Vector3& normal1, const Vector3& normal2) // Check for div by zero (if the normals are antiparallel) // and stretch the resulting normal, if necessary - if (factor != 0) + if ( factor != 0 ) { normal /= factor; } @@ -2909,33 +2909,33 @@ Vector3 getAverageNormal(const Vector3& normal1, const Vector3& normal2) return normal; } -void Patch::createThickenedOpposite(const Patch& sourcePatch, - const float thickness, - const int axis, - bool& no12, - bool& no34) +void Patch::createThickenedOpposite( const Patch& sourcePatch, + const float thickness, + const int axis, + bool& no12, + bool& no34 ) { // Clone the dimensions from the other patch - setDims(sourcePatch.getWidth(), sourcePatch.getHeight()); + setDims( sourcePatch.getWidth(), sourcePatch.getHeight() ); // Also inherit the tesselation from the source patch //setFixedSubdivisions(sourcePatch.subdivionsFixed(), sourcePatch.getSubdivisions()); // Copy the shader from the source patch - SetShader(sourcePatch.GetShader()); + SetShader( sourcePatch.GetShader() ); // if extrudeAxis == 0,0,0 the patch is extruded along its vertex normals - Vector3 extrudeAxis(0,0,0); + Vector3 extrudeAxis( 0 ); switch (axis) { case 0: // X-Axis - extrudeAxis = Vector3(1,0,0); + extrudeAxis = Vector3( 1, 0, 0 ); break; case 1: // Y-Axis - extrudeAxis = Vector3(0,1,0); + extrudeAxis = Vector3( 0, 1, 0 ); break; case 2: // Z-Axis - extrudeAxis = Vector3(0,0,1); + extrudeAxis = Vector3( 0, 0, 1 ); break; default: // Default value already set during initialisation @@ -2944,14 +2944,14 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, //check if certain seams are required + cycling in normals calculation is needed //( endpoints != startpoints ) - not a cylinder or something - for (std::size_t col = 0; col < m_width; col++){ + for ( std::size_t col = 0; col < m_width; col++ ){ if( vector3_length_squared( sourcePatch.ctrlAt( 0, col ).m_vertex - sourcePatch.ctrlAt( m_height - 1, col ).m_vertex ) > 0.1f ){ //globalOutputStream() << "yes12.\n"; no12 = false; break; } } - for (std::size_t row = 0; row < m_height; row++){ + for ( std::size_t row = 0; row < m_height; row++ ){ if( vector3_length_squared( sourcePatch.ctrlAt( row, 0 ).m_vertex - sourcePatch.ctrlAt( row, m_width - 1 ).m_vertex ) > 0.1f ){ no34 = false; //globalOutputStream() << "yes34.\n"; @@ -2959,33 +2959,33 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, } } - for (std::size_t col = 0; col < m_width; col++) + for ( std::size_t col = 0; col < m_width; col++ ) { - for (std::size_t row = 0; row < m_height; row++) + for ( std::size_t row = 0; row < m_height; row++ ) { // The current control vertex on the other patch - const PatchControl& curCtrl = sourcePatch.ctrlAt(row, col); + const PatchControl& curCtrl = sourcePatch.ctrlAt( row, col ); Vector3 normal; // Are we extruding along vertex normals (i.e. extrudeAxis == 0,0,0)? - if (extrudeAxis == Vector3(0,0,0)) + if ( extrudeAxis == Vector3( 0 ) ) { // The col tangents (empty if 0,0,0) - Vector3 colTangent[2] = { Vector3(0,0,0), Vector3(0,0,0) }; + Vector3 colTangent[2] = { Vector3( 0 ), Vector3( 0 ) }; // Are we at the beginning/end of the row? + not cylinder - if ( (col == 0 || col == m_width - 1) && !no34 ) + if ( ( col == 0 || col == m_width - 1 ) && !no34 ) { // Get the next col index - std::size_t nextCol = (col == m_width - 1) ? (col - 1) : (col + 1); + std::size_t nextCol = ( col == m_width - 1 ) ? ( col - 1 ) : ( col + 1 ); - const PatchControl& colNeighbour = sourcePatch.ctrlAt(row, nextCol); + const PatchControl& colNeighbour = sourcePatch.ctrlAt( row, nextCol ); // One available tangent colTangent[0] = colNeighbour.m_vertex - curCtrl.m_vertex; // Reverse it if we're at the end of the column - colTangent[0] *= (col == m_width - 1) ? -1 : +1; + colTangent[0] *= ( col == m_width - 1 ) ? -1 : +1; //normalize if ( vector3_length_squared( colTangent[0] ) != 0 ) vector3_normalise( colTangent[0] ); } @@ -3006,8 +3006,8 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, nextCol = col+1; prevCol = col-1; } - const PatchControl& neighbour1 = sourcePatch.ctrlAt(row, nextCol); - const PatchControl& neighbour2 = sourcePatch.ctrlAt(row, prevCol); + const PatchControl& neighbour1 = sourcePatch.ctrlAt( row, nextCol ); + const PatchControl& neighbour2 = sourcePatch.ctrlAt( row, prevCol ); // Calculate both available tangents @@ -3024,26 +3024,26 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, // Cull redundant tangents (parallel) if ( vector3_length_squared( colTangent[1] + colTangent[0] ) == 0 || vector3_length_squared( colTangent[1] - colTangent[0] ) == 0 ){ - colTangent[1] = Vector3(0,0,0); + colTangent[1] = Vector3( 0 ); } } // Calculate the tangent vectors to the next row - Vector3 rowTangent[2] = { Vector3(0,0,0), Vector3(0,0,0) }; + Vector3 rowTangent[2] = { Vector3( 0 ), Vector3( 0 ) }; // Are we at the beginning or the end? - if ( (row == 0 || row == m_height - 1) && !no12 ) + if ( ( row == 0 || row == m_height - 1 ) && !no12 ) { // Yes, only calculate one row tangent // Get the next row index - std::size_t nextRow = (row == m_height - 1) ? (row - 1) : (row + 1); + std::size_t nextRow = ( row == m_height - 1 ) ? ( row - 1 ) : ( row + 1 ); - const PatchControl& rowNeighbour = sourcePatch.ctrlAt(nextRow, col); + const PatchControl& rowNeighbour = sourcePatch.ctrlAt( nextRow, col ); // First tangent rowTangent[0] = rowNeighbour.m_vertex - curCtrl.m_vertex; // Reverse it accordingly - rowTangent[0] *= (row == m_height - 1) ? -1 : +1; + rowTangent[0] *= ( row == m_height - 1 ) ? -1 : +1; //normalize if ( vector3_length_squared( rowTangent[0] ) != 0 ) vector3_normalise( rowTangent[0] ); } @@ -3052,19 +3052,19 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, // Two tangents to calculate std::size_t nextRow, prevRow; if( row == 0 ){ - nextRow = row+1; - prevRow = m_height-2; + nextRow = row + 1; + prevRow = m_height - 2; } else if( row == m_height - 1 ){ nextRow = 1; - prevRow = row-1; + prevRow = row - 1; } else{ - nextRow = row+1; - prevRow = row-1; + nextRow = row + 1; + prevRow = row - 1; } - const PatchControl& rowNeighbour1 = sourcePatch.ctrlAt(nextRow, col); - const PatchControl& rowNeighbour2 = sourcePatch.ctrlAt(prevRow, col); + const PatchControl& rowNeighbour1 = sourcePatch.ctrlAt( nextRow, col ); + const PatchControl& rowNeighbour2 = sourcePatch.ctrlAt( prevRow, col ); // First tangent rowTangent[0] = rowNeighbour1.m_vertex - curCtrl.m_vertex; @@ -3080,7 +3080,7 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, // Cull redundant tangents (parallel) if ( vector3_length_squared( rowTangent[1] + rowTangent[0] ) == 0 || vector3_length_squared( rowTangent[1] - rowTangent[0] ) == 0 ){ - rowTangent[1] = Vector3(0,0,0); + rowTangent[1] = Vector3( 0 ); } } @@ -3088,29 +3088,29 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, //clean parallel pairs... if ( vector3_length_squared( rowTangent[0] + colTangent[0] ) == 0 || vector3_length_squared( rowTangent[0] - colTangent[0] ) == 0 ){ - rowTangent[0] = Vector3(0,0,0); + rowTangent[0] = Vector3( 0 ); } if ( vector3_length_squared( rowTangent[1] + colTangent[1] ) == 0 || vector3_length_squared( rowTangent[1] - colTangent[1] ) == 0 ){ - rowTangent[1] = Vector3(0,0,0); + rowTangent[1] = Vector3( 0 ); } if ( vector3_length_squared( rowTangent[0] + colTangent[1] ) == 0 || vector3_length_squared( rowTangent[0] - colTangent[1] ) == 0 ){ - colTangent[1] = Vector3(0,0,0); + colTangent[1] = Vector3( 0 ); } if ( vector3_length_squared( rowTangent[1] + colTangent[0] ) == 0 || vector3_length_squared( rowTangent[1] - colTangent[0] ) == 0 ){ - rowTangent[1] = Vector3(0,0,0); + rowTangent[1] = Vector3( 0 ); } //clean dummies if ( vector3_length_squared( colTangent[0] ) == 0 ){ colTangent[0] = colTangent[1]; - colTangent[1] = Vector3(0,0,0); + colTangent[1] = Vector3( 0 ); } if ( vector3_length_squared( rowTangent[0] ) == 0 ){ rowTangent[0] = rowTangent[1]; - rowTangent[1] = Vector3(0,0,0); + rowTangent[1] = Vector3( 0 ); } if( vector3_length_squared( rowTangent[0] ) == 0 || vector3_length_squared( colTangent[0] ) == 0 ){ normal = extrudeAxis; @@ -3125,7 +3125,7 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, Vector3 normal1 = vector3_normalised( vector3_cross( rowTangent[0], colTangent[0] ) ); Vector3 normal2 = vector3_normalised( vector3_cross( rowTangent[1], colTangent[1] ) ); - normal = getAverageNormal(normal1, normal2); + normal = getAverageNormal( normal1, normal2 ); /*globalOutputStream() << "0\n"; globalOutputStream() << normal1 << '\n'; globalOutputStream() << normal2 << '\n'; @@ -3139,7 +3139,7 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, Vector3 normal1 = vector3_normalised( vector3_cross( rowTangent[0], colTangent[0] ) ); Vector3 normal2 = vector3_normalised( vector3_cross( rowTangent[0], colTangent[1] ) ); - normal = getAverageNormal(normal1, normal2); + normal = getAverageNormal( normal1, normal2 ); /*globalOutputStream() << "1\n"; globalOutputStream() << normal1 << '\n'; globalOutputStream() << normal2 << '\n'; @@ -3155,7 +3155,7 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, Vector3 normal1 = vector3_normalised( vector3_cross( rowTangent[0], colTangent[0] ) ); Vector3 normal2 = vector3_normalised( vector3_cross( rowTangent[1], colTangent[0] ) ); - normal = getAverageNormal(normal1, normal2); + normal = getAverageNormal( normal1, normal2 ); /*globalOutputStream() << "2\n"; globalOutputStream() << rowTangent[0] << '\n'; globalOutputStream() << colTangent[0] << '\n'; @@ -3187,10 +3187,10 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, } // Store the new coordinates into this patch at the current coords - ctrlAt(row, col).m_vertex = curCtrl.m_vertex + normal*thickness; + ctrlAt( row, col ).m_vertex = curCtrl.m_vertex + normal * thickness; // Clone the texture cooordinates of the source patch - ctrlAt(row, col).m_texcoord = curCtrl.m_texcoord; + ctrlAt( row, col ).m_texcoord = curCtrl.m_texcoord; } } @@ -3198,12 +3198,12 @@ void Patch::createThickenedOpposite(const Patch& sourcePatch, controlPointsChanged(); } -void Patch::createThickenedWall(const Patch& sourcePatch, - const Patch& targetPatch, - const int wallIndex) +void Patch::createThickenedWall( const Patch& sourcePatch, + const Patch& targetPatch, + const int wallIndex ) { // Copy the shader from the source patch - SetShader(sourcePatch.GetShader()); + SetShader( sourcePatch.GetShader() ); // The start and end control vertex indices int start = 0; @@ -3216,65 +3216,65 @@ void Patch::createThickenedWall(const Patch& sourcePatch, int cols = 0; int rows = 3; - int sourceWidth = static_cast(sourcePatch.getWidth()); - int sourceHeight = static_cast(sourcePatch.getHeight()); + int sourceWidth = static_cast( sourcePatch.getWidth() ); + int sourceHeight = static_cast( sourcePatch.getHeight() ); /* bool sourceTesselationFixed = sourcePatch.subdivionsFixed(); - Subdivisions sourceTesselationX(sourcePatch.getSubdivisions().x(), 1); - Subdivisions sourceTesselationY(sourcePatch.getSubdivisions().y(), 1); + Subdivisions sourceTesselationX( sourcePatch.getSubdivisions().x(), 1 ); + Subdivisions sourceTesselationY( sourcePatch.getSubdivisions().y(), 1 ); */ // Determine which of the four edges have to be connected // and calculate the start, end & stepsize for the following loop - switch (wallIndex) { + switch ( wallIndex ) { case 0: cols = sourceWidth; start = 0; end = sourceWidth - 1; incr = 1; - //setFixedSubdivisions(sourceTesselationFixed, sourceTesselationX); + //setFixedSubdivisions( sourceTesselationFixed, sourceTesselationX ); break; case 1: cols = sourceWidth; start = sourceWidth * (sourceHeight-1); end = sourceWidth*sourceHeight - 1; incr = 1; - //setFixedSubdivisions(sourceTesselationFixed, sourceTesselationX); + //setFixedSubdivisions( sourceTesselationFixed, sourceTesselationX ); break; case 2: cols = sourceHeight; start = 0; end = sourceWidth*(sourceHeight-1); incr = sourceWidth; - //setFixedSubdivisions(sourceTesselationFixed, sourceTesselationY); + //setFixedSubdivisions( sourceTesselationFixed, sourceTesselationY ); break; case 3: cols = sourceHeight; start = sourceWidth - 1; end = sourceWidth*sourceHeight - 1; incr = sourceWidth; - //setFixedSubdivisions(sourceTesselationFixed, sourceTesselationY); + //setFixedSubdivisions( sourceTesselationFixed, sourceTesselationY ); break; } - setDims(cols, rows); + setDims( cols, rows ); const PatchControlArray& sourceCtrl = sourcePatch.getControlPoints(); const PatchControlArray& targetCtrl = targetPatch.getControlPoints(); int col = 0; // Now go through the control vertices with these calculated stepsize - for (int idx = start; idx <= end; idx += incr, col++) { + for ( int idx = start; idx <= end; idx += incr, col++ ) { Vector3 sourceCoord = sourceCtrl[idx].m_vertex; Vector3 targetCoord = targetCtrl[idx].m_vertex; - Vector3 middleCoord = (sourceCoord + targetCoord) / 2; + Vector3 middleCoord = ( sourceCoord + targetCoord ) / 2; // Now assign the vertex coordinates - ctrlAt(0, col).m_vertex = sourceCoord; - ctrlAt(1, col).m_vertex = middleCoord; - ctrlAt(2, col).m_vertex = targetCoord; + ctrlAt( 0, col ).m_vertex = sourceCoord; + ctrlAt( 1, col ).m_vertex = middleCoord; + ctrlAt( 2, col ).m_vertex = targetCoord; } - if (wallIndex == 0 || wallIndex == 3) { + if ( wallIndex == 0 || wallIndex == 3 ) { InvertMatrix(); } diff --git a/radiant/patch.h b/radiant/patch.h index af84b0cf..e9f4b022 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -1091,11 +1091,11 @@ inline bool Patch_importMatrix( Patch& patch, Tokeniser& tokeniser ){ { RETURN_FALSE_IF_FAIL( Tokeniser_parseToken( tokeniser, "(" ) ); - RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r,c ).m_vertex[0] ) ); - RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r,c ).m_vertex[1] ) ); - RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r,c ).m_vertex[2] ) ); - RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r,c ).m_texcoord[0] ) ); - RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r,c ).m_texcoord[1] ) ); + RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r, c ).m_vertex[0] ) ); + RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r, c ).m_vertex[1] ) ); + RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r, c ).m_vertex[2] ) ); + RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r, c ).m_texcoord[0] ) ); + RETURN_FALSE_IF_FAIL( Tokeniser_getFloat( tokeniser, patch.ctrlAt( r, c ).m_texcoord[1] ) ); RETURN_FALSE_IF_FAIL( Tokeniser_parseToken( tokeniser, ")" ) ); } @@ -1212,11 +1212,11 @@ inline void Patch_exportMatrix( const Patch& patch, TokenWriter& writer ){ { writer.writeToken( "(" ); - writer.writeFloat( patch.ctrlAt( r,c ).m_vertex[0] ); - writer.writeFloat( patch.ctrlAt( r,c ).m_vertex[1] ); - writer.writeFloat( patch.ctrlAt( r,c ).m_vertex[2] ); - writer.writeFloat( patch.ctrlAt( r,c ).m_texcoord[0] ); - writer.writeFloat( patch.ctrlAt( r,c ).m_texcoord[1] ); + writer.writeFloat( patch.ctrlAt( r, c ).m_vertex[0] ); + writer.writeFloat( patch.ctrlAt( r, c ).m_vertex[1] ); + writer.writeFloat( patch.ctrlAt( r, c ).m_vertex[2] ); + writer.writeFloat( patch.ctrlAt( r, c ).m_texcoord[0] ); + writer.writeFloat( patch.ctrlAt( r, c ).m_texcoord[1] ); writer.writeToken( ")" ); } diff --git a/radiant/points.cpp b/radiant/points.cpp index d709de36..bb022ba1 100644 --- a/radiant/points.cpp +++ b/radiant/points.cpp @@ -273,7 +273,7 @@ void Pointfile_Parse( CPointfile& pointfile ){ while ( *data ) { Vector3 v; - if ( sscanf( data,"%f %f %f", &v[0], &v[1], &v[2] ) != 3 ) { + if ( sscanf( data, "%f %f %f", &v[0], &v[1], &v[2] ) != 3 ) { globalWarningStream() << "Corrupt point file, line " << line << '\n'; break; } @@ -287,7 +287,7 @@ void Pointfile_Parse( CPointfile& pointfile ){ } // deal with zhlt style point files. if ( *data == '-' ) { - if ( sscanf( data,"- %f %f %f", &v[0], &v[1], &v[2] ) != 3 ) { + if ( sscanf( data, "- %f %f %f", &v[0], &v[1], &v[2] ) != 3 ) { globalWarningStream() << "Corrupt point file, line " << line << '\n'; break; } diff --git a/radiant/select.cpp b/radiant/select.cpp index 723845b5..617ba8cc 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -1036,7 +1036,7 @@ void Selection_Flipz(){ void Selection_Rotatex(){ UndoableCommand undo( "rotateSelected -axis x -angle -90" ); - Select_RotateAxis( 0,-90 ); + Select_RotateAxis( 0, -90 ); } void Selection_Rotatey(){ @@ -1046,7 +1046,7 @@ void Selection_Rotatey(){ void Selection_Rotatez(){ UndoableCommand undo( "rotateSelected -axis z -angle -90" ); - Select_RotateAxis( 2,-90 ); + Select_RotateAxis( 2, -90 ); } #include "xywindow.h" void Selection_FlipHorizontally(){ @@ -1489,11 +1489,11 @@ void Texdef_ScaleDown(){ } void Texdef_ScaleLeft(){ - Texdef_Scale( -g_si_globals.scale[0],0 ); + Texdef_Scale( -g_si_globals.scale[0], 0 ); } void Texdef_ScaleRight(){ - Texdef_Scale( g_si_globals.scale[0],0 ); + Texdef_Scale( g_si_globals.scale[0], 0 ); } void Texdef_Shift( float x, float y ){ diff --git a/radiant/select.h b/radiant/select.h index 4bbe5ea5..a6e66d7a 100644 --- a/radiant/select.h +++ b/radiant/select.h @@ -62,7 +62,7 @@ struct select_workzone_t Vector3 d_work_min, d_work_max; select_workzone_t() : - d_work_min( -64.0f,-64.0f,-64.0f ), + d_work_min(-64.0f,-64.0f,-64.0f ), d_work_max( 64.0f, 64.0f, 64.0f ){ } }; diff --git a/radiant/stacktrace.cpp b/radiant/stacktrace.cpp index 7d0a7afc..062d3721 100644 --- a/radiant/stacktrace.cpp +++ b/radiant/stacktrace.cpp @@ -285,7 +285,7 @@ void write_stack_trace( PCONTEXT pContext, TextOutputStream& outputStream ){ void write_stack_trace( TextOutputStream& outputStream ){ __try { - RaiseException( 0,0,0,0 ); + RaiseException( 0, 0, 0, 0 ); } __except( write_stack_trace( ( GetExceptionInformation() )->ContextRecord, outputStream ), EXCEPTION_CONTINUE_EXECUTION ) { } diff --git a/radiant/texmanip.cpp b/radiant/texmanip.cpp index 2a6f26da..bf24aaac 100644 --- a/radiant/texmanip.cpp +++ b/radiant/texmanip.cpp @@ -21,7 +21,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT @@ -44,7 +44,7 @@ void R_ResampleTextureLerpLine( const byte *in, byte *out, int inwidth, int outw fstep = (int) ( inwidth * 65536.0f / outwidth ); endx = ( inwidth - 1 ); if ( bytesperpixel == 4 ) { - for ( j = 0,f = 0; j < outwidth; j++, f += fstep ) + for ( j = 0, f = 0; j < outwidth; j++, f += fstep ) { xi = f >> 16; if ( xi != oldx ) { @@ -129,7 +129,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out R_ResampleTextureLerpLine( inrow, row1, inwidth, outwidth, bytesperpixel ); R_ResampleTextureLerpLine( inrow + inwidth4, row2, inwidth, outwidth, bytesperpixel ); - for ( i = 0, f = 0; i < outheight; i++,f += fstep ) + for ( i = 0, f = 0; i < outheight; i++, f += fstep ) { yi = f >> 16; if ( yi < endy ) { @@ -225,7 +225,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out oldy = 0; R_ResampleTextureLerpLine( inrow, row1, inwidth, outwidth, bytesperpixel ); R_ResampleTextureLerpLine( inrow + inwidth3, row2, inwidth, outwidth, bytesperpixel ); - for ( i = 0, f = 0; i < outheight; i++,f += fstep ) + for ( i = 0, f = 0; i < outheight; i++, f += fstep ) { yi = f >> 16; if ( yi < endy ) { diff --git a/radiant/texmanip.h b/radiant/texmanip.h index 642eda2f..2d8c05b2 100644 --- a/radiant/texmanip.h +++ b/radiant/texmanip.h @@ -21,7 +21,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/textures.cpp b/radiant/textures.cpp index 478e63cb..11a2082c 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -134,7 +134,7 @@ bool g_TextureAnisotropy = true; byte g_gammatable[256]; void ResampleGamma( float fGamma ){ - int i,inf; + int i, inf; if ( fGamma == 1.0 ) { for ( i = 0; i < 256; i++ ) g_gammatable[i] = i; @@ -269,7 +269,7 @@ void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHe ============== */ void Texture_InitPalette( byte *pal ){ - int r,g,b; + int r, g, b; int i; int inf; byte gammatable[256]; diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 41fec5b5..835377b6 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/watchbsp.h b/radiant/watchbsp.h index f568498f..89756e65 100644 --- a/radiant/watchbsp.h +++ b/radiant/watchbsp.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/xmlstuff.cpp b/radiant/xmlstuff.cpp index fbb4b852..cc1a6865 100644 --- a/radiant/xmlstuff.cpp +++ b/radiant/xmlstuff.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/xmlstuff.h b/radiant/xmlstuff.h index db15e8e5..2d589ffe 100644 --- a/radiant/xmlstuff.h +++ b/radiant/xmlstuff.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 3e489877..a99891c8 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -1331,11 +1331,6 @@ void XYWnd::XY_DrawGrid() { const float yb = step * floor( std::max( m_vOrigin[nDim2] - h, g_region_mins[nDim2] ) / step ); const float ye = step * ceil( std::min( m_vOrigin[nDim2] + h, g_region_maxs[nDim2] ) / step ); -#define COLORS_DIFFER( a,b ) \ - ( ( a )[0] != ( b )[0] || \ - ( a )[1] != ( b )[1] || \ - ( a )[2] != ( b )[2] ) - // djbob // draw minor blocks if ( g_xywindow_globals_private.d_showgrid /*|| a < 1.0f*/ ) { @@ -1343,7 +1338,7 @@ void XYWnd::XY_DrawGrid() { gl().glEnable( GL_BLEND ); } - if ( COLORS_DIFFER( g_xywindow_globals.color_gridminor, g_xywindow_globals.color_gridback ) ) { + if ( g_xywindow_globals.color_gridminor != g_xywindow_globals.color_gridback ) { gl().glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridminor, a ) ) ); gl().glBegin( GL_LINES ); @@ -1365,7 +1360,7 @@ void XYWnd::XY_DrawGrid() { } // draw major blocks - if ( COLORS_DIFFER( g_xywindow_globals.color_gridmajor, g_xywindow_globals.color_gridminor ) ) { + if ( g_xywindow_globals.color_gridmajor != g_xywindow_globals.color_gridminor ) { gl().glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridmajor, a ) ) ); gl().glBegin( GL_LINES ); @@ -1392,7 +1387,7 @@ void XYWnd::XY_DrawGrid() { gl().glEnable( GL_BLEND ); // draw minor blocks - if ( COLORS_DIFFER( g_xywindow_globals.color_gridminor, g_xywindow_globals.color_gridback ) ) { + if ( g_xywindow_globals.color_gridminor != g_xywindow_globals.color_gridback ) { gl().glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridminor, .5f ) ) ); gl().glBegin( GL_LINES ); @@ -1414,7 +1409,7 @@ void XYWnd::XY_DrawGrid() { } // draw major blocks - if ( COLORS_DIFFER( g_xywindow_globals.color_gridmajor, g_xywindow_globals.color_gridminor ) ) { + if ( g_xywindow_globals.color_gridmajor != g_xywindow_globals.color_gridminor ) { gl().glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridmajor, .5f ) ) ); gl().glBegin( GL_LINES ); @@ -1561,7 +1556,7 @@ void XYWnd::XY_DrawBlockGrid(){ for ( float y = yb; y < ye; y += bs2 ) { gl().glRasterPos2f( x + ( bs1 / 2 ), y + ( bs2 / 2 ) ); - sprintf( text, "%i,%i",(int)floor( x / bs1 ), (int)floor( y / bs2 ) ); + sprintf( text, "%i,%i", (int)floor( x / bs1 ), (int)floor( y / bs2 ) ); GlobalOpenGL().drawString( text ); } } @@ -1585,12 +1580,12 @@ void XYWnd::DrawCameraIcon( const Vector3& origin, const Vector3& angles ){ gl().glColor3fv( vector3_to_array( g_xywindow_globals.color_camera ) ); gl().glBegin( GL_LINE_STRIP ); - gl().glVertex3f( x - box,y,0 ); - gl().glVertex3f( x,y + ( box / 2 ),0 ); - gl().glVertex3f( x + box,y,0 ); - gl().glVertex3f( x,y - ( box / 2 ),0 ); - gl().glVertex3f( x - box,y,0 ); - gl().glVertex3f( x + box,y,0 ); + gl().glVertex3f( x - box, y , 0 ); + gl().glVertex3f( x , y + ( box / 2 ), 0 ); + gl().glVertex3f( x + box, y , 0 ); + gl().glVertex3f( x , y - ( box / 2 ), 0 ); + gl().glVertex3f( x - box, y , 0 ); + gl().glVertex3f( x + box, y , 0 ); gl().glEnd(); gl().glBegin( GL_LINE_STRIP ); @@ -2309,9 +2304,9 @@ void XYWindow_Construct(){ GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) ); GlobalPreferenceSystem().registerPreference( "ShowWorkzone2d", BoolImportStringCaller( g_xywindow_globals_private.show_workzone ), BoolExportStringCaller( g_xywindow_globals_private.show_workzone ) ); - GlobalPreferenceSystem().registerPreference( "ColorAxisX", Colour4bImportStringCaller( g_colour_x ),Colour4bExportStringCaller( g_colour_x ) ); - GlobalPreferenceSystem().registerPreference( "ColorAxisY", Colour4bImportStringCaller( g_colour_y ),Colour4bExportStringCaller( g_colour_y ) ); - GlobalPreferenceSystem().registerPreference( "ColorAxisZ", Colour4bImportStringCaller( g_colour_z ),Colour4bExportStringCaller( g_colour_z ) ); + GlobalPreferenceSystem().registerPreference( "ColorAxisX", Colour4bImportStringCaller( g_colour_x ), Colour4bExportStringCaller( g_colour_x ) ); + GlobalPreferenceSystem().registerPreference( "ColorAxisY", Colour4bImportStringCaller( g_colour_y ), Colour4bExportStringCaller( g_colour_y ) ); + GlobalPreferenceSystem().registerPreference( "ColorAxisZ", Colour4bImportStringCaller( g_colour_z ), Colour4bExportStringCaller( g_colour_z ) ); GlobalPreferenceSystem().registerPreference( "ColorGridBackground", Vector3ImportStringCaller( g_xywindow_globals.color_gridback ), Vector3ExportStringCaller( g_xywindow_globals.color_gridback ) ); GlobalPreferenceSystem().registerPreference( "ColorGridMinor", Vector3ImportStringCaller( g_xywindow_globals.color_gridminor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridminor ) ); GlobalPreferenceSystem().registerPreference( "ColorGridMajor", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor ) ); diff --git a/tools/quake3/common/cmdlib.cpp b/tools/quake3/common/cmdlib.cpp index 2030f323..f7d6c5e6 100644 --- a/tools/quake3/common/cmdlib.cpp +++ b/tools/quake3/common/cmdlib.cpp @@ -214,7 +214,7 @@ void SaveFile( const char *filename, const void *buffer, int count ){ #ifdef __BIG_ENDIAN__ short LittleShort( short l ){ - byte b1,b2; + byte b1, b2; b1 = l & 255; b2 = ( l >> 8 ) & 255; @@ -228,7 +228,7 @@ short BigShort( short l ){ int LittleLong( int l ){ - byte b1,b2,b3,b4; + byte b1, b2, b3, b4; b1 = l & 255; b2 = ( l >> 8 ) & 255; @@ -264,7 +264,7 @@ float BigFloat( float l ){ short BigShort( short l ){ - byte b1,b2; + byte b1, b2; b1 = l & 255; b2 = ( l >> 8 ) & 255; @@ -278,7 +278,7 @@ short LittleShort( short l ){ int BigLong( int l ){ - byte b1,b2,b3,b4; + byte b1, b2, b3, b4; b1 = l & 255; b2 = ( l >> 8 ) & 255; diff --git a/tools/quake3/common/jpeg.cpp b/tools/quake3/common/jpeg.cpp index 1b546654..83a05694 100644 --- a/tools/quake3/common/jpeg.cpp +++ b/tools/quake3/common/jpeg.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/tools/quake3/common/md4.cpp b/tools/quake3/common/md4.cpp index 48cca946..a3f0fefb 100644 --- a/tools/quake3/common/md4.cpp +++ b/tools/quake3/common/md4.cpp @@ -41,45 +41,45 @@ struct md4 { It assumes that a int is at least 32 bits long */ -#define F( X,Y,Z ) ( ( (X)&( Y ) ) | ( ( ~( X ) ) & ( Z ) ) ) -#define G( X,Y,Z ) ( ( (X)&( Y ) ) | ( (X)&( Z ) ) | ( (Y)&( Z ) ) ) -#define H( X,Y,Z ) ( ( X ) ^ ( Y ) ^ ( Z ) ) -#define lshift( x,s ) ( ( ( x ) << ( s ) ) | ( ( x ) >> ( 32 - ( s ) ) ) ) +#define F( X, Y, Z ) ( ( ( X ) & ( Y ) ) | ( ( ~( X ) ) & ( Z ) ) ) +#define G( X, Y, Z ) ( ( ( X ) & ( Y ) ) | ( ( X ) & ( Z ) ) | ( ( Y ) & ( Z ) ) ) +#define H( X, Y, Z ) ( ( X ) ^ ( Y ) ^ ( Z ) ) +#define lshift( x , s ) ( ( ( x ) << ( s ) ) | ( ( x ) >> ( 32 - ( s ) ) ) ) -#define ROUND1( a,b,c,d,k,s ) a = lshift( a + F( b,c,d ) + X[k], s ) -#define ROUND2( a,b,c,d,k,s ) a = lshift( a + G( b,c,d ) + X[k] + 0x5A827999,s ) -#define ROUND3( a,b,c,d,k,s ) a = lshift( a + H( b,c,d ) + X[k] + 0x6ED9EBA1,s ) +#define ROUND1( a, b, c, d, k, s ) a = lshift( a + F( b, c, d ) + X[k], s ) +#define ROUND2( a, b, c, d, k, s ) a = lshift( a + G( b, c, d ) + X[k] + 0x5A827999, s ) +#define ROUND3( a, b, c, d, k, s ) a = lshift( a + H( b, c, d ) + X[k] + 0x6ED9EBA1, s ) /* this applies md4 to 64 byte chunks */ inline void mdfour64( md4& m, const std::array X ){ std::uint32_t A = m.A, B = m.B, C = m.C, D = m.D; - ROUND1( A,B,C,D, 0, 3 ); ROUND1( D,A,B,C, 1, 7 ); - ROUND1( C,D,A,B, 2, 11 ); ROUND1( B,C,D,A, 3, 19 ); - ROUND1( A,B,C,D, 4, 3 ); ROUND1( D,A,B,C, 5, 7 ); - ROUND1( C,D,A,B, 6, 11 ); ROUND1( B,C,D,A, 7, 19 ); - ROUND1( A,B,C,D, 8, 3 ); ROUND1( D,A,B,C, 9, 7 ); - ROUND1( C,D,A,B, 10, 11 ); ROUND1( B,C,D,A, 11, 19 ); - ROUND1( A,B,C,D, 12, 3 ); ROUND1( D,A,B,C, 13, 7 ); - ROUND1( C,D,A,B, 14, 11 ); ROUND1( B,C,D,A, 15, 19 ); + ROUND1( A, B, C, D, 0, 3 ); ROUND1( D, A, B, C, 1, 7 ); + ROUND1( C, D, A, B, 2, 11 ); ROUND1( B, C, D, A, 3, 19 ); + ROUND1( A, B, C, D, 4, 3 ); ROUND1( D, A, B, C, 5, 7 ); + ROUND1( C, D, A, B, 6, 11 ); ROUND1( B, C, D, A, 7, 19 ); + ROUND1( A, B, C, D, 8, 3 ); ROUND1( D, A, B, C, 9, 7 ); + ROUND1( C, D, A, B, 10, 11 ); ROUND1( B, C, D, A, 11, 19 ); + ROUND1( A, B, C, D, 12, 3 ); ROUND1( D, A, B, C, 13, 7 ); + ROUND1( C, D, A, B, 14, 11 ); ROUND1( B, C, D, A, 15, 19 ); - ROUND2( A,B,C,D, 0, 3 ); ROUND2( D,A,B,C, 4, 5 ); - ROUND2( C,D,A,B, 8, 9 ); ROUND2( B,C,D,A, 12, 13 ); - ROUND2( A,B,C,D, 1, 3 ); ROUND2( D,A,B,C, 5, 5 ); - ROUND2( C,D,A,B, 9, 9 ); ROUND2( B,C,D,A, 13, 13 ); - ROUND2( A,B,C,D, 2, 3 ); ROUND2( D,A,B,C, 6, 5 ); - ROUND2( C,D,A,B, 10, 9 ); ROUND2( B,C,D,A, 14, 13 ); - ROUND2( A,B,C,D, 3, 3 ); ROUND2( D,A,B,C, 7, 5 ); - ROUND2( C,D,A,B, 11, 9 ); ROUND2( B,C,D,A, 15, 13 ); + ROUND2( A, B, C, D, 0, 3 ); ROUND2( D, A, B, C, 4, 5 ); + ROUND2( C, D, A, B, 8, 9 ); ROUND2( B, C, D, A, 12, 13 ); + ROUND2( A, B, C, D, 1, 3 ); ROUND2( D, A, B, C, 5, 5 ); + ROUND2( C, D, A, B, 9, 9 ); ROUND2( B, C, D, A, 13, 13 ); + ROUND2( A, B, C, D, 2, 3 ); ROUND2( D, A, B, C, 6, 5 ); + ROUND2( C, D, A, B, 10, 9 ); ROUND2( B, C, D, A, 14, 13 ); + ROUND2( A, B, C, D, 3, 3 ); ROUND2( D, A, B, C, 7, 5 ); + ROUND2( C, D, A, B, 11, 9 ); ROUND2( B, C, D, A, 15, 13 ); - ROUND3( A,B,C,D, 0, 3 ); ROUND3( D,A,B,C, 8, 9 ); - ROUND3( C,D,A,B, 4, 11 ); ROUND3( B,C,D,A, 12, 15 ); - ROUND3( A,B,C,D, 2, 3 ); ROUND3( D,A,B,C, 10, 9 ); - ROUND3( C,D,A,B, 6, 11 ); ROUND3( B,C,D,A, 14, 15 ); - ROUND3( A,B,C,D, 1, 3 ); ROUND3( D,A,B,C, 9, 9 ); - ROUND3( C,D,A,B, 5, 11 ); ROUND3( B,C,D,A, 13, 15 ); - ROUND3( A,B,C,D, 3, 3 ); ROUND3( D,A,B,C, 11, 9 ); - ROUND3( C,D,A,B, 7, 11 ); ROUND3( B,C,D,A, 15, 15 ); + ROUND3( A, B, C, D, 0, 3 ); ROUND3( D, A, B, C, 8, 9 ); + ROUND3( C, D, A, B, 4, 11 ); ROUND3( B, C, D, A, 12, 15 ); + ROUND3( A, B, C, D, 2, 3 ); ROUND3( D, A, B, C, 10, 9 ); + ROUND3( C, D, A, B, 6, 11 ); ROUND3( B, C, D, A, 14, 15 ); + ROUND3( A, B, C, D, 1, 3 ); ROUND3( D, A, B, C, 9, 9 ); + ROUND3( C, D, A, B, 5, 11 ); ROUND3( B, C, D, A, 13, 15 ); + ROUND3( A, B, C, D, 3, 3 ); ROUND3( D, A, B, C, 11, 9 ); + ROUND3( C, D, A, B, 7, 11 ); ROUND3( B, C, D, A, 15, 15 ); m.A += A; m.B += B; m.C += C; m.D += D; } diff --git a/tools/quake3/common/polylib.cpp b/tools/quake3/common/polylib.cpp index 0e7b465e..6fcbc001 100644 --- a/tools/quake3/common/polylib.cpp +++ b/tools/quake3/common/polylib.cpp @@ -643,7 +643,7 @@ inline const MinMax c_worldMinmax( Vector3( MIN_WORLD_COORD ), Vector3( MAX_WORL */ void CheckWinding( const winding_t& w ){ if ( w.size() < 3 ) { - Error( "CheckWinding: %zu points",w.size() ); + Error( "CheckWinding: %zu points", w.size() ); } const float area = WindingArea( w ); diff --git a/tools/quake3/common/qimagelib.cpp b/tools/quake3/common/qimagelib.cpp index a3819748..0fae334d 100644 --- a/tools/quake3/common/qimagelib.cpp +++ b/tools/quake3/common/qimagelib.cpp @@ -106,15 +106,15 @@ typedef enum typedef struct { - UWORD w,h; - short x,y; + UWORD w, h; + short x, y; UBYTE nPlanes; UBYTE masking; UBYTE compression; UBYTE pad1; UWORD transparentColor; - UBYTE xAspect,yAspect; - short pageWidth,pageHeight; + UBYTE xAspect, yAspect; + short pageWidth, pageHeight; } bmhd_t; extern bmhd_t bmhd; // will be in native byte order @@ -147,9 +147,9 @@ int Align( int l ){ Source must be evenly aligned! ================ */ -byte *LBMRLEDecompress( byte *source,byte *unpacked, int bpwidth ){ +byte *LBMRLEDecompress( byte *source, byte *unpacked, int bpwidth ){ int count; - byte b,rept; + byte b, rept; count = 0; @@ -160,12 +160,12 @@ byte *LBMRLEDecompress( byte *source,byte *unpacked, int bpwidth ){ if ( rept > 0x80 ) { rept = ( rept ^ 0xff ) + 2; b = *source++; - memset( unpacked,b,rept ); + memset( unpacked, b, rept ); unpacked += rept; } else if ( rept < 0x80 ) { rept++; - memcpy( unpacked,source,rept ); + memcpy( unpacked, source, rept ); unpacked += rept; source += rept; } @@ -198,8 +198,8 @@ void LoadLBM( const char *filename, byte **picture, byte **palette ){ byte *pic_p; byte *body_p; - int formtype,formlength; - int chunktype,chunklength; + int formtype, formlength; + int chunktype, chunklength; // qiet compiler warnings picbuffer = NULL; @@ -226,8 +226,8 @@ void LoadLBM( const char *filename, byte **picture, byte **palette ){ formtype = LittleLong( *(int *)LBM_P ); if ( formtype != ILBMID && formtype != PBMID ) { - Error( "Unrecognized form type: %c%c%c%c\n", formtype & 0xff - ,( formtype >> 8 ) & 0xff,( formtype >> 16 ) & 0xff,( formtype >> 24 ) & 0xff ); + Error( "Unrecognized form type: %c%c%c%c\n", formtype & 0xff, + ( formtype >> 8 ) & 0xff, ( formtype >> 16 ) & 0xff, ( formtype >> 24 ) & 0xff ); } LBM_P += 4; @@ -246,7 +246,7 @@ void LoadLBM( const char *filename, byte **picture, byte **palette ){ switch ( chunktype ) { case BMHDID: - memcpy( &bmhd,LBM_P,sizeof( bmhd ) ); + memcpy( &bmhd, LBM_P, sizeof( bmhd ) ); bmhd.w = BigShort( bmhd.w ); bmhd.h = BigShort( bmhd.h ); bmhd.x = BigShort( bmhd.x ); @@ -275,7 +275,7 @@ void LoadLBM( const char *filename, byte **picture, byte **palette ){ , pic_p, bmhd.w ); } else if ( bmhd.compression == cm_none ) { - memcpy( pic_p,body_p,bmhd.w ); + memcpy( pic_p, body_p, bmhd.w ); body_p += Align( bmhd.w ); } } @@ -351,7 +351,7 @@ void WriteLBMfile( const char *filename, byte *data, bmhdlength = (int *)lbmptr; lbmptr += 4; // leave space for length - memset( &basebmhd,0,sizeof( basebmhd ) ); + memset( &basebmhd, 0, sizeof( basebmhd ) ); basebmhd.w = BigShort( (short)width ); basebmhd.h = BigShort( (short)height ); basebmhd.nPlanes = BigShort( 8 ); @@ -360,7 +360,7 @@ void WriteLBMfile( const char *filename, byte *data, basebmhd.pageWidth = BigShort( (short)width ); basebmhd.pageHeight = BigShort( (short)height ); - memcpy( lbmptr,&basebmhd,sizeof( basebmhd ) ); + memcpy( lbmptr, &basebmhd, sizeof( basebmhd ) ); lbmptr += sizeof( basebmhd ); length = lbmptr - (byte *)bmhdlength - 4; @@ -380,7 +380,7 @@ void WriteLBMfile( const char *filename, byte *data, cmaplength = (int *)lbmptr; lbmptr += 4; // leave space for length - memcpy( lbmptr,palette,768 ); + memcpy( lbmptr, palette, 768 ); lbmptr += 768; length = lbmptr - (byte *)cmaplength - 4; @@ -400,7 +400,7 @@ void WriteLBMfile( const char *filename, byte *data, bodylength = (int *)lbmptr; lbmptr += 4; // leave space for length - memcpy( lbmptr,data,width * height ); + memcpy( lbmptr, data, width * height ); lbmptr += width * height; length = lbmptr - (byte *)bodylength - 4; @@ -440,8 +440,8 @@ typedef struct char version; char encoding; char bits_per_pixel; - unsigned short xmin,ymin,xmax,ymax; - unsigned short hres,vres; + unsigned short xmin, ymin, xmax, ymax; + unsigned short hres, vres; unsigned char palette[48]; char reserved; char color_planes; diff --git a/tools/quake3/common/vfs.cpp b/tools/quake3/common/vfs.cpp index e1075c03..fa58a90f 100644 --- a/tools/quake3/common/vfs.cpp +++ b/tools/quake3/common/vfs.cpp @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/tools/quake3/common/vfs.h b/tools/quake3/common/vfs.h index 753ea2f4..aed12e83 100644 --- a/tools/quake3/common/vfs.h +++ b/tools/quake3/common/vfs.h @@ -20,7 +20,7 @@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT diff --git a/tools/quake3/q3map2/convert_map.cpp b/tools/quake3/q3map2/convert_map.cpp index 794626fb..47494391 100644 --- a/tools/quake3/q3map2/convert_map.cpp +++ b/tools/quake3/q3map2/convert_map.cpp @@ -142,8 +142,7 @@ static void ConvertOriginBrush( FILE *f, int num, const Vector3& origin, bool br { "---", "--+", "+--", "- ", " +", "- ", " +" }, { "---", "-+-", "--+", " - ", " +", " + ", " +" } }; - int i; -#define S( a,b,c ) ( pattern[a][b][c] == '+' ? +1 : pattern[a][b][c] == '-' ? -1 : 0 ) +#define S( a, b, c ) ( pattern[a][b][c] == '+' ? +1 : pattern[a][b][c] == '-' ? -1 : 0 ) /* start brush */ fprintf( f, "\t// brush %d\n", num ); @@ -155,15 +154,15 @@ static void ConvertOriginBrush( FILE *f, int num, const Vector3& origin, bool br /* print brush side */ /* ( 640 24 -224 ) ( 448 24 -224 ) ( 448 -232 -224 ) common/caulk 0 48 0 0.500000 0.500000 0 0 0 */ - for ( i = 0; i < 6; ++i ) + for ( int i = 0; i < 6; ++i ) { if ( brushPrimitives ) { fprintf( f, "\t\t( %.3f %.3f %.3f ) ( %.3f %.3f %.3f ) ( %.3f %.3f %.3f ) ( ( %.8f %.8f %.8f ) ( %.8f %.8f %.8f ) ) %s %d 0 0\n", - origin[0] + 8 * S( i,0,0 ), origin[1] + 8 * S( i,0,1 ), origin[2] + 8 * S( i,0,2 ), - origin[0] + 8 * S( i,1,0 ), origin[1] + 8 * S( i,1,1 ), origin[2] + 8 * S( i,1,2 ), - origin[0] + 8 * S( i,2,0 ), origin[1] + 8 * S( i,2,1 ), origin[2] + 8 * S( i,2,2 ), - 1.0f / 16.0f, 0.0f, FRAC( ( S( i,5,0 ) * origin[0] + S( i,5,1 ) * origin[1] + S( i,5,2 ) * origin[2] ) / 16.0 + 0.5 ), - 0.0f, 1.0f / 16.0f, FRAC( ( S( i,6,0 ) * origin[0] + S( i,6,1 ) * origin[1] + S( i,6,2 ) * origin[2] ) / 16.0 + 0.5 ), + origin[0] + 8 * S( i, 0, 0 ), origin[1] + 8 * S( i, 0, 1 ), origin[2] + 8 * S( i, 0, 2 ), + origin[0] + 8 * S( i, 1, 0 ), origin[1] + 8 * S( i, 1, 1 ), origin[2] + 8 * S( i, 1, 2 ), + origin[0] + 8 * S( i, 2, 0 ), origin[1] + 8 * S( i, 2, 1 ), origin[2] + 8 * S( i, 2, 2 ), + 1.0f / 16.0f, 0.0f, FRAC( ( S( i, 5, 0 ) * origin[0] + S( i, 5, 1 ) * origin[1] + S( i, 5, 2 ) * origin[2] ) / 16.0 + 0.5 ), + 0.0f, 1.0f / 16.0f, FRAC( ( S( i, 6, 0 ) * origin[0] + S( i, 6, 1 ) * origin[1] + S( i, 6, 2 ) * origin[2] ) / 16.0 + 0.5 ), "common/origin", 0 ); @@ -171,12 +170,12 @@ static void ConvertOriginBrush( FILE *f, int num, const Vector3& origin, bool br else { fprintf( f, "\t\t( %.3f %.3f %.3f ) ( %.3f %.3f %.3f ) ( %.3f %.3f %.3f ) %s %.8f %.8f %.8f %.8f %.8f %d 0 0\n", - origin[0] + 8 * S( i,0,0 ), origin[1] + 8 * S( i,0,1 ), origin[2] + 8 * S( i,0,2 ), - origin[0] + 8 * S( i,1,0 ), origin[1] + 8 * S( i,1,1 ), origin[2] + 8 * S( i,1,2 ), - origin[0] + 8 * S( i,2,0 ), origin[1] + 8 * S( i,2,1 ), origin[2] + 8 * S( i,2,2 ), + origin[0] + 8 * S( i, 0, 0 ), origin[1] + 8 * S( i, 0, 1 ), origin[2] + 8 * S( i, 0, 2 ), + origin[0] + 8 * S( i, 1, 0 ), origin[1] + 8 * S( i, 1, 1 ), origin[2] + 8 * S( i, 1, 2 ), + origin[0] + 8 * S( i, 2, 0 ), origin[1] + 8 * S( i, 2, 1 ), origin[2] + 8 * S( i, 2, 2 ), "common/origin", - FRAC( ( S( i,3,0 ) * origin[0] + S( i,3,1 ) * origin[1] + S( i,3,2 ) * origin[2] ) / 16.0 + 0.5 ) * originSize, - FRAC( ( S( i,4,0 ) * origin[0] + S( i,4,1 ) * origin[1] + S( i,4,2 ) * origin[2] ) / 16.0 + 0.5 ) * originSize, + FRAC( ( S( i, 3, 0 ) * origin[0] + S( i, 3, 1 ) * origin[1] + S( i, 3, 2 ) * origin[2] ) / 16.0 + 0.5 ) * originSize, + FRAC( ( S( i, 4, 0 ) * origin[0] + S( i, 4, 1 ) * origin[1] + S( i, 4, 2 ) * origin[2] ) / 16.0 + 0.5 ) * originSize, 0.0f, 16.0 / originSize, 16.0 / originSize, 0 ); diff --git a/tools/quake3/q3map2/decals.cpp b/tools/quake3/q3map2/decals.cpp index da46fbf7..89175184 100644 --- a/tools/quake3/q3map2/decals.cpp +++ b/tools/quake3/q3map2/decals.cpp @@ -360,12 +360,9 @@ static int MakeDecalProjector( shaderInfo_t *si, const Plane3f& projection, floa #define PLANAR_EPSILON 0.5f void ProcessDecals(){ - int x, y, r, iterations; float distance; Plane3f projection, plane; entity_t *e2; - parseMesh_t *p; - mesh_t *mesh, *subdivided; /* note it */ @@ -395,7 +392,7 @@ void ProcessDecals(){ } /* walk entity patches */ - for ( p = e.patches; p != NULL; p = e.patches ) + for ( parseMesh_t *p = e.patches; p != NULL; p = e.patches ) { /* setup projector */ Vector3 origin; @@ -414,12 +411,12 @@ void ProcessDecals(){ /* create projectors */ if ( distance > 0.125f ) { /* tesselate the patch */ - iterations = IterationsForCurve( p->longestCurve, patchSubdivisions ); - subdivided = SubdivideMesh2( p->mesh, iterations ); + const int iterations = IterationsForCurve( p->longestCurve, patchSubdivisions ); + mesh_t *subdivided = SubdivideMesh2( p->mesh, iterations ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* offset by projector origin */ @@ -427,9 +424,9 @@ void ProcessDecals(){ vert.xyz += e.origin; /* iterate through the mesh quads */ - for ( y = 0; y < ( mesh->height - 1 ); y++ ) + for ( int y = 0; y < ( mesh->height - 1 ); y++ ) { - for ( x = 0; x < ( mesh->width - 1 ); x++ ) + for ( int x = 0; x < ( mesh->width - 1 ); x++ ) { /* set indexes */ const int pw[ 5 ] = { @@ -440,7 +437,7 @@ void ProcessDecals(){ x + ( y * mesh->width ) /* same as pw[ 0 ] */ }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* get drawverts */ const bspDrawVert_t *dv[ 4 ] = { @@ -616,43 +613,39 @@ static void ProjectDecalOntoFace( decalProjector_t *dp, mapDrawSurface_t *ds ){ */ static void ProjectDecalOntoPatch( decalProjector_t *dp, mapDrawSurface_t *ds ){ - int x, y, pw[ 5 ], r, iterations; - mesh_t src, *mesh, *subdivided; - - /* backface check */ - if ( ds->planar ) { - if ( vector3_dot( dp->planes[ 0 ].normal(), mapplanes[ ds->planeNum ].normal() ) < -0.0001f ) { + if ( ds->planar ) + if ( vector3_dot( dp->planes[ 0 ].normal(), mapplanes[ ds->planeNum ].normal() ) < -0.0001f ) return; - } - } /* tesselate the patch */ + mesh_t src; src.width = ds->patchWidth; src.height = ds->patchHeight; src.verts = ds->verts; - iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions ); - subdivided = SubdivideMesh2( src, iterations ); + const int iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions ); + mesh_t *subdivided = SubdivideMesh2( src, iterations ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* iterate through the mesh quads */ - for ( y = 0; y < ( mesh->height - 1 ); y++ ) + for ( int y = 0; y < ( mesh->height - 1 ); y++ ) { - for ( x = 0; x < ( mesh->width - 1 ); x++ ) + for ( int x = 0; x < ( mesh->width - 1 ); x++ ) { /* set indexes */ - pw[ 0 ] = x + ( y * mesh->width ); - pw[ 1 ] = x + ( ( y + 1 ) * mesh->width ); - pw[ 2 ] = x + 1 + ( ( y + 1 ) * mesh->width ); - pw[ 3 ] = x + 1 + ( y * mesh->width ); - pw[ 4 ] = x + ( y * mesh->width ); /* same as pw[ 0 ] */ - + const int pw[ 5 ] = { + x + ( y * mesh->width ), + x + ( ( y + 1 ) * mesh->width ), + x + 1 + ( ( y + 1 ) * mesh->width ), + x + 1 + ( y * mesh->width ), + x + ( y * mesh->width ) /* same as pw[ 0 ] */ + }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* generate decal for first triangle */ winding_t w{ diff --git a/tools/quake3/q3map2/facebsp.cpp b/tools/quake3/q3map2/facebsp.cpp index d3af1cc7..305bd8cd 100644 --- a/tools/quake3/q3map2/facebsp.cpp +++ b/tools/quake3/q3map2/facebsp.cpp @@ -43,7 +43,7 @@ static int c_faceLeafs; */ static void SelectSplitPlaneNum( const node_t *node, const facelist_t& list, int *splitPlaneNum, int *compileFlags ){ - //int frontC,backC,splitsC,facingC; + //int frontC, backC, splitsC, facingC; /* ydnar: set some defaults */ @@ -130,10 +130,10 @@ static void SelectSplitPlaneNum( const node_t *node, const facelist_t& list, int if ( value > bestValue ) { bestValue = value; bestSplit = &split; - //frontC=front; - //backC=back; - //splitsC=splits; - //facingC=facing; + //frontC = front; + //backC = back; + //splitsC = splits; + //facingC = facing; } } diff --git a/tools/quake3/q3map2/fog.cpp b/tools/quake3/q3map2/fog.cpp index b062f5c2..fef1a919 100644 --- a/tools/quake3/q3map2/fog.cpp +++ b/tools/quake3/q3map2/fog.cpp @@ -44,10 +44,7 @@ static int numFogPatchFragments; */ static mesh_t *DrawSurfToMesh( mapDrawSurface_t *ds ){ - mesh_t *m; - - - m = safe_malloc( sizeof( *m ) ); + mesh_t *m = safe_malloc( sizeof( *m ) ); m->width = ds->patchWidth; m->height = ds->patchHeight; m->verts = safe_malloc( sizeof( m->verts[ 0 ] ) * m->width * m->height ); @@ -249,7 +246,6 @@ static bool ChopPatchSurfaceByBrush( mapDrawSurface_t *ds, const brush_t *b ){ mesh_t *outside[MAX_BRUSH_SIDES]; int numOutside; mesh_t *m, *front, *back; - mapDrawSurface_t *newds; m = DrawSurfToMesh( ds ); numOutside = 0; @@ -289,7 +285,7 @@ static bool ChopPatchSurfaceByBrush( mapDrawSurface_t *ds, const brush_t *b ){ InvertMesh( outside[ i ] ); /* ydnar: do this the hacky right way */ - newds = AllocDrawSurface( ESurfaceType::Patch ); + mapDrawSurface_t *newds = AllocDrawSurface( ESurfaceType::Patch ); memcpy( newds, ds, sizeof( *ds ) ); newds->patchWidth = outside[ i ]->width; newds->patchHeight = outside[ i ]->height; diff --git a/tools/quake3/q3map2/games.cpp b/tools/quake3/q3map2/games.cpp index f93adea2..c2ba2890 100644 --- a/tools/quake3/q3map2/games.cpp +++ b/tools/quake3/q3map2/games.cpp @@ -279,13 +279,13 @@ struct game_tremulous : game_default homeBasePath = ".tremulous"; magic = "tremulous"; surfaceParms.insert( surfaceParms.end(), { - {"noalienbuild", TREM_CONT_NOALIENBUILD,0,0,0,0,0}, - {"nohumanbuild", TREM_CONT_NOHUMANBUILD,0,0,0,0,0}, - {"nobuild", TREM_CONT_NOBUILD,0,0,0,0,0}, + { "noalienbuild", TREM_CONT_NOALIENBUILD, 0, 0, 0, 0, 0 }, + { "nohumanbuild", TREM_CONT_NOHUMANBUILD, 0, 0, 0, 0, 0 }, + { "nobuild", TREM_CONT_NOBUILD, 0, 0, 0, 0, 0 }, - {"noalienbuildsurface", 0,0,TREM_SURF_NOALIENBUILDSURFACE,0,0,0}, - {"nohumanbuildsurface", 0,0,TREM_SURF_NOHUMANBUILDSURFACE,0,0,0}, - {"nobuildsurface", 0,0,TREM_SURF_NOBUILDSURFACE,0,0,0}, + { "noalienbuildsurface", 0, 0, TREM_SURF_NOALIENBUILDSURFACE, 0, 0, 0 }, + { "nohumanbuildsurface", 0, 0, TREM_SURF_NOHUMANBUILDSURFACE, 0, 0, 0 }, + { "nobuildsurface", 0, 0, TREM_SURF_NOBUILDSURFACE, 0, 0, 0 }, } ); } }; @@ -911,7 +911,7 @@ struct game_ja : game_sof2 homeBasePath = ".ja"; magic = "GameData"; flareShader = "gfx/misc/flare"; - surfaceParms.insert( surfaceParms.end(),{ + surfaceParms.insert( surfaceParms.end(), { { "inside", JA_CONT_INSIDE, 0, 0, 0, 0, 0 }, { "forcesight", 0, 0, JA_SURF_FORCESIGHT, 0, 0, 0 }, } ); diff --git a/tools/quake3/q3map2/help.cpp b/tools/quake3/q3map2/help.cpp index 87f115c8..391ee6d0 100644 --- a/tools/quake3/q3map2/help.cpp +++ b/tools/quake3/q3map2/help.cpp @@ -39,434 +39,434 @@ struct HelpOption const char* description; }; -static void HelpOptions(const char* group_name, int indentation, int width, const std::vector& options) +static void HelpOptions( const char* group_name, int indentation, int width, const std::vector& options ) { indentation *= 2; - char* indent = safe_malloc(indentation+1); - memset(indent, ' ', indentation); + char* indent = safe_malloc( indentation + 1 ); + memset( indent, ' ', indentation ); indent[indentation] = 0; - printf("%s%s:\n", indent, group_name); + printf( "%s%s:\n", indent, group_name ); indentation += 2; - indent = void_ptr( realloc(indent, indentation+1) ); - memset(indent, ' ', indentation); + indent = void_ptr( realloc( indent, indentation + 1 ) ); + memset( indent, ' ', indentation ); indent[indentation] = 0; for ( auto&& option : options ) { - int printed = printf("%s%-24s ", indent, option.name); - int descsz = strlen(option.description); + int printed = printf( "%s%-24s ", indent, option.name ); + int descsz = strlen( option.description ); int j = 0; while ( j < descsz && descsz-j > width - printed ) { if ( j != 0 ) - printf("%s%26c",indent,' '); + printf( "%s%26c", indent, ' ' ); int fragment = width - printed; - while ( fragment > 0 && option.description[j+fragment-1] != ' ') + while ( fragment > 0 && option.description[j + fragment - 1] != ' ' ) fragment--; - j += fwrite(option.description+j, sizeof(char), fragment, stdout); - putchar('\n'); - printed = indentation+26; + j += fwrite( option.description + j, sizeof(char), fragment, stdout ); + putchar( '\n' ); + printed = indentation + 26; } if ( j == 0 ) { - printf("%s\n",option.description+j); + printf( "%s\n", option.description + j ); } else if ( j < descsz ) { - printf("%s%26c%s\n",indent,' ',option.description+j); + printf( "%s%26c%s\n", indent, ' ', option.description + j ); } } - putchar('\n'); + putchar( '\n' ); - free(indent); + free( indent ); } static void HelpBsp() { const std::vector options = { - {"-bsp [options] ", "Switch that enters this stage"}, - {"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"}, - {"-autocaulk", "Only output special .caulk file for use by radiant"}, - {"-celshader ", "Sets a global cel shader name"}, - {"-clipdepth ", "Model autoclip brushes thickness, default = 2"}, - {"-custinfoparms", "Read scripts/custinfoparms.txt"}, - {"-debugclip", "Make model autoclip brushes visible, using shaders debugclip, debugclip2"}, - {"-debuginset", "Push all triangle vertexes towards the triangle center"}, - {"-debugportals", "Make BSP portals visible in the map"}, - {"-debugsurfaces", "Color the vertexes according to the index of the surface"}, - {"-deep", "Use detail brushes in the BSP tree, but at lowest priority (should give more fps)"}, - {"-de ", "Distance epsilon for plane snapping etc."}, - {"-fakemap", "Write fakemap.map containing all world brushes"}, - {"-flares", "Turn on support for flares"}, - {"-flat", "Enable flat shading (good for combining with -celshader)"}, - {"-fulldetail", "Treat detail brushes as structural ones"}, - {"-globalflag ", "Add surface flag to every bsp shader. Reusable, e.g. -globalflag slick -globalflag nodamage."}, - {"-keeplights", "Keep light entities in the BSP file after compile"}, - {"-keepmodels", "Keep misc_model entities in the BSP file after compile"}, - {"-leaktest", "Abort if a leak was found"}, - {"-maxarea", "Use Max Area face surface generation"}, - {"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"}, - {"-metaadequatescore ", "Adequate score for adding triangles to meta surfaces"}, - {"-metagoodscore ", "Good score for adding triangles to meta surfaces"}, - {"-minsamplesize ", "Sets minimum lightmap resolution in luxels/qu"}, - {"-mi ", "Sets the maximum number of indexes per surface"}, - {"-mv ", "Sets the maximum number of vertices of a lightmapped surface"}, - {"-ne ", "Normal epsilon for plane snapping etc."}, - {"-nobrushsnap", "Disable brush vertices snapping"}, - {"-nocurves", "Turn off support for patches"}, - {"-nodetail", "Leave out detail brushes"}, - {"-noflares", "Turn off support for flares"}, - {"-nofog", "Turn off support for fog volumes"}, - {"-nohint", "Turn off support for hint brushes"}, - {"-noob", "Assign surfaceparm noob to all map surfaces (Q3A:Defrag mod no-overbounces flag)"}, - {"-nosRGB", "Treat colors and textures as linear colorspace"}, - {"-nosRGBcolor", "Treat shader and light entity colors as linear colorspace"}, - {"-nosRGBtex", "Treat textures as linear colorspace"}, - {"-nosubdivide", "Turn off support for `q3map_tessSize` (breaks water vertex deforms)"}, - {"-notjunc", "Do not fix T-junctions (causes cracks between triangles, do not use)"}, - {"-nowater", "Turn off support for water, slime or lava (Stef, this is for you)"}, - {"-np ", "Force all surfaces to be nonplanar with a given shade angle"}, - {"-onlyents", "Only update entities in the BSP"}, - {"-patchmeta", "Turn patches into triangle meshes for display"}, - {"-rename", "Append suffix to miscmodel shaders (needed for SoF2)"}, - {"-samplesize ", "Sets default lightmap resolution in luxels/qu"}, - {"-skyfix", "Turn sky box into six surfaces to work around ATI problems"}, - {"-snap ", "Snap brush bevel planes to the given number of units"}, - {"-sRGBcolor", "Treat shader and light entity colors as sRGB colorspace"}, - {"-sRGBtex", "Treat textures as sRGB colorspace"}, - {"-tempname ", "Read the MAP file from the given file name"}, - {"-verboseentities", "Enable `-v` only for map entities, not for the world"}, + { "-bsp [options] ", "Switch that enters this stage" }, + { "-altsplit", "Alternate BSP tree splitting weights (should give more fps)" }, + { "-autocaulk", "Only output special .caulk file for use by radiant" }, + { "-celshader ", "Sets a global cel shader name" }, + { "-clipdepth ", "Model autoclip brushes thickness, default = 2" }, + { "-custinfoparms", "Read scripts/custinfoparms.txt" }, + { "-debugclip", "Make model autoclip brushes visible, using shaders debugclip, debugclip2" }, + { "-debuginset", "Push all triangle vertexes towards the triangle center" }, + { "-debugportals", "Make BSP portals visible in the map" }, + { "-debugsurfaces", "Color the vertexes according to the index of the surface" }, + { "-deep", "Use detail brushes in the BSP tree, but at lowest priority (should give more fps)" }, + { "-de ", "Distance epsilon for plane snapping etc." }, + { "-fakemap", "Write fakemap.map containing all world brushes" }, + { "-flares", "Turn on support for flares" }, + { "-flat", "Enable flat shading (good for combining with -celshader)" }, + { "-fulldetail", "Treat detail brushes as structural ones" }, + { "-globalflag ", "Add surface flag to every bsp shader. Reusable, e.g. -globalflag slick -globalflag nodamage." }, + { "-keeplights", "Keep light entities in the BSP file after compile" }, + { "-keepmodels", "Keep misc_model entities in the BSP file after compile" }, + { "-leaktest", "Abort if a leak was found" }, + { "-maxarea", "Use Max Area face surface generation" }, + { "-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)" }, + { "-metaadequatescore ", "Adequate score for adding triangles to meta surfaces" }, + { "-metagoodscore ", "Good score for adding triangles to meta surfaces" }, + { "-minsamplesize ", "Sets minimum lightmap resolution in luxels/qu" }, + { "-mi ", "Sets the maximum number of indexes per surface" }, + { "-mv ", "Sets the maximum number of vertices of a lightmapped surface" }, + { "-ne ", "Normal epsilon for plane snapping etc." }, + { "-nobrushsnap", "Disable brush vertices snapping" }, + { "-nocurves", "Turn off support for patches" }, + { "-nodetail", "Leave out detail brushes" }, + { "-noflares", "Turn off support for flares" }, + { "-nofog", "Turn off support for fog volumes" }, + { "-nohint", "Turn off support for hint brushes" }, + { "-noob", "Assign surfaceparm noob to all map surfaces (Q3A:Defrag mod no-overbounces flag)" }, + { "-nosRGB", "Treat colors and textures as linear colorspace" }, + { "-nosRGBcolor", "Treat shader and light entity colors as linear colorspace" }, + { "-nosRGBtex", "Treat textures as linear colorspace" }, + { "-nosubdivide", "Turn off support for `q3map_tessSize` (breaks water vertex deforms)" }, + { "-notjunc", "Do not fix T-junctions (causes cracks between triangles, do not use)" }, + { "-nowater", "Turn off support for water, slime or lava (Stef, this is for you)" }, + { "-np ", "Force all surfaces to be nonplanar with a given shade angle" }, + { "-onlyents", "Only update entities in the BSP" }, + { "-patchmeta", "Turn patches into triangle meshes for display" }, + { "-rename", "Append suffix to miscmodel shaders (needed for SoF2)" }, + { "-samplesize ", "Sets default lightmap resolution in luxels/qu" }, + { "-skyfix", "Turn sky box into six surfaces to work around ATI problems" }, + { "-snap ", "Snap brush bevel planes to the given number of units" }, + { "-sRGBcolor", "Treat shader and light entity colors as sRGB colorspace" }, + { "-sRGBtex", "Treat textures as sRGB colorspace" }, + { "-tempname ", "Read the MAP file from the given file name" }, + { "-verboseentities", "Enable `-v` only for map entities, not for the world" }, }; - HelpOptions("BSP Stage", 0, 80, options); + HelpOptions( "BSP Stage", 0, 80, options ); } static void HelpVis() { const std::vector options = { - {"-vis [options] ", "Switch that enters this stage"}, - {"-fast", "Very fast and crude vis calculation"}, - {"-hint", "Merge all but hint portals"}, - {"-mergeportals", "The less crude half of `-merge`, makes vis sometimes much faster but doesn't hurt fps usually"}, - {"-merge", "Faster but still okay vis calculation"}, - {"-nopassage", "Just use PortalFlow vis (usually less fps)"}, - {"-nosort", "Do not sort the portals before calculating vis (usually slower)"}, - {"-passageOnly", "Just use PassageFlow vis (usually less fps)"}, - {"-saveprt", "Keep the Portal file after running vis (so you can run vis again)"}, - {"-v -v", "Extra verbose mode for cluster debug"}, // q3map2 common takes first -v + { "-vis [options] ", "Switch that enters this stage" }, + { "-fast", "Very fast and crude vis calculation" }, + { "-hint", "Merge all but hint portals" }, + { "-mergeportals", "The less crude half of `-merge`, makes vis sometimes much faster but doesn't hurt fps usually" }, + { "-merge", "Faster but still okay vis calculation" }, + { "-nopassage", "Just use PortalFlow vis (usually less fps)" }, + { "-nosort", "Do not sort the portals before calculating vis (usually slower)" }, + { "-passageOnly", "Just use PassageFlow vis (usually less fps)" }, + { "-saveprt", "Keep the Portal file after running vis (so you can run vis again)" }, + { "-v -v", "Extra verbose mode for cluster debug" }, // q3map2 common takes first -v }; - HelpOptions("VIS Stage", 0, 80, options); + HelpOptions( "VIS Stage", 0, 80, options ); } static void HelpLight() { const std::vector options = { - {"-light [options] ", "Switch that enters this stage"}, - {"-approx ", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)"}, - {"-areascale , -area ", "Scaling factor for area lights (surfacelight)"}, - {"-backsplash ", "scale area lights backsplash fraction + set distance globally; (distance < -900 to omit distance setting); default = 1 23; real area lights have no backsplash (scale = 0); q3map_backsplash shader keyword overrides this setting"}, - {"-border", "Add a red border to lightmaps for debugging"}, - {"-bouncecolorratio ", "0..1 ratio of colorizing light sample by texture"}, - {"-bouncegrid", "Also compute radiosity on the light grid"}, - {"-bounceonly", "Only compute radiosity"}, - {"-bouncescale ", "Scaling factor for radiosity"}, - {"-bounce ", "Maximal number of bounces for radiosity"}, - {"-brightness ", "Scaling factor for resulting lightmaps brightness"}, - {"-cheapgrid", "Use `-cheap` style lighting for radiosity"}, - {"-cheap", "Abort vertex light calculations when white is reached"}, - {"-compensate ", "Lightmap compensate (darkening factor applied after everything else)"}, - {"-contrast ", "-255 .. 255 lighting contrast, default = 0"}, - {"-cpma", "CPMA vertex lighting mode"}, - {"-custinfoparms", "Read scripts/custinfoparms.txt"}, - {"-dark", "Darken lightmap seams"}, - {"-debugaxis", "Color the lightmaps according to the lightmap axis"}, - {"-debugcluster", "Color the lightmaps according to the index of the cluster"}, - {"-debugdeluxe", "Show deluxemaps on the lightmap"}, - {"-debugnormals", "Color the lightmaps according to the direction of the surface normal"}, - {"-debugorigin", "Color the lightmaps according to the origin of the luxels"}, - {"-debugsamplesize", "display all of 'surface too large for desired samplesize+lightmapsize' warnings"}, - {"-debugsurfaces, -debugsurface", "Color the lightmaps according to the index of the surface"}, - {"-debug", "Mark the lightmaps according to the cluster: unmapped clusters get yellow, occluded ones get pink, flooded ones get blue overlay color, otherwise red"}, - {"-deluxemode 0", "Use modelspace deluxemaps (DarkPlaces)"}, - {"-deluxemode 1", "Use tangentspace deluxemaps"}, - {"-deluxe, -deluxemap", "Enable deluxemapping (light direction maps)"}, - {"-dirtdebug, -debugdirt", "Store the dirtmaps as lightmaps for debugging"}, - {"-dirtdepth", "Dirtmapping depth"}, - {"-dirtgain", "Dirtmapping exponent"}, - {"-dirtmode 0", "Ordered direction dirtmapping"}, - {"-dirtmode 1", "Randomized direction dirtmapping"}, - {"-dirtscale", "Dirtmapping scaling factor"}, - {"-dirty", "Enable dirtmapping"}, - {"-dump", "Dump radiosity from `-bounce` into numbered MAP file prefabs"}, - {"-export", "Export lightmaps when compile finished (like `-export` mode)"}, - {"-exposure ", "Lightmap exposure to better support overbright spots"}, - {"-external", "Force external lightmaps even if at size of internal lightmaps"}, - {"-extlmhacksize ", "External lightmaps hack size: similar to -lightmapsize N: Size of lightmaps to generate (must be a power of two), but instead of native external lightmaps enables hack to reference them in autogenerated shader (for vanilla Q3 etc)"}, - {"-extradist ", "Extra distance for lights in map units"}, - {"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"}, - {"-fastbounce", "Use `-fast` style lighting for radiosity"}, - {"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"}, - {"-fastgrid", "Use `-fast` style lighting for the light grid"}, - {"-fast", "Ignore tiny light contributions"}, - {"-fill", "Fill lightmap colors from surrounding pixels to improve JPEG compression"}, - {"-fillpink", "Fill unoccupied lightmap pixels with pink colour"}, - {"-filter", "Lightmap filtering"}, - {"-floodlight", "Enable floodlight (zero-effort somewhat decent lighting)"}, - {"-gamma ", "Lightmap gamma"}, - {"-gridambientdirectionality ", "Ambient directional lighting received (default: 0.0)"}, - {"-gridambientscale ", "Scaling factor for the light grid ambient components only"}, - {"-griddirectionality ", "Directional lighting received (default: 1.0)"}, - {"-gridscale ", "Scaling factor for the light grid only"}, - {"-lightanglehl 0", "Disable half lambert light angle attenuation"}, - {"-lightanglehl 1", "Enable half lambert light angle attenuation"}, - {"-lightmapdir ", "Directory to store external lightmaps (default: same as map name without extension)"}, - {"-lightmapsearchblocksize ", "Restricted lightmap searching - block size"}, - {"-lightmapsearchpower ", "Restricted lightmap searching - merge power"}, - {"-lightmapsize ", "Size of lightmaps to generate (must be a power of two)"}, - {"-lomem", "Low memory but slower lighting mode"}, - {"-lowquality", "Low quality floodlight (appears to currently break floodlight)"}, - {"-minsamplesize ", "Sets minimum lightmap resolution in luxels/qu"}, - {"-nobouncestore", "Do not store BSP, lightmap and shader files between bounces"}, - {"-nocollapse", "Do not collapse identical lightmaps"}, - {"-nodeluxe, -nodeluxemap", "Disable deluxemapping"}, - {"-nofastpoint", "Disable fast point light calculation"}, - {"-nogrid", "Disable grid light calculation (makes all entities fullbright)"}, - {"-nolightmapsearch", "Do not optimize lightmap packing for GPU memory usage (as doing so costs fps)"}, - {"-nolm", "Skip lightmaps calculation"}, - {"-normalmap", "Color the lightmaps according to the direction of the surface normal (TODO is this identical to `-debugnormals`?)"}, - {"-nosRGB", "Treat colors, textures, and lightmaps as linear colorspace"}, - {"-nosRGBcolor", "Treat shader and light entity colors as linear colorspace"}, - {"-nosRGBlight", "Write lightmaps as linear colorspace"}, - {"-nosRGBtex", "Treat textures as linear colorspace"}, - {"-nostyle, -nostyles", "Disable support for light styles"}, - {"-nosurf", "Disable tracing against surfaces (only uses BSP nodes then)"}, - {"-notrace", "Disable shadow occlusion"}, - {"-novertex", "Disable vertex lighting; optional (0..1) value sets constant vertex light globally"}, - {"-patchshadows", "Cast shadows from patches"}, - {"-pointscale , -point ", "Scaling factor for spherical and spot point lights (light entities)"}, - {"-q3", "Use nonlinear falloff curve by default (like Q3A)"}, - {"-randomsamples", "Use random sampling for lightmaps"}, - {"-rawlightmapsizelimit ", "Sets maximum lightmap resolution in luxels/qu (only affects patches if used -patchmeta in BSP stage)"}, - {"-samplescale ", "Scales all lightmap resolutions"}, - {"-samplesize ", "Sets default lightmap resolution in luxels/qu"}, - {"-samplessearchboxsize ", "Search box size (1 to 4) for lightmap adaptive supersampling"}, - {"-samples ", "Adaptive supersampling quality"}, - {"-saturation ", "Lighting saturation: default = 1, > 1 = saturate, 0 = grayscale, < 0 = complementary colors"}, - {"-scale ", "Scaling factor for all light types"}, - {"-shadeangle ", "Angle for phong shading"}, - {"-shade", "Enable phong shading at default shade angle"}, - {"-skyscale , -sky ", "Scaling factor for sky and sun light"}, - {"-slowallocate", "Use old (a bit more careful, but much slower) lightmaps packing algorithm"}, - {"-sphericalscale , -spherical ", "Scaling factor for spherical point light entities"}, - {"-spotscale , -spot ", "Scaling factor for spot point light entities"}, - {"-sRGB", "Treat colors, textures, and lightmaps as sRGB colorspace"}, - {"-sRGBcolor", "Treat shader and light entity colors as sRGB colorspace"}, - {"-sRGBlight", "Write lightmaps as sRGB colorspace"}, - {"-sRGBtex", "Treat textures as sRGB colorspace"}, - {"-style, -styles", "Enable support for light styles"}, - {"-sunonly", "Only compute sun light"}, - {"-super , -supersample ", "Ordered grid supersampling quality"}, - {"-thresh ", "Triangle subdivision threshold"}, - {"-trianglecheck", "Broken check that should ensure luxels apply to the right triangle"}, - {"-trisoup", "Convert brush faces to triangle soup"}, - {"-vertexscale ", "Scaling factor for resulting vertex light values"}, - {"-wolf", "Use linear falloff curve by default (like W:ET)"}, + { "-light [options] ", "Switch that enters this stage" }, + { "-approx ", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)" }, + { "-areascale , -area ", "Scaling factor for area lights (surfacelight)" }, + { "-backsplash ", "scale area lights backsplash fraction + set distance globally; (distance < -900 to omit distance setting); default = 1 23; real area lights have no backsplash (scale = 0); q3map_backsplash shader keyword overrides this setting" }, + { "-border", "Add a red border to lightmaps for debugging" }, + { "-bouncecolorratio ", "0..1 ratio of colorizing light sample by texture" }, + { "-bouncegrid", "Also compute radiosity on the light grid" }, + { "-bounceonly", "Only compute radiosity" }, + { "-bouncescale ", "Scaling factor for radiosity" }, + { "-bounce ", "Maximal number of bounces for radiosity" }, + { "-brightness ", "Scaling factor for resulting lightmaps brightness" }, + { "-cheapgrid", "Use `-cheap` style lighting for radiosity" }, + { "-cheap", "Abort vertex light calculations when white is reached" }, + { "-compensate ", "Lightmap compensate (darkening factor applied after everything else)" }, + { "-contrast ", "-255 .. 255 lighting contrast, default = 0" }, + { "-cpma", "CPMA vertex lighting mode" }, + { "-custinfoparms", "Read scripts/custinfoparms.txt" }, + { "-dark", "Darken lightmap seams" }, + { "-debugaxis", "Color the lightmaps according to the lightmap axis" }, + { "-debugcluster", "Color the lightmaps according to the index of the cluster" }, + { "-debugdeluxe", "Show deluxemaps on the lightmap" }, + { "-debugnormals", "Color the lightmaps according to the direction of the surface normal" }, + { "-debugorigin", "Color the lightmaps according to the origin of the luxels" }, + { "-debugsamplesize", "display all of 'surface too large for desired samplesize+lightmapsize' warnings" }, + { "-debugsurfaces, -debugsurface", "Color the lightmaps according to the index of the surface" }, + { "-debug", "Mark the lightmaps according to the cluster: unmapped clusters get yellow, occluded ones get pink, flooded ones get blue overlay color, otherwise red" }, + { "-deluxemode 0", "Use modelspace deluxemaps (DarkPlaces)" }, + { "-deluxemode 1", "Use tangentspace deluxemaps" }, + { "-deluxe, -deluxemap", "Enable deluxemapping (light direction maps)" }, + { "-dirtdebug, -debugdirt", "Store the dirtmaps as lightmaps for debugging" }, + { "-dirtdepth", "Dirtmapping depth" }, + { "-dirtgain", "Dirtmapping exponent" }, + { "-dirtmode 0", "Ordered direction dirtmapping" }, + { "-dirtmode 1", "Randomized direction dirtmapping" }, + { "-dirtscale", "Dirtmapping scaling factor" }, + { "-dirty", "Enable dirtmapping" }, + { "-dump", "Dump radiosity from `-bounce` into numbered MAP file prefabs" }, + { "-export", "Export lightmaps when compile finished (like `-export` mode)" }, + { "-exposure ", "Lightmap exposure to better support overbright spots" }, + { "-external", "Force external lightmaps even if at size of internal lightmaps" }, + { "-extlmhacksize ", "External lightmaps hack size: similar to -lightmapsize N: Size of lightmaps to generate (must be a power of two), but instead of native external lightmaps enables hack to reference them in autogenerated shader (for vanilla Q3 etc)" }, + { "-extradist ", "Extra distance for lights in map units" }, + { "-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster" }, + { "-fastbounce", "Use `-fast` style lighting for radiosity" }, + { "-faster", "Use a faster falloff curve for lighting; also implies `-fast`" }, + { "-fastgrid", "Use `-fast` style lighting for the light grid" }, + { "-fast", "Ignore tiny light contributions" }, + { "-fill", "Fill lightmap colors from surrounding pixels to improve JPEG compression" }, + { "-fillpink", "Fill unoccupied lightmap pixels with pink colour" }, + { "-filter", "Lightmap filtering" }, + { "-floodlight", "Enable floodlight (zero-effort somewhat decent lighting)" }, + { "-gamma ", "Lightmap gamma" }, + { "-gridambientdirectionality ", "Ambient directional lighting received (default: 0.0)" }, + { "-gridambientscale ", "Scaling factor for the light grid ambient components only" }, + { "-griddirectionality ", "Directional lighting received (default: 1.0)" }, + { "-gridscale ", "Scaling factor for the light grid only" }, + { "-lightanglehl 0", "Disable half lambert light angle attenuation" }, + { "-lightanglehl 1", "Enable half lambert light angle attenuation" }, + { "-lightmapdir ", "Directory to store external lightmaps (default: same as map name without extension)" }, + { "-lightmapsearchblocksize ", "Restricted lightmap searching - block size" }, + { "-lightmapsearchpower ", "Restricted lightmap searching - merge power" }, + { "-lightmapsize ", "Size of lightmaps to generate (must be a power of two)" }, + { "-lomem", "Low memory but slower lighting mode" }, + { "-lowquality", "Low quality floodlight (appears to currently break floodlight)" }, + { "-minsamplesize ", "Sets minimum lightmap resolution in luxels/qu" }, + { "-nobouncestore", "Do not store BSP, lightmap and shader files between bounces" }, + { "-nocollapse", "Do not collapse identical lightmaps" }, + { "-nodeluxe, -nodeluxemap", "Disable deluxemapping" }, + { "-nofastpoint", "Disable fast point light calculation" }, + { "-nogrid", "Disable grid light calculation (makes all entities fullbright)" }, + { "-nolightmapsearch", "Do not optimize lightmap packing for GPU memory usage (as doing so costs fps)" }, + { "-nolm", "Skip lightmaps calculation" }, + { "-normalmap", "Color the lightmaps according to the direction of the surface normal (TODO is this identical to `-debugnormals`?)" }, + { "-nosRGB", "Treat colors, textures, and lightmaps as linear colorspace" }, + { "-nosRGBcolor", "Treat shader and light entity colors as linear colorspace" }, + { "-nosRGBlight", "Write lightmaps as linear colorspace" }, + { "-nosRGBtex", "Treat textures as linear colorspace" }, + { "-nostyle, -nostyles", "Disable support for light styles" }, + { "-nosurf", "Disable tracing against surfaces (only uses BSP nodes then)" }, + { "-notrace", "Disable shadow occlusion" }, + { "-novertex", "Disable vertex lighting; optional (0..1) value sets constant vertex light globally" }, + { "-patchshadows", "Cast shadows from patches" }, + { "-pointscale , -point ", "Scaling factor for spherical and spot point lights (light entities)" }, + { "-q3", "Use nonlinear falloff curve by default (like Q3A)" }, + { "-randomsamples", "Use random sampling for lightmaps" }, + { "-rawlightmapsizelimit ", "Sets maximum lightmap resolution in luxels/qu (only affects patches if used -patchmeta in BSP stage)" }, + { "-samplescale ", "Scales all lightmap resolutions" }, + { "-samplesize ", "Sets default lightmap resolution in luxels/qu" }, + { "-samplessearchboxsize ", "Search box size (1 to 4) for lightmap adaptive supersampling" }, + { "-samples ", "Adaptive supersampling quality" }, + { "-saturation ", "Lighting saturation: default = 1, > 1 = saturate, 0 = grayscale, < 0 = complementary colors" }, + { "-scale ", "Scaling factor for all light types" }, + { "-shadeangle ", "Angle for phong shading" }, + { "-shade", "Enable phong shading at default shade angle" }, + { "-skyscale , -sky ", "Scaling factor for sky and sun light" }, + { "-slowallocate", "Use old (a bit more careful, but much slower) lightmaps packing algorithm" }, + { "-sphericalscale , -spherical ", "Scaling factor for spherical point light entities" }, + { "-spotscale , -spot ", "Scaling factor for spot point light entities" }, + { "-sRGB", "Treat colors, textures, and lightmaps as sRGB colorspace" }, + { "-sRGBcolor", "Treat shader and light entity colors as sRGB colorspace" }, + { "-sRGBlight", "Write lightmaps as sRGB colorspace" }, + { "-sRGBtex", "Treat textures as sRGB colorspace" }, + { "-style, -styles", "Enable support for light styles" }, + { "-sunonly", "Only compute sun light" }, + { "-super , -supersample ", "Ordered grid supersampling quality" }, + { "-thresh ", "Triangle subdivision threshold" }, + { "-trianglecheck", "Broken check that should ensure luxels apply to the right triangle" }, + { "-trisoup", "Convert brush faces to triangle soup" }, + { "-vertexscale ", "Scaling factor for resulting vertex light values" }, + { "-wolf", "Use linear falloff curve by default (like W:ET)" }, }; - HelpOptions("Light Stage", 0, 80, options); + HelpOptions( "Light Stage", 0, 80, options ); } static void HelpAnalyze() { const std::vector options = { - {"-analyze [options] ", "Switch that enters this mode"}, - {"-lumpswap", "Swap byte order in the lumps"}, + { "-analyze [options] ", "Switch that enters this mode" }, + { "-lumpswap", "Swap byte order in the lumps" }, }; - HelpOptions("Analyzing BSP-like file structure", 0, 80, options); + HelpOptions( "Analyzing BSP-like file structure", 0, 80, options ); } static void HelpScale() { const std::vector options = { - {"-scale [options] ", "Scale uniformly"}, - {"-scale [options] ", "Scale non-uniformly"}, - {"-tex", "Option to scale without texture lock"}, - {"-spawn_ref ", "Option to vertically offset info_player_* entities (adds spawn_ref, scales, subtracts spawn_ref)"}, + { "-scale [options] ", "Scale uniformly" }, + { "-scale [options] ", "Scale non-uniformly" }, + { "-tex", "Option to scale without texture lock" }, + { "-spawn_ref ", "Option to vertically offset info_player_* entities (adds spawn_ref, scales, subtracts spawn_ref)" }, }; - HelpOptions("BSP Scaling", 0, 80, options); + HelpOptions( "BSP Scaling", 0, 80, options ); } static void HelpShift() { const std::vector options = { - {"-shift ", "Shift uniformly"}, - {"-shift ", "Shift non-uniformly"}, + { "-shift ", "Shift uniformly" }, + { "-shift ", "Shift non-uniformly" }, }; - HelpOptions("BSP Shift", 0, 80, options); + HelpOptions( "BSP Shift", 0, 80, options ); } static void HelpConvert() { const std::vector options = { - {"-convert [options] ", "Switch that enters this mode"}, - {"-deluxemapsastexcoord", "Save deluxemap names and texcoords instead of textures (only when writing ase and obj)"}, - {"-de ", "Distance epsilon for the conversion (only when reading map)"}, - {"-fast", "fast bsp to map conversion mode (without texture alignments)"}, - {"-format ", "Select the converter, default ase (available: map, map_bp, ase, obj, or game names)"}, - {"-lightmapsastexcoord", "Save lightmap names and texcoords instead of textures (only when writing ase and obj)"}, - {"-meta", "Combine adjacent triangles of the same texture to surfaces (only when reading map)"}, - {"-ne ", "Normal epsilon for the conversion (only when reading map)"}, - {"-patchmeta", "Turn patches into triangle meshes for display (only when reading map)"}, - {"-readbsp", "Force converting bsp to selected format"}, - {"-readmap", "Force converting map to selected format"}, - {"-shadersasbitmap", "Save shader names as bitmap names in the model so it works as a prefab (only when writing ase and obj)"}, + { "-convert [options] ", "Switch that enters this mode" }, + { "-deluxemapsastexcoord", "Save deluxemap names and texcoords instead of textures (only when writing ase and obj)" }, + { "-de ", "Distance epsilon for the conversion (only when reading map)" }, + { "-fast", "fast bsp to map conversion mode (without texture alignments)" }, + { "-format ", "Select the converter, default ase (available: map, map_bp, ase, obj, or game names)" }, + { "-lightmapsastexcoord", "Save lightmap names and texcoords instead of textures (only when writing ase and obj)" }, + { "-meta", "Combine adjacent triangles of the same texture to surfaces (only when reading map)" }, + { "-ne ", "Normal epsilon for the conversion (only when reading map)" }, + { "-patchmeta", "Turn patches into triangle meshes for display (only when reading map)" }, + { "-readbsp", "Force converting bsp to selected format" }, + { "-readmap", "Force converting map to selected format" }, + { "-shadersasbitmap", "Save shader names as bitmap names in the model so it works as a prefab (only when writing ase and obj)" }, }; - HelpOptions("Converting & Decompiling", 0, 80, options); + HelpOptions( "Converting & Decompiling", 0, 80, options ); } static void HelpExport() { const std::vector options = { - {"-export ", "Copies lightmaps from the BSP to `filename/lightmap_NNNN.tga`"} + { "-export ", "Copies lightmaps from the BSP to `filename/lightmap_NNNN.tga`" }, }; - HelpOptions("Exporting lightmaps", 0, 80, options); + HelpOptions( "Exporting lightmaps", 0, 80, options ); } static void HelpImport() { const std::vector options = { - {"-import ", "Copies lightmaps from `filename/lightmap_NNNN.tga` into the BSP"}, + { "-import ", "Copies lightmaps from `filename/lightmap_NNNN.tga` into the BSP" }, }; - HelpOptions("Importing lightmaps", 0, 80, options); + HelpOptions( "Importing lightmaps", 0, 80, options ); } static void HelpExportEnts() { const std::vector options = { - {"-exportents ", "Exports the entities to a text file (.ent)"}, + { "-exportents ", "Exports the entities to a text file (.ent)" }, }; - HelpOptions("ExportEnts Stage", 0, 80, options); + HelpOptions( "ExportEnts Stage", 0, 80, options ); } static void HelpFixaas() { const std::vector options = { - {"-fixaas ", "Writes BSP checksum to AAS file, so that it's accepted as valid by engine"}, + { "-fixaas ", "Writes BSP checksum to AAS file, so that it's accepted as valid by engine" }, }; - HelpOptions("Fixing AAS checksum", 0, 80, options); + HelpOptions( "Fixing AAS checksum", 0, 80, options ); } static void HelpInfo() { const std::vector options = { - {"-info ", "Switch that enters this mode"}, + { "-info ", "Switch that enters this mode" }, }; - HelpOptions("Get info about BSP file", 0, 80, options); + HelpOptions( "Get info about BSP file", 0, 80, options ); } static void HelpMinimap() { const std::vector options = { - {"-minimap [options] ", "Creates a minimap of the BSP, by default writes to `../gfx/filename_mini.tga`"}, - {"-autolevel", "Automatically level brightness and contrast"}, - {"-black", "Write the minimap as a black-on-transparency RGBA32 image"}, - {"-boost ", "Sets the contrast boost value (higher values make a brighter image); contrast boost is somewhat similar to gamma, but continuous even at zero"}, - {"-border ", "Sets the amount of border pixels relative to the total image size"}, - {"-brightness ", "Sets brightness value to add to minimap values"}, - {"-contrast ", "Sets contrast value to scale minimap values (doesn't affect brightness)"}, - {"-gray", "Write the minimap as a white-on-black GRAY8 image"}, - {"-keepaspect", "Ensure the aspect ratio is kept (the minimap is then letterboxed to keep aspect)"}, - {"-minmax ", "Forces specific map dimensions (note: the minimap actually uses these dimensions, scaled to the target size while keeping aspect with centering, and 1/64 of border appended to all sides)"}, - {"-noautolevel", "Do not automatically level brightness and contrast"}, - {"-nokeepaspect", "Do not ensure the aspect ratio is kept (makes it easier to use the image in your code, but looks bad together with sharpening)"}, - {"-o ", "Sets the output file name"}, - {"-random ", "Sets the randomized supersampling count (cannot be combined with `-samples`)"}, - {"-samples ", "Sets the ordered supersampling count (cannot be combined with `-random`)"}, - {"-sharpen ", "Sets the sharpening coefficient"}, - {"-size ", "Sets the width and height of the output image"}, - {"-white", "Write the minimap as a white-on-transparency RGBA32 image"}, + { "-minimap [options] ", "Creates a minimap of the BSP, by default writes to `../gfx/filename_mini.tga`" }, + { "-autolevel", "Automatically level brightness and contrast" }, + { "-black", "Write the minimap as a black-on-transparency RGBA32 image" }, + { "-boost ", "Sets the contrast boost value (higher values make a brighter image); contrast boost is somewhat similar to gamma, but continuous even at zero" }, + { "-border ", "Sets the amount of border pixels relative to the total image size" }, + { "-brightness ", "Sets brightness value to add to minimap values" }, + { "-contrast ", "Sets contrast value to scale minimap values (doesn't affect brightness)" }, + { "-gray", "Write the minimap as a white-on-black GRAY8 image" }, + { "-keepaspect", "Ensure the aspect ratio is kept (the minimap is then letterboxed to keep aspect)" }, + { "-minmax ", "Forces specific map dimensions (note: the minimap actually uses these dimensions, scaled to the target size while keeping aspect with centering, and 1/64 of border appended to all sides)" }, + { "-noautolevel", "Do not automatically level brightness and contrast" }, + { "-nokeepaspect", "Do not ensure the aspect ratio is kept (makes it easier to use the image in your code, but looks bad together with sharpening)" }, + { "-o ", "Sets the output file name" }, + { "-random ", "Sets the randomized supersampling count (cannot be combined with `-samples`)" }, + { "-samples ", "Sets the ordered supersampling count (cannot be combined with `-random`)" }, + { "-sharpen ", "Sets the sharpening coefficient" }, + { "-size ", "Sets the width and height of the output image" }, + { "-white", "Write the minimap as a white-on-transparency RGBA32 image" }, }; - HelpOptions("MiniMap", 0, 80, options); + HelpOptions( "MiniMap", 0, 80, options ); } static void HelpPk3() { const std::vector options = { - {"-pk3 [options] ", "Creates a pk3 for the BSP(s) (complete Q3 support). Using file 'gamename.exclude' to exclude vanilla game resources."}, - {"-complevel ", "Set compression level (-1 .. 10); 0 = uncompressed, -1 = 6, 10 = ultra zlib incompatible preset"}, - {"-dbg", "Print wall of debug text, useful for .exclude file creation"}, - {"-png", "include png textures, at highest priority; taking tga, jpg by default"}, + { "-pk3 [options] ", "Creates a pk3 for the BSP(s) (complete Q3 support). Using file 'gamename.exclude' to exclude vanilla game resources." }, + { "-complevel ", "Set compression level (-1 .. 10); 0 = uncompressed, -1 = 6, 10 = ultra zlib incompatible preset" }, + { "-dbg", "Print wall of debug text, useful for .exclude file creation" }, + { "-png", "include png textures, at highest priority; taking tga, jpg by default" }, }; - HelpOptions("PK3 creation", 0, 80, options); + HelpOptions( "PK3 creation", 0, 80, options ); } static void HelpRepack() { const std::vector options = { - {"-repack [options] ", "Creates repack of BSP(s) (complete Q3 support). Rips off only used shaders to new shader file. Using file 'gamename.exclude' to exclude vanilla game resources and 'repack.exclude' to exclude resources of existing repack."}, - {"-analyze", "Only print bsp resource references and exit"}, - {"-complevel ", "Set compression level (-1 .. 10); 0 = uncompressed, -1 = 6, 10 = ultra zlib incompatible preset"}, - {"-dbg", "Print wall of debug text"}, - {"-png", "include png textures, at highest priority; taking tga, jpg by default"}, + { "-repack [options] ", "Creates repack of BSP(s) (complete Q3 support). Rips off only used shaders to new shader file. Using file 'gamename.exclude' to exclude vanilla game resources and 'repack.exclude' to exclude resources of existing repack." }, + { "-analyze", "Only print bsp resource references and exit" }, + { "-complevel ", "Set compression level (-1 .. 10); 0 = uncompressed, -1 = 6, 10 = ultra zlib incompatible preset" }, + { "-dbg", "Print wall of debug text" }, + { "-png", "include png textures, at highest priority; taking tga, jpg by default" }, }; - HelpOptions("Maps repack creation", 0, 80, options); + HelpOptions( "Maps repack creation", 0, 80, options ); } static void HelpJson() { const std::vector options = { - {"-json [options] ", "Export/import BSP to/from json text files for debugging and editing purposes"}, - {"-unpack", "Unpack BSP to json"}, - {"-pack", "Pack json to BSP"}, - {"-useflagnames", "While packing, deduce surface/content flag values from their names in shaders.json (useful for conversion to a game with different flag values)"}, - {"-skipflags", "While -useflagnames, skip unknown flag names"}, + { "-json [options] ", "Export/import BSP to/from json text files for debugging and editing purposes" }, + { "-unpack", "Unpack BSP to json" }, + { "-pack", "Pack json to BSP" }, + { "-useflagnames", "While packing, deduce surface/content flag values from their names in shaders.json (useful for conversion to a game with different flag values)" }, + { "-skipflags", "While -useflagnames, skip unknown flag names" }, }; - HelpOptions("BSP json export/import", 0, 80, options); + HelpOptions( "BSP json export/import", 0, 80, options ); } static void HelpMergeBsp() { const std::vector options = { - {"-mergebsp [options] ", "Inject latter BSP to former. Tree and vis data of the main one are preserved."}, - {"-fixnames", "Make incoming BSP target/targetname names unique to not collide with existing names"}, - {"-world", "Also merge worldspawn model (brushes as if they were detail, no BSP tree is affected) (only merges entities by default)"}, + { "-mergebsp [options] ", "Inject latter BSP to former. Tree and vis data of the main one are preserved." }, + { "-fixnames", "Make incoming BSP target/targetname names unique to not collide with existing names" }, + { "-world", "Also merge worldspawn model (brushes as if they were detail, no BSP tree is affected) (only merges entities by default)" }, }; - HelpOptions("BSP merge", 0, 80, options); + HelpOptions( "BSP merge", 0, 80, options ); } static void HelpCommon() { const std::vector options = { - {"-connect
", "Talk to a NetRadiant instance using a specific XML based protocol"}, - {"-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may crash. Also enables decompilation of model autoclip brushes."}, - {"-fs_basepath ", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"}, - {"-fs_forbiddenpath ", "Pattern to ignore directories, pk3, and pk3dir; example pak?.pk3 (can be used more than once to look for multiple patterns)"}, - {"-fs_game ", "Sets extra game directory name to additionally load mod's resources from at higher priority (by default for Q3A 'baseq3' is loaded, -fs_game cpma will also load 'cpma'; can be used more than once)"}, - {"-fs_basegame ", "Overrides default game directory name (e.g. Q3A uses 'baseq3', OpenArena 'baseoa', so -game quake3 -fs_basegame baseoa for OA )"}, - {"-fs_home ", "Specifies where the user home directory is on Linux"}, - {"-fs_homebase ", "Specifies game home directory relative to user home directory on Linux (default for Q3A: .q3a)"}, - {"-fs_homepath ", "Sets the given path as the game home directory name (fs_home + fs_homebase)"}, - {"-fs_pakpath ", "Specify a package directory (can be used more than once to look in multiple paths)"}, - {"-game ", "Load settings for the given game (default: quake3), -help -game lists available games"}, - {"-maxmapdrawsurfs ", "Sets max amount of mapDrawSurfs, used during .map compilation (-bsp, -convert), default = 131072"}, - {"-maxshaderinfo ", "Sets max amount of shaderInfo, default = 8192"}, - {"-subdivisions ", "multiplier for patch subdivisions quality"}, - {"-threads ", "number of threads to use"}, - {"-v", "Verbose mode"} + { "-connect
", "Talk to a NetRadiant instance using a specific XML based protocol" }, + { "-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may crash. Also enables decompilation of model autoclip brushes." }, + { "-fs_basepath ", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)" }, + { "-fs_forbiddenpath ", "Pattern to ignore directories, pk3, and pk3dir; example pak?.pk3 (can be used more than once to look for multiple patterns)" }, + { "-fs_game ", "Sets extra game directory name to additionally load mod's resources from at higher priority (by default for Q3A 'baseq3' is loaded, -fs_game cpma will also load 'cpma'; can be used more than once)" }, + { "-fs_basegame ", "Overrides default game directory name (e.g. Q3A uses 'baseq3', OpenArena 'baseoa', so -game quake3 -fs_basegame baseoa for OA )" }, + { "-fs_home ", "Specifies where the user home directory is on Linux" }, + { "-fs_homebase ", "Specifies game home directory relative to user home directory on Linux (default for Q3A: .q3a)" }, + { "-fs_homepath ", "Sets the given path as the game home directory name (fs_home + fs_homebase)" }, + { "-fs_pakpath ", "Specify a package directory (can be used more than once to look in multiple paths)" }, + { "-game ", "Load settings for the given game (default: quake3), -help -game lists available games" }, + { "-maxmapdrawsurfs ", "Sets max amount of mapDrawSurfs, used during .map compilation (-bsp, -convert), default = 131072" }, + { "-maxshaderinfo ", "Sets max amount of shaderInfo, default = 8192" }, + { "-subdivisions ", "multiplier for patch subdivisions quality" }, + { "-threads ", "number of threads to use" }, + { "-v", "Verbose mode" }, }; - HelpOptions("Common Options", 0, 80, options); + HelpOptions( "Common Options", 0, 80, options ); } @@ -478,31 +478,31 @@ void HelpGames(){ void HelpMain(const char* arg) { - printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n"); - printf(" q3map2 -help [stage]\n\n"); + printf( "Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n" ); + printf( " q3map2 -help [stage]\n\n" ); HelpCommon(); const std::vector stages = { - {"-bsp", "BSP Stage"}, - {"-vis", "VIS Stage"}, - {"-light", "Light Stage"}, - {"-analyze", "Analyzing BSP-like file structure"}, - {"-scale", "Scaling"}, - {"-shift", "Shift"}, - {"-convert", "Converting & Decompiling"}, - {"-export", "Exporting lightmaps"}, - {"-import", "Importing lightmaps"}, - {"-exportents", "Exporting entities"}, - {"-fixaas", "Fixing AAS checksum"}, - {"-info", "Get info about BSP file"}, - {"-minimap", "MiniMap"}, - {"-pk3", "PK3 creation"}, - {"-repack", "Maps repack creation"}, - {"-json", "BSP json export/import"}, - {"-mergebsp", "BSP merge"}, + { "-bsp", "BSP Stage" }, + { "-vis", "VIS Stage" }, + { "-light", "Light Stage" }, + { "-analyze", "Analyzing BSP-like file structure" }, + { "-scale", "Scaling" }, + { "-shift", "Shift" }, + { "-convert", "Converting & Decompiling" }, + { "-export", "Exporting lightmaps" }, + { "-import", "Importing lightmaps" }, + { "-exportents", "Exporting entities" }, + { "-fixaas", "Fixing AAS checksum" }, + { "-info", "Get info about BSP file" }, + { "-minimap", "MiniMap" }, + { "-pk3", "PK3 creation" }, + { "-repack", "Maps repack creation" }, + { "-json", "BSP json export/import" }, + { "-mergebsp", "BSP merge" }, }; - void(*help_funcs[])() = { + void( *help_funcs[] )() = { HelpBsp, HelpVis, HelpLight, @@ -528,16 +528,12 @@ void HelpMain(const char* arg) arg++; for ( size_t i = 0; i < stages.size(); ++i ) - if ( striEqual(arg, stages[i].name+1) ) - { - help_funcs[i](); - return; - } - if( striEqual( arg, "game" ) ){ - HelpGames(); - return; - } + if ( striEqual( arg, stages[i].name + 1 ) ) + return help_funcs[i](); + + if( striEqual( arg, "game" ) ) + return HelpGames(); } - HelpOptions("Stages", 0, 80, stages); + HelpOptions( "Stages", 0, 80, stages ); } diff --git a/tools/quake3/q3map2/light_bounce.cpp b/tools/quake3/q3map2/light_bounce.cpp index 99104f59..9930b453 100644 --- a/tools/quake3/q3map2/light_bounce.cpp +++ b/tools/quake3/q3map2/light_bounce.cpp @@ -637,35 +637,27 @@ void RadLightForTriangles( int num, int lightmapNum, rawLightmap_t *lm, const sh #define PLANAR_EPSILON 0.1f void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shaderInfo_t *si, float scale, float subdivide, clipWork_t *cw ){ - int i, x, y, v, t, r; - bspDrawSurface_t *ds; - surfaceInfo_t *info; - bspDrawVert_t *bogus; - mesh_t src, *subdivided, *mesh; - bool planar; - radWinding_t rw; - - /* get surface */ - ds = &bspDrawSurfaces[ num ]; - info = &surfaceInfos[ num ]; + bspDrawSurface_t& ds = bspDrawSurfaces[ num ]; + const surfaceInfo_t& info = surfaceInfos[ num ]; /* construct a bogus vert list with color index stuffed into color[ 0 ] */ - bogus = safe_malloc( ds->numVerts * sizeof( bspDrawVert_t ) ); - memcpy( bogus, &yDrawVerts[ ds->firstVert ], ds->numVerts * sizeof( bspDrawVert_t ) ); - for ( i = 0; i < ds->numVerts; i++ ) + bspDrawVert_t *bogus = safe_malloc( ds.numVerts * sizeof( bspDrawVert_t ) ); + memcpy( bogus, &yDrawVerts[ ds.firstVert ], ds.numVerts * sizeof( bspDrawVert_t ) ); + for ( int i = 0; i < ds.numVerts; i++ ) bogus[ i ].color[ 0 ][ 0 ] = i; /* build a subdivided mesh identical to shadow facets for this patch */ /* this MUST MATCH FacetsForPatch() identically! */ - src.width = ds->patchWidth; - src.height = ds->patchHeight; + mesh_t src; + src.width = ds.patchWidth; + src.height = ds.patchHeight; src.verts = bogus; - //% subdivided = SubdivideMesh( src, 8, 512 ); - subdivided = SubdivideMesh2( src, info->patchIterations ); + //% mesh_t *subdivided = SubdivideMesh( src, 8, 512 ); + mesh_t *subdivided = SubdivideMesh2( src, info.patchIterations ); PutMeshOnCurve( *subdivided ); //% MakeMeshNormals( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); free( bogus ); @@ -674,15 +666,15 @@ void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shader /* fix up color indexes */ for ( bspDrawVert_t& vert : Span( mesh->verts, mesh->width * mesh->height ) ) { - if ( vert.color[ 0 ][ 0 ] >= ds->numVerts ) { - vert.color[ 0 ][ 0 ] = ds->numVerts - 1; + if ( vert.color[ 0 ][ 0 ] >= ds.numVerts ) { + vert.color[ 0 ][ 0 ] = ds.numVerts - 1; } } /* iterate through the mesh quads */ - for ( y = 0; y < ( mesh->height - 1 ); y++ ) + for ( int y = 0; y < ( mesh->height - 1 ); y++ ) { - for ( x = 0; x < ( mesh->width - 1 ); x++ ) + for ( int x = 0; x < ( mesh->width - 1 ); x++ ) { /* set indexes */ const int pw[ 5 ] = { @@ -693,7 +685,7 @@ void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shader x + ( y * mesh->width ) /* same as pw[ 0 ] */ }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* get drawverts */ const bspDrawVert_t *dv[ 4 ] = { @@ -704,7 +696,7 @@ void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shader }; /* planar? */ Plane3f plane; - planar = PlaneFromPoints( plane, dv[ 0 ]->xyz, dv[ 1 ]->xyz, dv[ 2 ]->xyz ); + bool planar = PlaneFromPoints( plane, dv[ 0 ]->xyz, dv[ 1 ]->xyz, dv[ 2 ]->xyz ); if ( planar ) { if ( fabs( plane3_distance_to_point( plane, dv[ 1 ]->xyz ) ) > PLANAR_EPSILON ) { planar = false; @@ -713,31 +705,33 @@ void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shader /* generate a quad */ if ( planar ) { + radWinding_t rw; rw.numVerts = 4; - for ( v = 0; v < 4; v++ ) + for ( int v = 0; v < 4; v++ ) { /* get most everything */ memcpy( &rw.verts[ v ], dv[ v ], sizeof( bspDrawVert_t ) ); /* fix colors */ - for ( i = 0; i < MAX_LIGHTMAPS; i++ ) + for ( int i = 0; i < MAX_LIGHTMAPS; i++ ) { - rw.verts[ v ].color[ i ].rgb() = getRadVertexLuxel( i, ds->firstVert + dv[ v ]->color[ 0 ][ 0 ] ); + rw.verts[ v ].color[ i ].rgb() = getRadVertexLuxel( i, ds.firstVert + dv[ v ]->color[ 0 ][ 0 ] ); rw.verts[ v ].color[ i ].alpha() = dv[ v ]->color[ i ].alpha(); } } /* subdivide into area lights */ - RadSubdivideDiffuseLight( lightmapNum, ds, lm, si, scale, subdivide, &rw, cw ); + RadSubdivideDiffuseLight( lightmapNum, &ds, lm, si, scale, subdivide, &rw, cw ); } /* generate 2 tris */ else { + radWinding_t rw; rw.numVerts = 3; - for ( t = 0; t < 2; t++ ) + for ( int t = 0; t < 2; t++ ) { - for ( v = 0; v < 3 + t; v++ ) + for ( int v = 0; v < 3 + t; v++ ) { /* get "other" triangle (stupid hacky logic, but whatevah) */ if ( v == 1 && t == 1 ) { @@ -748,15 +742,15 @@ void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shader memcpy( &rw.verts[ v ], dv[ v ], sizeof( bspDrawVert_t ) ); /* fix colors */ - for ( i = 0; i < MAX_LIGHTMAPS; i++ ) + for ( int i = 0; i < MAX_LIGHTMAPS; i++ ) { - rw.verts[ v ].color[ i ].rgb() = getRadVertexLuxel( i, ds->firstVert + dv[ v ]->color[ 0 ][ 0 ] ); + rw.verts[ v ].color[ i ].rgb() = getRadVertexLuxel( i, ds.firstVert + dv[ v ]->color[ 0 ][ 0 ] ); rw.verts[ v ].color[ i ].alpha() = dv[ v ]->color[ i ].alpha(); } } /* subdivide into area lights */ - RadSubdivideDiffuseLight( lightmapNum, ds, lm, si, scale, subdivide, &rw, cw ); + RadSubdivideDiffuseLight( lightmapNum, &ds, lm, si, scale, subdivide, &rw, cw ); } } } diff --git a/tools/quake3/q3map2/light_trace.cpp b/tools/quake3/q3map2/light_trace.cpp index d339daf7..9cd2bcc4 100644 --- a/tools/quake3/q3map2/light_trace.cpp +++ b/tools/quake3/q3map2/light_trace.cpp @@ -819,64 +819,59 @@ static int TriangulateTraceNode_r( int nodeNum ){ */ static void PopulateWithBSPModel( const bspModel_t& model, const Matrix4& transform ){ - int i, j, x, y, pw[ 5 ], r, nodeNum; - bspDrawSurface_t *ds; - surfaceInfo_t *info; - const bspDrawVert_t *verts; - const int *indexes; - mesh_t srcMesh, *mesh, *subdivided; + int nodeNum; traceInfo_t ti; traceWinding_t tw; /* walk the list of surfaces in this model and fill out the info structs */ - for ( i = 0; i < model.numBSPSurfaces; i++ ) + for ( int i = 0; i < model.numBSPSurfaces; i++ ) { /* get surface and info */ - ds = &bspDrawSurfaces[ model.firstBSPSurface + i ]; - info = &surfaceInfos[ model.firstBSPSurface + i ]; - if ( info->si == NULL ) { + const bspDrawSurface_t& ds = bspDrawSurfaces[ model.firstBSPSurface + i ]; + const surfaceInfo_t& info = surfaceInfos[ model.firstBSPSurface + i ]; + if ( info.si == NULL ) { continue; } /* no shadows */ - if ( !info->castShadows ) { + if ( !info.castShadows ) { continue; } /* patchshadows? */ - if ( ds->surfaceType == MST_PATCH && !patchShadows ) { + if ( ds.surfaceType == MST_PATCH && !patchShadows ) { continue; } /* some surfaces in the bsp might have been tagged as nodraw, with a bogus shader */ - if ( ( bspShaders[ ds->shaderNum ].contentFlags & noDrawContentFlags ) || - ( bspShaders[ ds->shaderNum ].surfaceFlags & noDrawSurfaceFlags ) ) { + if ( ( bspShaders[ ds.shaderNum ].contentFlags & noDrawContentFlags ) || + ( bspShaders[ ds.shaderNum ].surfaceFlags & noDrawSurfaceFlags ) ) { continue; } /* translucent surfaces that are neither alphashadow or lightfilter don't cast shadows */ - if ( ( info->si->compileFlags & C_NODRAW ) ) { + if ( ( info.si->compileFlags & C_NODRAW ) ) { continue; } - if ( ( info->si->compileFlags & C_TRANSLUCENT ) && - !( info->si->compileFlags & C_ALPHASHADOW ) && - !( info->si->compileFlags & C_LIGHTFILTER ) ) { + if ( ( info.si->compileFlags & C_TRANSLUCENT ) && + !( info.si->compileFlags & C_ALPHASHADOW ) && + !( info.si->compileFlags & C_LIGHTFILTER ) ) { continue; } /* setup trace info */ - ti.si = info->si; - ti.castShadows = info->castShadows; + ti.si = info.si; + ti.castShadows = info.castShadows; ti.surfaceNum = model.firstBSPBrush + i; - ti.skipGrid = ( ds->surfaceType == MST_PATCH ); + ti.skipGrid = ( ds.surfaceType == MST_PATCH ); /* choose which node (normal or skybox) */ - if ( info->parentSurfaceNum >= 0 ) { + if ( info.parentSurfaceNum >= 0 ) { nodeNum = skyboxNodeNum; /* sky surfaces in portal skies are ignored */ - if ( info->si->compileFlags & C_SKY ) { + if ( info.si->compileFlags & C_SKY ) { continue; } } @@ -890,47 +885,50 @@ static void PopulateWithBSPModel( const bspModel_t& model, const Matrix4& transf tw.numVerts = 3; /* switch on type */ - switch ( ds->surfaceType ) + switch ( ds.surfaceType ) { /* handle patches */ case MST_PATCH: + { /* subdivide the surface */ - srcMesh.width = ds->patchWidth; - srcMesh.height = ds->patchHeight; - srcMesh.verts = &bspDrawVerts[ ds->firstVert ]; - //% subdivided = SubdivideMesh( srcMesh, 8, 512 ); - subdivided = SubdivideMesh2( srcMesh, info->patchIterations ); + mesh_t srcMesh; + srcMesh.width = ds.patchWidth; + srcMesh.height = ds.patchHeight; + srcMesh.verts = &bspDrawVerts[ ds.firstVert ]; + //% mesh_t *subdivided = SubdivideMesh( srcMesh, 8, 512 ); + mesh_t *subdivided = SubdivideMesh2( srcMesh, info.patchIterations ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* set verts */ - verts = mesh->verts; + const bspDrawVert_t *verts = mesh->verts; /* subdivide each quad to place the models */ - for ( y = 0; y < ( mesh->height - 1 ); y++ ) + for ( int y = 0; y < ( mesh->height - 1 ); y++ ) { - for ( x = 0; x < ( mesh->width - 1 ); x++ ) + for ( int x = 0; x < ( mesh->width - 1 ); x++ ) { /* set indexes */ - pw[ 0 ] = x + ( y * mesh->width ); - pw[ 1 ] = x + ( ( y + 1 ) * mesh->width ); - pw[ 2 ] = x + 1 + ( ( y + 1 ) * mesh->width ); - pw[ 3 ] = x + 1 + ( y * mesh->width ); - pw[ 4 ] = x + ( y * mesh->width ); /* same as pw[ 0 ] */ - + const int pw[ 5 ] = { + x + ( y * mesh->width ), + x + ( ( y + 1 ) * mesh->width ), + x + 1 + ( ( y + 1 ) * mesh->width ), + x + 1 + ( y * mesh->width ), + x + ( y * mesh->width ) /* same as pw[ 0 ] */ + }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* make first triangle */ tw.v[ 0 ].xyz = verts[ pw[ r + 0 ] ].xyz; - tw.v[ 0 ].st = verts[ pw[ r + 0 ] ].st; + tw.v[ 0 ].st = verts[ pw[ r + 0 ] ].st; tw.v[ 1 ].xyz = verts[ pw[ r + 1 ] ].xyz; - tw.v[ 1 ].st = verts[ pw[ r + 1 ] ].st; + tw.v[ 1 ].st = verts[ pw[ r + 1 ] ].st; tw.v[ 2 ].xyz = verts[ pw[ r + 2 ] ].xyz; - tw.v[ 2 ].st = verts[ pw[ r + 2 ] ].st; + tw.v[ 2 ].st = verts[ pw[ r + 2 ] ].st; matrix4_transform_point( transform, tw.v[ 0 ].xyz ); matrix4_transform_point( transform, tw.v[ 1 ].xyz ); matrix4_transform_point( transform, tw.v[ 2 ].xyz ); @@ -938,11 +936,11 @@ static void PopulateWithBSPModel( const bspModel_t& model, const Matrix4& transf /* make second triangle */ tw.v[ 0 ].xyz = verts[ pw[ r + 0 ] ].xyz; - tw.v[ 0 ].st = verts[ pw[ r + 0 ] ].st; + tw.v[ 0 ].st = verts[ pw[ r + 0 ] ].st; tw.v[ 1 ].xyz = verts[ pw[ r + 2 ] ].xyz; - tw.v[ 1 ].st = verts[ pw[ r + 2 ] ].st; + tw.v[ 1 ].st = verts[ pw[ r + 2 ] ].st; tw.v[ 2 ].xyz = verts[ pw[ r + 3 ] ].xyz; - tw.v[ 2 ].st = verts[ pw[ r + 3 ] ].st; + tw.v[ 2 ].st = verts[ pw[ r + 3 ] ].st; matrix4_transform_point( transform, tw.v[ 0 ].xyz ); matrix4_transform_point( transform, tw.v[ 1 ].xyz ); matrix4_transform_point( transform, tw.v[ 2 ].xyz ); @@ -953,30 +951,31 @@ static void PopulateWithBSPModel( const bspModel_t& model, const Matrix4& transf /* free the subdivided mesh */ FreeMesh( mesh ); break; - + } /* handle triangle surfaces */ case MST_TRIANGLE_SOUP: case MST_PLANAR: + { /* set verts and indexes */ - verts = &bspDrawVerts[ ds->firstVert ]; - indexes = &bspDrawIndexes[ ds->firstIndex ]; + const bspDrawVert_t *verts = &bspDrawVerts[ ds.firstVert ]; + const int *indexes = &bspDrawIndexes[ ds.firstIndex ]; /* walk the triangle list */ - for ( j = 0; j < ds->numIndexes; j += 3 ) + for ( int j = 0; j < ds.numIndexes; j += 3 ) { - tw.v[ 0 ].xyz = verts[ indexes[ j ] ].xyz; - tw.v[ 0 ].st = verts[ indexes[ j ] ].st; + tw.v[ 0 ].xyz = verts[ indexes[ j + 0 ] ].xyz; + tw.v[ 0 ].st = verts[ indexes[ j + 0 ] ].st; tw.v[ 1 ].xyz = verts[ indexes[ j + 1 ] ].xyz; - tw.v[ 1 ].st = verts[ indexes[ j + 1 ] ].st; + tw.v[ 1 ].st = verts[ indexes[ j + 1 ] ].st; tw.v[ 2 ].xyz = verts[ indexes[ j + 2 ] ].xyz; - tw.v[ 2 ].st = verts[ indexes[ j + 2 ] ].st; + tw.v[ 2 ].st = verts[ indexes[ j + 2 ] ].st; matrix4_transform_point( transform, tw.v[ 0 ].xyz ); matrix4_transform_point( transform, tw.v[ 1 ].xyz ); matrix4_transform_point( transform, tw.v[ 2 ].xyz ); FilterTraceWindingIntoNodes_r( &tw, nodeNum ); } break; - + } /* other surface types do not cast shadows */ default: break; diff --git a/tools/quake3/q3map2/light_ydnar.cpp b/tools/quake3/q3map2/light_ydnar.cpp index e2dda59b..eda2e5a0 100644 --- a/tools/quake3/q3map2/light_ydnar.cpp +++ b/tools/quake3/q3map2/light_ydnar.cpp @@ -679,7 +679,7 @@ static void PerturbNormal( const bspDrawVert_t& dv, const shaderInfo_t *si, Vect #define NUDGE 0.5f #define BOGUS_NUDGE -99999.0f -static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, const bspDrawVert_t& dv, const Plane3f* plane, float pass, const Vector3 stv[ 3 ], const Vector3 ttv[ 3 ], const Vector3 worldverts[ 3 ] ){ +static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const bspDrawVert_t& dv, const Plane3f* plane, float pass, const Vector3 stv[ 3 ], const Vector3 ttv[ 3 ], const Vector3 worldverts[ 3 ] ){ int i, numClusters, *clusters, pointCluster; float lightmapSampleOffset; const shaderInfo_t *si; @@ -928,10 +928,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, const bspDraw than the distance between two luxels (thanks jc :) */ -static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, const TriRef& tri, Plane3f *plane, const Vector3 stv[ 3 ], const Vector3 ttv[ 3 ], const Vector3 worldverts[ 3 ] ){ - int max; - - +static void MapTriangle_r( rawLightmap_t *lm, const surfaceInfo_t *info, const TriRef& tri, Plane3f *plane, const Vector3 stv[ 3 ], const Vector3 ttv[ 3 ], const Vector3 worldverts[ 3 ] ){ /* map the vertexes */ #if 0 MapSingleLuxel( lm, info, *tri[ 0 ], plane, 1, stv, ttv ); @@ -940,9 +937,9 @@ static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, const TriRef& #endif /* subdivide calc */ + int max = -1; { /* find the longest edge and split it */ - max = -1; float maxDist = 0; for ( int i = 0; i < 3; i++ ) { @@ -987,7 +984,7 @@ static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, const TriRef& requires a cw ordered triangle */ -static bool MapTriangle( rawLightmap_t *lm, surfaceInfo_t *info, const TriRef& tri, bool mapNonAxial ){ +static bool MapTriangle( rawLightmap_t *lm, const surfaceInfo_t *info, const TriRef& tri, bool mapNonAxial ){ Plane3f plane; /* get plane if possible */ if ( lm->plane != NULL ) { @@ -1056,19 +1053,16 @@ static bool MapTriangle( rawLightmap_t *lm, surfaceInfo_t *info, const TriRef& t than the distance between two luxels */ -static void MapQuad_r( rawLightmap_t *lm, surfaceInfo_t *info, const QuadRef& dv, Plane3f *plane, const Vector3 stv[ 4 ], const Vector3 ttv[ 4 ] ){ - int max; - - +static void MapQuad_r( rawLightmap_t *lm, const surfaceInfo_t *info, const QuadRef& quad, Plane3f *plane, const Vector3 stv[ 4 ], const Vector3 ttv[ 4 ] ){ /* subdivide calc */ + int max = -1; { /* find the longest edge and split it */ - max = -1; float maxDist = 0; for ( int i = 0; i < 4; i++ ) { /* get dist */ - const float dist = vector2_length_squared( dv[ i ]->lightmap[ 0 ] - dv[ ( i + 1 ) % 4 ]->lightmap[ 0 ] ); + const float dist = vector2_length_squared( quad[ i ]->lightmap[ 0 ] - quad[ ( i + 1 ) % 4 ]->lightmap[ 0 ] ); /* longer? */ if ( dist > maxDist ) { maxDist = dist; @@ -1087,8 +1081,8 @@ static void MapQuad_r( rawLightmap_t *lm, surfaceInfo_t *info, const QuadRef& dv /* split the longest edges */ const bspDrawVert_t mid[ 2 ] = { - LerpDrawVert( *dv[ max + 0 ], *dv[ ( max + 1 ) % 4 ] ), - LerpDrawVert( *dv[ max + 2 ], *dv[ ( max + 3 ) % 4 ] ) }; + LerpDrawVert( *quad[ max + 0 ], *quad[ ( max + 1 ) % 4 ] ), + LerpDrawVert( *quad[ max + 2 ], *quad[ ( max + 3 ) % 4 ] ) }; /* map the vertexes */ MapSingleLuxel( lm, info, mid[ 0 ], plane, 1, stv, ttv, NULL ); @@ -1097,20 +1091,20 @@ static void MapQuad_r( rawLightmap_t *lm, surfaceInfo_t *info, const QuadRef& dv /* 0 and 2 */ if ( max == 0 ) { /* recurse to first quad */ - MapQuad_r( lm, info, QuadRef{ dv[ 0 ], &mid[ 0 ], &mid[ 1 ], dv[ 3 ] }, plane, stv, ttv ); + MapQuad_r( lm, info, QuadRef{ quad[ 0 ], &mid[ 0 ], &mid[ 1 ], quad[ 3 ] }, plane, stv, ttv ); /* recurse to second quad */ - MapQuad_r( lm, info, QuadRef{ &mid[ 0 ], dv[ 1 ], dv[ 2 ], &mid[ 1 ] }, plane, stv, ttv ); + MapQuad_r( lm, info, QuadRef{ &mid[ 0 ], quad[ 1 ], quad[ 2 ], &mid[ 1 ] }, plane, stv, ttv ); } /* 1 and 3 */ else { /* recurse to first quad */ - MapQuad_r( lm, info, QuadRef{ dv[ 0 ], dv[ 1 ], &mid[ 0 ], &mid[ 1 ] }, plane, stv, ttv ); + MapQuad_r( lm, info, QuadRef{ quad[ 0 ], quad[ 1 ], &mid[ 0 ], &mid[ 1 ] }, plane, stv, ttv ); /* recurse to second quad */ - MapQuad_r( lm, info, QuadRef{ &mid[ 1 ], &mid[ 0 ], dv[ 2 ], dv[ 3 ] }, plane, stv, ttv ); + MapQuad_r( lm, info, QuadRef{ &mid[ 1 ], &mid[ 0 ], quad[ 2 ], quad[ 3 ] }, plane, stv, ttv ); } } @@ -1124,25 +1118,25 @@ static void MapQuad_r( rawLightmap_t *lm, surfaceInfo_t *info, const QuadRef& dv #define QUAD_PLANAR_EPSILON 0.5f -static bool MapQuad( rawLightmap_t *lm, surfaceInfo_t *info, const QuadRef& dv ){ +static bool MapQuad( rawLightmap_t *lm, const surfaceInfo_t *info, const QuadRef& quad ){ Plane3f plane; /* get plane if possible */ if ( lm->plane != NULL ) { plane = *lm->plane; } /* otherwise make one from the points */ - else if ( !PlaneFromPoints( plane, dv[ 0 ]->xyz, dv[ 1 ]->xyz, dv[ 2 ]->xyz ) ) { + else if ( !PlaneFromPoints( plane, quad[ 0 ]->xyz, quad[ 1 ]->xyz, quad[ 2 ]->xyz ) ) { return false; } /* 4th point must fall on the plane */ - if ( fabs( plane3_distance_to_point( plane, dv[ 3 ]->xyz ) ) > QUAD_PLANAR_EPSILON ) { + if ( fabs( plane3_distance_to_point( plane, quad[ 3 ]->xyz ) ) > QUAD_PLANAR_EPSILON ) { return false; } Vector3 *stv, *ttv, stvStatic[ 4 ], ttvStatic[ 4 ]; /* check to see if we need to calculate texture->world tangent vectors */ - if ( info->si->normalImage != NULL && CalcTangentVectors( dv, stvStatic, ttvStatic ) ) { + if ( info->si->normalImage != NULL && CalcTangentVectors( quad, stvStatic, ttvStatic ) ) { stv = stvStatic; ttv = ttvStatic; } @@ -1153,13 +1147,13 @@ static bool MapQuad( rawLightmap_t *lm, surfaceInfo_t *info, const QuadRef& dv ) } /* map the vertexes */ - MapSingleLuxel( lm, info, *dv[ 0 ], &plane, 1, stv, ttv, NULL ); - MapSingleLuxel( lm, info, *dv[ 1 ], &plane, 1, stv, ttv, NULL ); - MapSingleLuxel( lm, info, *dv[ 2 ], &plane, 1, stv, ttv, NULL ); - MapSingleLuxel( lm, info, *dv[ 3 ], &plane, 1, stv, ttv, NULL ); + MapSingleLuxel( lm, info, *quad[ 0 ], &plane, 1, stv, ttv, NULL ); + MapSingleLuxel( lm, info, *quad[ 1 ], &plane, 1, stv, ttv, NULL ); + MapSingleLuxel( lm, info, *quad[ 2 ], &plane, 1, stv, ttv, NULL ); + MapSingleLuxel( lm, info, *quad[ 3 ], &plane, 1, stv, ttv, NULL ); /* subdivide the quad */ - MapQuad_r( lm, info, dv, &plane, stv, ttv ); + MapQuad_r( lm, info, quad, &plane, stv, ttv ); return true; } @@ -1171,13 +1165,10 @@ static bool MapQuad( rawLightmap_t *lm, surfaceInfo_t *info, const QuadRef& dv ) */ void MapRawLightmap( int rawLightmapNum ){ - int n, num, i, x, y, sx, sy, pw[ 5 ], r, mapNonAxial; + int n, i, x, y, sx, sy, mapNonAxial; float samples, radius, pass; rawLightmap_t *lm; - bspDrawSurface_t *ds; - surfaceInfo_t *info; - mesh_t src, *subdivided, *mesh; - bspDrawVert_t *verts, fake; + bspDrawVert_t fake; /* bail if this number exceeds the number of raw lightmaps */ @@ -1211,9 +1202,9 @@ void MapRawLightmap( int rawLightmapNum ){ } /* get surface */ - num = lightSurfaces[ lm->firstLightSurface + n ]; - ds = &bspDrawSurfaces[ num ]; - info = &surfaceInfos[ num ]; + const int num = lightSurfaces[ lm->firstLightSurface + n ]; + const bspDrawSurface_t& ds = bspDrawSurfaces[ num ]; + const surfaceInfo_t *info = &surfaceInfos[ num ]; /* bail if no lightmap to calculate */ if ( info->lm != lm ) { @@ -1222,36 +1213,39 @@ void MapRawLightmap( int rawLightmapNum ){ } /* map the surface onto the lightmap origin/cluster/normal buffers */ - switch ( ds->surfaceType ) + switch ( ds.surfaceType ) { case MST_PLANAR: + { /* get verts */ - verts = &yDrawVerts[ ds->firstVert ]; + const bspDrawVert_t *verts = &yDrawVerts[ ds.firstVert ]; /* map the triangles */ for ( mapNonAxial = 0; mapNonAxial < 2; mapNonAxial++ ) - for ( i = 0; i < ds->numIndexes; i += 3 ) + for ( i = 0; i < ds.numIndexes; i += 3 ) MapTriangle( lm, info, TriRef{ - &verts[ bspDrawIndexes[ ds->firstIndex + i ] ], - &verts[ bspDrawIndexes[ ds->firstIndex + i + 1 ] ], - &verts[ bspDrawIndexes[ ds->firstIndex + i + 2 ] ] }, mapNonAxial ); + &verts[ bspDrawIndexes[ ds.firstIndex + i ] ], + &verts[ bspDrawIndexes[ ds.firstIndex + i + 1 ] ], + &verts[ bspDrawIndexes[ ds.firstIndex + i + 2 ] ] }, mapNonAxial ); break; - + } case MST_PATCH: + { /* make a mesh from the drawsurf */ - src.width = ds->patchWidth; - src.height = ds->patchHeight; - src.verts = &yDrawVerts[ ds->firstVert ]; - //% subdivided = SubdivideMesh( src, 8, 512 ); - subdivided = SubdivideMesh2( src, info->patchIterations ); + mesh_t src; + src.width = ds.patchWidth; + src.height = ds.patchHeight; + src.verts = &yDrawVerts[ ds.firstVert ]; + //% mesh_t *subdivided = SubdivideMesh( src, 8, 512 ); + mesh_t *subdivided = SubdivideMesh2( src, info->patchIterations ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* get verts */ - verts = mesh->verts; + const bspDrawVert_t *verts = mesh->verts; /* debug code */ #if 0 @@ -1273,14 +1267,15 @@ void MapRawLightmap( int rawLightmapNum ){ for ( x = 0; x < ( mesh->width - 1 ); x++ ) { /* set indexes */ - pw[ 0 ] = x + ( y * mesh->width ); - pw[ 1 ] = x + ( ( y + 1 ) * mesh->width ); - pw[ 2 ] = x + 1 + ( ( y + 1 ) * mesh->width ); - pw[ 3 ] = x + 1 + ( y * mesh->width ); - pw[ 4 ] = x + ( y * mesh->width ); /* same as pw[ 0 ] */ - + const int pw[ 5 ] = { + x + ( y * mesh->width ), + x + ( ( y + 1 ) * mesh->width ), + x + 1 + ( ( y + 1 ) * mesh->width ), + x + 1 + ( y * mesh->width ), + x + ( y * mesh->width ) /* same as pw[ 0 ] */ + }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* get drawverts and map first triangle */ MapTriangle( lm, info, TriRef{ @@ -1304,14 +1299,15 @@ void MapRawLightmap( int rawLightmapNum ){ for ( x = 0; x < ( mesh->width - 1 ); x++ ) { /* set indexes */ - pw[ 0 ] = x + ( y * mesh->width ); - pw[ 1 ] = x + ( ( y + 1 ) * mesh->width ); - pw[ 2 ] = x + 1 + ( ( y + 1 ) * mesh->width ); - pw[ 3 ] = x + 1 + ( y * mesh->width ); - pw[ 4 ] = pw[ 0 ]; - + const int pw[ 5 ] = { + x + ( y * mesh->width ), + x + ( ( y + 1 ) * mesh->width ), + x + 1 + ( ( y + 1 ) * mesh->width ), + x + 1 + ( y * mesh->width ), + x + ( y * mesh->width ) /* same as pw[ 0 ] */ + }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* attempt to map quad first */ if ( MapQuad( lm, info, QuadRef{ @@ -1344,7 +1340,7 @@ void MapRawLightmap( int rawLightmapNum ){ /* free the mesh */ FreeMesh( mesh ); break; - + } default: break; } @@ -3716,7 +3712,7 @@ void SetupFloodLight(){ /* floodlight */ const char *value; if ( entities[ 0 ].read_keyvalue( value, "_floodlight" ) ) { - double v1,v2,v3,v4,v5,v6; + double v1, v2, v3, v4, v5, v6; v1 = v2 = v3 = 0; v4 = floodlightDistance; v5 = floodlightIntensity; diff --git a/tools/quake3/q3map2/lightmaps_ydnar.cpp b/tools/quake3/q3map2/lightmaps_ydnar.cpp index 081b6020..3763d829 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.cpp +++ b/tools/quake3/q3map2/lightmaps_ydnar.cpp @@ -452,11 +452,7 @@ static void FinishRawLightmap( rawLightmap_t *lm ){ */ static bool AddPatchToRawLightmap( int num, rawLightmap_t *lm ){ - bspDrawSurface_t *ds; - surfaceInfo_t *info; - int x, y; bspDrawVert_t *verts, *a, *b; - mesh_t src, *subdivided, *mesh; float sBasis, tBasis, s, t; float length, widthTable[ MAX_EXPANDED_AXIS ] = {0}, heightTable[ MAX_EXPANDED_AXIS ] = {0}; @@ -465,26 +461,27 @@ static bool AddPatchToRawLightmap( int num, rawLightmap_t *lm ){ lm->finished = true; /* get surface and info */ - ds = &bspDrawSurfaces[ num ]; - info = &surfaceInfos[ num ]; + const bspDrawSurface_t& ds = bspDrawSurfaces[ num ]; + const surfaceInfo_t& info = surfaceInfos[ num ]; /* make a temporary mesh from the drawsurf */ - src.width = ds->patchWidth; - src.height = ds->patchHeight; - src.verts = &yDrawVerts[ ds->firstVert ]; - //% subdivided = SubdivideMesh( src, 8, 512 ); - subdivided = SubdivideMesh2( src, info->patchIterations ); + mesh_t src; + src.width = ds.patchWidth; + src.height = ds.patchHeight; + src.verts = &yDrawVerts[ ds.firstVert ]; + //% mesh_t *subdivided = SubdivideMesh( src, 8, 512 ); + mesh_t *subdivided = SubdivideMesh2( src, info.patchIterations ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* find the longest distance on each row/column */ verts = mesh->verts; - for ( y = 0; y < mesh->height; y++ ) + for ( int y = 0; y < mesh->height; y++ ) { - for ( x = 0; x < mesh->width; x++ ) + for ( int x = 0; x < mesh->width; x++ ) { /* get width */ if ( x + 1 < mesh->width ) { @@ -504,21 +501,21 @@ static bool AddPatchToRawLightmap( int num, rawLightmap_t *lm ){ /* determine lightmap width */ length = 0; - for ( x = 0; x < ( mesh->width - 1 ); x++ ) + for ( int x = 0; x < ( mesh->width - 1 ); x++ ) length += widthTable[ x ]; lm->w = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0; - value_maximize( lm->w, ds->patchWidth ); + value_maximize( lm->w, ds.patchWidth ); value_minimize( lm->w, lm->customWidth ); - sBasis = (float) ( lm->w - 1 ) / (float) ( ds->patchWidth - 1 ); + sBasis = (float) ( lm->w - 1 ) / (float) ( ds.patchWidth - 1 ); /* determine lightmap height */ length = 0; - for ( y = 0; y < ( mesh->height - 1 ); y++ ) + for ( int y = 0; y < ( mesh->height - 1 ); y++ ) length += heightTable[ y ]; lm->h = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0; - value_maximize( lm->h, ds->patchHeight ); + value_maximize( lm->h, ds.patchHeight ); value_minimize( lm->h, lm->customHeight ); - tBasis = (float) ( lm->h - 1 ) / (float) ( ds->patchHeight - 1 ); + tBasis = (float) ( lm->h - 1 ) / (float) ( ds.patchHeight - 1 ); /* free the temporary mesh */ FreeMesh( mesh ); @@ -526,32 +523,32 @@ static bool AddPatchToRawLightmap( int num, rawLightmap_t *lm ){ /* set the lightmap texture coordinates in yDrawVerts */ lm->wrap[ 0 ] = true; lm->wrap[ 1 ] = true; - verts = &yDrawVerts[ ds->firstVert ]; - for ( y = 0; y < ds->patchHeight; y++ ) + verts = &yDrawVerts[ ds.firstVert ]; + for ( int y = 0; y < ds.patchHeight; y++ ) { t = ( tBasis * y ) + 0.5f; - for ( x = 0; x < ds->patchWidth; x++ ) + for ( int x = 0; x < ds.patchWidth; x++ ) { s = ( sBasis * x ) + 0.5f; - verts[ ( y * ds->patchWidth ) + x ].lightmap[ 0 ][ 0 ] = s * superSample; - verts[ ( y * ds->patchWidth ) + x ].lightmap[ 0 ][ 1 ] = t * superSample; + verts[ ( y * ds.patchWidth ) + x ].lightmap[ 0 ][ 0 ] = s * superSample; + verts[ ( y * ds.patchWidth ) + x ].lightmap[ 0 ][ 1 ] = t * superSample; - if ( y == 0 && !VectorCompare( verts[ x ].xyz, verts[ ( ( ds->patchHeight - 1 ) * ds->patchWidth ) + x ].xyz ) ) { + if ( y == 0 && !VectorCompare( verts[ x ].xyz, verts[ ( ( ds.patchHeight - 1 ) * ds.patchWidth ) + x ].xyz ) ) { lm->wrap[ 1 ] = false; } } - if ( !VectorCompare( verts[ ( y * ds->patchWidth ) ].xyz, verts[ ( y * ds->patchWidth ) + ( ds->patchWidth - 1 ) ].xyz ) ) { + if ( !VectorCompare( verts[ ( y * ds.patchWidth ) ].xyz, verts[ ( y * ds.patchWidth ) + ( ds.patchWidth - 1 ) ].xyz ) ) { lm->wrap[ 0 ] = false; } } /* debug code: */ //% Sys_Printf( "wrap S: %d wrap T: %d\n", lm->wrap[ 0 ], lm->wrap[ 1 ] ); - //% if( lm->w > (ds->lightmapWidth & 0xFF) || lm->h > (ds->lightmapHeight & 0xFF) ) - //% Sys_Printf( "Patch lightmap: (%3d %3d) > (%3d, %3d)\n", lm->w, lm->h, ds->lightmapWidth & 0xFF, ds->lightmapHeight & 0xFF ); - //% ds->lightmapWidth = lm->w | (ds->lightmapWidth & 0xFFFF0000); - //% ds->lightmapHeight = lm->h | (ds->lightmapHeight & 0xFFFF0000); + //% if( lm->w > (ds.lightmapWidth & 0xFF) || lm->h > (ds.lightmapHeight & 0xFF) ) + //% Sys_Printf( "Patch lightmap: (%3d %3d) > (%3d, %3d)\n", lm->w, lm->h, ds.lightmapWidth & 0xFF, ds.lightmapHeight & 0xFF ); + //% ds.lightmapWidth = lm->w | (ds.lightmapWidth & 0xFFFF0000); + //% ds.lightmapHeight = lm->h | (ds.lightmapHeight & 0xFFFF0000); /* add to counts */ numPatchesLightmapped++; @@ -936,7 +933,7 @@ struct CompareSurfaceInfo */ void SetupSurfaceLightmaps(){ - int i, j, k, s,num, num2; + int i, j, k, s, num, num2; bspDrawSurface_t *ds; surfaceInfo_t *info, *info2; rawLightmap_t *lm; @@ -1554,28 +1551,18 @@ static bool ApproximateLuxel( rawLightmap_t *lm, const bspDrawVert_t& dv ){ */ static bool ApproximateTriangle_r( rawLightmap_t *lm, const TriRef& tri ){ - int max; - - /* approximate the vertexes */ - if ( !ApproximateLuxel( lm, *tri[ 0 ] ) ) { + if ( !ApproximateLuxel( lm, *tri[ 0 ] ) + || !ApproximateLuxel( lm, *tri[ 1 ] ) + || !ApproximateLuxel( lm, *tri[ 2 ] ) ) return false; - } - if ( !ApproximateLuxel( lm, *tri[ 1 ] ) ) { - return false; - } - if ( !ApproximateLuxel( lm, *tri[ 2 ] ) ) { - return false; - } /* subdivide calc */ + int max = -1; { - int i; - /* find the longest edge and split it */ - max = -1; float maxDist = 0; - for ( i = 0; i < 3; i++ ) + for ( int i = 0; i < 3; i++ ) { const float dist = vector2_length( tri[ i ]->lightmap[ 0 ] - tri[ ( i + 1 ) % 3 ]->lightmap[ 0 ] ); if ( dist > maxDist ) { @@ -1585,7 +1572,7 @@ static bool ApproximateTriangle_r( rawLightmap_t *lm, const TriRef& tri ){ } /* try to early out */ - if ( i < 0 || maxDist < subdivideThreshold ) { + if ( max < 0 || maxDist < subdivideThreshold ) { return true; } } @@ -1617,14 +1604,6 @@ static bool ApproximateTriangle_r( rawLightmap_t *lm, const TriRef& tri ){ */ static bool ApproximateLightmap( rawLightmap_t *lm ){ - int n, num, i, x, y, pw[ 5 ], r; - bspDrawSurface_t *ds; - surfaceInfo_t *info; - mesh_t src, *subdivided, *mesh; - const bspDrawVert_t *verts; - bool approximated; - - /* approximating? */ if ( approximateTolerance <= 0 ) { return false; @@ -1638,7 +1617,7 @@ static bool ApproximateLightmap( rawLightmap_t *lm ){ } /* don't approx lightmaps with styles */ - for ( i = 1; i < MAX_LIGHTMAPS; i++ ) + for ( int i = 1; i < MAX_LIGHTMAPS; i++ ) { if ( lm->styles[ i ] != LS_NONE ) { return false; @@ -1647,97 +1626,101 @@ static bool ApproximateLightmap( rawLightmap_t *lm ){ #endif /* assume reduced until shadow detail is found */ - approximated = true; + bool approximated = true; /* walk the list of surfaces on this raw lightmap */ - for ( n = 0; n < lm->numLightSurfaces; n++ ) + for ( int n = 0; n < lm->numLightSurfaces; n++ ) { /* get surface */ - num = lightSurfaces[ lm->firstLightSurface + n ]; - ds = &bspDrawSurfaces[ num ]; - info = &surfaceInfos[ num ]; + const int num = lightSurfaces[ lm->firstLightSurface + n ]; + const bspDrawSurface_t& ds = bspDrawSurfaces[ num ]; + surfaceInfo_t& info = surfaceInfos[ num ]; /* assume not-reduced initially */ - info->approximated = false; + info.approximated = false; /* bail if lightmap doesn't match up */ - if ( info->lm != lm ) { + if ( info.lm != lm ) { continue; } /* bail if not vertex lit */ - if ( info->si->noVertexLight ) { + if ( info.si->noVertexLight ) { continue; } /* assume that surfaces whose bounding boxes is smaller than 2x samplesize will be forced to vertex */ - if ( ( info->minmax.maxs[ 0 ] - info->minmax.mins[ 0 ] ) <= ( 2.0f * info->sampleSize ) && - ( info->minmax.maxs[ 1 ] - info->minmax.mins[ 1 ] ) <= ( 2.0f * info->sampleSize ) && - ( info->minmax.maxs[ 2 ] - info->minmax.mins[ 2 ] ) <= ( 2.0f * info->sampleSize ) ) { - info->approximated = true; + if ( ( info.minmax.maxs[ 0 ] - info.minmax.mins[ 0 ] ) <= ( 2.0f * info.sampleSize ) && + ( info.minmax.maxs[ 1 ] - info.minmax.mins[ 1 ] ) <= ( 2.0f * info.sampleSize ) && + ( info.minmax.maxs[ 2 ] - info.minmax.mins[ 2 ] ) <= ( 2.0f * info.sampleSize ) ) { + info.approximated = true; numSurfsVertexForced++; continue; } /* handle the triangles */ - switch ( ds->surfaceType ) + switch ( ds.surfaceType ) { case MST_PLANAR: + { /* get verts */ - verts = &yDrawVerts[ ds->firstVert ]; + const bspDrawVert_t *verts = &yDrawVerts[ ds.firstVert ]; /* map the triangles */ - info->approximated = true; - for ( i = 0; i < ds->numIndexes && info->approximated; i += 3 ) + info.approximated = true; + for ( int i = 0; i < ds.numIndexes && info.approximated; i += 3 ) { - info->approximated = ApproximateTriangle_r( lm, TriRef{ - &verts[ bspDrawIndexes[ ds->firstIndex + i + 0 ] ], - &verts[ bspDrawIndexes[ ds->firstIndex + i + 1 ] ], - &verts[ bspDrawIndexes[ ds->firstIndex + i + 2 ] ] } ); + info.approximated = ApproximateTriangle_r( lm, TriRef{ + &verts[ bspDrawIndexes[ ds.firstIndex + i + 0 ] ], + &verts[ bspDrawIndexes[ ds.firstIndex + i + 1 ] ], + &verts[ bspDrawIndexes[ ds.firstIndex + i + 2 ] ] } ); } break; - + } case MST_PATCH: + { /* make a mesh from the drawsurf */ - src.width = ds->patchWidth; - src.height = ds->patchHeight; - src.verts = &yDrawVerts[ ds->firstVert ]; - //% subdivided = SubdivideMesh( src, 8, 512 ); - subdivided = SubdivideMesh2( src, info->patchIterations ); + mesh_t src; + src.width = ds.patchWidth; + src.height = ds.patchHeight; + src.verts = &yDrawVerts[ ds.firstVert ]; + //% mesh_t *subdivided = SubdivideMesh( src, 8, 512 ); + mesh_t *subdivided = SubdivideMesh2( src, info.patchIterations ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* get verts */ - verts = mesh->verts; + const bspDrawVert_t *verts = mesh->verts; /* map the mesh quads */ - info->approximated = true; - for ( y = 0; y < ( mesh->height - 1 ) && info->approximated; y++ ) + info.approximated = true; + for ( int y = 0; y < ( mesh->height - 1 ) && info.approximated; y++ ) { - for ( x = 0; x < ( mesh->width - 1 ) && info->approximated; x++ ) + for ( int x = 0; x < ( mesh->width - 1 ) && info.approximated; x++ ) { /* set indexes */ - pw[ 0 ] = x + ( y * mesh->width ); - pw[ 1 ] = x + ( ( y + 1 ) * mesh->width ); - pw[ 2 ] = x + 1 + ( ( y + 1 ) * mesh->width ); - pw[ 3 ] = x + 1 + ( y * mesh->width ); - pw[ 4 ] = x + ( y * mesh->width ); /* same as pw[ 0 ] */ - + const int pw[ 5 ] = { + x + ( y * mesh->width ), + x + ( ( y + 1 ) * mesh->width ), + x + 1 + ( ( y + 1 ) * mesh->width ), + x + 1 + ( y * mesh->width ), + x + ( y * mesh->width ) /* same as pw[ 0 ] */ + }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* get drawverts and map first triangle */ - info->approximated = ApproximateTriangle_r( lm, TriRef{ + info.approximated = ApproximateTriangle_r( lm, TriRef{ &verts[ pw[ r + 0 ] ], &verts[ pw[ r + 1 ] ], &verts[ pw[ r + 2 ] ] } ); /* get drawverts and map second triangle */ - if ( info->approximated ) { - info->approximated = ApproximateTriangle_r( lm, TriRef{ + if ( info.approximated ) { + info.approximated = ApproximateTriangle_r( lm, TriRef{ &verts[ pw[ r + 0 ] ], &verts[ pw[ r + 2 ] ], &verts[ pw[ r + 3 ] ] } ); @@ -1748,13 +1731,13 @@ static bool ApproximateLightmap( rawLightmap_t *lm ){ /* free the mesh */ FreeMesh( mesh ); break; - + } default: break; } /* reduced? */ - if ( !info->approximated ) { + if ( !info.approximated ) { approximated = false; } else{ diff --git a/tools/quake3/q3map2/map.cpp b/tools/quake3/q3map2/map.cpp index eb184449..7c7f7746 100644 --- a/tools/quake3/q3map2/map.cpp +++ b/tools/quake3/q3map2/map.cpp @@ -167,23 +167,23 @@ static bool SnapNormal( Vector3& normal ){ /* - for ( i=0; i<30; i++ ) + for ( i = 0; i < 30; i++ ) { double x, y, z, length; x=(double) 1.0; y=(double) ( 0.00001 * i ); z=(double) 0.0; - Sys_Printf("(%6.18f %6.18f %6.18f)inNormal\n", x,y,z ); + Sys_Printf( "(%6.18f %6.18f %6.18f)inNormal\n", x, y, z ); length = sqrt( ( x * x ) + ( y * y ) + ( z * z ) ); - Sys_Printf("(%6.18f)length\n", length); + Sys_Printf( "(%6.18f)length\n", length ); x = (vec_t) ( x / length ); y = (vec_t) ( y / length ); z = (vec_t) ( z / length ); - Sys_Printf("(%6.18f %6.18f %6.18f)outNormal\n\n", x,y,z ); + Sys_Printf( "(%6.18f %6.18f %6.18f)outNormal\n\n", x, y, z ); } - Error("vectorNormalize test completed"); + Error( "vectorNormalize test completed" ); */ for ( i = 0; i < 3; i++ ) diff --git a/tools/quake3/q3map2/mesh.cpp b/tools/quake3/q3map2/mesh.cpp index c039fa88..82740514 100644 --- a/tools/quake3/q3map2/mesh.cpp +++ b/tools/quake3/q3map2/mesh.cpp @@ -171,7 +171,8 @@ void MakeMeshNormals( mesh_t in ){ bool wrapWidth, wrapHeight; int neighbors[8][2] = { - {0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1} + { 0, 1 }, { 1, 1 }, { 1, 0 }, { 1,-1 }, + { 0,-1 }, {-1,-1 }, {-1, 0 }, {-1, 1 } }; @@ -296,23 +297,21 @@ void PutMeshOnCurve( mesh_t in ) { ================= */ mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ){ - int i, j, k; mesh_t out; - bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS]; out.width = in.width; out.height = in.height; - for ( i = 0; i < in.width; ++i ) { - for ( j = 0; j < in.height; ++j ) { + for ( int i = 0; i < in.width; ++i ) { + for ( int j = 0; j < in.height; ++j ) { expand[j][i] = in.verts[j * in.width + i]; } } // horizontal subdivisions - for ( j = 0; j + 2 < out.width; j += 2 ) { + for ( int i, j = 0; j + 2 < out.width; j += 2 ) { // check subdivided midpoints against control points for ( i = 0; i < out.height; ++i ) { const Vector3 prevxyz = expand[i][j + 1].xyz - expand[i][j].xyz; @@ -343,7 +342,7 @@ mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ){ out.width += 2; for ( i = 0; i < out.height; ++i ) { - for ( k = out.width - 1; k > j + 3; --k ) { + for ( int k = out.width - 1; k > j + 3; --k ) { expand[i][k] = expand[i][k - 2]; } expand[i][j + 3] = LerpDrawVert( expand[i][j + 1], expand[i][j + 2] ); @@ -357,7 +356,7 @@ mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ){ } // vertical subdivisions - for ( j = 0; j + 2 < out.height; j += 2 ) { + for ( int i, j = 0; j + 2 < out.height; j += 2 ) { // check subdivided midpoints against control points for ( i = 0; i < out.width; ++i ) { const Vector3 prevxyz = expand[j + 1][i].xyz - expand[j][i].xyz; @@ -387,7 +386,7 @@ mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ){ out.height += 2; for ( i = 0; i < out.width; ++i ) { - for ( k = out.height - 1; k > j + 3; --k ) { + for ( int k = out.height - 1; k > j + 3; --k ) { expand[k][i] = expand[k - 2][i]; } expand[j + 3][i] = LerpDrawVert( expand[j + 1][i], expand[j + 2][i] ); @@ -403,7 +402,7 @@ mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ){ // collapse the verts out.verts = &expand[0][0]; - for ( i = 1; i < out.height; ++i ) { + for ( int i = 1; i < out.height; ++i ) { memmove( &out.verts[i * out.width], expand[i], out.width * sizeof( bspDrawVert_t ) ); } @@ -442,18 +441,16 @@ int IterationsForCurve( float len, int subdivisions ){ */ mesh_t *SubdivideMesh2( mesh_t in, int iterations ){ - int i, j, k; mesh_t out; - bspDrawVert_t expand[ MAX_EXPANDED_AXIS ][ MAX_EXPANDED_AXIS ]; /* initial setup */ out.width = in.width; out.height = in.height; - for ( i = 0; i < in.width; i++ ) + for ( int i = 0; i < in.width; i++ ) { - for ( j = 0; j < in.height; j++ ) + for ( int j = 0; j < in.height; j++ ) expand[ j ][ i ] = in.verts[ j * in.width + i ]; } @@ -461,7 +458,7 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ){ for ( ; iterations > 0; --iterations ) { /* horizontal subdivisions */ - for ( j = 0; j + 2 < out.width; j += 4 ) + for ( int j = 0; j + 2 < out.width; j += 4 ) { /* check size limit */ if ( out.width + 2 >= MAX_EXPANDED_AXIS ) { @@ -470,9 +467,9 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ){ /* insert two columns and replace the peak */ out.width += 2; - for ( i = 0; i < out.height; i++ ) + for ( int i = 0; i < out.height; i++ ) { - for ( k = out.width - 1; k > j + 3; --k ) + for ( int k = out.width - 1; k > j + 3; --k ) expand [ i ][ k ] = expand[ i ][ k - 2 ]; expand[ i ][ j + 3 ] = LerpDrawVert( expand[ i ][ j + 1 ], expand[ i ][ j + 2 ] ); @@ -483,7 +480,7 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ){ } /* vertical subdivisions */ - for ( j = 0; j + 2 < out.height; j += 4 ) + for ( int j = 0; j + 2 < out.height; j += 4 ) { /* check size limit */ if ( out.height + 2 >= MAX_EXPANDED_AXIS ) { @@ -492,9 +489,9 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ){ /* insert two columns and replace the peak */ out.height += 2; - for ( i = 0; i < out.width; i++ ) + for ( int i = 0; i < out.width; i++ ) { - for ( k = out.height - 1; k > j + 3; k-- ) + for ( int k = out.height - 1; k > j + 3; k-- ) expand[ k ][ i ] = expand[ k - 2 ][ i ]; expand[ j + 3 ][ i ] = LerpDrawVert( expand[ j + 1 ][ i ], expand[ j + 2 ][ i ] ); @@ -506,7 +503,7 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ){ /* collapse the verts */ out.verts = &expand[ 0 ][ 0 ]; - for ( i = 1; i < out.height; i++ ) + for ( int i = 1; i < out.height; i++ ) memmove( &out.verts[ i * out.width ], expand[ i ], out.width * sizeof( bspDrawVert_t ) ); /* return to sender */ diff --git a/tools/quake3/q3map2/patch.cpp b/tools/quake3/q3map2/patch.cpp index df6838d5..5b3bcc57 100644 --- a/tools/quake3/q3map2/patch.cpp +++ b/tools/quake3/q3map2/patch.cpp @@ -197,7 +197,6 @@ static void ExpandMaxIterations( int *maxIterations, int maxError, const Vector3 void ParsePatch( bool onlyLights, entity_t& mapEnt, int mapPrimitiveNum ){ float info[ 5 ]; mesh_t m; - bspDrawVert_t *verts; bool degenerate; float longestCurve; int maxIterations; @@ -212,7 +211,7 @@ void ParsePatch( bool onlyLights, entity_t& mapEnt, int mapPrimitiveNum ){ m.width = info[0]; m.height = info[1]; const int size = ( m.width * m.height ); - m.verts = verts = safe_malloc( size * sizeof( m.verts[0] ) ); + bspDrawVert_t *verts = m.verts = safe_malloc( size * sizeof( m.verts[0] ) ); if ( m.width < 0 || m.width > MAX_PATCH_SIZE || m.height < 0 || m.height > MAX_PATCH_SIZE ) { Error( "ParsePatch: bad size" ); diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 87f659fe..ad587931 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -2911,19 +2911,13 @@ static int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, const surfaceMode */ static int AddSurfaceModels( mapDrawSurface_t *ds, entity_t& entity ){ - int localNumSurfaceModels, iterations; - mesh_t src, *mesh, *subdivided; - bspDrawVert_t centroid; - float alpha; - - /* dummy check */ if ( ds == NULL || ds->shaderInfo == NULL || ds->shaderInfo->surfaceModels.empty() ) { return 0; } /* init */ - localNumSurfaceModels = 0; + int localNumSurfaceModels = 0; /* walk the model list */ for ( const auto& model : ds->shaderInfo->surfaceModels ) @@ -2934,9 +2928,11 @@ static int AddSurfaceModels( mapDrawSurface_t *ds, entity_t& entity ){ /* handle brush faces and decals */ case ESurfaceType::Face: case ESurfaceType::Decal: + { /* calculate centroid */ + bspDrawVert_t centroid; memset( ¢roid, 0, sizeof( centroid ) ); - alpha = 0.0f; + float alpha = 0.0f; /* walk verts */ for ( const bspDrawVert_t& vert : Span( ds->verts, ds->numVerts ) ) @@ -2969,20 +2965,22 @@ static int AddSurfaceModels( mapDrawSurface_t *ds, entity_t& entity ){ localNumSurfaceModels += n; } break; - + } /* handle patches */ case ESurfaceType::Patch: + { /* subdivide the surface */ + mesh_t src; src.width = ds->patchWidth; src.height = ds->patchHeight; src.verts = ds->verts; - //% subdivided = SubdivideMesh( src, 8.0f, 512 ); - iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions ); - subdivided = SubdivideMesh2( src, iterations ); + //% mesh_t *subdivided = SubdivideMesh( src, 8.0f, 512 ); + const int iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions ); + mesh_t *subdivided = SubdivideMesh2( src, iterations ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* subdivide each quad to place the models */ @@ -3026,7 +3024,7 @@ static int AddSurfaceModels( mapDrawSurface_t *ds, entity_t& entity ){ /* free the subdivided mesh */ FreeMesh( mesh ); break; - + } /* handle triangle surfaces */ case ESurfaceType::Triangles: case ESurfaceType::ForcedMeta: diff --git a/tools/quake3/q3map2/surface_foliage.cpp b/tools/quake3/q3map2/surface_foliage.cpp index 8e0e3fb2..dcd730be 100644 --- a/tools/quake3/q3map2/surface_foliage.cpp +++ b/tools/quake3/q3map2/surface_foliage.cpp @@ -155,14 +155,8 @@ static void SubdivideFoliageTriangle_r( mapDrawSurface_t *ds, const foliage_t& f */ void Foliage( mapDrawSurface_t *src, entity_t& entity ){ - int oldNumMapDrawSurfs; - shaderInfo_t *si; - mesh_t srcMesh, *subdivided, *mesh; - const bspDrawVert_t *verts; - - /* get shader */ - si = src->shaderInfo; + shaderInfo_t *si = src->shaderInfo; if ( si == NULL || si->foliage.empty() ) { return; } @@ -179,8 +173,9 @@ void Foliage( mapDrawSurface_t *src, entity_t& entity ){ case ESurfaceType::Meta: case ESurfaceType::ForcedMeta: case ESurfaceType::Triangles: + { /* get verts */ - verts = src->verts; + const bspDrawVert_t *verts = src->verts; /* map the triangles */ for ( int i = 0; i < src->numIndexes; i += 3 ) @@ -190,21 +185,23 @@ void Foliage( mapDrawSurface_t *src, entity_t& entity ){ &verts[ src->indexes[ i + 2 ] ] } ); break; - + } case ESurfaceType::Patch: + { /* make a mesh from the drawsurf */ + mesh_t srcMesh; srcMesh.width = src->patchWidth; srcMesh.height = src->patchHeight; srcMesh.verts = src->verts; - subdivided = SubdivideMesh( srcMesh, 8, 512 ); + mesh_t *subdivided = SubdivideMesh( srcMesh, 8, 512 ); /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); /* get verts */ - verts = mesh->verts; + const bspDrawVert_t *verts = mesh->verts; /* map the mesh quads */ for ( int y = 0; y < ( mesh->height - 1 ); y++ ) @@ -240,7 +237,7 @@ void Foliage( mapDrawSurface_t *src, entity_t& entity ){ /* free the mesh */ FreeMesh( mesh ); break; - + } default: break; } @@ -251,7 +248,7 @@ void Foliage( mapDrawSurface_t *src, entity_t& entity ){ } /* remember surface count */ - oldNumMapDrawSurfs = numMapDrawSurfs; + const int oldNumMapDrawSurfs = numMapDrawSurfs; /* add the model to the bsp */ InsertModel( foliage.model.c_str(), NULL, 0, matrix4_scale_for_vec3( Vector3( foliage.scale ) ), NULL, NULL, entity, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0, clipDepthGlobal ); diff --git a/tools/quake3/q3map2/surface_meta.cpp b/tools/quake3/q3map2/surface_meta.cpp index 09b0b6fb..e74c7df0 100644 --- a/tools/quake3/q3map2/surface_meta.cpp +++ b/tools/quake3/q3map2/surface_meta.cpp @@ -343,10 +343,6 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ){ */ static void TriangulatePatchSurface( const entity_t& e, mapDrawSurface_t *ds ){ - int x, y, pw[ 5 ], r; - mapDrawSurface_t *dsNew; - mesh_t src, *subdivided, *mesh; - /* vortex: _patchMeta, _patchQuality, _patchSubdivide support */ const bool forcePatchMeta = e.boolForKey( "_patchMeta", "patchMeta" ); @@ -355,14 +351,14 @@ static void TriangulatePatchSurface( const entity_t& e, mapDrawSurface_t *ds ){ return; } /* make a mesh from the drawsurf */ + mesh_t src; src.width = ds->patchWidth; src.height = ds->patchHeight; src.verts = ds->verts; - //% subdivided = SubdivideMesh( src, 8, 999 ); + //% mesh_t *subdivided = SubdivideMesh( src, 8, 999 ); int iterations; - int patchSubdivision; - if ( e.read_keyvalue( patchSubdivision, "_patchSubdivide", "patchSubdivide" ) ) { + if ( int patchSubdivision; e.read_keyvalue( patchSubdivision, "_patchSubdivide", "patchSubdivide" ) ) { iterations = IterationsForCurve( ds->longestCurve, patchSubdivision ); } else{ @@ -370,16 +366,16 @@ static void TriangulatePatchSurface( const entity_t& e, mapDrawSurface_t *ds ){ iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions / ( patchQuality == 0? 1 : patchQuality ) ); } - subdivided = SubdivideMesh2( src, iterations ); //% ds->maxIterations + mesh_t *subdivided = SubdivideMesh2( src, iterations ); //% ds->maxIterations /* fit it to the curve and remove colinear verts on rows/columns */ PutMeshOnCurve( *subdivided ); - mesh = RemoveLinearMeshColumnsRows( subdivided ); + mesh_t *mesh = RemoveLinearMeshColumnsRows( subdivided ); FreeMesh( subdivided ); //% MakeMeshNormals( mesh ); /* make a copy of the drawsurface */ - dsNew = AllocDrawSurface( ESurfaceType::Meta ); + mapDrawSurface_t *dsNew = AllocDrawSurface( ESurfaceType::Meta ); memcpy( dsNew, ds, sizeof( *ds ) ); /* if the patch is nonsolid, then discard it */ @@ -400,19 +396,20 @@ static void TriangulatePatchSurface( const entity_t& e, mapDrawSurface_t *ds ){ ds->verts = mesh->verts; /* iterate through the mesh quads */ - for ( y = 0; y < ( mesh->height - 1 ); y++ ) + for ( int y = 0; y < ( mesh->height - 1 ); y++ ) { - for ( x = 0; x < ( mesh->width - 1 ); x++ ) + for ( int x = 0; x < ( mesh->width - 1 ); x++ ) { /* set indexes */ - pw[ 0 ] = x + ( y * mesh->width ); - pw[ 1 ] = x + ( ( y + 1 ) * mesh->width ); - pw[ 2 ] = x + 1 + ( ( y + 1 ) * mesh->width ); - pw[ 3 ] = x + 1 + ( y * mesh->width ); - pw[ 4 ] = x + ( y * mesh->width ); /* same as pw[ 0 ] */ - + const int pw[ 5 ] = { + x + ( y * mesh->width ), + x + ( ( y + 1 ) * mesh->width ), + x + 1 + ( ( y + 1 ) * mesh->width ), + x + 1 + ( y * mesh->width ), + x + ( y * mesh->width ) /* same as pw[ 0 ] */ + }; /* set radix */ - r = ( x + y ) & 1; + const int r = ( x + y ) & 1; /* make first triangle */ ds->indexes[ ds->numIndexes++ ] = pw[ r + 0 ]; diff --git a/tools/quake3/q3map2/vis.cpp b/tools/quake3/q3map2/vis.cpp index 97e9bb49..2f1995eb 100644 --- a/tools/quake3/q3map2/vis.cpp +++ b/tools/quake3/q3map2/vis.cpp @@ -63,7 +63,7 @@ static void print_leaf( const leaf_t *l ){ for ( const vportal_t *p : Span( l->portals, l->numportals ) ) { const visPlane_t pl = p->plane; - Sys_Printf( "portal %4i to leaf %4i : %7.1f : (%4.1f, %4.1f, %4.1f)\n",(int)( p - portals ), p->leaf, pl.dist(), pl.normal()[0], pl.normal()[1], pl.normal()[2] ); + Sys_Printf( "portal %4i to leaf %4i : %7.1f : (%4.1f, %4.1f, %4.1f)\n", (int)( p - portals ), p->leaf, pl.dist(), pl.normal()[0], pl.normal()[1], pl.normal()[2] ); } }