std::vector<bspPlane_t> bspPlanes
This commit is contained in:
parent
76d2b565b3
commit
bccd3bafd7
|
|
@ -184,7 +184,7 @@ void SwapBSPFile( void ){
|
|||
}
|
||||
|
||||
/* planes */
|
||||
SwapBlock( (int*) bspPlanes, numBSPPlanes * sizeof( bspPlanes[ 0 ] ) );
|
||||
SwapBlock( bspPlanes );
|
||||
|
||||
/* nodes */
|
||||
SwapBlock( (int*) bspNodes, numBSPNodes * sizeof( bspNodes[ 0 ] ) );
|
||||
|
|
@ -472,8 +472,8 @@ void PrintBSPFileSizes( void ){
|
|||
numBSPBrushSides, (int) ( numBSPBrushSides * sizeof( bspBrushSide_t ) ) );
|
||||
Sys_Printf( "%9d fogs %9d\n",
|
||||
numBSPFogs, (int) ( numBSPFogs * sizeof( bspFog_t ) ) );
|
||||
Sys_Printf( "%9d planes %9d\n",
|
||||
numBSPPlanes, (int) ( numBSPPlanes * sizeof( bspPlane_t ) ) );
|
||||
Sys_Printf( "%9zu planes %9zu\n",
|
||||
bspPlanes.size(), bspPlanes.size() * sizeof( bspPlanes[0] ) );
|
||||
Sys_Printf( "%9zu entdata %9zu\n",
|
||||
entities.size(), bspEntData.size() );
|
||||
Sys_Printf( "\n" );
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ void LoadIBSPFile( const char *filename ){
|
|||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_MODELS, bspModels );
|
||||
|
||||
numBSPPlanes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_PLANES, (void **) &bspPlanes, sizeof( bspPlane_t ), &allocatedBSPPlanes );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_PLANES, bspPlanes );
|
||||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LEAFS, bspLeafs );
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ void WriteIBSPFile( const char *filename ){
|
|||
|
||||
/* add lumps */
|
||||
AddLump( file, header->lumps[LUMP_SHADERS], bspShaders );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_PLANES, bspPlanes, numBSPPlanes * sizeof( bspPlane_t ) );
|
||||
AddLump( file, header->lumps[LUMP_PLANES], bspPlanes );
|
||||
AddLump( file, header->lumps[LUMP_LEAFS], bspLeafs );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_NODES, bspNodes, numBSPNodes * sizeof( bspNode_t ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes, numBSPBrushes * sizeof( bspBrush_t ) );
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ void LoadRBSPFile( const char *filename ){
|
|||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_MODELS, bspModels );
|
||||
|
||||
numBSPPlanes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_PLANES, (void **) &bspPlanes, sizeof( bspPlane_t ), &allocatedBSPPlanes );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_PLANES, bspPlanes );
|
||||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LEAFS, bspLeafs );
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ void WriteRBSPFile( const char *filename ){
|
|||
|
||||
/* add lumps */
|
||||
AddLump( file, header->lumps[LUMP_SHADERS], bspShaders );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_PLANES, bspPlanes, numBSPPlanes * sizeof( bspPlane_t ) );
|
||||
AddLump( file, header->lumps[LUMP_PLANES], bspPlanes );
|
||||
AddLump( file, header->lumps[LUMP_LEAFS], bspLeafs );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_NODES, bspNodes, numBSPNodes * sizeof( bspNode_t ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_BRUSHES, bspBrushes, numBSPBrushes * sizeof( bspBrush_t ) );
|
||||
|
|
|
|||
|
|
@ -552,19 +552,19 @@ int ScaleBSPMain( Args& args ){
|
|||
|
||||
/* scale planes */
|
||||
if ( uniform ) {
|
||||
for ( i = 0; i < numBSPPlanes; i++ )
|
||||
for ( bspPlane_t& plane : bspPlanes )
|
||||
{
|
||||
bspPlanes[ i ].dist() *= scale[0];
|
||||
plane.dist() *= scale[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( i = 0; i < numBSPPlanes; i++ )
|
||||
for ( bspPlane_t& plane : bspPlanes )
|
||||
{
|
||||
bspPlanes[i].normal() /= scale;
|
||||
const double len = vector3_length( bspPlanes[i].normal() );
|
||||
bspPlanes[i].normal() /= len;
|
||||
bspPlanes[i].dist() /= len;
|
||||
plane.normal() /= scale;
|
||||
const double len = vector3_length( plane.normal() );
|
||||
plane.normal() /= len;
|
||||
plane.dist() /= len;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -674,9 +674,9 @@ int ShiftBSPMain( Args& args ){
|
|||
}
|
||||
|
||||
/* shift planes */
|
||||
for ( i = 0; i < numBSPPlanes; i++ )
|
||||
for ( bspPlane_t& plane : bspPlanes )
|
||||
{
|
||||
bspPlanes[i].dist() = vector3_dot( bspPlanes[i].normal(), bspPlanes[i].normal() * bspPlanes[i].dist() + shift );
|
||||
plane.dist() = vector3_dot( plane.normal(), plane.normal() * plane.dist() + shift );
|
||||
}
|
||||
|
||||
// fixme: engine says 'light grid mismatch', unless translation is multiple of grid size
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ static void write_json( const char *directory ){
|
|||
}
|
||||
{
|
||||
doc.RemoveAllMembers();
|
||||
for_indexed( auto&& plane : Span( bspPlanes, numBSPPlanes ) ){
|
||||
for_indexed( const auto& plane : bspPlanes ){
|
||||
rapidjson::Value value( rapidjson::kArrayType );
|
||||
value.PushBack( plane.a, all );
|
||||
value.PushBack( plane.b, all );
|
||||
|
|
@ -399,16 +399,13 @@ static void read_json( const char *directory ){
|
|||
}
|
||||
{
|
||||
const auto doc = load_json( StringOutputStream( 256 )( directory, "planes.json" ) );
|
||||
static std::vector<bspPlane_t> items;
|
||||
for( auto&& obj : doc.GetObj() ){
|
||||
auto&& item = items.emplace_back();
|
||||
auto&& item = bspPlanes.emplace_back();
|
||||
item.a = obj.value[0].GetFloat();
|
||||
item.b = obj.value[1].GetFloat();
|
||||
item.c = obj.value[2].GetFloat();
|
||||
item.d = obj.value[3].GetFloat();
|
||||
}
|
||||
bspPlanes = items.data();
|
||||
numBSPPlanes = items.size();
|
||||
}
|
||||
{
|
||||
const auto doc = load_json( StringOutputStream( 256 )( directory, "leafs.json" ) );
|
||||
|
|
|
|||
|
|
@ -823,8 +823,8 @@ static void ConvertModel( FILE *f, const bspModel_t& model, const Vector3& origi
|
|||
|
||||
|
||||
/* convert bsp planes to map planes */
|
||||
mapplanes.resize( numBSPPlanes );
|
||||
for ( i = 0; i < numBSPPlanes; i++ )
|
||||
mapplanes.resize( bspPlanes.size() );
|
||||
for ( size_t i = 0; i < bspPlanes.size(); ++i )
|
||||
{
|
||||
plane_t& plane = mapplanes[i];
|
||||
plane.plane = bspPlanes[ i ];
|
||||
|
|
|
|||
|
|
@ -2342,9 +2342,7 @@ Q_EXTERN std::vector<char> bspEntData;
|
|||
|
||||
Q_EXTERN std::vector<bspLeaf_t> bspLeafs; // MAX_MAP_LEAFS
|
||||
|
||||
Q_EXTERN int numBSPPlanes Q_ASSIGN( 0 );
|
||||
Q_EXTERN int allocatedBSPPlanes Q_ASSIGN( 0 );
|
||||
Q_EXTERN bspPlane_t *bspPlanes;
|
||||
Q_EXTERN std::vector<bspPlane_t> bspPlanes;
|
||||
|
||||
Q_EXTERN int numBSPNodes Q_ASSIGN( 0 );
|
||||
Q_EXTERN int allocatedBSPNodes Q_ASSIGN( 0 );
|
||||
|
|
|
|||
|
|
@ -100,16 +100,15 @@ int EmitShader( const char *shader, const int *contentFlags, const int *surfaceF
|
|||
*/
|
||||
|
||||
void EmitPlanes( void ){
|
||||
bspPlanes.reserve( mapplanes.size() );
|
||||
/* walk plane list */
|
||||
for ( size_t i = 0; i < mapplanes.size(); ++i )
|
||||
for ( const plane_t& plane : mapplanes )
|
||||
{
|
||||
AUTOEXPAND_BY_REALLOC_BSP( Planes, 1024 );
|
||||
bspPlanes[ numBSPPlanes ] = mapplanes[i].plane;
|
||||
numBSPPlanes++;
|
||||
bspPlanes.push_back( plane.plane );
|
||||
}
|
||||
|
||||
/* emit some statistics */
|
||||
Sys_FPrintf( SYS_VRB, "%9d BSP planes\n", numBSPPlanes );
|
||||
Sys_FPrintf( SYS_VRB, "%9zu BSP planes\n", bspPlanes.size() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user