Recast: fix tile tool not rebuilding static pathing data

Static pathing data is only build when the entire navmesh is build, but if an individual tile has been created, then the data isn't rebuild to accommodate the changes. Building code has been moved to the base class as it should be used for all tile editors, and is now also called from other code paths that require it.
This commit is contained in:
Kawe Mazidjatari 2024-07-13 11:43:18 +02:00
parent 4a3beeb658
commit fadb53cb46
3 changed files with 20 additions and 11 deletions

View File

@ -21,6 +21,7 @@
#include "Shared/Include/SharedAssert.h"
#include "Detour/Include/DetourNavMesh.h"
#include "Detour/Include/DetourNavMeshQuery.h"
#include "Detour/Include/DetourNavMeshBuilder.h"
#include "DetourCrowd/Include/DetourCrowd.h"
#include "DebugUtils/Include/RecastDebugDraw.h"
#include "DebugUtils/Include/DetourDebugDraw.h"
@ -308,6 +309,20 @@ void Editor::handleUpdate(const float dt)
updateToolStates(dt);
}
void Editor::buildStaticPathingData()
{
dtDisjointSet data;
if (!dtCreateDisjointPolyGroups(m_navMesh, data))
{
m_ctx->log(RC_LOG_ERROR, "buildStaticPathingData: Failed to build disjoint poly groups.");
}
if (!dtCreateTraversalTableData(m_navMesh, data, NavMesh_GetTraversalTableCountForNavMeshType(m_selectedNavMeshType)))
{
m_ctx->log(RC_LOG_ERROR, "buildStaticPathingData: Failed to build traversal table data.");
}
}
void Editor::updateToolStates(const float dt)
{

View File

@ -113,6 +113,8 @@ public:
m_editor->removeTile(m_hitPos);
else
m_editor->buildTile(m_hitPos);
m_editor->buildStaticPathingData();
}
}
@ -521,17 +523,7 @@ void Editor_TileMesh::buildAllTiles()
}
}
dtDisjointSet data;
if (!dtCreateDisjointPolyGroups(m_navMesh, data))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Failed to build disjoint poly groups.");
}
if (!dtCreateTraversalTableData(m_navMesh, data, NavMesh_GetTraversalTableCountForNavMeshType(m_selectedNavMeshType)))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Failed to build traversal table data.");
}
buildStaticPathingData();
// Start the build process.
m_ctx->stopTimer(RC_TIMER_TEMP);

View File

@ -207,6 +207,8 @@ public:
void resetCommonSettings();
void handleCommonSettings();
void buildStaticPathingData();
private:
// Explicitly disabled copy constructor and copy assignment operator.
Editor(const Editor&);