mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-24 13:47:46 +00:00
pcb_reader:
- try free up some memory (recast still leaking a lot though)
This commit is contained in:
parent
3827650c9e
commit
ebeb5db3ba
6 changed files with 45 additions and 24 deletions
|
@ -65,8 +65,20 @@ public:
|
|||
return pFile;
|
||||
}
|
||||
|
||||
void purge()
|
||||
{
|
||||
std::scoped_lock lock( m_mutex );
|
||||
_purge();
|
||||
}
|
||||
|
||||
private:
|
||||
void _purge()
|
||||
{
|
||||
m_lgbCache.clear();
|
||||
m_sgbCache.clear();
|
||||
m_pcbCache.clear();
|
||||
//std::cout << "Purged PCB/SGB/LGB cache \n";
|
||||
}
|
||||
template< typename T >
|
||||
std::shared_ptr< T > loadFile( const std::string& filepath )
|
||||
{
|
||||
|
@ -80,10 +92,7 @@ private:
|
|||
m_totalFiles++;
|
||||
if( m_totalFiles % 1000 == 0 )
|
||||
{
|
||||
m_lgbCache.clear();
|
||||
m_sgbCache.clear();
|
||||
m_pcbCache.clear();
|
||||
std::cout << "Purged PCB/SGB/LGB cache \n";
|
||||
_purge();
|
||||
m_totalFiles = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,15 +31,18 @@ public:
|
|||
}
|
||||
|
||||
void exportGroup( const std::string& zoneName, const ExportedGroup& group, ExportFileType exportFileTypes )
|
||||
{
|
||||
m_threadpool.queue( [zoneName, group, exportFileTypes]()
|
||||
{
|
||||
if( exportFileTypes & ExportFileType::WavefrontObj )
|
||||
{
|
||||
m_threadpool.queue( [zoneName, group](){ ObjExporter::exportGroup( zoneName, group ); } );
|
||||
ObjExporter::exportGroup( zoneName, group );
|
||||
}
|
||||
// if( exportFileTypes & ExportFileType::Navmesh )
|
||||
// {
|
||||
// m_threadpool.queue( [zoneName, group](){ NavmeshExporter::exportGroup( zoneName, group ); } );
|
||||
// }
|
||||
if( exportFileTypes & ExportFileType::Navmesh )
|
||||
{
|
||||
NavmeshExporter::exportGroup( zoneName, group );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void waitForTasks()
|
||||
|
|
|
@ -335,7 +335,7 @@ struct LGB_GROUP
|
|||
entries.push_back( std::make_shared< LGB_EOBJ_ENTRY >( buf, entryOffset ) );
|
||||
break;
|
||||
case LgbEntryType::CollisionBox:
|
||||
entries.push_back( std::make_shared< LGB_COLLISION_BOX_ENTRY >( buf, entryOffset ) );
|
||||
//entries.push_back( std::make_shared< LGB_COLLISION_BOX_ENTRY >( buf, entryOffset ) );
|
||||
break;
|
||||
default:
|
||||
//std::cout << "\t\tUnknown SGB entry! Group: " << name << " type: " << ( int )type << " index: " << i << " entryOffset: " << entryOffset << "\n";
|
||||
|
|
|
@ -206,6 +206,7 @@ int main( int argc, char* argv[] )
|
|||
zoneDumpList.emplace( zoneName );
|
||||
}
|
||||
|
||||
int zoneCount = 0;
|
||||
for( auto zoneName : zoneDumpList )
|
||||
{
|
||||
try
|
||||
|
@ -495,7 +496,8 @@ int main( int argc, char* argv[] )
|
|||
}
|
||||
}
|
||||
exportMgr.exportZone( exportedZone, static_cast< ExportFileType >( exportFileType ) );
|
||||
|
||||
if( zoneCount++ % 3 == 0 )
|
||||
pCache->purge();
|
||||
|
||||
printf( "Exported %s in %lu seconds \n",
|
||||
zoneName.c_str(),
|
||||
|
@ -508,6 +510,7 @@ int main( int argc, char* argv[] )
|
|||
printf( "Usage: pcb_reader2 territory \"path/to/game/sqpack/ffxiv\"\n" );
|
||||
}
|
||||
}
|
||||
pCache->purge();
|
||||
exportMgr.waitForTasks();
|
||||
std::cout << "\n\n\n";
|
||||
|
||||
|
|
|
@ -87,14 +87,19 @@ bool TiledNavmeshGenerator::init( const std::string& path )
|
|||
|
||||
TiledNavmeshGenerator::~TiledNavmeshGenerator()
|
||||
{
|
||||
if( m_mesh )
|
||||
delete m_mesh;
|
||||
if( m_chunkyMesh )
|
||||
delete m_chunkyMesh;
|
||||
|
||||
if( m_ctx )
|
||||
if( m_triareas )
|
||||
delete[] m_triareas;
|
||||
if( m_solid )
|
||||
delete m_solid;
|
||||
delete m_ctx;
|
||||
|
||||
rcFreeContourSet( m_cset );
|
||||
rcFreeCompactHeightfield(m_chf);
|
||||
rcFreePolyMesh( m_pmesh );
|
||||
rcFreePolyMeshDetail( m_dmesh );
|
||||
dtFreeNavMesh( m_navMesh );
|
||||
dtFreeNavMeshQuery( m_navQuery );
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@ public:
|
|||
|
||||
auto dir = fs::current_path().string() + "/pcb_export/" + zone.name + "/";
|
||||
auto fileName = dir + zone.name;
|
||||
auto objName = fileName + ".obj";
|
||||
|
||||
std::error_code e;
|
||||
if( !fs::exists( fileName, e ) )
|
||||
if( !fs::exists( objName, e ) )
|
||||
ObjExporter::exportZone( zone );
|
||||
|
||||
{
|
||||
TiledNavmeshGenerator gen;
|
||||
|
||||
auto objName = fileName + ".obj";
|
||||
if( !gen.init( objName ) )
|
||||
{
|
||||
printf( "[Navmesh] failed to init TiledNavmeshGenerator for file '%s'\n", zone.name.c_str() );
|
||||
|
@ -48,6 +48,7 @@ public:
|
|||
}
|
||||
|
||||
gen.saveNavmesh( zone.name );
|
||||
}
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
printf( "[Navmesh] Finished exporting %s in %lu ms\n",
|
||||
|
@ -64,15 +65,15 @@ public:
|
|||
|
||||
auto dir = fs::current_path().string() + "/pcb_export/" + zoneName + "/";
|
||||
auto fileName = dir + zoneName + "_" + group.name;
|
||||
auto objName = fileName + ".obj";
|
||||
|
||||
std::error_code e;
|
||||
if( !fs::exists( fileName, e ) )
|
||||
if( !fs::exists( objName, e ) )
|
||||
ObjExporter::exportGroup( zoneName, group );
|
||||
|
||||
|
||||
TiledNavmeshGenerator gen;
|
||||
|
||||
auto objName = fileName + ".obj";
|
||||
if( !gen.init( objName ) )
|
||||
{
|
||||
printf( "[Navmesh] failed to init TiledNavmeshGenerator for file '%s'\n", fileName.c_str() );
|
||||
|
|
Loading…
Add table
Reference in a new issue