From 2e3977426eb9f0d727ce0127c4fd9aa37aaf8973 Mon Sep 17 00:00:00 2001 From: Graham Pentheny Date: Thu, 7 Aug 2025 15:04:08 -0400 Subject: [PATCH] Renamed tool methods --- RecastDemo/Include/ConvexVolumeTool.h | 16 +++++----- RecastDemo/Include/CrowdTool.h | 14 ++++----- RecastDemo/Include/NavMeshPruneTool.h | 14 ++++----- RecastDemo/Include/NavMeshTesterTool.h | 14 ++++----- RecastDemo/Include/OffMeshConnectionTool.h | 14 ++++----- RecastDemo/Include/Sample.h | 17 ++++++----- RecastDemo/Source/ConvexVolumeTool.cpp | 8 ++--- RecastDemo/Source/CrowdTool.cpp | 14 ++++----- RecastDemo/Source/NavMeshPruneTool.cpp | 8 ++--- RecastDemo/Source/NavMeshTesterTool.cpp | 14 ++++----- RecastDemo/Source/OffMeshConnectionTool.cpp | 14 ++++----- RecastDemo/Source/Sample.cpp | 8 ++--- RecastDemo/Source/Sample_SoloMesh.cpp | 6 ++-- RecastDemo/Source/Sample_TempObstacles.cpp | 34 ++++++++++----------- RecastDemo/Source/Sample_TileMesh.cpp | 20 ++++++------ 15 files changed, 109 insertions(+), 106 deletions(-) diff --git a/RecastDemo/Include/ConvexVolumeTool.h b/RecastDemo/Include/ConvexVolumeTool.h index 27eb345b..809020c3 100644 --- a/RecastDemo/Include/ConvexVolumeTool.h +++ b/RecastDemo/Include/ConvexVolumeTool.h @@ -30,7 +30,7 @@ class ConvexVolumeTool : public SampleTool float boxDescent = 1.0f; static constexpr int MAX_PTS = 12; - + float points[MAX_PTS * 3] {}; int numPoints = 0; int hull[MAX_PTS] {}; @@ -44,11 +44,11 @@ public: numPoints = 0; numHull = 0; } - void handleMenu() override; - void handleClick(const float* s, const float* p, bool shift) override; - void handleToggle() override {} - void handleStep() override {} - void handleUpdate(const float) override {} - void handleRender() override; - void handleRenderOverlay(double* proj, double* model, int* view) override; + void drawMenuUI() override; + void onClick(const float* s, const float* p, bool shift) override; + void onToggle() override {} + void singleStep() override {} + void update(const float) override {} + void render() override; + void renderOverlay(double* proj, double* model, int* view) override; }; diff --git a/RecastDemo/Include/CrowdTool.h b/RecastDemo/Include/CrowdTool.h index d1e805f7..c8cd9b87 100644 --- a/RecastDemo/Include/CrowdTool.h +++ b/RecastDemo/Include/CrowdTool.h @@ -120,11 +120,11 @@ public: SampleToolType type() override { return SampleToolType::CROWD; } void init(Sample* sample) override; void reset() override; - void handleMenu() override; - void handleClick(const float* s, const float* p, bool shift) override; - void handleToggle() override; - void handleStep() override; - void handleUpdate(float dt) override; - void handleRender() override; - void handleRenderOverlay(double* proj, double* model, int* view) override; + void drawMenuUI() override; + void onClick(const float* s, const float* p, bool shift) override; + void onToggle() override; + void singleStep() override; + void update(float dt) override; + void render() override; + void renderOverlay(double* proj, double* model, int* view) override; }; diff --git a/RecastDemo/Include/NavMeshPruneTool.h b/RecastDemo/Include/NavMeshPruneTool.h index 42bf7b43..dbbb2430 100644 --- a/RecastDemo/Include/NavMeshPruneTool.h +++ b/RecastDemo/Include/NavMeshPruneTool.h @@ -43,11 +43,11 @@ public: SampleToolType type() override { return SampleToolType::NAVMESH_PRUNE; } void init(Sample* newSample) override { sample = newSample; } void reset() override; - void handleMenu() override; - void handleClick(const float* s, const float* p, bool shift) override; - void handleToggle() override {} - void handleStep() override {} - void handleUpdate(const float /*dt*/) override {} - void handleRender() override; - void handleRenderOverlay(double* proj, double* model, int* view) override; + void drawMenuUI() override; + void onClick(const float* s, const float* p, bool shift) override; + void onToggle() override {} + void singleStep() override {} + void update(const float /*dt*/) override {} + void render() override; + void renderOverlay(double* proj, double* model, int* view) override; }; diff --git a/RecastDemo/Include/NavMeshTesterTool.h b/RecastDemo/Include/NavMeshTesterTool.h index 3a387829..6afc740b 100644 --- a/RecastDemo/Include/NavMeshTesterTool.h +++ b/RecastDemo/Include/NavMeshTesterTool.h @@ -96,13 +96,13 @@ public: SampleToolType type() override { return SampleToolType::NAVMESH_TESTER; } void init(Sample* newSample) override; void reset() override; - void handleMenu() override; - void handleClick(const float* s, const float* p, bool shift) override; - void handleToggle() override; - void handleStep() override; - void handleUpdate(const float dt) override; - void handleRender() override; - void handleRenderOverlay(double* proj, double* model, int* view) override; + void drawMenuUI() override; + void onClick(const float* s, const float* p, bool shift) override; + void onToggle() override; + void singleStep() override; + void update(const float dt) override; + void render() override; + void renderOverlay(double* proj, double* model, int* view) override; void recalc(); void drawAgent(const float* pos, float r, float h, float c, const unsigned int col); diff --git a/RecastDemo/Include/OffMeshConnectionTool.h b/RecastDemo/Include/OffMeshConnectionTool.h index 686f0de4..84e8fa33 100644 --- a/RecastDemo/Include/OffMeshConnectionTool.h +++ b/RecastDemo/Include/OffMeshConnectionTool.h @@ -42,11 +42,11 @@ public: SampleToolType type() override { return SampleToolType::OFFMESH_CONNECTION; } void init(Sample* sample) override; void reset() override; - void handleMenu() override; - void handleClick(const float* rayStartTime, const float* rayHitPos, bool shift) override; - void handleToggle() override; - void handleStep() override; - void handleUpdate(const float dt) override; - void handleRender() override; - void handleRenderOverlay(double* proj, double* model, int* view) override; + void drawMenuUI() override; + void onClick(const float* rayStartTime, const float* rayHitPos, bool shift) override; + void onToggle() override; + void singleStep() override; + void update(const float dt) override; + void render() override; + void renderOverlay(double* proj, double* model, int* view) override; }; diff --git a/RecastDemo/Include/Sample.h b/RecastDemo/Include/Sample.h index 4b70c855..6826e4f2 100644 --- a/RecastDemo/Include/Sample.h +++ b/RecastDemo/Include/Sample.h @@ -98,13 +98,16 @@ struct SampleTool virtual SampleToolType type() = 0; virtual void init(Sample* sample) = 0; virtual void reset() = 0; - virtual void handleMenu() = 0; - virtual void handleClick(const float* rayStartPos, const float* rayHitPos, bool shift) = 0; - virtual void handleRender() = 0; - virtual void handleRenderOverlay(double* proj, double* model, int* view) = 0; - virtual void handleToggle() = 0; - virtual void handleStep() = 0; - virtual void handleUpdate(float dt) = 0; + + virtual void drawMenuUI() = 0; + + virtual void singleStep() = 0; + virtual void update(float dt) = 0; + virtual void render() = 0; + virtual void renderOverlay(double* proj, double* model, int* view) = 0; + + virtual void onClick(const float* rayStartPos, const float* rayHitPos, bool shift) = 0; + virtual void onToggle() = 0; }; struct SampleToolState diff --git a/RecastDemo/Source/ConvexVolumeTool.cpp b/RecastDemo/Source/ConvexVolumeTool.cpp index 76760971..19be635e 100644 --- a/RecastDemo/Source/ConvexVolumeTool.cpp +++ b/RecastDemo/Source/ConvexVolumeTool.cpp @@ -116,7 +116,7 @@ bool pointInPoly(int nvert, const float* verts, const float* p) } } -void ConvexVolumeTool::handleMenu() +void ConvexVolumeTool::drawMenuUI() { ImGui::SliderFloat("##Shape Height", &boxHeight, 0.1f, 20.0f, "Shape Height = %f"); ImGui::SliderFloat("##Shape Descent", &boxDescent, 0.1f, 20.0f, "Shape Descent = %f"); @@ -160,7 +160,7 @@ void ConvexVolumeTool::handleMenu() } } -void ConvexVolumeTool::handleClick(const float* /*s*/, const float* p, bool shift) +void ConvexVolumeTool::onClick(const float* /*s*/, const float* p, bool shift) { if (!sample) { @@ -253,7 +253,7 @@ void ConvexVolumeTool::handleClick(const float* /*s*/, const float* p, bool shif } } -void ConvexVolumeTool::handleRender() +void ConvexVolumeTool::render() { duDebugDraw& dd = sample->debugDraw; @@ -293,7 +293,7 @@ void ConvexVolumeTool::handleRender() dd.end(); } -void ConvexVolumeTool::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* view) +void ConvexVolumeTool::renderOverlay(double* /*proj*/, double* /*model*/, int* view) { // Tool help if (!numPoints) diff --git a/RecastDemo/Source/CrowdTool.cpp b/RecastDemo/Source/CrowdTool.cpp index b157f983..e05de6bd 100644 --- a/RecastDemo/Source/CrowdTool.cpp +++ b/RecastDemo/Source/CrowdTool.cpp @@ -1037,7 +1037,7 @@ void CrowdTool::init(Sample* newSample) void CrowdTool::reset() {} -void CrowdTool::handleMenu() +void CrowdTool::drawMenuUI() { if (!state) { @@ -1105,7 +1105,7 @@ void CrowdTool::handleMenu() } } -void CrowdTool::handleClick(const float* s, const float* p, bool shift) +void CrowdTool::onClick(const float* s, const float* p, bool shift) { if (!sample) { @@ -1177,7 +1177,7 @@ void CrowdTool::handleClick(const float* s, const float* p, bool shift) } } -void CrowdTool::handleStep() +void CrowdTool::singleStep() { if (!state) { @@ -1190,7 +1190,7 @@ void CrowdTool::handleStep() state->setRunning(false); } -void CrowdTool::handleToggle() +void CrowdTool::onToggle() { if (!state) { @@ -1199,14 +1199,14 @@ void CrowdTool::handleToggle() state->setRunning(!state->isRunning()); } -void CrowdTool::handleUpdate(const float dt) +void CrowdTool::update(const float dt) { rcIgnoreUnused(dt); } -void CrowdTool::handleRender() {} +void CrowdTool::render() {} -void CrowdTool::handleRenderOverlay(double* proj, double* model, int* view) +void CrowdTool::renderOverlay(double* proj, double* model, int* view) { (void)model; (void)proj; diff --git a/RecastDemo/Source/NavMeshPruneTool.cpp b/RecastDemo/Source/NavMeshPruneTool.cpp index a0408047..9b80ba19 100644 --- a/RecastDemo/Source/NavMeshPruneTool.cpp +++ b/RecastDemo/Source/NavMeshPruneTool.cpp @@ -215,7 +215,7 @@ void NavMeshPruneTool::reset() flags = nullptr; } -void NavMeshPruneTool::handleMenu() +void NavMeshPruneTool::drawMenuUI() { if (!flags) { @@ -241,7 +241,7 @@ void NavMeshPruneTool::handleMenu() } } -void NavMeshPruneTool::handleClick(const float* s, const float* p, bool shift) +void NavMeshPruneTool::onClick(const float* s, const float* p, bool shift) { rcIgnoreUnused(s); rcIgnoreUnused(shift); @@ -283,7 +283,7 @@ void NavMeshPruneTool::handleClick(const float* s, const float* p, bool shift) floodNavmesh(nav, flags, ref, 1); } -void NavMeshPruneTool::handleRender() +void NavMeshPruneTool::render() { duDebugDraw& debugDraw = sample->debugDraw; @@ -324,7 +324,7 @@ void NavMeshPruneTool::handleRender() } } -void NavMeshPruneTool::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* view) +void NavMeshPruneTool::renderOverlay(double* /*proj*/, double* /*model*/, int* view) { DrawScreenspaceText(280.0f, 40.0f, IM_COL32(255, 255, 255, 192), "LMB: Click fill area."); } diff --git a/RecastDemo/Source/NavMeshTesterTool.cpp b/RecastDemo/Source/NavMeshTesterTool.cpp index 70f01430..676b2630 100644 --- a/RecastDemo/Source/NavMeshTesterTool.cpp +++ b/RecastDemo/Source/NavMeshTesterTool.cpp @@ -208,7 +208,7 @@ void NavMeshTesterTool::init(Sample* newSample) randomRadius = sample->agentRadius * 30.0f; } -void NavMeshTesterTool::handleMenu() +void NavMeshTesterTool::drawMenuUI() { if (ImGui::RadioButton("Pathfind Follow", toolMode == TOOLMODE_PATHFIND_FOLLOW)) { @@ -430,7 +430,7 @@ void NavMeshTesterTool::handleMenu() ImGui::Separator(); } -void NavMeshTesterTool::handleClick(const float* /*s*/, const float* p, bool shift) +void NavMeshTesterTool::onClick(const float* /*s*/, const float* p, bool shift) { if (shift) { @@ -445,9 +445,9 @@ void NavMeshTesterTool::handleClick(const float* /*s*/, const float* p, bool shi recalc(); } -void NavMeshTesterTool::handleStep() {} +void NavMeshTesterTool::singleStep() {} -void NavMeshTesterTool::handleToggle() +void NavMeshTesterTool::onToggle() { // TODO: merge separate to a path iterator. Use same code in recalc() too. if (toolMode != TOOLMODE_PATHFIND_FOLLOW) { return; } @@ -610,7 +610,7 @@ void NavMeshTesterTool::handleToggle() } } -void NavMeshTesterTool::handleUpdate(const float /*dt*/) +void NavMeshTesterTool::update(const float /*dt*/) { if (toolMode == TOOLMODE_PATHFIND_SLICED) { @@ -1096,7 +1096,7 @@ static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center) center[2] *= s; } -void NavMeshTesterTool::handleRender() +void NavMeshTesterTool::render() { duDebugDraw& dd = sample->debugDraw; @@ -1489,7 +1489,7 @@ void NavMeshTesterTool::handleRender() } } -void NavMeshTesterTool::handleRenderOverlay(double* proj, double* model, int* view) +void NavMeshTesterTool::renderOverlay(double* proj, double* model, int* view) { GLdouble x, y, z; diff --git a/RecastDemo/Source/OffMeshConnectionTool.cpp b/RecastDemo/Source/OffMeshConnectionTool.cpp index edfbf217..d9c14545 100644 --- a/RecastDemo/Source/OffMeshConnectionTool.cpp +++ b/RecastDemo/Source/OffMeshConnectionTool.cpp @@ -54,7 +54,7 @@ void OffMeshConnectionTool::reset() hitPosSet = false; } -void OffMeshConnectionTool::handleMenu() +void OffMeshConnectionTool::drawMenuUI() { if (ImGui::RadioButton("One Way", !bidir)) { @@ -66,7 +66,7 @@ void OffMeshConnectionTool::handleMenu() } } -void OffMeshConnectionTool::handleClick(const float* /*rayStartPos*/, const float* rayHitPos, bool shift) +void OffMeshConnectionTool::onClick(const float* /*rayStartPos*/, const float* rayHitPos, bool shift) { if (!sample) { @@ -124,13 +124,13 @@ void OffMeshConnectionTool::handleClick(const float* /*rayStartPos*/, const floa } } -void OffMeshConnectionTool::handleToggle() {} +void OffMeshConnectionTool::onToggle() {} -void OffMeshConnectionTool::handleStep() {} +void OffMeshConnectionTool::singleStep() {} -void OffMeshConnectionTool::handleUpdate(const float /*dt*/) {} +void OffMeshConnectionTool::update(const float /*dt*/) {} -void OffMeshConnectionTool::handleRender() +void OffMeshConnectionTool::render() { duDebugDraw& dd = sample->debugDraw; @@ -145,7 +145,7 @@ void OffMeshConnectionTool::handleRender() } } -void OffMeshConnectionTool::handleRenderOverlay(double* proj, double* model, int* view) +void OffMeshConnectionTool::renderOverlay(double* proj, double* model, int* view) { GLdouble x, y, z; diff --git a/RecastDemo/Source/Sample.cpp b/RecastDemo/Source/Sample.cpp index dc5c26d6..d7cdc865 100644 --- a/RecastDemo/Source/Sample.cpp +++ b/RecastDemo/Source/Sample.cpp @@ -273,7 +273,7 @@ void Sample::onClick(const float* rayStartPos, const float* rayHitPos, bool shif { if (tool) { - tool->handleClick(rayStartPos, rayHitPos, shift); + tool->onClick(rayStartPos, rayHitPos, shift); } } @@ -281,7 +281,7 @@ void Sample::onToggle() { if (tool) { - tool->handleToggle(); + tool->onToggle(); } } @@ -289,7 +289,7 @@ void Sample::singleStep() { if (tool) { - tool->handleStep(); + tool->singleStep(); } } @@ -302,7 +302,7 @@ void Sample::update(const float dt) { if (tool) { - tool->handleUpdate(dt); + tool->update(dt); } updateToolStates(dt); } diff --git a/RecastDemo/Source/Sample_SoloMesh.cpp b/RecastDemo/Source/Sample_SoloMesh.cpp index c9550aa7..0cab1efb 100644 --- a/RecastDemo/Source/Sample_SoloMesh.cpp +++ b/RecastDemo/Source/Sample_SoloMesh.cpp @@ -135,7 +135,7 @@ void Sample_SoloMesh::drawToolsUI() if (tool) { - tool->handleMenu(); + tool->drawMenuUI(); } } @@ -320,7 +320,7 @@ void Sample_SoloMesh::render() if (tool) { - tool->handleRender(); + tool->render(); } renderToolStates(); @@ -331,7 +331,7 @@ void Sample_SoloMesh::renderOverlay(double* proj, double* model, int* view) { if (tool) { - tool->handleRenderOverlay(proj, model, view); + tool->renderOverlay(proj, model, view); } renderOverlayToolStates(proj, model, view); } diff --git a/RecastDemo/Source/Sample_TempObstacles.cpp b/RecastDemo/Source/Sample_TempObstacles.cpp index 775f1f98..da3d8ec8 100644 --- a/RecastDemo/Source/Sample_TempObstacles.cpp +++ b/RecastDemo/Source/Sample_TempObstacles.cpp @@ -756,7 +756,7 @@ public: void reset() override {} - void handleMenu() override + void drawMenuUI() override { ImGui::Text("Highlight Tile Cache"); ImGui::Text("Click LMB to highlight a tile."); @@ -779,19 +779,19 @@ public: } } - void handleClick(const float* /*s*/, const float* p, bool /*shift*/) override + void onClick(const float* /*s*/, const float* p, bool /*shift*/) override { m_hitPosSet = true; rcVcopy(m_hitPos, p); } - void handleToggle() override {} + void onToggle() override {} - void handleStep() override {} + void singleStep() override {} - void handleUpdate(const float /*dt*/) override {} + void update(const float /*dt*/) override {} - void handleRender() override + void render() override { if (m_hitPosSet && m_sample) { @@ -814,7 +814,7 @@ public: } } - void handleRenderOverlay(double* proj, double* model, int* view) override + void renderOverlay(double* proj, double* model, int* view) override { if (m_hitPosSet) { @@ -841,7 +841,7 @@ public: void reset() override {} - void handleMenu() override + void drawMenuUI() override { ImGui::Text("Create Temp Obstacles"); @@ -856,7 +856,7 @@ public: ImGui::Text("Shift+LMB to remove an obstacle."); } - void handleClick(const float* s, const float* p, bool shift) override + void onClick(const float* s, const float* p, bool shift) override { if (m_sample) { @@ -871,11 +871,11 @@ public: } } - void handleToggle() override {} - void handleStep() override {} - void handleUpdate(const float /*dt*/) override {} - void handleRender() override {} - void handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/) override {} + void onToggle() override {} + void singleStep() override {} + void update(const float /*dt*/) override {} + void render() override {} + void renderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/) override {} }; Sample_TempObstacles::Sample_TempObstacles() @@ -1009,7 +1009,7 @@ void Sample_TempObstacles::drawToolsUI() if (tool) { - tool->handleMenu(); + tool->drawMenuUI(); } } @@ -1187,7 +1187,7 @@ void Sample_TempObstacles::render() if (tool) { - tool->handleRender(); + tool->render(); } renderToolStates(); @@ -1214,7 +1214,7 @@ void Sample_TempObstacles::renderOverlay(double* proj, double* model, int* view) { if (tool) { - tool->handleRenderOverlay(proj, model, view); + tool->renderOverlay(proj, model, view); } renderOverlayToolStates(proj, model, view); diff --git a/RecastDemo/Source/Sample_TileMesh.cpp b/RecastDemo/Source/Sample_TileMesh.cpp index c507416e..3d23704e 100644 --- a/RecastDemo/Source/Sample_TileMesh.cpp +++ b/RecastDemo/Source/Sample_TileMesh.cpp @@ -115,7 +115,7 @@ public: void init(Sample* sample) override { m_sample = static_cast(sample); } void reset() override {} - void handleMenu() override + void drawMenuUI() override { ImGui::Text("Create Tiles"); if (ImGui::Button("Create All")) @@ -134,7 +134,7 @@ public: } } - void handleClick(const float* /*s*/, const float* p, bool shift) override + void onClick(const float* /*s*/, const float* p, bool shift) override { m_hitPosSet = true; rcVcopy(m_hitPos, p); @@ -151,13 +151,13 @@ public: } } - void handleToggle() override {} + void onToggle() override {} - void handleStep() override {} + void singleStep() override {} - void handleUpdate(const float /*dt*/) override {} + void update(const float /*dt*/) override {} - void handleRender() override + void render() override { if (!m_hitPosSet) { @@ -178,7 +178,7 @@ public: glLineWidth(1.0f); } - void handleRenderOverlay(double* proj, double* model, int* view) override + void renderOverlay(double* proj, double* model, int* view) override { GLdouble x, y, z; if (m_hitPosSet && gluProject(m_hitPos[0], m_hitPos[1], m_hitPos[2], model, proj, view, &x, &y, &z)) @@ -312,7 +312,7 @@ void Sample_TileMesh::drawToolsUI() if (tool) { - tool->handleMenu(); + tool->drawMenuUI(); } } @@ -527,7 +527,7 @@ void Sample_TileMesh::render() if (tool) { - tool->handleRender(); + tool->render(); } renderToolStates(); @@ -558,7 +558,7 @@ void Sample_TileMesh::renderOverlay(double* proj, double* model, int* view) if (tool) { - tool->handleRenderOverlay(proj, model, view); + tool->renderOverlay(proj, model, view); } renderOverlayToolStates(proj, model, view); }