Recast: hook up traverse link dumper

This commit is contained in:
Kawe Mazidjatari 2024-08-09 14:20:04 +02:00
parent c63061419a
commit d5ddaf3313
2 changed files with 29 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include "Detour/Include/DetourNavMeshBuilder.h"
#include "DebugUtils/Include/RecastDebugDraw.h"
#include "DebugUtils/Include/DetourDebugDraw.h"
#include "DebugUtils/Include/DetourDump.h"
#include "NavEditor/Include/NavMeshTesterTool.h"
#include "NavEditor/Include/NavMeshPruneTool.h"
#include "NavEditor/Include/OffMeshConnectionTool.h"
@ -49,6 +50,7 @@ class NavMeshTileTool : public EditorTool
Editor_TileMesh* m_editor;
dtNavMesh* m_navMesh;
float m_hitPos[3];
int m_selectedTraverseType;
dtPolyRef m_markedPolyRef;
@ -69,6 +71,7 @@ public:
NavMeshTileTool() :
m_editor(0),
m_navMesh(0),
m_selectedTraverseType(-1),
m_markedPolyRef(0),
m_textOverlayDrawMode(TO_DRAW_DISABLED),
m_hitPosSet(false)
@ -132,6 +135,30 @@ public:
m_markedPolyRef = 0;
}
}
dtNavMeshQuery* query = m_editor->getNavMeshQuery();
if (query && m_navMesh)
{
ImGui::PushItemWidth(83);
ImGui::SliderInt("Selected Traverse Type", &m_selectedTraverseType, -1, 31);
ImGui::PopItemWidth();
if (ImGui::Button("Dump Traverse Links"))
{
FileIO io;
const char* modelName = m_editor->getModelName();
char buf[512];
snprintf(buf, sizeof(buf), "%s_%d.txt", modelName, m_selectedTraverseType);
if (io.openForWrite(buf))
{
duDumpTraverseLinkDetail(*m_navMesh, query, m_selectedTraverseType, &io);
}
}
}
}
virtual void handleClick(const float* /*s*/, const float* p, bool shift)

View File

@ -225,6 +225,8 @@ public:
inline NavMeshType_e getSelectedNavMeshType() const { return m_selectedNavMeshType; }
inline NavMeshType_e getLoadedNavMeshType() const { return m_loadedNavMeshType; }
inline const char* getModelName() const { return m_modelName.c_str(); }
void updateToolStates(const float dt);
void initToolStates(Editor* editor);
void resetToolStates();