mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 07:07:45 +00:00
pcb_reader:
- export obj if it doesnt exist already
This commit is contained in:
parent
4c15aae042
commit
c2dab83c8b
2 changed files with 49 additions and 7 deletions
|
@ -87,9 +87,12 @@ bool TiledNavmeshGenerator::init( const std::string& path )
|
|||
|
||||
TiledNavmeshGenerator::~TiledNavmeshGenerator()
|
||||
{
|
||||
if( m_mesh )
|
||||
delete m_mesh;
|
||||
if( m_chunkyMesh )
|
||||
delete m_chunkyMesh;
|
||||
|
||||
if( m_ctx )
|
||||
delete m_ctx;
|
||||
|
||||
dtFreeNavMesh( m_navMesh );
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <chrono>
|
||||
|
||||
#include "exporter.h"
|
||||
#include "obj_exporter.h"
|
||||
#include "nav/TiledNavmeshGenerator.h"
|
||||
|
||||
#include <experimental/filesystem>
|
||||
|
@ -25,13 +26,18 @@ public:
|
|||
static std::string currPath = std::experimental::filesystem::current_path().string();
|
||||
|
||||
auto dir = fs::current_path().string() + "/pcb_export/" + zone.name + "/";
|
||||
auto fileName = dir + zone.name + ".obj";
|
||||
auto fileName = dir + zone.name;
|
||||
|
||||
std::error_code e;
|
||||
if( !fs::exists( fileName, e ) )
|
||||
ObjExporter::exportZone( zone );
|
||||
|
||||
TiledNavmeshGenerator gen;
|
||||
|
||||
if( !gen.init( fileName ) )
|
||||
auto objName = fileName + ".obj";
|
||||
if( !gen.init( objName ) )
|
||||
{
|
||||
printf( "[Navmesh] failed to init TiledNavmeshGenerator for file '%s'\n", fileName.c_str() );
|
||||
printf( "[Navmesh] failed to init TiledNavmeshGenerator for file '%s'\n", zone.name.c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,13 +51,46 @@ public:
|
|||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
printf( "[Navmesh] Finished exporting %s in %lu ms\n",
|
||||
fileName.c_str(),
|
||||
zone.name.c_str(),
|
||||
std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
|
||||
}
|
||||
|
||||
static void exportGroup( const std::string& zoneName, const ExportedGroup& group )
|
||||
{
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
static std::string currPath = std::experimental::filesystem::current_path().string();
|
||||
|
||||
|
||||
auto dir = fs::current_path().string() + "/pcb_export/" + zoneName + "/";
|
||||
auto fileName = dir + zoneName + "_" + group.name;
|
||||
|
||||
std::error_code e;
|
||||
if( !fs::exists( fileName, 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() );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !gen.buildNavmesh() )
|
||||
{
|
||||
printf( "[Navmesh] Failed to build navmesh for '%s'\n", fileName.c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
gen.saveNavmesh( fileName );
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
printf( "[Navmesh] Finished exporting %s in %lu ms\n",
|
||||
fileName.c_str(),
|
||||
std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
|
||||
}
|
||||
};
|
||||
#endif // !OBJ_EXPORTER_H
|
||||
|
|
Loading…
Add table
Reference in a new issue