mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: move navmesh loading logic into single function
Make sure tools are always initialized properly whenever a navmesh is loaded.
This commit is contained in:
parent
af2159a523
commit
9dcb1dd86c
@ -732,4 +732,23 @@ void Editor::saveAll(std::string path, const dtNavMesh* mesh)
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
bool Editor::loadNavMesh(const char* path, const bool fullPath)
|
||||
{
|
||||
const bool result = Editor::loadAll(path, fullPath);
|
||||
m_navQuery->init(m_navMesh, 2048);
|
||||
|
||||
m_loadedNavMeshType = m_selectedNavMeshType;
|
||||
|
||||
if (m_tool)
|
||||
{
|
||||
m_tool->reset();
|
||||
m_tool->init(this);
|
||||
}
|
||||
|
||||
resetToolStates();
|
||||
initToolStates(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -404,19 +404,7 @@ void Editor_StaticTileMeshCommon::renderIntermediateTileMeshOptions()
|
||||
|
||||
if (ImGui::Button("Load", ImVec2(123, 0)))
|
||||
{
|
||||
Editor::loadAll(m_modelName.c_str());
|
||||
m_navQuery->init(m_navMesh, 2048);
|
||||
|
||||
m_loadedNavMeshType = m_selectedNavMeshType;
|
||||
|
||||
if (m_tool)
|
||||
{
|
||||
m_tool->reset();
|
||||
m_tool->init(this);
|
||||
}
|
||||
|
||||
resetToolStates();
|
||||
initToolStates(this);
|
||||
Editor::loadNavMesh(m_modelName.c_str());
|
||||
}
|
||||
|
||||
if (ImGui::Button("Save", ImVec2(123, 0)))
|
||||
|
@ -443,6 +443,7 @@ bool Editor_SoloMesh::handleBuild()
|
||||
int navDataSize = 0;
|
||||
|
||||
// Update poly flags from areas.
|
||||
// todo(amos): needs to be updated and/or done differently for r2 and r5.
|
||||
for (int i = 0; i < m_pmesh->npolys; ++i)
|
||||
{
|
||||
if (m_pmesh->areas[i] == RC_WALKABLE_AREA)
|
||||
@ -462,7 +463,7 @@ bool Editor_SoloMesh::handleBuild()
|
||||
//}
|
||||
else if (m_pmesh->areas[i] == EDITOR_POLYAREA_DOOR)
|
||||
{
|
||||
m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK | EDITOR_POLYFLAGS_DOOR;
|
||||
m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK /*| EDITOR_POLYFLAGS_DOOR*/;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,6 +171,7 @@ struct MeshProcess : public dtTileCacheMeshProcess
|
||||
unsigned char* polyAreas, unsigned short* polyFlags)
|
||||
{
|
||||
// Update poly flags from areas.
|
||||
// todo(amos): needs to be updated and/or done differently for r2 and r5.
|
||||
for (int i = 0; i < params->polyCount; ++i)
|
||||
{
|
||||
if (polyAreas[i] == DT_TILECACHE_WALKABLE_AREA)
|
||||
@ -190,7 +191,7 @@ struct MeshProcess : public dtTileCacheMeshProcess
|
||||
//}
|
||||
else if (polyAreas[i] == EDITOR_POLYAREA_DOOR)
|
||||
{
|
||||
polyFlags[i] = EDITOR_POLYFLAGS_WALK | EDITOR_POLYFLAGS_DOOR;
|
||||
polyFlags[i] = EDITOR_POLYFLAGS_WALK /*| EDITOR_POLYFLAGS_DOOR*/;
|
||||
}
|
||||
}
|
||||
|
||||
@ -833,11 +834,7 @@ void Editor_TempObstacles::handleSettings()
|
||||
|
||||
if (ImGui::Button("Load", ImVec2(123, 0)))
|
||||
{
|
||||
Editor::loadAll(m_modelName.c_str());
|
||||
m_navQuery->init(m_navMesh, 2048);
|
||||
|
||||
m_loadedNavMeshType = m_selectedNavMeshType;
|
||||
initToolStates(this);
|
||||
Editor::loadNavMesh(m_modelName.c_str());
|
||||
}
|
||||
|
||||
if (ImGui::Button("Save", ImVec2(123, 0)))
|
||||
|
@ -1025,8 +1025,7 @@ int not_main(int argc, char** argv)
|
||||
|
||||
if (GetOpenFileNameA(&diag))
|
||||
{
|
||||
editor->loadAll(szFile, true);
|
||||
editor->getNavMeshQuery()->init(editor->getNavMesh(), 2048);
|
||||
editor->loadNavMesh(szFile, true);
|
||||
}
|
||||
}
|
||||
if (ImGui::Button(meshName.empty() ? "Choose Level..." : meshName.c_str()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user