From c7adefa56c0a1574f2d75d18f67af8710186294d Mon Sep 17 00:00:00 2001 From: Amos Date: Wed, 24 Jul 2024 23:39:39 +0200 Subject: [PATCH] Recast: update poly area's for MSET >= 7 These should be the poly area enumerants for MSET version 7 or higher. --- src/naveditor/ConvexVolumeTool.cpp | 24 ++++--------------- src/naveditor/Editor.cpp | 20 ++++++---------- src/naveditor/Editor_SoloMesh.cpp | 16 +++++++------ src/naveditor/Editor_TempObstacles.cpp | 16 +++++++------ src/naveditor/Editor_TileMesh.cpp | 16 +++++++------ src/naveditor/InputGeom.cpp | 8 +++---- src/naveditor/NavMeshTesterTool.cpp | 6 ++--- src/naveditor/include/Editor.h | 24 ++++++++++++++++--- .../DebugUtils/Source/DetourDebugDraw.cpp | 4 ++-- 9 files changed, 68 insertions(+), 66 deletions(-) diff --git a/src/naveditor/ConvexVolumeTool.cpp b/src/naveditor/ConvexVolumeTool.cpp index d4cdf273..d3bfba7c 100644 --- a/src/naveditor/ConvexVolumeTool.cpp +++ b/src/naveditor/ConvexVolumeTool.cpp @@ -91,7 +91,7 @@ static int pointInPoly(int nvert, const float* verts, const float* p) // todo(am ConvexVolumeTool::ConvexVolumeTool() : m_editor(0), - m_areaType(EDITOR_POLYAREA_GROUND), + m_areaType(RC_NULL_AREA), m_polyOffset(0.0f), m_boxHeight(650.0f), m_boxDescent(150.0f), @@ -126,31 +126,15 @@ void ConvexVolumeTool::handleMenu() ImGui::Text("Brushes"); ImGui::Indent(); - bool isEnabled = m_areaType == EDITOR_POLYAREA_GROUND; + bool isEnabled = m_areaType == RC_NULL_AREA; if (ImGui::Checkbox("Clip", &isEnabled)) - m_areaType = EDITOR_POLYAREA_GROUND; - - isEnabled = m_areaType == EDITOR_POLYAREA_JUMP; - if (ImGui::Checkbox("Jump", &isEnabled)) - m_areaType = EDITOR_POLYAREA_JUMP; - - isEnabled = m_areaType == EDITOR_POLYAREA_ROAD; - if (ImGui::Checkbox("Road", &isEnabled)) - m_areaType = EDITOR_POLYAREA_ROAD; + m_areaType = RC_NULL_AREA; isEnabled = m_areaType == EDITOR_POLYAREA_DOOR; - if (ImGui::Checkbox("Door", &isEnabled)) + if (ImGui::Checkbox("Trigger", &isEnabled)) m_areaType = EDITOR_POLYAREA_DOOR; - isEnabled = m_areaType == EDITOR_POLYAREA_GRASS; - if (ImGui::Checkbox("Grass", &isEnabled)) - m_areaType = EDITOR_POLYAREA_GRASS; - - isEnabled = m_areaType == EDITOR_POLYAREA_WATER; - if (ImGui::Checkbox("Water", &isEnabled)) - m_areaType = EDITOR_POLYAREA_WATER; - ImGui::Unindent(); ImGui::Separator(); diff --git a/src/naveditor/Editor.cpp b/src/naveditor/Editor.cpp index 3d61ead3..82b51bcc 100644 --- a/src/naveditor/Editor.cpp +++ b/src/naveditor/Editor.cpp @@ -37,20 +37,14 @@ unsigned int EditorDebugDraw::areaToCol(unsigned int area) { switch(area) { - // Ground (0) : light blue + // Ground : light blue case EDITOR_POLYAREA_GROUND: return duRGBA(0, 192, 215, 255); - // Jump : yellow - case EDITOR_POLYAREA_JUMP: return duRGBA(255, 255, 0, 255); - // Road : brown - case EDITOR_POLYAREA_ROAD: return duRGBA(50, 20, 12, 255); - // Door : cyan - case EDITOR_POLYAREA_DOOR: return duRGBA(0, 255, 255, 255); - // Grass : green - case EDITOR_POLYAREA_GRASS: return duRGBA(0, 255, 0, 255); - // Water : blue - case EDITOR_POLYAREA_WATER: return duRGBA(0, 0, 255, 255); - // Unexpected : orange - default: return duRGBA(255, 100, 10, 255); + // Jump : purple + case EDITOR_POLYAREA_JUMP: return duRGBA(255, 0, 255, 255); + // Trigger : light green + case EDITOR_POLYAREA_DOOR: return duRGBA(20, 245, 0, 255); + // Unexpected : white + default: return duRGBA(255, 255, 255, 255); } } diff --git a/src/naveditor/Editor_SoloMesh.cpp b/src/naveditor/Editor_SoloMesh.cpp index abd42831..62868d86 100644 --- a/src/naveditor/Editor_SoloMesh.cpp +++ b/src/naveditor/Editor_SoloMesh.cpp @@ -448,16 +448,18 @@ bool Editor_SoloMesh::handleBuild() if (m_pmesh->areas[i] == RC_WALKABLE_AREA) m_pmesh->areas[i] = EDITOR_POLYAREA_GROUND; - if (m_pmesh->areas[i] == EDITOR_POLYAREA_GROUND || - m_pmesh->areas[i] == EDITOR_POLYAREA_GRASS || - m_pmesh->areas[i] == EDITOR_POLYAREA_ROAD) + if (m_pmesh->areas[i] == EDITOR_POLYAREA_GROUND + //|| + //m_pmesh->areas[i] == EDITOR_POLYAREA_GRASS || + //m_pmesh->areas[i] == EDITOR_POLYAREA_ROAD + ) { m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK; } - else if (m_pmesh->areas[i] == EDITOR_POLYAREA_WATER) - { - m_pmesh->flags[i] = EDITOR_POLYFLAGS_SWIM; - } + //else if (m_pmesh->areas[i] == EDITOR_POLYAREA_WATER) + //{ + // m_pmesh->flags[i] = EDITOR_POLYFLAGS_SWIM; + //} else if (m_pmesh->areas[i] == EDITOR_POLYAREA_DOOR) { m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK | EDITOR_POLYFLAGS_DOOR; diff --git a/src/naveditor/Editor_TempObstacles.cpp b/src/naveditor/Editor_TempObstacles.cpp index f89e9b7e..32d49691 100644 --- a/src/naveditor/Editor_TempObstacles.cpp +++ b/src/naveditor/Editor_TempObstacles.cpp @@ -176,16 +176,18 @@ struct MeshProcess : public dtTileCacheMeshProcess if (polyAreas[i] == DT_TILECACHE_WALKABLE_AREA) polyAreas[i] = EDITOR_POLYAREA_GROUND; - if (polyAreas[i] == EDITOR_POLYAREA_GROUND || - polyAreas[i] == EDITOR_POLYAREA_GRASS || - polyAreas[i] == EDITOR_POLYAREA_ROAD) + if (polyAreas[i] == EDITOR_POLYAREA_GROUND + //|| + //polyAreas[i] == EDITOR_POLYAREA_GRASS || + //polyAreas[i] == EDITOR_POLYAREA_ROAD + ) { polyFlags[i] = EDITOR_POLYFLAGS_WALK; } - else if (polyAreas[i] == EDITOR_POLYAREA_WATER) - { - polyFlags[i] = EDITOR_POLYFLAGS_SWIM; - } + //else if (polyAreas[i] == EDITOR_POLYAREA_WATER) + //{ + // polyFlags[i] = EDITOR_POLYFLAGS_SWIM; + //} else if (polyAreas[i] == EDITOR_POLYAREA_DOOR) { polyFlags[i] = EDITOR_POLYFLAGS_WALK | EDITOR_POLYFLAGS_DOOR; diff --git a/src/naveditor/Editor_TileMesh.cpp b/src/naveditor/Editor_TileMesh.cpp index ad67353f..c3130b8f 100644 --- a/src/naveditor/Editor_TileMesh.cpp +++ b/src/naveditor/Editor_TileMesh.cpp @@ -986,16 +986,18 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const if (m_pmesh->areas[i] == RC_WALKABLE_AREA) m_pmesh->areas[i] = EDITOR_POLYAREA_GROUND; - if (m_pmesh->areas[i] == EDITOR_POLYAREA_GROUND || - m_pmesh->areas[i] == EDITOR_POLYAREA_GRASS || - m_pmesh->areas[i] == EDITOR_POLYAREA_ROAD) + if (m_pmesh->areas[i] == EDITOR_POLYAREA_GROUND + //|| + //m_pmesh->areas[i] == EDITOR_POLYAREA_GRASS || + //m_pmesh->areas[i] == EDITOR_POLYAREA_ROAD + ) { m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK; } - else if (m_pmesh->areas[i] == EDITOR_POLYAREA_WATER) - { - m_pmesh->flags[i] = EDITOR_POLYFLAGS_SWIM; - } + //else if (m_pmesh->areas[i] == EDITOR_POLYAREA_WATER) + //{ + // m_pmesh->flags[i] = EDITOR_POLYFLAGS_SWIM; + //} else if (m_pmesh->areas[i] == EDITOR_POLYAREA_DOOR) { m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK | EDITOR_POLYFLAGS_DOOR; diff --git a/src/naveditor/InputGeom.cpp b/src/naveditor/InputGeom.cpp index e4109f6e..46f9ffe4 100644 --- a/src/naveditor/InputGeom.cpp +++ b/src/naveditor/InputGeom.cpp @@ -644,8 +644,8 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, const float* offset, b const ConvexVolume* vol = &m_volumes[i]; unsigned int col; - if (vol->area == EDITOR_POLYAREA_GROUND) - col = duRGBA(255, 0, 0, 128); // Use red for visibility (ground acts as deletion). + if (vol->area == RC_NULL_AREA) + col = duRGBA(255, 0, 0, 128); // Use red for visibility (null acts as deletion). else col = duTransCol(dd->areaToCol(vol->area), 64); @@ -676,7 +676,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, const float* offset, b const ConvexVolume* vol = &m_volumes[i]; unsigned int col; - if (vol->area == EDITOR_POLYAREA_GROUND) + if (vol->area == RC_NULL_AREA) col = duRGBA(255, 0, 0, 220); else col = duTransCol(dd->areaToCol(vol->area), 220); @@ -701,7 +701,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, const float* offset, b const ConvexVolume* vol = &m_volumes[i]; unsigned int col; - if (vol->area == EDITOR_POLYAREA_GROUND) + if (vol->area == RC_NULL_AREA) col = duRGBA(255, 0, 0, 220); else col = duDarkenCol(duTransCol(dd->areaToCol(vol->area), 220)); diff --git a/src/naveditor/NavMeshTesterTool.cpp b/src/naveditor/NavMeshTesterTool.cpp index 3983eac3..0965e4e8 100644 --- a/src/naveditor/NavMeshTesterTool.cpp +++ b/src/naveditor/NavMeshTesterTool.cpp @@ -198,10 +198,10 @@ void NavMeshTesterTool::init(Editor* editor) // Change costs. m_filter.setAreaCost(EDITOR_POLYAREA_GROUND, 1.0f); m_filter.setAreaCost(EDITOR_POLYAREA_JUMP, 1.5f); - m_filter.setAreaCost(EDITOR_POLYAREA_ROAD, 1.0f); + //m_filter.setAreaCost(EDITOR_POLYAREA_ROAD, 1.0f); m_filter.setAreaCost(EDITOR_POLYAREA_DOOR, 1.0f); - m_filter.setAreaCost(EDITOR_POLYAREA_GRASS, 2.0f); - m_filter.setAreaCost(EDITOR_POLYAREA_WATER, 10.0f); + //m_filter.setAreaCost(EDITOR_POLYAREA_GRASS, 2.0f); + //m_filter.setAreaCost(EDITOR_POLYAREA_WATER, 10.0f); } m_neighbourhoodRadius = editor->getAgentRadius() * 20.0f; diff --git a/src/naveditor/include/Editor.h b/src/naveditor/include/Editor.h index 4a4e2bba..00691011 100644 --- a/src/naveditor/include/Editor.h +++ b/src/naveditor/include/Editor.h @@ -52,15 +52,33 @@ enum EditorToolType /// These are just poly areas to use consistent values across the editors. /// The use should specify these base on his needs. +//enum EditorPolyAreas // note: original poly area's for reference. +//{ +// EDITOR_POLYAREA_GROUND, +// EDITOR_POLYAREA_JUMP, +// EDITOR_POLYAREA_ROAD, +// EDITOR_POLYAREA_DOOR, +// EDITOR_POLYAREA_GRASS, +// EDITOR_POLYAREA_WATER, +//}; + +#if DT_NAVMESH_SET_VERSION >= 7 +enum EditorPolyAreas +{ + EDITOR_POLYAREA_JUMP, + EDITOR_POLYAREA_GROUND, + EDITOR_POLYAREA_RESERVED, + EDITOR_POLYAREA_DOOR, // rename to trigger +}; +#else enum EditorPolyAreas { EDITOR_POLYAREA_GROUND, EDITOR_POLYAREA_JUMP, - EDITOR_POLYAREA_ROAD, EDITOR_POLYAREA_DOOR, - EDITOR_POLYAREA_GRASS, - EDITOR_POLYAREA_WATER, }; +#endif + enum EditorPolyFlags { EDITOR_POLYFLAGS_WALK = 0x01, // Ability to walk (ground, grass, road) diff --git a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp index d5d6a10c..8fdd7b4e 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp @@ -287,9 +287,9 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh unsigned int col; if (query && query->isInClosedList(base | (dtPolyRef)i)) - col = duRGBA(255,196,0,220); + col = duRGBA(255, 196, 0, 220); else - col = duDarkenCol(duTransCol(duRGBA(0,0,255,255), 220)); + col = duDarkenCol(duTransCol(dd->areaToCol(p->getArea()), 220)); const float* va = &tile->verts[p->verts[0]*3]; const float* vb = &tile->verts[p->verts[1]*3];