std::vector<fog_t> mapFogs
This commit is contained in:
parent
efa324ebe6
commit
1b1e6769e8
|
|
@ -444,9 +444,6 @@ bool ChopFaceSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, const brush_t *b
|
|||
*/
|
||||
|
||||
void FogDrawSurfaces( entity_t *e ){
|
||||
int i, j, fogNum;
|
||||
fog_t *fog;
|
||||
mapDrawSurface_t *ds;
|
||||
int fogged, numFogged;
|
||||
int numBaseDrawSurfs;
|
||||
|
||||
|
|
@ -459,17 +456,17 @@ void FogDrawSurfaces( entity_t *e ){
|
|||
numFogFragments = 0;
|
||||
|
||||
/* walk fog list */
|
||||
for ( fogNum = 0; fogNum < numMapFogs; fogNum++ )
|
||||
for ( size_t fogNum = 0; fogNum < mapFogs.size(); ++fogNum )
|
||||
{
|
||||
/* get fog */
|
||||
fog = &mapFogs[ fogNum ];
|
||||
const fog_t& fog = mapFogs[ fogNum ];
|
||||
|
||||
/* clip each surface into this, but don't clip any of the resulting fragments to the same brush */
|
||||
numBaseDrawSurfs = numMapDrawSurfs;
|
||||
for ( i = 0; i < numBaseDrawSurfs; i++ )
|
||||
for ( int i = 0; i < numBaseDrawSurfs; i++ )
|
||||
{
|
||||
/* get the drawsurface */
|
||||
ds = &mapDrawSurfs[ i ];
|
||||
mapDrawSurface_t *ds = &mapDrawSurfs[ i ];
|
||||
|
||||
/* no fog? */
|
||||
if ( ds->shaderInfo->noFog ) {
|
||||
|
|
@ -477,7 +474,7 @@ void FogDrawSurfaces( entity_t *e ){
|
|||
}
|
||||
|
||||
/* global fog doesn't have a brush */
|
||||
if ( fog->brush == NULL ) {
|
||||
if ( fog.brush == NULL ) {
|
||||
/* don't re-fog already fogged surfaces */
|
||||
if ( ds->fogNum >= 0 ) {
|
||||
continue;
|
||||
|
|
@ -488,11 +485,11 @@ void FogDrawSurfaces( entity_t *e ){
|
|||
{
|
||||
/* find drawsurface bounds */
|
||||
MinMax minmax;
|
||||
for ( j = 0; j < ds->numVerts; j++ )
|
||||
for ( int j = 0; j < ds->numVerts; j++ )
|
||||
minmax.extend( ds->verts[ j ].xyz );
|
||||
|
||||
/* check against the fog brush */
|
||||
if( !minmax.test( fog->brush->minmax ) ){
|
||||
if( !minmax.test( fog.brush->minmax ) ){
|
||||
continue; /* no intersection */
|
||||
}
|
||||
|
||||
|
|
@ -501,12 +498,12 @@ void FogDrawSurfaces( entity_t *e ){
|
|||
{
|
||||
/* handle brush faces */
|
||||
case ESurfaceType::Face:
|
||||
fogged = ChopFaceSurfaceByBrush( e, ds, fog->brush );
|
||||
fogged = ChopFaceSurfaceByBrush( e, ds, fog.brush );
|
||||
break;
|
||||
|
||||
/* handle patches */
|
||||
case ESurfaceType::Patch:
|
||||
fogged = ChopPatchSurfaceByBrush( e, ds, fog->brush );
|
||||
fogged = ChopPatchSurfaceByBrush( e, ds, fog.brush );
|
||||
break;
|
||||
|
||||
/* handle triangle surfaces (fixme: split triangle surfaces) */
|
||||
|
|
@ -549,7 +546,7 @@ int FogForPoint( const Vector3& point, float epsilon ){
|
|||
int fogNum = defaultFogNum;
|
||||
|
||||
/* walk the list of fog volumes */
|
||||
for ( int i = 0; i < numMapFogs; i++ )
|
||||
for ( size_t i = 0; i < mapFogs.size(); ++i )
|
||||
{
|
||||
/* sof2: global fog doesn't reference a brush */
|
||||
if ( mapFogs[ i ].brush == NULL ) {
|
||||
|
|
@ -586,7 +583,7 @@ int FogForPoint( const Vector3& point, float epsilon ){
|
|||
*/
|
||||
|
||||
int FogForBounds( const MinMax& minmax, float epsilon ){
|
||||
int fogNum, i;
|
||||
int fogNum;
|
||||
|
||||
/* start with bogus fog num */
|
||||
fogNum = defaultFogNum;
|
||||
|
|
@ -595,7 +592,7 @@ int FogForBounds( const MinMax& minmax, float epsilon ){
|
|||
float bestVolume = 0.0f;
|
||||
|
||||
/* walk the list of fog volumes */
|
||||
for ( i = 0; i < numMapFogs; i++ )
|
||||
for ( size_t i = 0; i < mapFogs.size(); ++i )
|
||||
{
|
||||
/* sof2: global fog doesn't reference a brush */
|
||||
if ( mapFogs[ i ].brush == NULL ) {
|
||||
|
|
@ -658,13 +655,8 @@ void CreateMapFogs( void ){
|
|||
continue;
|
||||
}
|
||||
|
||||
/* test limit */
|
||||
if ( numMapFogs >= MAX_MAP_FOGS ) {
|
||||
Error( "Exceeded MAX_MAP_FOGS (%d)", MAX_MAP_FOGS );
|
||||
}
|
||||
|
||||
/* set up fog */
|
||||
fog_t& fog = mapFogs[ numMapFogs++ ];
|
||||
fog_t& fog = mapFogs.emplace_back();
|
||||
fog.si = brush.contentShader;
|
||||
fog.brush = &brush;
|
||||
fog.visibleSide = -1;
|
||||
|
|
@ -688,18 +680,12 @@ void CreateMapFogs( void ){
|
|||
}
|
||||
|
||||
/* ydnar: global fog */
|
||||
const char *globalFog;
|
||||
if ( entities[ 0 ].read_keyvalue( globalFog, "_fog", "fog" ) ) {
|
||||
/* test limit */
|
||||
if ( numMapFogs >= MAX_MAP_FOGS ) {
|
||||
Error( "Exceeded MAX_MAP_FOGS (%d) trying to add global fog", MAX_MAP_FOGS );
|
||||
}
|
||||
|
||||
if ( const char *globalFog; entities[ 0 ].read_keyvalue( globalFog, "_fog", "fog" ) ) {
|
||||
/* note it */
|
||||
Sys_FPrintf( SYS_VRB, "Map has global fog shader %s\n", globalFog );
|
||||
|
||||
/* set up fog */
|
||||
fog_t& fog = mapFogs[ numMapFogs++ ];
|
||||
fog_t& fog = mapFogs.emplace_back();
|
||||
fog.si = ShaderInfoForShaderNull( globalFog );
|
||||
if ( fog.si == NULL ) {
|
||||
Error( "Invalid shader \"%s\" referenced trying to add global fog", globalFog );
|
||||
|
|
@ -708,7 +694,7 @@ void CreateMapFogs( void ){
|
|||
fog.visibleSide = -1;
|
||||
|
||||
/* set as default fog */
|
||||
defaultFogNum = numMapFogs - 1;
|
||||
defaultFogNum = mapFogs.size() - 1;
|
||||
|
||||
/* mark all worldspawn brushes as fogged */
|
||||
for ( brush_t& brush : entities[ 0 ].brushes )
|
||||
|
|
@ -716,5 +702,5 @@ void CreateMapFogs( void ){
|
|||
}
|
||||
|
||||
/* emit some stats */
|
||||
Sys_FPrintf( SYS_VRB, "%9d fogs\n", numMapFogs );
|
||||
Sys_FPrintf( SYS_VRB, "%9zu fogs\n", mapFogs.size() );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ enum class EBrushType
|
|||
|
||||
/* ok to increase these at the expense of more memory */
|
||||
#define MAX_MAP_AREAS 0x100 /* MAX_MAP_AREA_BYTES in q_shared must match! */
|
||||
#define MAX_MAP_FOGS 0x100 /* technically unlimited in engine, but drawsurf sorting code only has 5 bits for fogs */
|
||||
/* MAX_MAP_FOGS is technically unlimited in engine, but drawsurf sorting code only has 5 bits for fogs */
|
||||
#define MAX_IBSP_FOGS 31 /* (2^5 - world fog) */
|
||||
#define MAX_RBSP_FOGS 30 /* (2^5 - world fog - goggles) */
|
||||
#define MAX_MAP_LEAFS 0x20000
|
||||
|
|
@ -1991,8 +1991,7 @@ Q_EXTERN MinMax g_mapMinmax;
|
|||
inline const MinMax c_worldMinmax( Vector3( MIN_WORLD_COORD ), Vector3( MAX_WORLD_COORD ) );
|
||||
|
||||
Q_EXTERN int defaultFogNum Q_ASSIGN( -1 ); /* ydnar: cleaner fog handling */
|
||||
Q_EXTERN int numMapFogs Q_ASSIGN( 0 );
|
||||
Q_EXTERN fog_t mapFogs[ MAX_MAP_FOGS ];
|
||||
Q_EXTERN std::vector<fog_t> mapFogs;
|
||||
|
||||
Q_EXTERN entity_t *mapEnt;
|
||||
Q_EXTERN brush_t buildBrush;
|
||||
|
|
@ -2351,7 +2350,7 @@ Q_EXTERN std::vector<int> bspDrawIndexes;
|
|||
|
||||
Q_EXTERN std::vector<bspDrawSurface_t> bspDrawSurfaces; // MAX_MAP_DRAW_SURFS
|
||||
|
||||
Q_EXTERN std::vector<bspFog_t> bspFogs; // MAX_MAP_FOGS
|
||||
Q_EXTERN std::vector<bspFog_t> bspFogs;
|
||||
|
||||
Q_EXTERN std::vector<bspAdvertisement_t> bspAds;
|
||||
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){
|
|||
|
||||
void EmitFogs( void ){
|
||||
/* walk list */
|
||||
for ( int i = 0; i < numMapFogs; i++ )
|
||||
for ( size_t i = 0; i < mapFogs.size(); ++i )
|
||||
{
|
||||
const fog_t& fog = mapFogs[i];
|
||||
bspFog_t& bspFog = bspFogs.emplace_back();
|
||||
|
|
@ -437,10 +437,10 @@ void EmitFogs( void ){
|
|||
}
|
||||
|
||||
/* find visible axial side */
|
||||
for ( int j = 6; j-- > 0; ) // prioritize +Z (index 5) then -Z (index 4) in ambiguous case; fogged pit is assumed as most likely case
|
||||
for ( size_t j = 6; j-- > 0; ) // prioritize +Z (index 5) then -Z (index 4) in ambiguous case; fogged pit is assumed as most likely case
|
||||
{
|
||||
if ( !fog.brush->sides[ j ].visibleHull.empty() ) {
|
||||
Sys_Printf( "Fog %d has visible side %d\n", i, j );
|
||||
Sys_Printf( "Fog %zu has visible side %zu\n", i, j );
|
||||
bspFog.visibleSide = j;
|
||||
break;
|
||||
}
|
||||
|
|
@ -450,7 +450,7 @@ void EmitFogs( void ){
|
|||
for ( size_t j = 6; j < fog.brush->sides.size(); ++j )
|
||||
{
|
||||
if ( !fog.brush->sides[ j ].visibleHull.empty() ) {
|
||||
Sys_Printf( "Fog %d has visible side %d\n", i, j );
|
||||
Sys_Printf( "Fog %zu has visible side %zu\n", i, j );
|
||||
bspFog.visibleSide = j;
|
||||
break;
|
||||
}
|
||||
|
|
@ -461,11 +461,11 @@ void EmitFogs( void ){
|
|||
|
||||
/* warn about overflow */
|
||||
if( strEqual( g_game->bspIdent, "RBSP" ) ){
|
||||
if( numMapFogs > MAX_RBSP_FOGS )
|
||||
Sys_Warning( "MAX_RBSP_FOGS (%i) exceeded (%i). Visual inconsistencies are expected.\n", MAX_RBSP_FOGS, numMapFogs );
|
||||
if( mapFogs.size() > MAX_RBSP_FOGS )
|
||||
Sys_Warning( "MAX_RBSP_FOGS (%i) exceeded (%zu). Visual inconsistencies are expected.\n", MAX_RBSP_FOGS, mapFogs.size() );
|
||||
}
|
||||
else if( numMapFogs > MAX_IBSP_FOGS )
|
||||
Sys_Warning( "MAX_IBSP_FOGS (%i) exceeded (%i). Visual inconsistencies are expected.\n", MAX_IBSP_FOGS, numMapFogs );
|
||||
else if( mapFogs.size() > MAX_IBSP_FOGS )
|
||||
Sys_Warning( "MAX_IBSP_FOGS (%i) exceeded (%zu). Visual inconsistencies are expected.\n", MAX_IBSP_FOGS, mapFogs.size() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user