diff --git a/tools/quake3/common/qmath.h b/tools/quake3/common/qmath.h index 0e9cc292..d3d71e81 100644 --- a/tools/quake3/common/qmath.h +++ b/tools/quake3/common/qmath.h @@ -27,6 +27,9 @@ struct MinMax___ mins.x() = mins.y() = mins.z() = std::numeric_limits::max(); maxs.x() = maxs.y() = maxs.z() = std::numeric_limits::lowest(); } + bool valid() const { + return mins.x() < maxs.x() && mins.y() < maxs.y() && mins.z() < maxs.z(); + } template void extend( const BasicVector3& point ){ for ( size_t i = 0; i < 3; ++i ){ diff --git a/tools/quake3/q3map2/light.cpp b/tools/quake3/q3map2/light.cpp index 253e7541..d894d85b 100644 --- a/tools/quake3/q3map2/light.cpp +++ b/tools/quake3/q3map2/light.cpp @@ -113,7 +113,7 @@ static void CreateSunLight( sun_t *sun ){ light->style = noStyles ? LS_NORMAL : sun->style; /* set the light's position out to infinity */ - light->origin = -direction * ( MAX_WORLD_COORD * 8.0f ); /* MAX_WORLD_COORD * 2.0f */ + light->origin = direction * ( MAX_WORLD_COORD * 8.0f ); /* MAX_WORLD_COORD * 2.0f */ /* set the facing to be the inverse of the sun direction */ light->normal = -direction; diff --git a/tools/quake3/q3map2/shaders.cpp b/tools/quake3/q3map2/shaders.cpp index 57a7a709..da316e14 100644 --- a/tools/quake3/q3map2/shaders.cpp +++ b/tools/quake3/q3map2/shaders.cpp @@ -1120,10 +1120,8 @@ static void ParseShaderFile( const char *filename ){ GetTokenAppend( shaderText, false ); amp = atof( token ); /* calculate */ - const Vector3 mins = amt * base; - const Vector3 maxs = amt * amp + mins; - si->minmax.mins += mins; - si->minmax.maxs += maxs; + si->minmax.mins = amt * base; + si->minmax.maxs = amt * amp + si->minmax.mins; } } diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 69d84db1..44d4afc9 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -1999,10 +1999,7 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){ si = ds->shaderInfo; /* ydnar: is this the head node? */ - if ( node->parent == NULL && si != NULL && - ( si->minmax.mins[ 0 ] != 0.0f || si->minmax.maxs[ 0 ] != 0.0f || - si->minmax.mins[ 1 ] != 0.0f || si->minmax.maxs[ 1 ] != 0.0f || - si->minmax.mins[ 2 ] != 0.0f || si->minmax.maxs[ 2 ] != 0.0f ) ) { + if ( node->parent == NULL && si != NULL && si->minmax.valid() ) { static bool warned = false; if ( !warned ) { Sys_Warning( "this map uses the deformVertexes move hack\n" ); diff --git a/tools/quake3/q3map2/writebsp.cpp b/tools/quake3/q3map2/writebsp.cpp index ff64a05c..2576d8b9 100644 --- a/tools/quake3/q3map2/writebsp.cpp +++ b/tools/quake3/q3map2/writebsp.cpp @@ -560,7 +560,7 @@ void BeginModel( void ){ } /* ydnar: lightgrid mins/maxs */ - if ( lgMinmax.mins[ 0 ] < 99999 ) { + if ( lgMinmax.valid() ) { /* use lightgrid bounds */ mod->minmax = lgMinmax; } @@ -572,7 +572,8 @@ void BeginModel( void ){ /* note size */ Sys_FPrintf( SYS_VRB, "BSP bounds: { %f %f %f } { %f %f %f }\n", minmax.mins[0], minmax.mins[1], minmax.mins[2], minmax.maxs[0], minmax.maxs[1], minmax.maxs[2] ); - Sys_FPrintf( SYS_VRB, "Lightgrid bounds: { %f %f %f } { %f %f %f }\n", lgMinmax.mins[0], lgMinmax.mins[1], lgMinmax.mins[2], lgMinmax.maxs[0], lgMinmax.maxs[1], lgMinmax.maxs[2] ); + if ( lgMinmax.valid() ) + Sys_FPrintf( SYS_VRB, "Lightgrid bounds: { %f %f %f } { %f %f %f }\n", lgMinmax.mins[0], lgMinmax.mins[1], lgMinmax.mins[2], lgMinmax.maxs[0], lgMinmax.maxs[1], lgMinmax.maxs[2] ); /* set firsts */ mod->firstBSPSurface = numBSPDrawSurfaces;