std::vector<int> bspLeafSurfaces
This commit is contained in:
parent
b1f32e6faa
commit
6066fe2cc2
|
|
@ -193,7 +193,7 @@ void SwapBSPFile( void ){
|
|||
SwapBlock( bspLeafs );
|
||||
|
||||
/* leaffaces */
|
||||
SwapBlock( (int*) bspLeafSurfaces, numBSPLeafSurfaces * sizeof( bspLeafSurfaces[ 0 ] ) );
|
||||
SwapBlock( bspLeafSurfaces );
|
||||
|
||||
/* leafbrushes */
|
||||
SwapBlock( (int*) bspLeafBrushes, numBSPLeafBrushes * sizeof( bspLeafBrushes[ 0 ] ) );
|
||||
|
|
@ -482,8 +482,8 @@ void PrintBSPFileSizes( void ){
|
|||
bspNodes.size(), bspNodes.size() * sizeof( bspNodes[0] ) );
|
||||
Sys_Printf( "%9zu leafs %9zu\n",
|
||||
bspLeafs.size(), bspLeafs.size() * sizeof( bspLeafs[0] ) );
|
||||
Sys_Printf( "%9d leafsurfaces %9d\n",
|
||||
numBSPLeafSurfaces, (int) ( numBSPLeafSurfaces * sizeof( *bspLeafSurfaces ) ) );
|
||||
Sys_Printf( "%zu leafsurfaces %zu\n",
|
||||
bspLeafSurfaces.size(), bspLeafSurfaces.size() * sizeof( bspLeafSurfaces[0] ) );
|
||||
Sys_Printf( "%9d leafbrushes %9d\n",
|
||||
numBSPLeafBrushes, (int) ( numBSPLeafBrushes * sizeof( *bspLeafBrushes ) ) );
|
||||
Sys_Printf( "\n" );
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ void LoadIBSPFile( const char *filename ){
|
|||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_NODES, bspNodes );
|
||||
|
||||
numBSPLeafSurfaces = CopyLump_Allocate( (bspHeader_t*) header, LUMP_LEAFSURFACES, (void **) &bspLeafSurfaces, sizeof( bspLeafSurfaces[ 0 ] ), &allocatedBSPLeafSurfaces );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LEAFSURFACES, bspLeafSurfaces );
|
||||
|
||||
numBSPLeafBrushes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_LEAFBRUSHES, (void **) &bspLeafBrushes, sizeof( bspLeafBrushes[ 0 ] ), &allocatedBSPLeafBrushes );
|
||||
|
||||
|
|
@ -557,7 +557,7 @@ void WriteIBSPFile( const char *filename ){
|
|||
AddLump( file, header->lumps[LUMP_NODES], bspNodes );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes, numBSPBrushes * sizeof( bspBrush_t ) );
|
||||
AddBrushSidesLump( file, header );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_LEAFSURFACES, bspLeafSurfaces, numBSPLeafSurfaces * sizeof( bspLeafSurfaces[ 0 ] ) );
|
||||
AddLump( file, header->lumps[LUMP_LEAFSURFACES], bspLeafSurfaces );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_LEAFBRUSHES, bspLeafBrushes, numBSPLeafBrushes * sizeof( bspLeafBrushes[ 0 ] ) );
|
||||
AddLump( file, header->lumps[LUMP_MODELS], bspModels );
|
||||
AddDrawVertsLump( file, header );
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ void LoadRBSPFile( const char *filename ){
|
|||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_NODES, bspNodes );
|
||||
|
||||
numBSPLeafSurfaces = CopyLump_Allocate( (bspHeader_t*) header, LUMP_LEAFSURFACES, (void **) &bspLeafSurfaces, sizeof( bspLeafSurfaces[ 0 ] ), &allocatedBSPLeafSurfaces );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LEAFSURFACES, bspLeafSurfaces );
|
||||
|
||||
numBSPLeafBrushes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_LEAFBRUSHES, (void **) &bspLeafBrushes, sizeof( bspLeafBrushes[ 0 ] ), &allocatedBSPLeafBrushes );
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ void WriteRBSPFile( const char *filename ){
|
|||
AddLump( file, header->lumps[LUMP_NODES], bspNodes );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes, numBSPBrushes * sizeof( bspBrush_t ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_BRUSHSIDES, bspBrushSides, numBSPBrushSides * sizeof( bspBrushSides[ 0 ] ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_LEAFSURFACES, bspLeafSurfaces, numBSPLeafSurfaces * sizeof( bspLeafSurfaces[ 0 ] ) );
|
||||
AddLump( file, header->lumps[LUMP_LEAFSURFACES], bspLeafSurfaces );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_LEAFBRUSHES, bspLeafBrushes, numBSPLeafBrushes * sizeof( bspLeafBrushes[ 0 ] ) );
|
||||
AddLump( file, header->lumps[LUMP_MODELS], bspModels );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_DRAWVERTS, bspDrawVerts, numBSPDrawVerts * sizeof( bspDrawVerts[ 0 ] ) );
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ static void write_json( const char *directory ){
|
|||
}
|
||||
{
|
||||
doc.RemoveAllMembers();
|
||||
for_indexed( auto&& ls : Span( bspLeafSurfaces, numBSPLeafSurfaces ) ){
|
||||
for_indexed( const auto& ls : bspLeafSurfaces ){
|
||||
rapidjson::Value value( rapidjson::kObjectType );
|
||||
value.AddMember( "Num", ls, all );
|
||||
doc.AddMember( rapidjson::Value( StringOutputStream( 16 )( "LeafSurface#", i ).c_str(), all ), value, all );
|
||||
|
|
@ -434,13 +434,10 @@ static void read_json( const char *directory ){
|
|||
}
|
||||
{
|
||||
const auto doc = load_json( StringOutputStream( 256 )( directory, "LeafSurfaces.json" ) );
|
||||
static std::vector<int> items;
|
||||
for( auto&& obj : doc.GetObj() ){
|
||||
auto&& item = items.emplace_back();
|
||||
auto&& item = bspLeafSurfaces.emplace_back();
|
||||
item = obj.value["Num"].GetInt();
|
||||
}
|
||||
bspLeafSurfaces = items.data();
|
||||
numBSPLeafSurfaces = items.size();
|
||||
}
|
||||
{
|
||||
const auto doc = load_json( StringOutputStream( 256 )( directory, "LeafBrushes.json" ) );
|
||||
|
|
|
|||
|
|
@ -947,7 +947,7 @@ void SetupSurfaceLightmaps( void ){
|
|||
|
||||
/* allocate a list of surface clusters */
|
||||
numSurfaceClusters = 0;
|
||||
maxSurfaceClusters = numBSPLeafSurfaces;
|
||||
maxSurfaceClusters = bspLeafSurfaces.size();
|
||||
surfaceClusters = safe_calloc( maxSurfaceClusters * sizeof( *surfaceClusters ) );
|
||||
|
||||
/* allocate a list for per-surface info */
|
||||
|
|
|
|||
|
|
@ -2346,9 +2346,7 @@ Q_EXTERN std::vector<bspPlane_t> bspPlanes;
|
|||
|
||||
Q_EXTERN std::vector<bspNode_t> bspNodes;
|
||||
|
||||
Q_EXTERN int numBSPLeafSurfaces Q_ASSIGN( 0 );
|
||||
Q_EXTERN int allocatedBSPLeafSurfaces Q_ASSIGN( 0 );
|
||||
Q_EXTERN int* bspLeafSurfaces Q_ASSIGN( NULL );
|
||||
Q_EXTERN std::vector<int> bspLeafSurfaces;
|
||||
|
||||
Q_EXTERN int numBSPLeafBrushes Q_ASSIGN( 0 );
|
||||
Q_EXTERN int allocatedBSPLeafBrushes Q_ASSIGN( 0 );
|
||||
|
|
|
|||
|
|
@ -153,15 +153,13 @@ void EmitLeaf( node_t *node ){
|
|||
}
|
||||
|
||||
/* add the drawSurfRef_t drawsurfs */
|
||||
leaf.firstBSPLeafSurface = numBSPLeafSurfaces;
|
||||
leaf.firstBSPLeafSurface = bspLeafSurfaces.size();
|
||||
for ( const drawSurfRef_t *dsr = node->drawSurfReferences; dsr; dsr = dsr->nextRef )
|
||||
{
|
||||
AUTOEXPAND_BY_REALLOC_BSP( LeafSurfaces, 1024 );
|
||||
bspLeafSurfaces[ numBSPLeafSurfaces ] = dsr->outputNum;
|
||||
numBSPLeafSurfaces++;
|
||||
bspLeafSurfaces.push_back( dsr->outputNum );
|
||||
}
|
||||
|
||||
leaf.numBSPLeafSurfaces = numBSPLeafSurfaces - leaf.firstBSPLeafSurface;
|
||||
leaf.numBSPLeafSurfaces = bspLeafSurfaces.size() - leaf.firstBSPLeafSurface;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -323,7 +321,7 @@ void BeginBSPFile( void ){
|
|||
bspModels.clear();
|
||||
bspNodes.clear();
|
||||
numBSPBrushSides = 0;
|
||||
numBSPLeafSurfaces = 0;
|
||||
bspLeafSurfaces.clear();
|
||||
numBSPLeafBrushes = 0;
|
||||
|
||||
/* leave leaf 0 as an error, because leafs are referenced as negative number nodes */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user