diff --git a/tools/quake3/q3map2/convert_bsp.cpp b/tools/quake3/q3map2/convert_bsp.cpp index 02104e4d..104421f5 100644 --- a/tools/quake3/q3map2/convert_bsp.cpp +++ b/tools/quake3/q3map2/convert_bsp.cpp @@ -570,8 +570,7 @@ int ScaleBSPMain( int argc, char **argv ){ { switch ( bspDrawSurfaces[i].surfaceType ) { - case SURFACE_FACE: - case SURFACE_META: + case MST_PLANAR: if ( bspDrawSurfaces[i].numIndexes % 3 ) { Error( "Not a triangulation!" ); } diff --git a/tools/quake3/q3map2/decals.cpp b/tools/quake3/q3map2/decals.cpp index 658b3e0f..81897efa 100644 --- a/tools/quake3/q3map2/decals.cpp +++ b/tools/quake3/q3map2/decals.cpp @@ -603,7 +603,7 @@ static void ProjectDecalOntoWinding( decalProjector_t *dp, mapDrawSurface_t *ds, numDecalSurfaces++; /* make a new surface */ - ds2 = AllocDrawSurface( SURFACE_DECAL ); + ds2 = AllocDrawSurface( ESurfaceType::Decal ); /* set it up */ ds2->entityNum = ds->entityNum; @@ -772,7 +772,7 @@ static void ProjectDecalOntoTriangles( decalProjector_t *dp, mapDrawSurface_t *d /* triangle surfaces without shaders don't get marks by default */ - if ( ds->type == SURFACE_TRIANGLES && ds->shaderInfo->shaderText == NULL ) { + if ( ds->type == ESurfaceType::Triangles && ds->shaderInfo->shaderText == NULL ) { return; } @@ -866,17 +866,17 @@ void MakeEntityDecals( entity_t *e ){ /* switch on type */ switch ( ds->type ) { - case SURFACE_FACE: + case ESurfaceType::Face: ProjectDecalOntoFace( &dp, ds ); break; - case SURFACE_PATCH: + case ESurfaceType::Patch: ProjectDecalOntoPatch( &dp, ds ); break; - case SURFACE_TRIANGLES: - case SURFACE_FORCED_META: - case SURFACE_META: + case ESurfaceType::Triangles: + case ESurfaceType::ForcedMeta: + case ESurfaceType::Meta: ProjectDecalOntoTriangles( &dp, ds ); break; diff --git a/tools/quake3/q3map2/fog.cpp b/tools/quake3/q3map2/fog.cpp index 56639162..bd164217 100644 --- a/tools/quake3/q3map2/fog.cpp +++ b/tools/quake3/q3map2/fog.cpp @@ -297,7 +297,7 @@ bool ChopPatchSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, brush_t *b ){ InvertMesh( outside[ i ] ); /* ydnar: do this the hacky right way */ - newds = AllocDrawSurface( SURFACE_PATCH ); + newds = AllocDrawSurface( ESurfaceType::Patch ); memcpy( newds, ds, sizeof( *ds ) ); newds->patchWidth = outside[ i ]->width; newds->patchHeight = outside[ i ]->height; @@ -541,19 +541,19 @@ void FogDrawSurfaces( entity_t *e ){ switch ( ds->type ) { /* handle brush faces */ - case SURFACE_FACE: + case ESurfaceType::Face: fogged = ChopFaceSurfaceByBrush( e, ds, fog->brush ); break; /* handle patches */ - case SURFACE_PATCH: + case ESurfaceType::Patch: fogged = ChopPatchSurfaceByBrush( e, ds, fog->brush ); break; /* handle triangle surfaces (fixme: split triangle surfaces) */ - case SURFACE_TRIANGLES: - case SURFACE_FORCED_META: - case SURFACE_META: + case ESurfaceType::Triangles: + case ESurfaceType::ForcedMeta: + case ESurfaceType::Meta: fogged = 1; break; diff --git a/tools/quake3/q3map2/model.cpp b/tools/quake3/q3map2/model.cpp index ff6125a8..358fad7a 100644 --- a/tools/quake3/q3map2/model.cpp +++ b/tools/quake3/q3map2/model.cpp @@ -398,7 +398,7 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, const } /* allocate a surface (ydnar: gs mods) */ - ds = AllocDrawSurface( SURFACE_TRIANGLES ); + ds = AllocDrawSurface( ESurfaceType::Triangles ); ds->entityNum = eNum; ds->castShadows = castShadows; ds->recvShadows = recvShadows; @@ -408,11 +408,11 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, const /* force to meta? */ if ( ( si != NULL && si->forceMeta ) || ( spawnFlags & 4 ) ) { /* 3rd bit */ - ds->type = SURFACE_FORCED_META; + ds->type = ESurfaceType::ForcedMeta; } /* fix the surface's normals (jal: conditioned by shader info) */ - if ( !( spawnFlags & 64 ) && ( shadeAngle == 0.0f || ds->type != SURFACE_FORCED_META ) ) { + if ( !( spawnFlags & 64 ) && ( shadeAngle == 0.0f || ds->type != ESurfaceType::ForcedMeta ) ) { PicoFixSurfaceNormals( surface ); } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 5d062293..0f96997c 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -415,7 +415,7 @@ struct bspDrawVert_t }; -typedef enum +enum bspSurfaceType_t { MST_BAD, MST_PLANAR, @@ -423,8 +423,7 @@ typedef enum MST_TRIANGLE_SOUP, MST_FLARE, MST_FOLIAGE -} -bspSurfaceType_t; +}; struct bspGridPoint_t @@ -900,55 +899,47 @@ struct parseMesh_t - planar patches */ -typedef enum +enum class ESurfaceType { /* ydnar: these match up exactly with bspSurfaceType_t */ - SURFACE_BAD, - SURFACE_FACE, - SURFACE_PATCH, - SURFACE_TRIANGLES, - SURFACE_FLARE, - SURFACE_FOLIAGE, /* wolf et */ + Bad, + Face, + Patch, + Triangles, + Flare, + Foliage, /* wolf et */ /* ydnar: compiler-relevant surface types */ - SURFACE_FORCED_META, - SURFACE_META, - SURFACE_FOGHULL, - SURFACE_DECAL, - SURFACE_SHADER, + ForcedMeta, + Meta, + Foghull, + Decal, + Shader, // this is used to define number of enum items +}; - NUM_SURFACE_TYPES -} -surfaceType_t; - -#ifndef MAIN_C -extern -#endif -const char *surfaceTypes[ NUM_SURFACE_TYPES ] -#ifndef MAIN_C -; -#else - = +constexpr const char *surfaceTypeName( ESurfaceType type ){ + switch ( type ) { - "SURFACE_BAD", - "SURFACE_FACE", - "SURFACE_PATCH", - "SURFACE_TRIANGLES", - "SURFACE_FLARE", - "SURFACE_FOLIAGE", - "SURFACE_FORCED_META", - "SURFACE_META", - "SURFACE_FOGHULL", - "SURFACE_DECAL", - "SURFACE_SHADER" - }; -#endif + case ESurfaceType::Bad: return "ESurfaceType::Bad"; + case ESurfaceType::Face: return "ESurfaceType::Face"; + case ESurfaceType::Patch: return "ESurfaceType::Patch"; + case ESurfaceType::Triangles: return "ESurfaceType::Triangles"; + case ESurfaceType::Flare: return "ESurfaceType::Flare"; + case ESurfaceType::Foliage: return "ESurfaceType::Foliage"; + case ESurfaceType::ForcedMeta: return "ESurfaceType::ForcedMeta"; + case ESurfaceType::Meta: return "ESurfaceType::Meta"; + case ESurfaceType::Foghull: return "ESurfaceType::Foghull"; + case ESurfaceType::Decal: return "ESurfaceType::Decal"; + case ESurfaceType::Shader: return "ESurfaceType::Shader"; + } + return "SURFACE NAME ERROR"; +} /* ydnar: this struct needs an overhaul (again, heh) */ struct mapDrawSurface_t { - surfaceType_t type; + ESurfaceType type; bool planar; int outputNum; /* ydnar: to match this sort of thing up */ @@ -1612,7 +1603,7 @@ void AddTriangleModels( entity_t *e ); /* surface.c */ -mapDrawSurface_t *AllocDrawSurface( surfaceType_t type ); +mapDrawSurface_t *AllocDrawSurface( ESurfaceType type ); void FinishSurface( mapDrawSurface_t *ds ); void StripFaceSurface( mapDrawSurface_t *ds ); void MaxAreaFaceSurface( mapDrawSurface_t *ds ); @@ -2082,7 +2073,7 @@ Q_EXTERN int numStrippedLights Q_ASSIGN( 0 ); Q_EXTERN mapDrawSurface_t *mapDrawSurfs Q_ASSIGN( NULL ); Q_EXTERN int numMapDrawSurfs; -Q_EXTERN int numSurfacesByType[ NUM_SURFACE_TYPES ]; +Q_EXTERN int numSurfacesByType[ static_cast( ESurfaceType::Shader ) + 1 ]; Q_EXTERN int numClearedSurfaces; Q_EXTERN int numStripSurfaces; Q_EXTERN int numMaxAreaSurfaces; diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 29b87a7b..d7121c09 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -43,20 +43,12 @@ ydnar: gs mods: changed to force an explicit type when allocating */ -mapDrawSurface_t *AllocDrawSurface( surfaceType_t type ){ - mapDrawSurface_t *ds; - - - /* ydnar: gs mods: only allocate valid types */ - if ( type <= SURFACE_BAD || type >= NUM_SURFACE_TYPES ) { - Error( "AllocDrawSurface: Invalid surface type %d specified", type ); - } - +mapDrawSurface_t *AllocDrawSurface( ESurfaceType type ){ /* bounds check */ if ( numMapDrawSurfs >= MAX_MAP_DRAW_SURFS ) { Error( "MAX_MAP_DRAW_SURFS (%d) exceeded", MAX_MAP_DRAW_SURFS ); } - ds = &mapDrawSurfs[ numMapDrawSurfs ]; + mapDrawSurface_t *ds = &mapDrawSurfs[ numMapDrawSurfs ]; numMapDrawSurfs++; /* ydnar: do initial surface setup */ @@ -82,7 +74,7 @@ void FinishSurface( mapDrawSurface_t *ds ){ /* dummy check */ - if ( ds == NULL || ds->shaderInfo == NULL || ds->type <= SURFACE_BAD || ds->type >= NUM_SURFACE_TYPES ) { + if ( ds == NULL || ds->shaderInfo == NULL ) { return; } @@ -273,7 +265,7 @@ bool IsTriangleDegenerate( bspDrawVert_t *points, int a, int b, int c ){ */ void ClearSurface( mapDrawSurface_t *ds ){ - ds->type = SURFACE_BAD; + ds->type = ESurfaceType::Bad; ds->planar = false; ds->planeNum = -1; ds->numVerts = 0; @@ -314,8 +306,8 @@ void TidyEntitySurfaces( entity_t *e ){ in = &mapDrawSurfs[ j ]; /* this surface ok? */ - if ( in->type == SURFACE_FLARE || in->type == SURFACE_SHADER || - ( in->type != SURFACE_BAD && in->numVerts > 0 ) ) { + if ( in->type == ESurfaceType::Flare || in->type == ESurfaceType::Shader || + ( in->type != ESurfaceType::Bad && in->numVerts > 0 ) ) { break; } @@ -500,7 +492,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){ for ( ; numSurfs > 0; numSurfs--, ds++ ) { /* ignore bogus (or flare) surfaces */ - if ( ds->type == SURFACE_BAD || ds->numVerts <= 0 ) { + if ( ds->type == ESurfaceType::Bad || ds->numVerts <= 0 ) { continue; } @@ -511,9 +503,9 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){ force meta if vertex count is too high or shader requires it ----------------------------------------------------------------- */ - if ( ds->type != SURFACE_PATCH && ds->type != SURFACE_FACE ) { + if ( ds->type != ESurfaceType::Patch && ds->type != ESurfaceType::Face ) { if ( ds->numVerts > SHADER_MAX_VERTEXES ) { - ds->type = SURFACE_FORCED_META; + ds->type = ESurfaceType::ForcedMeta; } } @@ -594,7 +586,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){ ----------------------------------------------------------------- */ /* vertex lit surfaces don't need this information */ - if ( si->compileFlags & C_VERTEXLIT || ds->type == SURFACE_TRIANGLES || nolm ) { + if ( si->compileFlags & C_VERTEXLIT || ds->type == ESurfaceType::Triangles || nolm ) { VectorClear( ds->lightmapAxis ); //% VectorClear( ds->lightmapVecs[ 2 ] ); ds->sampleSize = 0; @@ -605,7 +597,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){ if ( si->lightmapAxis[ 0 ] || si->lightmapAxis[ 1 ] || si->lightmapAxis[ 2 ] ) { VectorCopy( si->lightmapAxis, ds->lightmapAxis ); } - else if ( ds->type == SURFACE_FORCED_META ) { + else if ( ds->type == ESurfaceType::ForcedMeta ) { VectorClear( ds->lightmapAxis ); } else if ( ds->planar ) { @@ -633,13 +625,13 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){ /* set axis if possible */ if ( bestAxis < 6 ) { - //% if( ds->type == SURFACE_PATCH ) + //% if( ds->type == ESurfaceType::Patch ) //% Sys_Printf( "Mapped axis %d onto patch\n", bestAxis ); VectorCopy( axii[ bestAxis ], ds->lightmapAxis ); } /* debug code */ - //% if( ds->type == SURFACE_PATCH ) + //% if( ds->type == ESurfaceType::Patch ) //% Sys_Printf( "Failed to map axis %d onto patch\n", bestAxis ); } @@ -919,7 +911,7 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin } /* ydnar: gs mods */ - ds = AllocDrawSurface( SURFACE_FACE ); + ds = AllocDrawSurface( ESurfaceType::Face ); ds->entityNum = b->entityNum; ds->castShadows = b->castShadows; ds->recvShadows = b->recvShadows; @@ -1109,7 +1101,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh /* ydnar: gs mods */ - ds = AllocDrawSurface( SURFACE_PATCH ); + ds = AllocDrawSurface( ESurfaceType::Patch ); ds->entityNum = p->entityNum; ds->castShadows = p->castShadows; ds->recvShadows = p->recvShadows; @@ -1227,7 +1219,7 @@ mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec3_t normal, } /* allocate drawsurface */ - ds = AllocDrawSurface( SURFACE_FLARE ); + ds = AllocDrawSurface( ESurfaceType::Flare ); ds->entityNum = entNum; /* set it up */ @@ -1288,7 +1280,7 @@ mapDrawSurface_t *DrawSurfaceForShader( const char *shader ){ } /* create a new surface */ - ds = AllocDrawSurface( SURFACE_SHADER ); + ds = AllocDrawSurface( ESurfaceType::Shader ); ds->entityNum = 0; ds->shaderInfo = ShaderInfoForShader( shader ); @@ -1426,7 +1418,7 @@ void SubdivideFaceSurfaces( entity_t *e, tree_t *tree ){ ds = &mapDrawSurfs[ i ]; /* only subdivide brush sides */ - if ( ds->type != SURFACE_FACE || ds->mapBrush == NULL || ds->sideRef == NULL || ds->sideRef->side == NULL ) { + if ( ds->type != ESurfaceType::Face || ds->mapBrush == NULL || ds->sideRef == NULL || ds->sideRef->side == NULL ) { continue; } @@ -2496,7 +2488,7 @@ void EmitDrawIndexes( mapDrawSurface_t *ds, bspDrawSurface_t *out ){ bspDrawIndexes[ numBSPDrawIndexes ] = ds->indexes[ i ]; /* validate the index */ - if ( ds->type != SURFACE_PATCH ) { + if ( ds->type != ESurfaceType::Patch ) { if ( bspDrawIndexes[ numBSPDrawIndexes ] < 0 || bspDrawIndexes[ numBSPDrawIndexes ] >= ds->numVerts ) { Sys_Warning( "%d %s has invalid index %d (%d)\n", numBSPDrawSurfaces, @@ -2527,7 +2519,7 @@ void EmitFlareSurface( mapDrawSurface_t *ds ){ /* ydnar: nuking useless flare drawsurfaces */ - if ( !emitFlares && ds->type != SURFACE_SHADER ) { + if ( !emitFlares && ds->type != ESurfaceType::Shader ) { return; } @@ -2537,9 +2529,6 @@ void EmitFlareSurface( mapDrawSurface_t *ds ){ } /* allocate a new surface */ - if ( numBSPDrawSurfaces == MAX_MAP_DRAW_SURFS ) { - Error( "MAX_MAP_DRAW_SURFS" ); - } out = &bspDrawSurfaces[ numBSPDrawSurfaces ]; ds->outputNum = numBSPDrawSurfaces; numBSPDrawSurfaces++; @@ -2566,7 +2555,7 @@ void EmitFlareSurface( mapDrawSurface_t *ds ){ VectorCopy( ds->lightmapVecs[ 2 ], out->lightmapVecs[ 2 ] ); /* normal */ /* add to count */ - numSurfacesByType[ ds->type ]++; + numSurfacesByType[ static_cast( ds->type ) ]++; } /* @@ -2669,7 +2658,7 @@ void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds ){ EmitDrawIndexes( ds, out ); /* add to count */ - numSurfacesByType[ ds->type ]++; + numSurfacesByType[ static_cast( ds->type ) ]++; } /* @@ -2828,15 +2817,15 @@ void EmitTriangleSurface( mapDrawSurface_t *ds ){ memset( out, 0, sizeof( *out ) ); /* ydnar/sd: handle wolf et foliage surfaces */ - if ( ds->type == SURFACE_FOLIAGE ) { + if ( ds->type == ESurfaceType::Foliage ) { out->surfaceType = MST_FOLIAGE; } /* ydnar: gs mods: handle lightmapped terrain (force to planar type) */ - //% else if( VectorLength( ds->lightmapAxis ) <= 0.0f || ds->type == SURFACE_TRIANGLES || ds->type == SURFACE_FOGHULL || debugSurfaces ) + //% else if( VectorLength( ds->lightmapAxis ) <= 0.0f || ds->type == ESurfaceType::Triangles || ds->type == ESurfaceType::Foghull || debugSurfaces ) else if ( ( VectorLength( ds->lightmapAxis ) <= 0.0f && !ds->planar ) || - ds->type == SURFACE_TRIANGLES || - ds->type == SURFACE_FOGHULL || + ds->type == ESurfaceType::Triangles || + ds->type == ESurfaceType::Foghull || ds->numVerts > maxLMSurfaceVerts || debugSurfaces ) { out->surfaceType = MST_TRIANGLE_SOUP; @@ -2920,7 +2909,7 @@ void EmitTriangleSurface( mapDrawSurface_t *ds ){ EmitDrawIndexes( ds, out ); /* add to count */ - numSurfacesByType[ ds->type ]++; + numSurfacesByType[ static_cast( ds->type ) ]++; } @@ -2987,7 +2976,7 @@ static void MakeDebugPortalSurfs_r( node_t *node, shaderInfo_t *si ){ } /* allocate a drawsurface */ - ds = AllocDrawSurface( SURFACE_FACE ); + ds = AllocDrawSurface( ESurfaceType::Face ); ds->shaderInfo = si; ds->planar = true; ds->sideRef = AllocSideRef( p->side, NULL ); @@ -3082,7 +3071,7 @@ void MakeFogHullSurfs( entity_t *e, tree_t *tree, const char *shader ){ si = ShaderInfoForShader( shader ); /* allocate a drawsurface */ - ds = AllocDrawSurface( SURFACE_FOGHULL ); + ds = AllocDrawSurface( ESurfaceType::Foghull ); ds->shaderInfo = si; ds->fogNum = -1; ds->numVerts = 8; @@ -3313,8 +3302,8 @@ int AddSurfaceModels( mapDrawSurface_t *ds ){ switch ( ds->type ) { /* handle brush faces and decals */ - case SURFACE_FACE: - case SURFACE_DECAL: + case ESurfaceType::Face: + case ESurfaceType::Decal: /* calculate centroid */ memset( ¢roid, 0, sizeof( centroid ) ); alpha = 0.0f; @@ -3364,7 +3353,7 @@ int AddSurfaceModels( mapDrawSurface_t *ds ){ break; /* handle patches */ - case SURFACE_PATCH: + case ESurfaceType::Patch: /* subdivide the surface */ src.width = ds->patchWidth; src.height = ds->patchHeight; @@ -3420,9 +3409,9 @@ int AddSurfaceModels( mapDrawSurface_t *ds ){ break; /* handle triangle surfaces */ - case SURFACE_TRIANGLES: - case SURFACE_FORCED_META: - case SURFACE_META: + case ESurfaceType::Triangles: + case ESurfaceType::ForcedMeta: + case ESurfaceType::Meta: /* walk the triangle list */ for ( i = 0; i < ds->numIndexes; i += 3 ) { @@ -3552,7 +3541,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ { /* get surface and try to early out */ ds = &mapDrawSurfs[ i ]; - if ( ds->numVerts == 0 && ds->type != SURFACE_FLARE && ds->type != SURFACE_SHADER ) { + if ( ds->numVerts == 0 && ds->type != ESurfaceType::Flare && ds->type != ESurfaceType::Shader ) { continue; } @@ -3598,7 +3587,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ } /* ydnar: don't emit nodraw surfaces (like nodraw fog) */ - if ( ( si->compileFlags & C_NODRAW ) && ds->type != SURFACE_PATCH ) { + if ( ( si->compileFlags & C_NODRAW ) && ds->type != ESurfaceType::Patch ) { continue; } @@ -3629,8 +3618,8 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ switch ( ds->type ) { /* handle brush faces */ - case SURFACE_FACE: - case SURFACE_DECAL: + case ESurfaceType::Face: + case ESurfaceType::Decal: if ( refs == 0 ) { refs = FilterFaceIntoTree( ds, tree ); } @@ -3640,7 +3629,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ break; /* handle patches */ - case SURFACE_PATCH: + case ESurfaceType::Patch: if ( refs == 0 ) { refs = FilterPatchIntoTree( ds, tree ); } @@ -3650,9 +3639,9 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ break; /* handle triangle surfaces */ - case SURFACE_TRIANGLES: - case SURFACE_FORCED_META: - case SURFACE_META: + case ESurfaceType::Triangles: + case ESurfaceType::ForcedMeta: + case ESurfaceType::Meta: //% Sys_FPrintf( SYS_VRB, "Surface %4d: [%1d] %4d verts %s\n", numSurfs, ds->planar, ds->numVerts, si->shader ); if ( refs == 0 ) { refs = FilterTrianglesIntoTree( ds, tree ); @@ -3663,7 +3652,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ break; /* handle foliage surfaces (splash damage/wolf et) */ - case SURFACE_FOLIAGE: + case ESurfaceType::Foliage: //% Sys_FPrintf( SYS_VRB, "Surface %4d: [%d] %4d verts %s\n", numSurfs, ds->numFoliageInstances, ds->numVerts, si->shader ); if ( refs == 0 ) { refs = FilterFoliageIntoTree( ds, tree ); @@ -3674,7 +3663,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ break; /* handle foghull surfaces */ - case SURFACE_FOGHULL: + case ESurfaceType::Foghull: if ( refs == 0 ) { refs = AddReferenceToTree_r( ds, tree->headnode, false ); } @@ -3684,7 +3673,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ break; /* handle flares */ - case SURFACE_FLARE: + case ESurfaceType::Flare: if ( refs == 0 ) { refs = FilterFlareSurfIntoTree( ds, tree ); } @@ -3694,7 +3683,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ break; /* handle shader-only surfaces */ - case SURFACE_SHADER: + case ESurfaceType::Shader: refs = 1; EmitFlareSurface( ds ); break; @@ -3728,7 +3717,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ if ( out->numVerts == 3 && out->numIndexes > 3 ) { Sys_Printf( "\n" ); Sys_Warning( "Potentially bad %s surface (%d: %d, %d)\n %s\n", - surfaceTypes[ ds->type ], + surfaceTypeName( ds->type ), numBSPDrawSurfaces - 1, out->numVerts, out->numIndexes, si->shader.c_str() ); } } @@ -3749,8 +3738,8 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){ Sys_FPrintf( SYS_VRB, "%9d maxarea'd face surfaces\n", numMaxAreaSurfaces ); Sys_FPrintf( SYS_VRB, "%9d surface models generated\n", numSurfaceModels ); Sys_FPrintf( SYS_VRB, "%9d skybox surfaces generated\n", numSkyboxSurfaces ); - for ( i = 0; i < NUM_SURFACE_TYPES; i++ ) - Sys_FPrintf( SYS_VRB, "%9d %s surfaces\n", numSurfacesByType[ i ], surfaceTypes[ i ] ); + for ( std::size_t i = 0; i < ARRAY_SIZE( numSurfacesByType ); i++ ) + Sys_FPrintf( SYS_VRB, "%9d %s surfaces\n", numSurfacesByType[ i ], surfaceTypeName( static_cast( i ) ) ); Sys_FPrintf( SYS_VRB, "%9d redundant indexes supressed, saving %d Kbytes\n", numRedundantIndexes, ( numRedundantIndexes * 4 / 1024 ) ); } diff --git a/tools/quake3/q3map2/surface_extra.cpp b/tools/quake3/q3map2/surface_extra.cpp index 1a5c8dfc..a55ae869 100644 --- a/tools/quake3/q3map2/surface_extra.cpp +++ b/tools/quake3/q3map2/surface_extra.cpp @@ -243,7 +243,7 @@ void WriteSurfaceExtraFile( const char *path ){ else { fprintf( sf, " // %s V: %d I: %d %s\n", - surfaceTypes[ se->mds->type ], + surfaceTypeName( se->mds->type ), se->mds->numVerts, se->mds->numIndexes, ( se->mds->planar ? "planar" : "" ) ); diff --git a/tools/quake3/q3map2/surface_foliage.cpp b/tools/quake3/q3map2/surface_foliage.cpp index d6bc7468..eb1d1024 100644 --- a/tools/quake3/q3map2/surface_foliage.cpp +++ b/tools/quake3/q3map2/surface_foliage.cpp @@ -200,9 +200,9 @@ void Foliage( mapDrawSurface_t *src ){ /* map the surface onto the lightmap origin/cluster/normal buffers */ switch ( src->type ) { - case SURFACE_META: - case SURFACE_FORCED_META: - case SURFACE_TRIANGLES: + case ESurfaceType::Meta: + case ESurfaceType::ForcedMeta: + case ESurfaceType::Triangles: /* get verts */ verts = src->verts; @@ -216,7 +216,7 @@ void Foliage( mapDrawSurface_t *src ){ } break; - case SURFACE_PATCH: + case ESurfaceType::Patch: /* make a mesh from the drawsurf */ srcMesh.width = src->patchWidth; srcMesh.height = src->patchHeight; @@ -290,7 +290,7 @@ void Foliage( mapDrawSurface_t *src ){ ds = &mapDrawSurfs[ i ]; /* set up */ - ds->type = SURFACE_FOLIAGE; + ds->type = ESurfaceType::Foliage; ds->numFoliageInstances = numFoliageInstances; /* a wee hack */ diff --git a/tools/quake3/q3map2/surface_meta.cpp b/tools/quake3/q3map2/surface_meta.cpp index db3761da..5ee38dce 100644 --- a/tools/quake3/q3map2/surface_meta.cpp +++ b/tools/quake3/q3map2/surface_meta.cpp @@ -232,10 +232,10 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ){ /* only handle certain types of surfaces */ - if ( ds->type != SURFACE_FACE && - ds->type != SURFACE_META && - ds->type != SURFACE_FORCED_META && - ds->type != SURFACE_DECAL ) { + if ( ds->type != ESurfaceType::Face && + ds->type != ESurfaceType::Meta && + ds->type != ESurfaceType::ForcedMeta && + ds->type != ESurfaceType::Decal ) { return; } @@ -243,7 +243,7 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ){ firstSearchMetaVert = numMetaVerts; /* only handle valid surfaces */ - if ( ds->type != SURFACE_BAD && ds->numVerts >= 3 && ds->numIndexes >= 3 ) { + if ( ds->type != ESurfaceType::Bad && ds->numVerts >= 3 && ds->numIndexes >= 3 ) { /* walk the indexes and create triangles */ for ( i = 0; i < ds->numIndexes; i += 3 ) { @@ -279,7 +279,7 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ){ numMetaSurfaces++; } - /* clear the surface (free verts and indexes, sets it to SURFACE_BAD) */ + /* clear the surface (free verts and indexes, sets it to ESurfaceType::Bad) */ ClearSurface( ds ); } @@ -299,7 +299,7 @@ void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){ const bool forcePatchMeta = BoolForKey( e, "_patchMeta", "patchMeta" ); /* try to early out */ - if ( ds->numVerts == 0 || ds->type != SURFACE_PATCH || ( !patchMeta && !forcePatchMeta ) ) { + if ( ds->numVerts == 0 || ds->type != ESurfaceType::Patch || ( !patchMeta && !forcePatchMeta ) ) { return; } /* make a mesh from the drawsurf */ @@ -327,7 +327,7 @@ void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){ //% MakeMeshNormals( mesh ); /* make a copy of the drawsurface */ - dsNew = AllocDrawSurface( SURFACE_META ); + dsNew = AllocDrawSurface( ESurfaceType::Meta ); memcpy( dsNew, ds, sizeof( *ds ) ); /* if the patch is nonsolid, then discard it */ @@ -339,7 +339,7 @@ void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){ ds = dsNew; /* basic transmogrification */ - ds->type = SURFACE_META; + ds->type = ESurfaceType::Meta; ds->numIndexes = 0; ds->indexes = safe_malloc( mesh->width * mesh->height * 6 * sizeof( int ) ); @@ -562,7 +562,7 @@ int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){ void MaxAreaFaceSurface( mapDrawSurface_t *ds ){ int n; /* try to early out */ - if ( !ds->numVerts || ( ds->type != SURFACE_FACE && ds->type != SURFACE_DECAL ) ) { + if ( !ds->numVerts || ( ds->type != ESurfaceType::Face && ds->type != ESurfaceType::Decal ) ) { return; } @@ -610,7 +610,7 @@ void FanFaceSurface( mapDrawSurface_t *ds ){ /* try to early out */ - if ( !ds->numVerts || ( ds->type != SURFACE_FACE && ds->type != SURFACE_DECAL ) ) { + if ( !ds->numVerts || ( ds->type != ESurfaceType::Face && ds->type != ESurfaceType::Decal ) ) { return; } @@ -699,7 +699,7 @@ void StripFaceSurface( mapDrawSurface_t *ds ){ /* try to early out */ - if ( !ds->numVerts || ( ds->type != SURFACE_FACE && ds->type != SURFACE_DECAL ) ) { + if ( !ds->numVerts || ( ds->type != ESurfaceType::Face && ds->type != ESurfaceType::Decal ) ) { return; } @@ -862,8 +862,8 @@ void MakeEntityMetaTriangles( entity_t *e ){ /* switch on type */ switch ( ds->type ) { - case SURFACE_FACE: - case SURFACE_DECAL: + case ESurfaceType::Face: + case ESurfaceType::Decal: if ( maxAreaFaceSurface ) { MaxAreaFaceSurface( ds ); } @@ -873,15 +873,15 @@ void MakeEntityMetaTriangles( entity_t *e ){ SurfaceToMetaTriangles( ds ); break; - case SURFACE_PATCH: + case ESurfaceType::Patch: TriangulatePatchSurface( e, ds ); break; - case SURFACE_TRIANGLES: + case ESurfaceType::Triangles: break; - case SURFACE_FORCED_META: - case SURFACE_META: + case ESurfaceType::ForcedMeta: + case ESurfaceType::Meta: SurfaceToMetaTriangles( ds ); break; @@ -1647,7 +1647,7 @@ static void MetaTrianglesToSurface( int numPossibles, metaTriangle_t *possibles, ----------------------------------------------------------------- */ /* start a new drawsurface */ - ds = AllocDrawSurface( SURFACE_META ); + ds = AllocDrawSurface( ESurfaceType::Meta ); ds->entityNum = seed->entityNum; ds->surfaceNum = seed->surfaceNum; ds->castShadows = seed->castShadows; diff --git a/tools/quake3/q3map2/tjunction.cpp b/tools/quake3/q3map2/tjunction.cpp index cac08df1..8799b606 100644 --- a/tools/quake3/q3map2/tjunction.cpp +++ b/tools/quake3/q3map2/tjunction.cpp @@ -521,7 +521,7 @@ bool FixBrokenSurface( mapDrawSurface_t *ds ){ if ( ds == NULL ) { return false; } - if ( ds->type != SURFACE_FACE ) { + if ( ds->type != ESurfaceType::Face ) { return false; } @@ -650,12 +650,12 @@ void FixTJunctions( entity_t *ent ){ switch ( ds->type ) { /* handle brush faces */ - case SURFACE_FACE: + case ESurfaceType::Face: AddSurfaceEdges( ds ); break; /* handle patches */ - case SURFACE_PATCH: + case ESurfaceType::Patch: AddPatchEdges( ds ); break; @@ -688,7 +688,7 @@ void FixTJunctions( entity_t *ent ){ /* get surface and early out if possible */ ds = &mapDrawSurfs[ i ]; si = ds->shaderInfo; - if ( ( si->compileFlags & C_NODRAW ) || si->autosprite || si->notjunc || ds->numVerts == 0 || ds->type != SURFACE_FACE ) { + if ( ( si->compileFlags & C_NODRAW ) || si->autosprite || si->notjunc || ds->numVerts == 0 || ds->type != ESurfaceType::Face ) { continue; } @@ -696,7 +696,7 @@ void FixTJunctions( entity_t *ent ){ switch ( ds->type ) { /* handle brush faces */ - case SURFACE_FACE: + case ESurfaceType::Face: FixSurfaceJunctions( ds ); if ( !FixBrokenSurface( ds ) ) { c_broken++;