std::vector<byte> bspVisBytes
This commit is contained in:
parent
28dfbaa5ab
commit
560060a908
|
|
@ -205,8 +205,8 @@ void SwapBSPFile( void ){
|
|||
SwapBlock( bspBrushSides );
|
||||
|
||||
// vis
|
||||
( (int*) &bspVisBytes )[ 0 ] = LittleLong( ( (int*) &bspVisBytes )[ 0 ] );
|
||||
( (int*) &bspVisBytes )[ 1 ] = LittleLong( ( (int*) &bspVisBytes )[ 1 ] );
|
||||
( (int*) bspVisBytes.data() )[ 0 ] = LittleLong( ( (int*) bspVisBytes.data() )[ 0 ] );
|
||||
( (int*) bspVisBytes.data() )[ 1 ] = LittleLong( ( (int*) bspVisBytes.data() )[ 1 ] );
|
||||
|
||||
/* drawverts (don't swap colors) */
|
||||
for ( i = 0; i < numBSPDrawVerts; i++ )
|
||||
|
|
@ -506,8 +506,8 @@ void PrintBSPFileSizes( void ){
|
|||
bspLightBytes.size() / ( g_game->lightmapSize * g_game->lightmapSize * 3 ), bspLightBytes.size() );
|
||||
Sys_Printf( "%9zu lightgrid %9zu *\n",
|
||||
bspGridPoints.size(), bspGridPoints.size() * sizeof( bspGridPoints[0] ) );
|
||||
Sys_Printf( " visibility %9d\n",
|
||||
numBSPVisBytes );
|
||||
Sys_Printf( " visibility %9zu\n",
|
||||
bspVisBytes.size() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ void LoadIBSPFile( const char *filename ){
|
|||
|
||||
numBSPDrawIndexes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_DRAWINDEXES, (void **) &bspDrawIndexes, sizeof( bspDrawIndexes[ 0 ] ), &allocatedBSPDrawIndexes );
|
||||
|
||||
numBSPVisBytes = CopyLump( (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, 1 ); // TODO fix overflow
|
||||
CopyLump( (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes );
|
||||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes );
|
||||
|
||||
|
|
@ -464,7 +464,7 @@ void WriteIBSPFile( const char *filename ){
|
|||
AddLump( file, header->lumps[LUMP_MODELS], bspModels );
|
||||
AddDrawVertsLump( file, header );
|
||||
AddDrawSurfacesLump( file, header );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, numBSPVisBytes );
|
||||
AddLump( file, header->lumps[LUMP_VISIBILITY], bspVisBytes );
|
||||
AddLump( file, header->lumps[LUMP_LIGHTMAPS], bspLightBytes );
|
||||
AddLump( file, header->lumps[LUMP_LIGHTGRID], std::vector<ibspGridPoint_t>( bspGridPoints.begin(), bspGridPoints.end() ) );
|
||||
AddLump( file, header->lumps[LUMP_ENTITIES], bspEntData );
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ void LoadRBSPFile( const char *filename ){
|
|||
|
||||
numBSPDrawIndexes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_DRAWINDEXES, (void **) &bspDrawIndexes, sizeof( bspDrawIndexes[ 0 ] ), &allocatedBSPDrawIndexes );
|
||||
|
||||
numBSPVisBytes = CopyLump( (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, 1 );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes );
|
||||
|
||||
CopyLump( (bspHeader_t*) header, LUMP_LIGHTMAPS, bspLightBytes );
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ void WriteRBSPFile( const char *filename ){
|
|||
AddLump( file, header->lumps[LUMP_MODELS], bspModels );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_DRAWVERTS, bspDrawVerts, numBSPDrawVerts * sizeof( bspDrawVerts[ 0 ] ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_SURFACES, bspDrawSurfaces, numBSPDrawSurfaces * sizeof( bspDrawSurfaces[ 0 ] ) );
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_VISIBILITY, bspVisBytes, numBSPVisBytes );
|
||||
AddLump( file, header->lumps[LUMP_VISIBILITY], bspVisBytes );
|
||||
AddLump( file, header->lumps[LUMP_LIGHTMAPS], bspLightBytes );
|
||||
AddLightGridLumps( file, header );
|
||||
AddLump( file, header->lumps[LUMP_ENTITIES], bspEntData );
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ static void write_json( const char *directory ){
|
|||
}
|
||||
{
|
||||
doc.RemoveAllMembers();
|
||||
for_indexed( auto&& index : Span( bspVisBytes, numBSPVisBytes ) ){
|
||||
for_indexed( const auto& index : bspVisBytes ){
|
||||
rapidjson::Value value( rapidjson::kObjectType );
|
||||
value.AddMember( "Num", index, all );
|
||||
doc.AddMember( rapidjson::Value( StringOutputStream( 16 )( "VisByte#", i ).c_str(), all ), value, all );
|
||||
|
|
@ -529,13 +529,10 @@ static void read_json( const char *directory ){
|
|||
}
|
||||
{
|
||||
const auto doc = load_json( StringOutputStream( 256 )( directory, "VisBytes.json" ) );
|
||||
static std::vector<byte> items;
|
||||
for( auto&& obj : doc.GetObj() ){
|
||||
auto&& item = items.emplace_back();
|
||||
auto&& item = bspVisBytes.emplace_back();
|
||||
item = obj.value["Num"].GetInt();
|
||||
}
|
||||
std::copy( items.begin(), items.end(), bspVisBytes );
|
||||
numBSPVisBytes = items.size();
|
||||
}
|
||||
{
|
||||
const auto doc = load_json( StringOutputStream( 256 )( directory, "LightBytes.json" ) );
|
||||
|
|
|
|||
|
|
@ -2997,10 +2997,6 @@ void SetupBrushes( void ){
|
|||
*/
|
||||
|
||||
bool ClusterVisible( int a, int b ){
|
||||
int leafBytes;
|
||||
byte *pvs;
|
||||
|
||||
|
||||
/* dummy check */
|
||||
if ( a < 0 || b < 0 ) {
|
||||
return false;
|
||||
|
|
@ -3012,20 +3008,17 @@ bool ClusterVisible( int a, int b ){
|
|||
}
|
||||
|
||||
/* not vised? */
|
||||
if ( numBSPVisBytes <= 8 ) {
|
||||
if ( bspVisBytes.size() <= 8 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* get pvs data */
|
||||
/* portalClusters = ((int *) bspVisBytes)[ 0 ]; */
|
||||
leafBytes = ( (int*) bspVisBytes )[ 1 ];
|
||||
pvs = bspVisBytes + VIS_HEADER_SIZE + ( a * leafBytes );
|
||||
const int leafBytes = ( (int*) bspVisBytes.data() )[ 1 ];
|
||||
const byte *pvs = bspVisBytes.data() + VIS_HEADER_SIZE + ( a * leafBytes );
|
||||
|
||||
/* check */
|
||||
if ( ( pvs[ b >> 3 ] & ( 1 << ( b & 7 ) ) ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ( pvs[ b >> 3 ] & ( 1 << ( b & 7 ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2358,8 +2358,7 @@ Q_EXTERN std::vector<byte> bspLightBytes;
|
|||
|
||||
Q_EXTERN std::vector<bspGridPoint_t> bspGridPoints;
|
||||
|
||||
Q_EXTERN int numBSPVisBytes Q_ASSIGN( 0 );
|
||||
Q_EXTERN byte bspVisBytes[ MAX_MAP_VISIBILITY ];
|
||||
Q_EXTERN std::vector<byte> bspVisBytes; // MAX_MAP_VISIBILITY
|
||||
|
||||
Q_EXTERN int numBSPDrawVerts Q_ASSIGN( 0 );
|
||||
Q_EXTERN bspDrawVert_t *bspDrawVerts Q_ASSIGN( NULL );
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ void ClusterMerge( int leafnum ){
|
|||
//Sys_FPrintf( SYS_VRB, "cluster %4i : %4i visible\n", leafnum, numvis );
|
||||
++clustersizehistogram[numvis];
|
||||
|
||||
memcpy( bspVisBytes + VIS_HEADER_SIZE + leafnum * leafbytes, uncompressed, leafbytes );
|
||||
memcpy( bspVisBytes.data() + VIS_HEADER_SIZE + leafnum * leafbytes, uncompressed, leafbytes );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -886,14 +886,14 @@ void LoadPortals( char *name ){
|
|||
for ( i = 0; i < portalclusters; i++ )
|
||||
leafs[i].merged = -1;
|
||||
|
||||
numBSPVisBytes = VIS_HEADER_SIZE + portalclusters * leafbytes;
|
||||
bspVisBytes.resize( VIS_HEADER_SIZE + portalclusters * leafbytes );
|
||||
|
||||
if ( numBSPVisBytes > MAX_MAP_VISIBILITY ) {
|
||||
if ( bspVisBytes.size() > MAX_MAP_VISIBILITY ) {
|
||||
Error( "MAX_MAP_VISIBILITY exceeded" );
|
||||
}
|
||||
|
||||
( (int *)bspVisBytes )[0] = portalclusters;
|
||||
( (int *)bspVisBytes )[1] = leafbytes;
|
||||
( (int *)bspVisBytes.data() )[0] = portalclusters;
|
||||
( (int *)bspVisBytes.data() )[1] = leafbytes;
|
||||
|
||||
for ( i = 0, p = portals ; i < numportals ; i++ )
|
||||
{
|
||||
|
|
@ -1118,7 +1118,7 @@ int VisMain( Args& args ){
|
|||
CountActivePortals();
|
||||
/* WritePortals( "maps/hints.prs" );*/
|
||||
|
||||
Sys_Printf( "visdatasize:%i\n", numBSPVisBytes );
|
||||
Sys_Printf( "visdatasize:%zu\n", bspVisBytes.size() );
|
||||
|
||||
CalcVis();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user