mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Ability to load navmeshes from game directory
Load navmeshes from '..\\maps\\navmesh\\' first before attempting to load from root.
This commit is contained in:
parent
68440361cc
commit
7481cefd78
@ -332,13 +332,20 @@ void Sample::renderOverlayToolStates(double* proj, double* model, int* view)
|
||||
}
|
||||
}
|
||||
|
||||
dtNavMesh* Sample::loadAll(const char* path)
|
||||
dtNavMesh* Sample::loadAll(std::string path)
|
||||
{
|
||||
std::filesystem::path p = "..\\maps\\navmesh\\";
|
||||
if (std::filesystem::is_directory(p))
|
||||
{
|
||||
path.insert(0, p.string());
|
||||
}
|
||||
|
||||
char buffer[256];
|
||||
sprintf(buffer, "%s_%s.nm", path, m_navmeshName);
|
||||
sprintf(buffer, "%s_%s.nm", path.c_str(), m_navmeshName);
|
||||
|
||||
FILE* fp = fopen(buffer, "rb");
|
||||
if (!fp) return 0;
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
||||
// Read header.
|
||||
NavMeshSetHeader header;
|
||||
@ -405,15 +412,16 @@ dtNavMesh* Sample::loadAll(const char* path)
|
||||
|
||||
fclose(fp);
|
||||
|
||||
fclose(fp);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void Sample::saveAll(std::string path, dtNavMesh* mesh)
|
||||
{
|
||||
if (!mesh) return;
|
||||
if (!mesh)
|
||||
return;
|
||||
|
||||
std::filesystem::path p = "..\\maps\\navmesh\\";
|
||||
|
||||
if (std::filesystem::is_directory(p))
|
||||
{
|
||||
path.insert(0, p.string());
|
||||
|
@ -144,8 +144,8 @@ protected:
|
||||
|
||||
SampleDebugDraw m_dd;
|
||||
|
||||
dtNavMesh* loadAll(const char* path);
|
||||
void saveAll(std::string path,dtNavMesh* mesh);
|
||||
dtNavMesh* loadAll(std::string path);
|
||||
void saveAll(std::string path, dtNavMesh* mesh);
|
||||
|
||||
public:
|
||||
std::string m_modelName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user