Recast: fix navmesh query crash regression

Caused in commit ce4d4aa59831fbb6a2b7c32820561b321484dc56. Need to properly free and set the navmesh pointer.
This commit is contained in:
Amos 2024-07-24 23:53:14 +02:00
parent 73d0e81983
commit 034c0f07d4
4 changed files with 4 additions and 2 deletions

View File

@ -544,6 +544,9 @@ void Editor::selectNavMeshType(const NavMeshType_e navMeshType)
bool Editor::loadAll(std::string path, const bool fullPath)
{
dtFreeNavMesh(m_navMesh);
m_navMesh = nullptr;
const char* navMeshPath = nullptr;
char buffer[256];

View File

@ -404,7 +404,6 @@ void Editor_StaticTileMeshCommon::renderIntermediateTileMeshOptions()
if (ImGui::Button("Load", ImVec2(123, 0)))
{
dtFreeNavMesh(m_navMesh);
Editor::loadAll(m_modelName.c_str());
m_navQuery->init(m_navMesh, 2048);

View File

@ -833,7 +833,6 @@ void Editor_TempObstacles::handleSettings()
if (ImGui::Button("Load", ImVec2(123, 0)))
{
dtFreeNavMesh(m_navMesh);
Editor::loadAll(m_modelName.c_str());
m_navQuery->init(m_navMesh, 2048);

View File

@ -1026,6 +1026,7 @@ int not_main(int argc, char** argv)
if (GetOpenFileNameA(&diag))
{
editor->loadAll(szFile, true);
editor->getNavMeshQuery()->init(editor->getNavMesh(), 2048);
}
}
if (ImGui::Button(meshName.empty() ? "Choose Level..." : meshName.c_str()))