From 0edf5c171709eaf8f43806beb6d20354d728ff2c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 14 Jul 2024 18:34:13 +0200 Subject: [PATCH] Recast: add ability to offset Recast and Detour debug drawing New ability to adjust it in all directions, recast and detour offsets are separate. By default, the Recast mesh renders 20 units from the input geom and Detour 30 units to avoid z-fighting. --- src/naveditor/ConvexVolumeTool.cpp | 5 +- src/naveditor/CrowdTool.cpp | 52 +++---- src/naveditor/Editor.cpp | 25 +++- src/naveditor/EditorInterfaces.cpp | 36 ++++- src/naveditor/Editor_Common.cpp | 129 ++++++++++-------- src/naveditor/Editor_Debug.cpp | 14 +- src/naveditor/Editor_SoloMesh.cpp | 6 +- src/naveditor/Editor_TileMesh.cpp | 24 +++- src/naveditor/InputGeom.cpp | 12 +- src/naveditor/NavMeshPruneTool.cpp | 5 +- src/naveditor/NavMeshTesterTool.cpp | 79 ++++++----- src/naveditor/OffMeshConnectionTool.cpp | 4 +- src/naveditor/include/Editor.h | 7 +- src/naveditor/include/EditorInterfaces.h | 5 +- src/naveditor/include/Editor_Common.h | 4 +- src/naveditor/include/InputGeom.h | 4 +- .../recast/DebugUtils/Include/DebugDraw.h | 33 +++-- .../DebugUtils/Include/DetourDebugDraw.h | 24 ++-- .../DebugUtils/Include/RecastDebugDraw.h | 32 +++-- .../recast/DebugUtils/Source/DebugDraw.cpp | 62 +++++---- .../DebugUtils/Source/DetourDebugDraw.cpp | 123 +++++++++-------- .../DebugUtils/Source/RecastDebugDraw.cpp | 82 +++++------ 22 files changed, 441 insertions(+), 326 deletions(-) diff --git a/src/naveditor/ConvexVolumeTool.cpp b/src/naveditor/ConvexVolumeTool.cpp index 17132b82..8e83350c 100644 --- a/src/naveditor/ConvexVolumeTool.cpp +++ b/src/naveditor/ConvexVolumeTool.cpp @@ -261,6 +261,7 @@ void ConvexVolumeTool::handleUpdate(const float /*dt*/) void ConvexVolumeTool::handleRender() { duDebugDraw& dd = m_editor->getDebugDraw(); + const float* drawOffset = m_editor->getDetourDrawOffset(); // Find height extent of the shape. float minh = FLT_MAX, maxh = 0; @@ -269,7 +270,7 @@ void ConvexVolumeTool::handleRender() minh -= m_boxDescent; maxh = minh + m_boxHeight; - dd.begin(DU_DRAW_POINTS, 4.0f); + dd.begin(DU_DRAW_POINTS, 4.0f, drawOffset); for (int i = 0; i < m_npts; ++i) { unsigned int col = duRGBA(255,255,255,255); @@ -279,7 +280,7 @@ void ConvexVolumeTool::handleRender() } dd.end(); - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); for (int i = 0, j = m_nhull-1; i < m_nhull; j = i++) { const float* vi = &m_pts[m_hull[j]*3]; diff --git a/src/naveditor/CrowdTool.cpp b/src/naveditor/CrowdTool.cpp index 88319779..54bcbc64 100644 --- a/src/naveditor/CrowdTool.cpp +++ b/src/naveditor/CrowdTool.cpp @@ -196,12 +196,15 @@ void CrowdToolState::handleRender() dtCrowd* crowd = m_editor->getCrowd(); if (!nav || !crowd) return; + + const float* drawOffset = m_editor->getDetourDrawOffset(); + const unsigned int drawFlags = m_editor->getNavMeshDrawFlags(); if (m_toolParams.m_showNodes && crowd->getPathQueue()) { const dtNavMeshQuery* navquery = crowd->getPathQueue()->getNavQuery(); if (navquery) - duDebugDrawNavMeshNodes(&dd, *navquery); + duDebugDrawNavMeshNodes(&dd, *navquery, drawOffset); } dd.depthMask(false); @@ -219,12 +222,12 @@ void CrowdToolState::handleRender() const dtPolyRef* path = ag->corridor.getPath(); const int npath = ag->corridor.getPathCount(); for (int j = 0; j < npath; ++j) - duDebugDrawNavMeshPoly(&dd, *nav, path[j], duRGBA(255,255,255,24)); + duDebugDrawNavMeshPoly(&dd, *nav, path[j], drawOffset, drawFlags, duRGBA(255,255,255,24)); } } if (m_targetRef) - duDebugDrawCross(&dd, m_targetPos[0],m_targetPos[1],m_targetPos[2]+0.1f, rad, duRGBA(255,255,255,192), 2.0f); + duDebugDrawCross(&dd, m_targetPos[0],m_targetPos[1],m_targetPos[2]+0.1f, rad, duRGBA(255,255,255,192), 2.0f, drawOffset); // Occupancy grid. if (m_toolParams.m_showGrid) @@ -239,7 +242,7 @@ void CrowdToolState::handleRender() } gridz += 1.0f; - dd.begin(DU_DRAW_QUADS); + dd.begin(DU_DRAW_QUADS,1.0f,drawOffset); const dtProximityGrid* grid = crowd->getGrid(); const int* bounds = grid->getBounds(); const float cs = grid->getCellSize(); @@ -269,7 +272,7 @@ void CrowdToolState::handleRender() const AgentTrail* trail = &m_trails[i]; const float* pos = ag->npos; - dd.begin(DU_DRAW_LINES,3.0f); + dd.begin(DU_DRAW_LINES,3.0f,drawOffset); float prev[3], preva = 1; dtVcopy(prev, pos); for (int j = 0; j < AGENT_MAX_TRAIL-1; ++j) @@ -302,7 +305,7 @@ void CrowdToolState::handleRender() { if (ag->ncorners) { - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f,drawOffset); for (int j = 0; j < ag->ncorners; ++j) { const float* va = j == 0 ? agentPos : &ag->cornerVerts[(j-1)*3]; @@ -332,7 +335,7 @@ void CrowdToolState::handleRender() const float* tgt = &ag->cornerVerts[0]; const float z = ag->npos[2]+off; - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); dd.vertex(ag->npos[0],ag->npos[1],z, duRGBA(255,0,0,192)); dd.vertex(pos[0],pos[1],z, duRGBA(255,0,0,192)); @@ -347,11 +350,11 @@ void CrowdToolState::handleRender() if (m_toolParams.m_showCollisionSegments) { const float* center = ag->boundary.getCenter(); - duDebugDrawCross(&dd, center[0],center[1],center[2]+agentRadius, 0.2f, duRGBA(192,0,128,255), 2.0f); + duDebugDrawCross(&dd, center[0],center[1],center[2]+agentRadius, 0.2f, duRGBA(192,0,128,255), 2.0f, drawOffset); duDebugDrawCircle(&dd, center[0],center[1],center[2]+agentRadius, ag->params.collisionQueryRange, - duRGBA(192,0,128,128), 2.0f); + duRGBA(192,0,128,128), 2.0f, drawOffset); - dd.begin(DU_DRAW_LINES, 3.0f); + dd.begin(DU_DRAW_LINES, 3.0f, drawOffset); for (int j = 0; j < ag->boundary.getSegmentCount(); ++j) { const float* s = ag->boundary.getSegment(j); @@ -367,9 +370,9 @@ void CrowdToolState::handleRender() if (m_toolParams.m_showNeis) { duDebugDrawCircle(&dd, agentPos[0],agentPos[1],agentPos[2]+agentRadius, ag->params.collisionQueryRange, - duRGBA(0,192,128,128), 2.0f); + duRGBA(0,192,128,128), 2.0f, drawOffset); - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); for (int j = 0; j < ag->nneis; ++j) { // Get 'n'th active agent. @@ -386,7 +389,7 @@ void CrowdToolState::handleRender() if (m_toolParams.m_showOpt) { - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); dd.vertex(m_agentDebug.optStart[0],m_agentDebug.optStart[1],m_agentDebug.optStart[2]+0.3f, duRGBA(0,128,0,192)); dd.vertex(m_agentDebug.optEnd[0],m_agentDebug.optEnd[1],m_agentDebug.optEnd[2]+0.3f, duRGBA(0,128,0,192)); dd.end(); @@ -406,7 +409,7 @@ void CrowdToolState::handleRender() if (m_agentDebug.idx == i) col = duRGBA(255,0,0,128); - duDebugDrawCircle(&dd, pos[0], pos[1], pos[2], radius, col, 2.0f); + duDebugDrawCircle(&dd, pos[0], pos[1], pos[2], radius, col, 2.0f, drawOffset); } for (int i = 0; i < crowd->getAgentCount(); ++i) @@ -429,7 +432,7 @@ void CrowdToolState::handleRender() col = duLerpCol(col, duRGBA(64,255,0,128), 128); duDebugDrawCylinder(&dd, pos[0]-radius, pos[1]-radius, pos[2]+radius*0.1f, - pos[0]+radius, pos[1]+radius, pos[2]+height, col); + pos[0]+radius, pos[1]+radius, pos[2]+height, col, drawOffset); } if (m_toolParams.m_showVO) @@ -449,9 +452,9 @@ void CrowdToolState::handleRender() const float dy = ag->npos[1]; const float dz = ag->npos[2]+ag->params.height; - duDebugDrawCircle(&dd, dx,dy,dz, ag->params.maxSpeed, duRGBA(255,255,255,64), 2.0f); + duDebugDrawCircle(&dd, dx,dy,dz, ag->params.maxSpeed, duRGBA(255,255,255,64), 2.0f, drawOffset); - dd.begin(DU_DRAW_QUADS); + dd.begin(DU_DRAW_QUADS, 1.0f, drawOffset); for (int j = 0; j < vod->getSampleCount(); ++j) { const float* p = vod->getSampleVelocity(j); @@ -491,15 +494,15 @@ void CrowdToolState::handleRender() else if (ag->targetState == DT_CROWDAGENT_TARGET_VELOCITY) col = duLerpCol(col, duRGBA(64,255,0,192), 128); - duDebugDrawCircle(&dd, pos[0], pos[1], pos[2]+height, radius, col, 2.0f); + duDebugDrawCircle(&dd, pos[0], pos[1], pos[2]+height, radius, col, 2.0f, drawOffset); duDebugDrawArrow(&dd, pos[0],pos[1],pos[2]+height, pos[0]+dvel[0],pos[1]+dvel[1],pos[2]+height+dvel[2], - 0.0f, 30.0f, duRGBA(0,192,255,192), (m_agentDebug.idx == i) ? 2.0f : 1.0f); + 0.0f, 30.0f, duRGBA(0,192,255,192), (m_agentDebug.idx == i) ? 2.0f : 1.0f, drawOffset); duDebugDrawArrow(&dd, pos[0],pos[1],pos[2]+height, pos[0]+vel[0],pos[1]+vel[1],pos[2]+height+vel[2], - 0.0f, 30.0f, duRGBA(0,0,0,160), 2.0f); + 0.0f, 30.0f, duRGBA(0,0,0,160), 2.0f, drawOffset); } dd.depthMask(true); @@ -514,9 +517,10 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view) { GLdouble x, y, z; const int windowHeight = view[3]; + const float* drawOffset = m_editor->getDetourDrawOffset(); // Draw start and end point labels - if (m_targetRef && gluProject((GLdouble)m_targetPos[0], (GLdouble)m_targetPos[1], (GLdouble)m_targetPos[2], + if (m_targetRef && gluProject((GLdouble)m_targetPos[0]+drawOffset[0], (GLdouble)m_targetPos[1]+drawOffset[1], (GLdouble)m_targetPos[2]+drawOffset[2], model, proj, view, &x, &y, &z)) { ImGui_RenderText(ImGuiTextAlign_e::kAlignCenter, @@ -541,7 +545,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view) const dtNode* node = pool->getNodeAtIdx(j+1); if (!node) continue; - if (gluProject((GLdouble)node->pos[0],(GLdouble)node->pos[1],(GLdouble)node->pos[2]+off, + if (gluProject((GLdouble)node->pos[0]+drawOffset[0],(GLdouble)node->pos[1]+drawOffset[1],(GLdouble)node->pos[2]+drawOffset[2]+off, model, proj, view, &x, &y, &z)) { const float heuristic = node->total;// - node->cost; @@ -565,7 +569,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view) if (!ag->active) continue; const float* pos = ag->npos; const float h = ag->params.height; - if (gluProject((GLdouble)pos[0], (GLdouble)pos[1], (GLdouble)pos[2]+h, + if (gluProject((GLdouble)pos[0]+drawOffset[0], (GLdouble)pos[1]+drawOffset[1], (GLdouble)pos[2]+drawOffset[2]+h, model, proj, view, &x, &y, &z)) { const TraverseAnimType_e animType = ag->params.traverseAnimType; @@ -599,7 +603,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view) const dtCrowdAgent* nei = crowd->getAgent(ag->neis[j].idx); if (!nei->active) continue; - if (gluProject((GLdouble)nei->npos[0], (GLdouble)nei->npos[1], (GLdouble)nei->npos[2]+radius, + if (gluProject((GLdouble)nei->npos[0]+drawOffset[0], (GLdouble)nei->npos[1]+drawOffset[1], (GLdouble)nei->npos[2]+drawOffset[2]+radius, model, proj, view, &x, &y, &z)) { ImGui_RenderText(ImGuiTextAlign_e::kAlignCenter, diff --git a/src/naveditor/Editor.cpp b/src/naveditor/Editor.cpp index 304451f2..287e7351 100644 --- a/src/naveditor/Editor.cpp +++ b/src/naveditor/Editor.cpp @@ -19,6 +19,7 @@ #include "Pch.h" #include "Recast/Include/Recast.h" #include "Shared/Include/SharedAssert.h" +#include "Detour/Include/DetourCommon.h" #include "Detour/Include/DetourNavMesh.h" #include "Detour/Include/DetourNavMeshQuery.h" #include "Detour/Include/DetourNavMeshBuilder.h" @@ -32,6 +33,7 @@ #include "game/server/ai_navmesh.h" #include "game/server/ai_hull.h" +#include "coordsize.h" unsigned int EditorDebugDraw::areaToCol(unsigned int area) { @@ -79,6 +81,9 @@ Editor::Editor() : for (int i = 0; i < MAX_TOOLS; i++) m_toolStates[i] = 0; + + dtVset(m_recastDrawOffset, 0.0f,0.0f,20.0f); + dtVset(m_detourDrawOffset, 0.0f,0.0f,30.0f); } Editor::~Editor() @@ -118,11 +123,11 @@ void Editor::handleRender() // Draw mesh duDebugDrawTriMesh(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(), - m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0, 1.0f); + m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0, 1.0f, nullptr); // Draw bounds const float* bmin = m_geom->getMeshBoundsMin(); const float* bmax = m_geom->getMeshBoundsMax(); - duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f); + duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f, nullptr); } void Editor::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/) @@ -369,9 +374,21 @@ void Editor::renderOverlayToolStates(double* proj, double* model, int* view) } } -void Editor::renderNavMeshDebugMenu() +void Editor::renderMeshOffsetOptions() { - ImGui::Text("NavMesh Render Options"); + ImGui::Text("Render Offsets"); + + ImGui::PushItemWidth(230); + + ImGui::SliderFloat3("Recast##RenderOffset", m_recastDrawOffset, -500, 500); + ImGui::SliderFloat3("Detour##RenderOffset", m_detourDrawOffset, -500, 500); + + ImGui::PopItemWidth(); +} + +void Editor::renderDetourDebugMenu() +{ + ImGui::Text("Detour Render Options"); bool isEnabled = (getNavMeshDrawFlags() & DU_DRAWNAVMESH_OFFMESHCONS); diff --git a/src/naveditor/EditorInterfaces.cpp b/src/naveditor/EditorInterfaces.cpp index aaeea3c9..efd2f3e2 100644 --- a/src/naveditor/EditorInterfaces.cpp +++ b/src/naveditor/EditorInterfaces.cpp @@ -1,5 +1,6 @@ #include "Pch.h" #include "Recast/Include/Recast.h" +#include "Detour/Include/DetourCommon.h" #include "DebugUtils/Include/RecastDebugDraw.h" #include "DebugUtils/Include/DetourDebugDraw.h" #include "NavEditor/Include/EditorInterfaces.h" @@ -195,7 +196,7 @@ void DebugDrawGL::texture(bool state) } } -void DebugDrawGL::begin(duDebugDrawPrimitives prim, float size) +void DebugDrawGL::begin(const duDebugDrawPrimitives prim, const float size, const float* offset) { switch (prim) { @@ -214,32 +215,55 @@ void DebugDrawGL::begin(duDebugDrawPrimitives prim, float size) glBegin(GL_QUADS); break; }; + + if (offset) + dtVcopy(m_drawOffset,offset); } void DebugDrawGL::vertex(const float* pos, unsigned int color) { glColor4ubv((GLubyte*)&color); - glVertex3fv(pos); + + float opos[3]; + dtVadd(opos,pos,m_drawOffset); + + glVertex3fv(opos); } void DebugDrawGL::vertex(const float x, const float y, const float z, unsigned int color) { glColor4ubv((GLubyte*)&color); - glVertex3f(x,y,z); + + float opos[3]; + + dtVset(opos, x,y,z); + dtVadd(opos,opos,m_drawOffset); + + glVertex3fv(opos); } void DebugDrawGL::vertex(const float* pos, unsigned int color, const float* uv) { glColor4ubv((GLubyte*)&color); glTexCoord2fv(uv); - glVertex3fv(pos); + + float opos[3]; + dtVadd(opos,pos,m_drawOffset); + + glVertex3fv(opos); } void DebugDrawGL::vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v) { glColor4ubv((GLubyte*)&color); glTexCoord2f(u,v); - glVertex3f(x,y,z); + + float opos[3]; + + dtVset(opos, x,y,z); + dtVadd(opos,opos,m_drawOffset); + + glVertex3fv(opos); } void DebugDrawGL::end() @@ -247,6 +271,8 @@ void DebugDrawGL::end() glEnd(); glLineWidth(1.0f); glPointSize(1.0f); + + dtVset(m_drawOffset, 0.0f,0.0f,0.0f); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/naveditor/Editor_Common.cpp b/src/naveditor/Editor_Common.cpp index 0120a012..58ecd0ba 100644 --- a/src/naveditor/Editor_Common.cpp +++ b/src/naveditor/Editor_Common.cpp @@ -55,7 +55,7 @@ static void EditorCommon_DrawInputGeometry(duDebugDraw* const dd, const InputGeo { duDebugDrawTriMeshSlope(dd, geom->getMesh()->getVerts(), geom->getMesh()->getVertCount(), geom->getMesh()->getTris(), geom->getMesh()->getNormals(), geom->getMesh()->getTriCount(), - maxSlope, textureScale); + maxSlope, textureScale, nullptr); } static void EditorCommon_DrawBoundingBox(duDebugDraw* const dd, const InputGeom* const geom) @@ -63,7 +63,7 @@ static void EditorCommon_DrawBoundingBox(duDebugDraw* const dd, const InputGeom* // Draw bounds const float* const bmin = geom->getNavMeshBoundsMin(); const float* const bmax = geom->getNavMeshBoundsMax(); - duDebugDrawBoxWire(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duRGBA(255, 255, 255, 128), 1.0f); + duDebugDrawBoxWire(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duRGBA(255, 255, 255, 128), 1.0f, nullptr); } static void EditorCommon_DrawTilingGrid(duDebugDraw* const dd, const InputGeom* const geom, const int tileSize, const float cellSize) @@ -78,7 +78,7 @@ static void EditorCommon_DrawTilingGrid(duDebugDraw* const dd, const InputGeom* const int th = (gh + tileSize - 1) / tileSize; const float s = tileSize * cellSize; - duDebugDrawGridXY(dd, bmax[0], bmin[1], bmin[2], tw, th, s, duRGBA(0, 0, 0, 64), 1.0f); + duDebugDrawGridXY(dd, bmax[0], bmin[1], bmin[2], tw, th, s, duRGBA(0, 0, 0, 64), 1.0f, nullptr); } int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom, const int tileSize, @@ -162,9 +162,9 @@ void Editor_StaticTileMeshCommon::cleanup() m_dmesh = 0; } -void Editor_StaticTileMeshCommon::renderTileMeshRenderOptions() +void Editor_StaticTileMeshCommon::renderRecastDebugMenu() { - ImGui::Text("TileMesh Render Options"); + ImGui::Text("Recast Render Options"); bool isEnabled = m_tileMeshDrawFlags & TM_DRAWFLAGS_INPUT_MESH; @@ -271,14 +271,14 @@ void Editor_StaticTileMeshCommon::renderTileMeshRenderOptions() ImGui::EndDisabled(); - if (intermediateDataUnavailable) - { - ImGui::Separator(); + //if (intermediateDataUnavailable) // todo(amos): tool tip + //{ + // ImGui::Separator(); - ImGui::Text("Tick 'Keep Intermediate Results'"); - ImGui::Text("rebuild some tiles to see"); - ImGui::Text("more debug mode options."); - } + // ImGui::Text("Tick 'Keep Intermediate Results'"); + // ImGui::Text("rebuild some tiles to see"); + // ImGui::Text("more debug mode options."); + //} } void Editor_StaticTileMeshCommon::renderTileMeshData() @@ -300,19 +300,26 @@ void Editor_StaticTileMeshCommon::renderTileMeshData() // Tiling grid. EditorCommon_DrawTilingGrid(&m_dd, m_geom, m_tileSize, m_cellSize); + const float* recastDrawOffset = getRecastDrawOffset(); + const float* detourDrawOffset = getDetourDrawOffset(); + + const unsigned int recastDrawFlags = getTileMeshDrawFlags(); + const unsigned int detourDrawFlags = getNavMeshDrawFlags(); + if (m_drawActiveTile) { // Draw active tile - duDebugDrawBoxWire(&m_dd, m_lastBuiltTileBmin[0], m_lastBuiltTileBmin[1], m_lastBuiltTileBmin[2], - m_lastBuiltTileBmax[0], m_lastBuiltTileBmax[1], m_lastBuiltTileBmax[2], m_tileCol, 1.0f); + // NOTE: only perform offset in x-y + duDebugDrawBoxWire(&m_dd, m_lastBuiltTileBmin[0]+detourDrawOffset[0], m_lastBuiltTileBmin[1]+detourDrawOffset[1], m_lastBuiltTileBmin[2], + m_lastBuiltTileBmax[0]+detourDrawOffset[0], m_lastBuiltTileBmax[1]+detourDrawOffset[1], m_lastBuiltTileBmax[2], m_tileCol, 1.0f, nullptr); } if (m_navMesh && m_navQuery) { if (m_tileMeshDrawFlags & TM_DRAWFLAGS_NAVMESH) { - duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags); - duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, EDITOR_POLYFLAGS_DISABLED, duRGBA(0, 0, 0, 128)); + duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, detourDrawOffset, m_navMeshDrawFlags); + duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, EDITOR_POLYFLAGS_DISABLED, detourDrawOffset, detourDrawFlags, duRGBA(0, 0, 0, 128)); } } @@ -320,74 +327,74 @@ void Editor_StaticTileMeshCommon::renderTileMeshData() if (m_chf) { - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_COMPACT) - duDebugDrawCompactHeightfieldSolid(&m_dd, *m_chf); + if (recastDrawFlags & TM_DRAWFLAGS_COMPACT) + duDebugDrawCompactHeightfieldSolid(&m_dd, *m_chf, recastDrawOffset); - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_COMPACT_DISTANCE) - duDebugDrawCompactHeightfieldDistance(&m_dd, *m_chf); - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_COMPACT_REGIONS) - duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf); + if (recastDrawFlags & TM_DRAWFLAGS_COMPACT_DISTANCE) + duDebugDrawCompactHeightfieldDistance(&m_dd, *m_chf, recastDrawOffset); + if (recastDrawFlags & TM_DRAWFLAGS_COMPACT_REGIONS) + duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf, recastDrawOffset); } if (m_solid) { - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_VOXELS) + if (recastDrawFlags & TM_DRAWFLAGS_VOXELS) { glEnable(GL_FOG); - duDebugDrawHeightfieldSolid(&m_dd, *m_solid); + duDebugDrawHeightfieldSolid(&m_dd, *m_solid, recastDrawOffset); glDisable(GL_FOG); } - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_VOXELS_WALKABLE) + if (recastDrawFlags & TM_DRAWFLAGS_VOXELS_WALKABLE) { glEnable(GL_FOG); - duDebugDrawHeightfieldWalkable(&m_dd, *m_solid); + duDebugDrawHeightfieldWalkable(&m_dd, *m_solid, recastDrawOffset); glDisable(GL_FOG); } } if (m_cset) { - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_RAW_CONTOURS) + if (recastDrawFlags & TM_DRAWFLAGS_RAW_CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawRawContours(&m_dd, *m_cset); + duDebugDrawRawContours(&m_dd, *m_cset, recastDrawOffset); glDepthMask(GL_TRUE); } - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_CONTOURS) + if (recastDrawFlags & TM_DRAWFLAGS_CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawContours(&m_dd, *m_cset); + duDebugDrawContours(&m_dd, *m_cset, recastDrawOffset); glDepthMask(GL_TRUE); } } if ((m_chf &&m_cset) && - (getTileMeshDrawFlags() & TM_DRAWFLAGS_REGION_CONNECTIONS)) + (recastDrawFlags & TM_DRAWFLAGS_REGION_CONNECTIONS)) { - duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf); + duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf, recastDrawOffset); glDepthMask(GL_FALSE); - duDebugDrawRegionConnections(&m_dd, *m_cset); + duDebugDrawRegionConnections(&m_dd, *m_cset, recastDrawOffset); glDepthMask(GL_TRUE); } - if (m_pmesh && (getTileMeshDrawFlags() & TM_DRAWFLAGS_POLYMESH)) + if (m_pmesh && (recastDrawFlags & TM_DRAWFLAGS_POLYMESH)) { glDepthMask(GL_FALSE); - duDebugDrawPolyMesh(&m_dd, *m_pmesh); + duDebugDrawPolyMesh(&m_dd, *m_pmesh, recastDrawOffset); glDepthMask(GL_TRUE); } - if (m_dmesh && (getTileMeshDrawFlags() & TM_DRAWFLAGS_POLYMESH_DETAIL)) + if (m_dmesh && (recastDrawFlags & TM_DRAWFLAGS_POLYMESH_DETAIL)) { glDepthMask(GL_FALSE); - duDebugDrawPolyMeshDetail(&m_dd, *m_dmesh); + duDebugDrawPolyMeshDetail(&m_dd, *m_dmesh, recastDrawOffset); glDepthMask(GL_TRUE); } // TODO: also add flags for this - m_geom->drawConvexVolumes(&m_dd); - m_geom->drawOffMeshConnections(&m_dd); + m_geom->drawConvexVolumes(&m_dd, recastDrawOffset); + m_geom->drawOffMeshConnections(&m_dd, recastDrawOffset); if (m_tool) m_tool->handleRender(); @@ -441,7 +448,7 @@ void Editor_StaticTileMeshCommon::renderIntermediateTileMeshOptions() ImGui::Separator(); } -void drawTiles(duDebugDraw* dd, dtTileCache* tc) +void drawTiles(duDebugDraw* dd, dtTileCache* tc, const float* offset) { unsigned int fcol[6]; float bmin[3], bmax[3]; @@ -455,7 +462,7 @@ void drawTiles(duDebugDraw* dd, dtTileCache* tc) const unsigned int col = duIntToCol(i, 64); duCalcBoxColors(fcol, col, col); - duDebugDrawBox(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], fcol); + duDebugDrawBox(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], fcol, offset); } for (int i = 0; i < tc->getTileCount(); ++i) @@ -468,11 +475,11 @@ void drawTiles(duDebugDraw* dd, dtTileCache* tc) const unsigned int col = duIntToCol(i, 255); const float pad = tc->getParams()->cs * 0.1f; duDebugDrawBoxWire(dd, bmin[0] - pad, bmin[1] - pad, bmin[2] - pad, - bmax[0] + pad, bmax[1] + pad, bmax[2] + pad, col, 2.0f); + bmax[0] + pad, bmax[1] + pad, bmax[2] + pad, col, 2.0f, offset); } } -void drawObstacles(duDebugDraw* dd, const dtTileCache* tc) +void drawObstacles(duDebugDraw* dd, const dtTileCache* tc, const float* offset) { // Draw obstacles for (int i = 0; i < tc->getObstacleCount(); ++i) @@ -490,8 +497,8 @@ void drawObstacles(duDebugDraw* dd, const dtTileCache* tc) else if (ob->state == DT_OBSTACLE_REMOVING) col = duRGBA(220, 0, 0, 128); - duDebugDrawCylinder(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], col); - duDebugDrawCylinderWire(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duDarkenCol(col), 2); + duDebugDrawCylinder(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], col, offset); + duDebugDrawCylinderWire(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duDarkenCol(col), 2.0f, offset); } } @@ -510,9 +517,9 @@ Editor_DynamicTileMeshCommon::Editor_DynamicTileMeshCommon() { } -void Editor_DynamicTileMeshCommon::renderTileMeshRenderOptions() +void Editor_DynamicTileMeshCommon::renderRecastRenderOptions() { - ImGui::Text("TileMesh Render Options"); + ImGui::Text("Recast Render Options"); bool isEnabled = m_tileMeshDrawFlags & TM_DRAWFLAGS_INPUT_MESH; @@ -551,10 +558,14 @@ void Editor_DynamicTileMeshCommon::renderTileMeshData() return; const float texScale = 1.0f / (m_cellSize * 10.0f); - const unsigned int drawFlags = getTileMeshDrawFlags(); + const unsigned int recastDrawFlags = getTileMeshDrawFlags(); + const unsigned int detourDrawFlags = getNavMeshDrawFlags(); + + const float* recastDrawOffset = getRecastDrawOffset(); + const float* detourDrawOffset = getDetourDrawOffset(); // Draw input mesh - if (getTileMeshDrawFlags() & TM_DRAWFLAGS_INPUT_MESH) + if (recastDrawFlags & TM_DRAWFLAGS_INPUT_MESH) EditorCommon_DrawInputGeometry(&m_dd, m_geom, m_agentMaxSlope, texScale); // Draw bounds @@ -563,26 +574,24 @@ void Editor_DynamicTileMeshCommon::renderTileMeshData() // Tiling grid. EditorCommon_DrawTilingGrid(&m_dd, m_geom, m_tileSize, m_cellSize); - if (m_tileCache && drawFlags & TM_DRAWFLAGS_TILE_CACHE_BOUNDS) - drawTiles(&m_dd, m_tileCache); + if (m_tileCache && recastDrawFlags & TM_DRAWFLAGS_TILE_CACHE_BOUNDS) + drawTiles(&m_dd, m_tileCache, detourDrawOffset); - if (m_tileCache && drawFlags & TM_DRAWFLAGS_TILE_CACHE_OBSTACLES) - drawObstacles(&m_dd, m_tileCache); - - const bool navMeshRenderingEnabled = (drawFlags & TM_DRAWFLAGS_NAVMESH) != 0; + if (m_tileCache && recastDrawFlags & TM_DRAWFLAGS_TILE_CACHE_OBSTACLES) + drawObstacles(&m_dd, m_tileCache, detourDrawOffset); if (m_navMesh && m_navQuery) { - if (drawFlags & TM_DRAWFLAGS_NAVMESH) + if (recastDrawFlags & TM_DRAWFLAGS_NAVMESH) { - duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags); - duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, EDITOR_POLYFLAGS_DISABLED, duRGBA(0, 0, 0, 128)); + duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, detourDrawOffset, detourDrawFlags); + duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, EDITOR_POLYFLAGS_DISABLED, detourDrawOffset, detourDrawFlags, duRGBA(0, 0, 0, 128)); } } // TODO: also add flags for this - m_geom->drawConvexVolumes(&m_dd); - m_geom->drawOffMeshConnections(&m_dd); + m_geom->drawConvexVolumes(&m_dd, recastDrawOffset); + m_geom->drawOffMeshConnections(&m_dd, recastDrawOffset); if (m_tool) m_tool->handleRender(); diff --git a/src/naveditor/Editor_Debug.cpp b/src/naveditor/Editor_Debug.cpp index 64d0bf77..6eb65cbb 100644 --- a/src/naveditor/Editor_Debug.cpp +++ b/src/naveditor/Editor_Debug.cpp @@ -184,15 +184,15 @@ void Editor_Debug::handleRender() { if (m_chf) { - duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf); -// duDebugDrawCompactHeightfieldSolid(&dd, *m_chf); + duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf, m_recastDrawOffset); +// duDebugDrawCompactHeightfieldSolid(&dd, *m_chf, m_recastRenderOffset); } if (m_navMesh) - duDebugDrawNavMesh(&m_dd, *m_navMesh, DU_DRAWNAVMESH_OFFMESHCONS); + duDebugDrawNavMesh(&m_dd, *m_navMesh, m_detourDrawOffset, DU_DRAWNAVMESH_OFFMESHCONS); if (m_ref && m_navMesh) - duDebugDrawNavMeshPoly(&m_dd, *m_navMesh, m_ref, duRGBA(255,0,0,128)); + duDebugDrawNavMeshPoly(&m_dd, *m_navMesh, m_ref, m_detourDrawOffset, m_navMeshDrawFlags, duRGBA(255,0,0,128)); /* float bmin[3], bmax[3]; rcVsub(bmin, m_center, m_halfExtents); @@ -202,13 +202,13 @@ void Editor_Debug::handleRender() if (m_cset) { - duDebugDrawRawContours(&m_dd, *m_cset, 0.25f); - duDebugDrawContours(&m_dd, *m_cset); + duDebugDrawRawContours(&m_dd, *m_cset, m_recastDrawOffset, 0.25f); + duDebugDrawContours(&m_dd, *m_cset, m_recastDrawOffset); } if (m_pmesh) { - duDebugDrawPolyMesh(&m_dd, *m_pmesh); + duDebugDrawPolyMesh(&m_dd, *m_pmesh, m_recastDrawOffset); } /* diff --git a/src/naveditor/Editor_SoloMesh.cpp b/src/naveditor/Editor_SoloMesh.cpp index b0c2af48..74d92052 100644 --- a/src/naveditor/Editor_SoloMesh.cpp +++ b/src/naveditor/Editor_SoloMesh.cpp @@ -118,9 +118,11 @@ void Editor_SoloMesh::handleTools() void Editor_SoloMesh::handleDebugMode() { - Editor::renderNavMeshDebugMenu(); + Editor::renderMeshOffsetOptions(); ImGui::Separator(); - Editor_StaticTileMeshCommon::renderTileMeshRenderOptions(); + Editor_StaticTileMeshCommon::renderRecastDebugMenu(); + ImGui::Separator(); + Editor::renderDetourDebugMenu(); } void Editor_SoloMesh::handleRender() diff --git a/src/naveditor/Editor_TileMesh.cpp b/src/naveditor/Editor_TileMesh.cpp index b33bd866..11022b65 100644 --- a/src/naveditor/Editor_TileMesh.cpp +++ b/src/naveditor/Editor_TileMesh.cpp @@ -147,6 +147,13 @@ public: { GLdouble x, y, z; const int h = view[3]; + const float* drawOffset = m_editor->getDetourDrawOffset(); + + // NOTE: don't add the render offset here as we want to keep the overlay at the hit position, this + // way we can have the navmesh on the side and hit a specific location on the input geometry, and + // see which tile we build as this will be drawn on the hit position, while we can enumerate all + // the tiles using the debug options in the NavMeshTileTool which will always be aligned with the + // navmesh. if (m_hitPosSet && gluProject((GLdouble)m_hitPos[0], (GLdouble)m_hitPos[1], (GLdouble)m_hitPos[2], model, proj, view, &x, &y, &z)) { @@ -181,7 +188,7 @@ public: rdAssert(0); } - if (gluProject((GLdouble)poly->center[0], (GLdouble)poly->center[1], (GLdouble)poly->center[2] + 30, + if (gluProject((GLdouble)poly->center[0]+drawOffset[0], (GLdouble)poly->center[1]+drawOffset[1], (GLdouble)poly->center[2]+drawOffset[2]+30, model, proj, view, &x, &y, &z)) { ImGui_RenderText(ImGuiTextAlign_e::kAlignCenter, @@ -301,9 +308,11 @@ void Editor_TileMesh::handleTools() void Editor_TileMesh::handleDebugMode() { - Editor::renderNavMeshDebugMenu(); + Editor::renderMeshOffsetOptions(); ImGui::Separator(); - Editor_StaticTileMeshCommon::renderTileMeshRenderOptions(); + Editor_StaticTileMeshCommon::renderRecastDebugMenu(); + ImGui::Separator(); + Editor::renderDetourDebugMenu(); } void Editor_TileMesh::handleRender() @@ -315,9 +324,16 @@ void Editor_TileMesh::handleRenderOverlay(double* proj, double* model, int* view { GLdouble x, y, z; const int h = view[3]; + const float* drawOffset = getDetourDrawOffset(); + + float projectPos[3]; + dtVset(projectPos, + ((m_lastBuiltTileBmin[0]+m_lastBuiltTileBmax[0])/2)+drawOffset[0], + ((m_lastBuiltTileBmin[1]+m_lastBuiltTileBmax[1])/2)+drawOffset[1], + ((m_lastBuiltTileBmin[2]+m_lastBuiltTileBmax[2])/2)+drawOffset[2]); // Draw start and end point labels - if (m_tileBuildTime > 0.0f && gluProject((GLdouble)(m_lastBuiltTileBmin[0]+m_lastBuiltTileBmax[0])/2, (GLdouble)(m_lastBuiltTileBmin[1]+m_lastBuiltTileBmax[1])/2, (GLdouble)(m_lastBuiltTileBmin[2]+m_lastBuiltTileBmax[2])/2, + if (m_tileBuildTime > 0.0f && gluProject((GLdouble)projectPos[0], (GLdouble)projectPos[1], (GLdouble)projectPos[2], model, proj, view, &x, &y, &z)) { ImGui_RenderText(ImGuiTextAlign_e::kAlignCenter, ImVec2((float)x, h-(float)(y-25)), diff --git a/src/naveditor/InputGeom.cpp b/src/naveditor/InputGeom.cpp index 8ebebef2..d3b297a6 100644 --- a/src/naveditor/InputGeom.cpp +++ b/src/naveditor/InputGeom.cpp @@ -560,13 +560,13 @@ void InputGeom::deleteOffMeshConnection(int i) m_offMeshConFlags[i] = m_offMeshConFlags[m_offMeshConCount]; } -void InputGeom::drawOffMeshConnections(duDebugDraw* dd, bool hilight) +void InputGeom::drawOffMeshConnections(duDebugDraw* dd, const float* offset, bool hilight) { unsigned int conColor = duRGBA(192,0,128,192); unsigned int baseColor = duRGBA(0,0,0,64); dd->depthMask(false); - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int i = 0; i < m_offMeshConCount; ++i) { float* v = &m_offMeshConVerts[i*3*2]; @@ -617,11 +617,11 @@ void InputGeom::deleteConvexVolume(int i) m_volumes[i] = m_volumes[m_volumeCount]; } -void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/) +void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, const float* offset, bool /*hilight*/) { dd->depthMask(false); - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < m_volumeCount; ++i) { @@ -654,7 +654,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/) dd->end(); - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int i = 0; i < m_volumeCount; ++i) { const ConvexVolume* vol = &m_volumes[i]; @@ -679,7 +679,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/) } dd->end(); - dd->begin(DU_DRAW_POINTS, 3.0f); + dd->begin(DU_DRAW_POINTS, 3.0f, offset); for (int i = 0; i < m_volumeCount; ++i) { const ConvexVolume* vol = &m_volumes[i]; diff --git a/src/naveditor/NavMeshPruneTool.cpp b/src/naveditor/NavMeshPruneTool.cpp index eff43132..f229d1e7 100644 --- a/src/naveditor/NavMeshPruneTool.cpp +++ b/src/naveditor/NavMeshPruneTool.cpp @@ -285,6 +285,9 @@ void NavMeshPruneTool::handleRender() } const dtNavMesh* nav = m_editor->getNavMesh(); + const float* drawOffset = m_editor->getDetourDrawOffset(); + const unsigned int drawFlags = m_editor->getNavMeshDrawFlags(); + if (m_flags && nav) { for (int i = 0; i < nav->getMaxTiles(); ++i) @@ -297,7 +300,7 @@ void NavMeshPruneTool::handleRender() const dtPolyRef ref = base | (unsigned int)j; if (m_flags->getFlags(ref)) { - duDebugDrawNavMeshPoly(&dd, *nav, ref, duRGBA(255,255,255,128)); + duDebugDrawNavMeshPoly(&dd, *nav, ref, drawOffset, drawFlags, duRGBA(255,255,255,128)); } } } diff --git a/src/naveditor/NavMeshTesterTool.cpp b/src/naveditor/NavMeshTesterTool.cpp index 54cfd02d..d95fbff8 100644 --- a/src/naveditor/NavMeshTesterTool.cpp +++ b/src/naveditor/NavMeshTesterTool.cpp @@ -1092,6 +1092,8 @@ void NavMeshTesterTool::handleRender() const float agentRadius = m_editor->getAgentRadius(); const float agentHeight = m_editor->getAgentHeight(); const float agentClimb = m_editor->getAgentClimb(); + + const unsigned int drawFlags = m_editor->getNavMeshDrawFlags(); dd.depthMask(false); if (m_sposSet) @@ -1105,10 +1107,12 @@ void NavMeshTesterTool::handleRender() return; } + const float* drawOffset = m_editor->getDetourDrawOffset(); + if (m_toolMode == TOOLMODE_PATHFIND_FOLLOW) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, startCol); - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_endRef, endCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, drawOffset, drawFlags, startCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_endRef, drawOffset, drawFlags, endCol); if (m_npolys) { @@ -1116,7 +1120,7 @@ void NavMeshTesterTool::handleRender() { if (m_polys[i] == m_startRef || m_polys[i] == m_endRef) continue; - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], drawOffset, drawFlags, pathCol); } } @@ -1124,7 +1128,7 @@ void NavMeshTesterTool::handleRender() { dd.depthMask(false); const unsigned int spathCol = duRGBA(0,0,0,220); - dd.begin(DU_DRAW_LINES, 3.0f); + dd.begin(DU_DRAW_LINES, 3.0f, drawOffset); for (int i = 0; i < m_nsmoothPath; ++i) dd.vertex(m_smoothPath[i*3], m_smoothPath[i*3+1], m_smoothPath[i*3+2]+0.1f, spathCol); dd.end(); @@ -1133,10 +1137,10 @@ void NavMeshTesterTool::handleRender() if (m_pathIterNum) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_pathIterPolys[0], duRGBA(255,255,255,128)); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_pathIterPolys[0], drawOffset, drawFlags, duRGBA(255,255,255,128)); dd.depthMask(false); - dd.begin(DU_DRAW_LINES, 1.0f); + dd.begin(DU_DRAW_LINES, 1.0f, drawOffset); const unsigned int prevCol = duRGBA(255,192,0,220); const unsigned int curCol = duRGBA(255,255,255,220); @@ -1167,8 +1171,8 @@ void NavMeshTesterTool::handleRender() else if (m_toolMode == TOOLMODE_PATHFIND_STRAIGHT || m_toolMode == TOOLMODE_PATHFIND_SLICED) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, startCol); - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_endRef, endCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, drawOffset, drawFlags, startCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_endRef, drawOffset, drawFlags, endCol); if (m_npolys) { @@ -1176,7 +1180,7 @@ void NavMeshTesterTool::handleRender() { if (m_polys[i] == m_startRef || m_polys[i] == m_endRef) continue; - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], drawOffset, drawFlags, pathCol); } } @@ -1185,7 +1189,7 @@ void NavMeshTesterTool::handleRender() dd.depthMask(false); const unsigned int spathCol = duRGBA(64,16,0,220); const unsigned int offMeshCol = duRGBA(128,96,0,220); - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); for (int i = 0; i < m_nstraightPath-1; ++i) { unsigned int col; @@ -1198,7 +1202,7 @@ void NavMeshTesterTool::handleRender() dd.vertex(m_straightPath[(i+1)*3], m_straightPath[(i+1)*3+1], m_straightPath[(i+1)*3+2] + 0.4f, col); } dd.end(); - dd.begin(DU_DRAW_POINTS, 6.0f); + dd.begin(DU_DRAW_POINTS, 6.0f, drawOffset); for (int i = 0; i < m_nstraightPath; ++i) { unsigned int col; @@ -1218,23 +1222,23 @@ void NavMeshTesterTool::handleRender() } else if (m_toolMode == TOOLMODE_RAYCAST) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, startCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, drawOffset, drawFlags, startCol); if (m_nstraightPath) { for (int i = 1; i < m_npolys; ++i) - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], drawOffset, drawFlags, pathCol); dd.depthMask(false); const unsigned int spathCol = m_hitResult ? duRGBA(64,16,0,220) : duRGBA(240,240,240,220); - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); for (int i = 0; i < m_nstraightPath-1; ++i) { dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1], m_straightPath[i*3+2] + 0.4f, spathCol); dd.vertex(m_straightPath[(i+1)*3], m_straightPath[(i+1)*3+1], m_straightPath[(i+1)*3+2] + 0.4f, spathCol); } dd.end(); - dd.begin(DU_DRAW_POINTS, 4.0f); + dd.begin(DU_DRAW_POINTS, 4.0f, drawOffset); for (int i = 0; i < m_nstraightPath; ++i) dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1], m_straightPath[i*3+2] + 0.4f, spathCol); dd.end(); @@ -1242,7 +1246,7 @@ void NavMeshTesterTool::handleRender() if (m_hitResult) { const unsigned int hitCol = duRGBA(0,0,0,128); - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); dd.vertex(m_hitPos[0],m_hitPos[1],m_hitPos[2]+0.4f,hitCol); dd.vertex(m_hitPos[0]+m_hitNormal[0]*agentRadius, m_hitPos[1]+m_hitNormal[1]*agentRadius, @@ -1254,10 +1258,10 @@ void NavMeshTesterTool::handleRender() } else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, startCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_startRef, drawOffset, drawFlags, startCol); dd.depthMask(false); - duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, m_distanceToWall, duRGBA(64,16,0,220), 2.0f); - dd.begin(DU_DRAW_LINES, 3.0f); + duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, m_distanceToWall, duRGBA(64,16,0,220), 2.0f, drawOffset); + dd.begin(DU_DRAW_LINES, 3.0f, drawOffset); dd.vertex(m_hitPos[0], m_hitPos[1] , m_hitPos[2] + 0.02f, duRGBA(0,0,0,192)); dd.vertex(m_hitPos[0], m_hitPos[1] , m_hitPos[2] + agentHeight, duRGBA(0,0,0,192)); dd.end(); @@ -1267,7 +1271,7 @@ void NavMeshTesterTool::handleRender() { for (int i = 0; i < m_npolys; ++i) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], drawOffset, drawFlags, pathCol); dd.depthMask(false); if (m_parent[i]) { @@ -1275,7 +1279,7 @@ void NavMeshTesterTool::handleRender() dd.depthMask(false); getPolyCenter(m_navMesh, m_parent[i], p0); getPolyCenter(m_navMesh, m_polys[i], p1); - duDebugDrawArc(&dd, p0[0],p0[1],p0[2], p1[0],p1[1],p1[2], 0.25f, 0.0f, 30.0f, duRGBA(0,0,0,128), 2.0f); + duDebugDrawArc(&dd, p0[0],p0[1],p0[2], p1[0],p1[1],p1[2], 0.25f, 0.0f, 30.0f, duRGBA(0,0,0,128), 2.0f, drawOffset); dd.depthMask(true); } dd.depthMask(true); @@ -1287,7 +1291,7 @@ void NavMeshTesterTool::handleRender() const float dx = m_epos[0] - m_spos[0]; const float dy = m_epos[1] - m_spos[1]; const float dist = sqrtf(dx*dx + dy*dy); - duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, dist, duRGBA(64,16,0,220), 2.0f); + duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, dist, duRGBA(64,16,0,220), 2.0f, drawOffset); dd.depthMask(true); } } @@ -1295,7 +1299,7 @@ void NavMeshTesterTool::handleRender() { for (int i = 0; i < m_npolys; ++i) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], drawOffset, drawFlags, pathCol); dd.depthMask(false); if (m_parent[i]) { @@ -1303,7 +1307,7 @@ void NavMeshTesterTool::handleRender() dd.depthMask(false); getPolyCenter(m_navMesh, m_parent[i], p0); getPolyCenter(m_navMesh, m_polys[i], p1); - duDebugDrawArc(&dd, p0[0],p0[1],p0[2], p1[0],p1[1],p1[2], 0.25f, 0.0f, 30.0f, duRGBA(0,0,0,128), 2.0f); + duDebugDrawArc(&dd, p0[0],p0[1],p0[2], p1[0],p1[1],p1[2], 0.25f, 0.0f, 30.0f, duRGBA(0,0,0,128), 2.0f, drawOffset); dd.depthMask(true); } dd.depthMask(true); @@ -1313,7 +1317,7 @@ void NavMeshTesterTool::handleRender() { dd.depthMask(false); const unsigned int col = duRGBA(64,16,0,220); - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); for (int i = 0, j = 3; i < 4; j=i++) { const float* p0 = &m_queryPoly[j*3]; @@ -1329,7 +1333,7 @@ void NavMeshTesterTool::handleRender() { for (int i = 0; i < m_npolys; ++i) { - duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol); + duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], drawOffset, drawFlags, pathCol); dd.depthMask(false); if (m_parent[i]) { @@ -1337,7 +1341,7 @@ void NavMeshTesterTool::handleRender() dd.depthMask(false); getPolyCenter(m_navMesh, m_parent[i], p0); getPolyCenter(m_navMesh, m_polys[i], p1); - duDebugDrawArc(&dd, p0[0],p0[1],p0[2], p1[0],p1[1],p1[2], 0.25f, 0.0f, 30.0f, duRGBA(0,0,0,128), 2.0f); + duDebugDrawArc(&dd, p0[0],p0[1],p0[2], p1[0],p1[1],p1[2], 0.25f, 0.0f, 30.0f, duRGBA(0,0,0,128), 2.0f, drawOffset); dd.depthMask(true); } @@ -1347,7 +1351,7 @@ void NavMeshTesterTool::handleRender() memset(refs, 0, sizeof(dtPolyRef)*MAX_SEGS); int nsegs = 0; m_navQuery->getPolyWallSegments(m_polys[i], &m_filter, segs, refs, &nsegs, MAX_SEGS); - dd.begin(DU_DRAW_LINES, 2.0f); + dd.begin(DU_DRAW_LINES, 2.0f, drawOffset); for (int j = 0; j < nsegs; ++j) { const float* s = &segs[j*6]; @@ -1395,14 +1399,14 @@ void NavMeshTesterTool::handleRender() if (m_sposSet) { dd.depthMask(false); - duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, m_neighbourhoodRadius, duRGBA(64,16,0,220), 2.0f); + duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, m_neighbourhoodRadius, duRGBA(64,16,0,220), 2.0f, drawOffset); dd.depthMask(true); } } if (m_nrandPoints > 0) { - dd.begin(DU_DRAW_POINTS, 6.0f); + dd.begin(DU_DRAW_POINTS, 6.0f, drawOffset); for (int i = 0; i < m_nrandPoints; i++) { const float* p = &m_randPoints[i*3]; @@ -1412,7 +1416,7 @@ void NavMeshTesterTool::handleRender() if (m_randPointsInCircle && m_sposSet) { - duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, m_randomRadius, duRGBA(64,16,0,220), 2.0f); + duDebugDrawCircle(&dd, m_spos[0], m_spos[1], m_spos[2] + agentHeight / 2, m_randomRadius, duRGBA(64,16,0,220), 2.0f, drawOffset); } } } @@ -1421,15 +1425,16 @@ void NavMeshTesterTool::handleRenderOverlay(double* proj, double* model, int* vi { GLdouble x, y, z; const int h = view[3]; + const float* drawOffset = m_editor->getDetourDrawOffset(); // Draw start and end point labels - if (m_sposSet && gluProject((GLdouble)m_spos[0], (GLdouble)m_spos[1], (GLdouble)m_spos[2], + if (m_sposSet && gluProject((GLdouble)m_spos[0]+drawOffset[0], (GLdouble)m_spos[1]+drawOffset[1], (GLdouble)m_spos[2]+drawOffset[2], model, proj, view, &x, &y, &z)) { ImGui_RenderText(ImGuiTextAlign_e::kAlignCenter, ImVec2((float)x, h-((float)y-25)), ImVec4(0,0,0,0.8f), "Start"); } - if (m_eposSet && gluProject((GLdouble)m_epos[0], (GLdouble)m_epos[1], (GLdouble)m_epos[2], + if (m_eposSet && gluProject((GLdouble)m_epos[0]+drawOffset[0], (GLdouble)m_epos[1]+drawOffset[1], (GLdouble)m_epos[2]+drawOffset[2], model, proj, view, &x, &y, &z)) { ImGui_RenderText(ImGuiTextAlign_e::kAlignCenter, @@ -1446,14 +1451,16 @@ void NavMeshTesterTool::drawAgent(const float* pos, float r, float h, float c, c duDebugDraw& dd = m_editor->getDebugDraw(); dd.depthMask(false); + + const float* drawOffset = m_editor->getDetourDrawOffset(); // Agent dimensions. - duDebugDrawCylinderWire(&dd, pos[0]-r, pos[1]-r, pos[2]+0.02f, pos[0]+r, pos[1]+r, pos[2]+h, col, 2.0f); + duDebugDrawCylinderWire(&dd, pos[0]-r, pos[1]-r, pos[2]+0.02f, pos[0]+r, pos[1]+r, pos[2]+h, col, 2.0f, drawOffset); - duDebugDrawCircle(&dd, pos[0],pos[1],pos[2] + c,r,duRGBA(0,0,0,64),1.0f); + duDebugDrawCircle(&dd, pos[0],pos[1],pos[2] + c,r,duRGBA(0,0,0,64),1.0f, drawOffset); unsigned int colb = duRGBA(0,0,0,196); - dd.begin(DU_DRAW_LINES); + dd.begin(DU_DRAW_LINES, 1.0f, drawOffset); dd.vertex(pos[0],pos[1],pos[2]-c,colb); dd.vertex(pos[0],pos[1],pos[2]+c,colb); dd.vertex(pos[0]-r/2,pos[1],pos[2]+0.02f,colb); diff --git a/src/naveditor/OffMeshConnectionTool.cpp b/src/naveditor/OffMeshConnectionTool.cpp index d031e8ea..ea3fc68e 100644 --- a/src/naveditor/OffMeshConnectionTool.cpp +++ b/src/naveditor/OffMeshConnectionTool.cpp @@ -138,11 +138,11 @@ void OffMeshConnectionTool::handleRender() const float s = m_editor->getAgentRadius(); if (m_hitPosSet) - duDebugDrawCross(&dd, m_hitPos[0],m_hitPos[1],m_hitPos[2]+0.1f, s, duRGBA(0,0,0,128), 2.0f); + duDebugDrawCross(&dd, m_hitPos[0],m_hitPos[1],m_hitPos[2]+0.1f, s, duRGBA(0,0,0,128), 2.0f, nullptr); InputGeom* geom = m_editor->getInputGeom(); if (geom) - geom->drawOffMeshConnections(&dd, true); + geom->drawOffMeshConnections(&dd, m_editor->getRecastDrawOffset(), true); } void OffMeshConnectionTool::handleRenderOverlay(double* proj, double* model, int* view) diff --git a/src/naveditor/include/Editor.h b/src/naveditor/include/Editor.h index 8a4cce0c..31900bb9 100644 --- a/src/naveditor/include/Editor.h +++ b/src/naveditor/include/Editor.h @@ -146,6 +146,8 @@ protected: BuildContext* m_ctx; EditorDebugDraw m_dd; + float m_recastDrawOffset[3]; + float m_detourDrawOffset[3]; dtNavMesh* loadAll(std::string path); void saveAll(std::string path, const dtNavMesh* mesh); @@ -163,6 +165,8 @@ public: void setToolState(int type, EditorToolState* s) { m_toolStates[type] = s; } EditorDebugDraw& getDebugDraw() { return m_dd; } + const float* getRecastDrawOffset() const { return m_recastDrawOffset; } + const float* getDetourDrawOffset() const { return m_detourDrawOffset; } virtual void handleSettings(); virtual void handleTools(); @@ -199,7 +203,8 @@ public: void renderToolStates(); void renderOverlayToolStates(double* proj, double* model, int* view); - void renderNavMeshDebugMenu(); + void renderMeshOffsetOptions(); + void renderDetourDebugMenu(); void renderIntermediateTileMeshOptions(); void selectNavMeshType(const NavMeshType_e navMeshType); diff --git a/src/naveditor/include/EditorInterfaces.h b/src/naveditor/include/EditorInterfaces.h index ad344f06..63d0da40 100644 --- a/src/naveditor/include/EditorInterfaces.h +++ b/src/naveditor/include/EditorInterfaces.h @@ -67,12 +67,15 @@ class DebugDrawGL : public duDebugDraw public: virtual void depthMask(bool state); virtual void texture(bool state); - virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f); + virtual void begin(const duDebugDrawPrimitives prim, const float size = 1.0f, const float* offset = 0); virtual void vertex(const float* pos, unsigned int color); virtual void vertex(const float x, const float y, const float z, unsigned int color); virtual void vertex(const float* pos, unsigned int color, const float* uv); virtual void vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v); virtual void end(); + +private: + float m_drawOffset[3]; }; /// stdio file implementation. diff --git a/src/naveditor/include/Editor_Common.h b/src/naveditor/include/Editor_Common.h index 9e73ad61..1a8eb3c8 100644 --- a/src/naveditor/include/Editor_Common.h +++ b/src/naveditor/include/Editor_Common.h @@ -45,7 +45,7 @@ public: Editor_StaticTileMeshCommon(); void cleanup(); - void renderTileMeshRenderOptions(); + void renderRecastDebugMenu(); void renderTileMeshData(); void renderIntermediateTileMeshOptions(); @@ -82,7 +82,7 @@ class Editor_DynamicTileMeshCommon : public Editor public: Editor_DynamicTileMeshCommon(); - void renderTileMeshRenderOptions(); + void renderRecastRenderOptions(); void renderTileMeshData(); inline unsigned int getTileMeshDrawFlags() const { return m_tileMeshDrawFlags; } diff --git a/src/naveditor/include/InputGeom.h b/src/naveditor/include/InputGeom.h index 37e2518a..c542df0b 100644 --- a/src/naveditor/include/InputGeom.h +++ b/src/naveditor/include/InputGeom.h @@ -133,7 +133,7 @@ public: void addOffMeshConnection(const float* spos, const float* epos, const float rad, unsigned char bidir, unsigned char area, unsigned short flags); void deleteOffMeshConnection(int i); - void drawOffMeshConnections(struct duDebugDraw* dd, bool hilight = false); + void drawOffMeshConnections(struct duDebugDraw* dd, const float* offset, bool hilight = false); ///@} /// @name Box Volumes. @@ -143,7 +143,7 @@ public: void addConvexVolume(const float* verts, const int nverts, const float minh, const float maxh, unsigned char area); void deleteConvexVolume(int i); - void drawConvexVolumes(struct duDebugDraw* dd, bool hilight = false); + void drawConvexVolumes(struct duDebugDraw* dd, const float* offset, bool hilight = false); ///@} private: diff --git a/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h b/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h index e62def56..e9627c7d 100644 --- a/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h +++ b/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h @@ -42,7 +42,7 @@ struct duDebugDraw /// Begin drawing primitives. /// @param prim [in] primitive type to draw, one of rcDebugDrawPrimitives. /// @param size [in] size of a primitive, applies to point size and line width only. - virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f) = 0; + virtual void begin(const duDebugDrawPrimitives prim, const float size = 1.0f, const float* offset = 0) = 0; /// Submit a vertex /// @param pos [in] position of the verts. @@ -129,37 +129,41 @@ inline unsigned int duTransCol(unsigned int c, unsigned int a) void duCalcBoxColors(unsigned int* colors, unsigned int colTop, unsigned int colSide); void duDebugDrawCylinderWire(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, unsigned int col, const float lineWidth); + float maxx, float maxy, float maxz, unsigned int col, + const float lineWidth, const float* offset); void duDebugDrawBoxWire(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, unsigned int col, const float lineWidth); + float maxx, float maxy, float maxz, unsigned int col, + const float lineWidth, const float* offset); void duDebugDrawArc(struct duDebugDraw* dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float h, - const float as0, const float as1, unsigned int col, const float lineWidth); + const float as0, const float as1, unsigned int col, + const float lineWidth, const float* offset); void duDebugDrawArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, - const float as0, const float as1, unsigned int col, const float lineWidth); + const float as0, const float as1, unsigned int col, + const float lineWidth, const float* offset); void duDebugDrawCircle(struct duDebugDraw* dd, const float x, const float y, const float z, - const float r, unsigned int col, const float lineWidth); + const float r, unsigned int col, const float lineWidth, const float* offset); void duDebugDrawCross(struct duDebugDraw* dd, const float x, const float y, const float z, - const float size, unsigned int col, const float lineWidth); + const float size, unsigned int col, const float lineWidth, const float* offset); void duDebugDrawBox(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, const unsigned int* fcol); + float maxx, float maxy, float maxz, const unsigned int* fcol, const float* offset); void duDebugDrawCylinder(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, unsigned int col); + float maxx, float maxy, float maxz, unsigned int col, const float* offset); void duDebugDrawGridXZ(struct duDebugDraw* dd, const float ox, const float oy, const float oz, const int w, const int h, const float size, - const unsigned int col, const float lineWidth); + const unsigned int col, const float lineWidth, const float* offset); void duDebugDrawGridXY(struct duDebugDraw* dd, const float ox, const float oy, const float oz, const int w, const int h, const float size, - const unsigned int col, const float lineWidth); + const unsigned int col, const float lineWidth, const float* offset); // Versions without begin/end, can be used to draw multiple primitives. void duAppendCylinderWire(struct duDebugDraw* dd, float minx, float miny, float minz, @@ -196,12 +200,15 @@ class duDisplayList : public duDebugDraw { float* m_pos; unsigned int* m_color; + int m_size; int m_cap; - bool m_depthMask; duDebugDrawPrimitives m_prim; float m_primSize; + + float m_drawOffset[3]; + bool m_depthMask; void resize(int cap); @@ -209,7 +216,7 @@ public: duDisplayList(int cap = 512); ~duDisplayList(); virtual void depthMask(bool state); - virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f); + virtual void begin(const duDebugDrawPrimitives prim, const float size = 1.0f, const float* offset = 0); virtual void vertex(const float x, const float y, const float z, unsigned int color); virtual void vertex(const float* pos, unsigned int color); virtual void end(); diff --git a/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h b/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h index 5e405a6e..7243ec68 100644 --- a/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h +++ b/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h @@ -40,19 +40,21 @@ enum DrawNavMeshFlags DU_DRAWNAVMESH_ALPHA = 1 << 12, // Use transparency. }; -void duDebugDrawNavMesh(struct duDebugDraw* dd, const dtNavMesh& mesh, unsigned int flags); -void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, unsigned int flags); -void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query); -void duDebugDrawNavMeshBVTree(struct duDebugDraw* dd, const dtNavMesh& mesh); -void duDebugDrawNavMeshPortals(struct duDebugDraw* dd, const dtNavMesh& mesh); -void duDebugDrawNavMeshPolysWithFlags(struct duDebugDraw* dd, const dtNavMesh& mesh, const unsigned short polyFlags, const unsigned int col); -void duDebugDrawNavMeshPoly(struct duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef ref, const unsigned int col); +void duDebugDrawNavMesh(struct duDebugDraw* dd, const dtNavMesh& mesh, const float* offset, unsigned int flags); +void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, const float* offset, unsigned int flags); +void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query, const float* offset); +void duDebugDrawNavMeshBVTree(struct duDebugDraw* dd, const dtNavMesh& mesh, const float* offset); +void duDebugDrawNavMeshPortals(struct duDebugDraw* dd, const dtNavMesh& mesh, const float* offset); +void duDebugDrawNavMeshPolysWithFlags(struct duDebugDraw* dd, const dtNavMesh& mesh, const unsigned short polyFlags, const float* offset, + const unsigned int drawFlags, const unsigned int col); +void duDebugDrawNavMeshPoly(struct duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef ref, const float* offset, + const unsigned int drawFlags, const unsigned int col); -void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch); -void duDebugDrawTileCacheLayerRegions(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch); +void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch, const float* offset); +void duDebugDrawTileCacheLayerRegions(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch, const float* offset); void duDebugDrawTileCacheContours(duDebugDraw* dd, const struct dtTileCacheContourSet& lcset, - const float* orig, const float cs, const float ch); + const float* orig, const float cs, const float ch, const float* offset); void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyMesh& lmesh, - const float* orig, const float cs, const float ch); + const float* orig, const float cs, const float ch, const float* offset); #endif // DETOURDEBUGDRAW_H diff --git a/src/thirdparty/recast/DebugUtils/Include/RecastDebugDraw.h b/src/thirdparty/recast/DebugUtils/Include/RecastDebugDraw.h index 6a55fa64..8e033799 100644 --- a/src/thirdparty/recast/DebugUtils/Include/RecastDebugDraw.h +++ b/src/thirdparty/recast/DebugUtils/Include/RecastDebugDraw.h @@ -19,24 +19,26 @@ #ifndef RECAST_DEBUGDRAW_H #define RECAST_DEBUGDRAW_H -void duDebugDrawTriMesh(struct duDebugDraw* dd, const float* verts, int nverts, const int* tris, const float* normals, int ntris, const unsigned char* flags, const float texScale); -void duDebugDrawTriMeshSlope(struct duDebugDraw* dd, const float* verts, int nverts, const int* tris, const float* normals, int ntris, const float walkableSlopeAngle, const float texScale); +void duDebugDrawTriMesh(struct duDebugDraw* dd, const float* verts, int nverts, const int* tris, const float* normals, int ntris, + const unsigned char* flags, const float texScale, const float* offset); +void duDebugDrawTriMeshSlope(struct duDebugDraw* dd, const float* verts, int nverts, const int* tris, const float* normals, int ntris, + const float walkableSlopeAngle, const float texScale, const float* offset); -void duDebugDrawHeightfieldSolid(struct duDebugDraw* dd, const struct rcHeightfield& hf); -void duDebugDrawHeightfieldWalkable(struct duDebugDraw* dd, const struct rcHeightfield& hf); +void duDebugDrawHeightfieldSolid(struct duDebugDraw* dd, const struct rcHeightfield& hf, const float* offset); +void duDebugDrawHeightfieldWalkable(struct duDebugDraw* dd, const struct rcHeightfield& hf, const float* offset); -void duDebugDrawCompactHeightfieldSolid(struct duDebugDraw* dd, const struct rcCompactHeightfield& chf); -void duDebugDrawCompactHeightfieldRegions(struct duDebugDraw* dd, const struct rcCompactHeightfield& chf); -void duDebugDrawCompactHeightfieldDistance(struct duDebugDraw* dd, const struct rcCompactHeightfield& chf); +void duDebugDrawCompactHeightfieldSolid(struct duDebugDraw* dd, const struct rcCompactHeightfield& chf, const float* offset); +void duDebugDrawCompactHeightfieldRegions(struct duDebugDraw* dd, const struct rcCompactHeightfield& chf, const float* offset); +void duDebugDrawCompactHeightfieldDistance(struct duDebugDraw* dd, const struct rcCompactHeightfield& chf, const float* offset); -void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLayer& layer, const int idx); -void duDebugDrawHeightfieldLayers(duDebugDraw* dd, const struct rcHeightfieldLayerSet& lset); -void duDebugDrawHeightfieldLayersRegions(duDebugDraw* dd, const struct rcHeightfieldLayerSet& lset); +void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLayer& layer, const int idx, const float* offset); +void duDebugDrawHeightfieldLayers(duDebugDraw* dd, const struct rcHeightfieldLayerSet& lset, const float* offset); +void duDebugDrawHeightfieldLayersRegions(duDebugDraw* dd, const struct rcHeightfieldLayerSet& lset, const float* offset); -void duDebugDrawRegionConnections(struct duDebugDraw* dd, const struct rcContourSet& cset, const float alpha = 1.0f); -void duDebugDrawRawContours(struct duDebugDraw* dd, const struct rcContourSet& cset, const float alpha = 1.0f); -void duDebugDrawContours(struct duDebugDraw* dd, const struct rcContourSet& cset, const float alpha = 1.0f); -void duDebugDrawPolyMesh(struct duDebugDraw* dd, const struct rcPolyMesh& mesh); -void duDebugDrawPolyMeshDetail(struct duDebugDraw* dd, const struct rcPolyMeshDetail& dmesh); +void duDebugDrawRegionConnections(struct duDebugDraw* dd, const struct rcContourSet& cset, const float* offset, const float alpha = 1.0f); +void duDebugDrawRawContours(struct duDebugDraw* dd, const struct rcContourSet& cset, const float* offset, const float alpha = 1.0f); +void duDebugDrawContours(struct duDebugDraw* dd, const struct rcContourSet& cset, const float* offset, const float alpha = 1.0f); +void duDebugDrawPolyMesh(struct duDebugDraw* dd, const struct rcPolyMesh& mesh, const float* offset); +void duDebugDrawPolyMeshDetail(struct duDebugDraw* dd, const struct rcPolyMeshDetail& dmesh, const float* offset); #endif // RECAST_DEBUGDRAW_H diff --git a/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp index 1dc8796d..d5600ff4 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp @@ -19,6 +19,7 @@ #define _USE_MATH_DEFINES #include #include "DebugUtils/Include/DebugDraw.h" +#include "Detour/Include/DetourCommon.h" #include "Detour/Include/DetourMath.h" #include "Detour/Include/DetourNavMesh.h" @@ -77,94 +78,98 @@ void duCalcBoxColors(unsigned int* colors, unsigned int colTop, unsigned int col } void duDebugDrawCylinderWire(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, unsigned int col, const float lineWidth) + float maxx, float maxy, float maxz, unsigned int col, + const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); duAppendCylinderWire(dd, minx,miny,minz, maxx,maxy,maxz, col); dd->end(); } void duDebugDrawBoxWire(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, unsigned int col, const float lineWidth) + float maxx, float maxy, float maxz, unsigned int col, + const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); duAppendBoxWire(dd, minx,miny,minz, maxx,maxy,maxz, col); dd->end(); } void duDebugDrawArc(struct duDebugDraw* dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float h, - const float as0, const float as1, unsigned int col, const float lineWidth) + const float as0, const float as1, unsigned int col, + const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); duAppendArc(dd, x0,y0,z0, x1,y1,z1, h, as0, as1, col); dd->end(); } void duDebugDrawArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, - const float as0, const float as1, unsigned int col, const float lineWidth) + const float as0, const float as1, unsigned int col, + const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); duAppendArrow(dd, x0,y0,z0, x1,y1,z1, as0, as1, col); dd->end(); } void duDebugDrawCircle(struct duDebugDraw* dd, const float x, const float y, const float z, - const float r, unsigned int col, const float lineWidth) + const float r, unsigned int col, const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); duAppendCircle(dd, x,y,z, r, col); dd->end(); } void duDebugDrawCross(struct duDebugDraw* dd, const float x, const float y, const float z, - const float size, unsigned int col, const float lineWidth) + const float size, unsigned int col, const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); duAppendCross(dd, x,y,z, size, col); dd->end(); } void duDebugDrawBox(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, const unsigned int* fcol) + float maxx, float maxy, float maxz, const unsigned int* fcol, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); duAppendBox(dd, minx,miny,minz, maxx,maxy,maxz, fcol); dd->end(); } void duDebugDrawCylinder(struct duDebugDraw* dd, float minx, float miny, float minz, - float maxx, float maxy, float maxz, unsigned int col) + float maxx, float maxy, float maxz, unsigned int col, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); duAppendCylinder(dd, minx,miny,minz, maxx,maxy,maxz, col); dd->end(); } void duDebugDrawGridXZ(struct duDebugDraw* dd, const float ox, const float oy, const float oz, const int w, const int h, const float size, - const unsigned int col, const float lineWidth) + const unsigned int col, const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); for (int i = 0; i <= h; ++i) { dd->vertex(ox,oy,oz+i*size, col); @@ -180,11 +185,11 @@ void duDebugDrawGridXZ(struct duDebugDraw* dd, const float ox, const float oy, c void duDebugDrawGridXY(struct duDebugDraw* dd, const float ox, const float oy, const float oz, const int w, const int h, const float size, - const unsigned int col, const float lineWidth) + const unsigned int col, const float lineWidth, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_LINES, lineWidth); + dd->begin(DU_DRAW_LINES, lineWidth, offset); for (int i = 0; i <= h; ++i) { dd->vertex(ox,oy+i*size,oz, col); @@ -541,17 +546,18 @@ void duAppendCross(struct duDebugDraw* dd, const float x, const float y, const f } duDisplayList::duDisplayList(int cap) : + m_prim(DU_DRAW_LINES), + m_primSize(1.0f), m_pos(0), m_color(0), m_size(0), m_cap(0), - m_depthMask(true), - m_prim(DU_DRAW_LINES), - m_primSize(1.0f) + m_depthMask(true) { if (cap < 8) cap = 8; resize(cap); + dtVset(m_drawOffset, 0.0f,0.0f,0.0f); } duDisplayList::~duDisplayList() @@ -587,11 +593,13 @@ void duDisplayList::depthMask(bool state) m_depthMask = state; } -void duDisplayList::begin(duDebugDrawPrimitives prim, float size) +void duDisplayList::begin(const duDebugDrawPrimitives prim, const float size, const float* offset) { clear(); m_prim = prim; m_primSize = size; + if (offset) + dtVcopy(m_drawOffset, offset); } void duDisplayList::vertex(const float x, const float y, const float z, unsigned int color) @@ -599,9 +607,8 @@ void duDisplayList::vertex(const float x, const float y, const float z, unsigned if (m_size+1 >= m_cap) resize(m_cap*2); float* p = &m_pos[m_size*3]; - p[0] = x; - p[1] = y; - p[2] = z; + dtVset(p,x,y,z); + dtVadd(p,p,m_drawOffset); m_color[m_size] = color; m_size++; } @@ -613,6 +620,7 @@ void duDisplayList::vertex(const float* pos, unsigned int color) void duDisplayList::end() { + dtVset(m_drawOffset, 0.0f,0.0f,0.0f); } void duDisplayList::draw(struct duDebugDraw* dd) diff --git a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp index 396d2954..2191bb61 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp @@ -46,11 +46,11 @@ static void drawOffMeshConnectionRefPosition(duDebugDraw* dd, const dtOffMeshCon } static void drawPolyBoundaries(duDebugDraw* dd, const dtMeshTile* tile, - const float linew, bool inner) + const float linew, const float* offset, bool inner) { static const float thr = 0.01f*0.01f; - dd->begin(DU_DRAW_LINES, linew); + dd->begin(DU_DRAW_LINES, linew, offset); for (int i = 0; i < tile->header->polyCount; ++i) { @@ -124,17 +124,17 @@ static void drawPolyBoundaries(duDebugDraw* dd, const dtMeshTile* tile, dd->end(); } -static void drawPolyCenters(duDebugDraw* dd, const dtMeshTile* tile, const unsigned int col, const float linew) +static void drawPolyCenters(duDebugDraw* dd, const dtMeshTile* tile, const unsigned int col, const float linew, const float* offset) { for (int i = 0; i < tile->header->polyCount; ++i) { const dtPoly* p = &tile->polys[i]; - duDebugDrawCross(dd, p->center[0], p->center[1], p->center[2], 3.0f, col, linew); + duDebugDrawCross(dd, p->center[0], p->center[1], p->center[2], 3.0f, col, linew, offset); } } static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery* query, - const dtMeshTile* tile, unsigned int flags) + const dtMeshTile* tile, const float* offset, unsigned int flags) { // If the "Alpha" flag isn't set, force the colour to be opaque instead of semi-transparent. const int tileAlpha = flags & DU_DRAWNAVMESH_ALPHA ? 170 : 255; @@ -144,7 +144,7 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh dd->depthMask(depthTest); - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < tile->header->polyCount; ++i) { const dtPoly* p = &tile->polys[i]; @@ -182,19 +182,19 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh // Draw inner poly boundaries if (flags & DU_DRAWNAVMESH_INNERBOUND) - drawPolyBoundaries(dd, tile, 2.5f, true); + drawPolyBoundaries(dd, tile, 2.5f, offset, true); // Draw outer poly boundaries if (flags & DU_DRAWNAVMESH_OUTERBOUND) - drawPolyBoundaries(dd, tile, 4.5f, false); + drawPolyBoundaries(dd, tile, 4.5f, offset, false); // Draw poly centers if (flags & DU_DRAWNAVMESH_POLYCENTERS) - drawPolyCenters(dd, tile, duRGBA(255, 255, 255, 100), 1.0f); + drawPolyCenters(dd, tile, duRGBA(255, 255, 255, 100), 1.0f, offset); if (flags & DU_DRAWNAVMESH_OFFMESHCONS) { - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int i = 0; i < tile->header->polyCount; ++i) { const dtPoly* p = &tile->polys[i]; @@ -253,7 +253,7 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh if (flags & DU_DRAWNAVMESH_VERTS) { const unsigned int vcol = duRGBA(0,0,0,196); - dd->begin(DU_DRAW_POINTS, 5.0f); + dd->begin(DU_DRAW_POINTS, 5.0f, offset); for (int i = 0; i < tile->header->vertCount; ++i) { const float* v = &tile->verts[i*3]; @@ -265,7 +265,7 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh dd->depthMask(true); } -void duDebugDrawNavMesh(duDebugDraw* dd, const dtNavMesh& mesh, unsigned int flags) +void duDebugDrawNavMesh(duDebugDraw* dd, const dtNavMesh& mesh, const float* offset, unsigned int flags) { if (!dd) return; @@ -273,11 +273,11 @@ void duDebugDrawNavMesh(duDebugDraw* dd, const dtNavMesh& mesh, unsigned int fla { const dtMeshTile* tile = mesh.getTile(i); if (!tile->header) continue; - drawMeshTile(dd, mesh, 0, tile, flags); + drawMeshTile(dd, mesh, 0, tile, offset, flags); } } -void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, unsigned int flags) +void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, const float* offset, unsigned int flags) { if (!dd) return; @@ -287,18 +287,18 @@ void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& m { const dtMeshTile* tile = mesh.getTile(i); if (!tile->header) continue; - drawMeshTile(dd, mesh, q, tile, flags); + drawMeshTile(dd, mesh, q, tile, offset, flags); } if (flags & DU_DRAWNAVMESH_BVTREE) - duDebugDrawNavMeshBVTree(dd, mesh); + duDebugDrawNavMeshBVTree(dd, mesh, offset); if (flags & DU_DRAWNAVMESH_PORTALS) - duDebugDrawNavMeshPortals(dd, mesh); + duDebugDrawNavMeshPortals(dd, mesh, offset); if (flags & DU_DRAWNAVMESH_NODES) - duDebugDrawNavMeshNodes(dd, query); + duDebugDrawNavMeshNodes(dd, query, offset); } -void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query) +void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query, const float* offset) { if (!dd) return; @@ -306,7 +306,7 @@ void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query if (pool) { const float off = 0.5f; - dd->begin(DU_DRAW_POINTS, 4.0f); + dd->begin(DU_DRAW_POINTS, 4.0f, offset); for (int i = 0; i < pool->getHashSize(); ++i) { for (dtNodeIndex j = pool->getFirst(i); j != DT_NULL_IDX; j = pool->getNext(j)) @@ -318,7 +318,7 @@ void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query } dd->end(); - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int i = 0; i < pool->getHashSize(); ++i) { for (dtNodeIndex j = pool->getFirst(i); j != DT_NULL_IDX; j = pool->getNext(j)) @@ -337,11 +337,11 @@ void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query } -static void drawMeshTileBVTree(duDebugDraw* dd, const dtMeshTile* tile) +static void drawMeshTileBVTree(duDebugDraw* dd, const dtMeshTile* tile, const float* offset) { // Draw BV nodes. const float cs = 1.0f / tile->header->bvQuantFactor; - dd->begin(DU_DRAW_LINES, 1.0f); + dd->begin(DU_DRAW_LINES, 1.0f, offset); for (int i = 0; i < tile->header->bvNodeCount; ++i) { const dtBVNode* n = &tile->bvTree[i]; @@ -358,7 +358,7 @@ static void drawMeshTileBVTree(duDebugDraw* dd, const dtMeshTile* tile) dd->end(); } -void duDebugDrawNavMeshBVTree(duDebugDraw* dd, const dtNavMesh& mesh) +void duDebugDrawNavMeshBVTree(duDebugDraw* dd, const dtNavMesh& mesh, const float* offset) { if (!dd) return; @@ -366,17 +366,17 @@ void duDebugDrawNavMeshBVTree(duDebugDraw* dd, const dtNavMesh& mesh) { const dtMeshTile* tile = mesh.getTile(i); if (!tile->header) continue; - drawMeshTileBVTree(dd, tile); + drawMeshTileBVTree(dd, tile, offset); } } -static void drawMeshTilePortal(duDebugDraw* dd, const dtMeshTile* tile) +static void drawMeshTilePortal(duDebugDraw* dd, const dtMeshTile* tile, const float* offset) { // Draw portals const float padx = 0.04f; const float padz = tile->header->walkableClimb; - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int side = 0; side < 8; ++side) { @@ -441,7 +441,7 @@ static void drawMeshTilePortal(duDebugDraw* dd, const dtMeshTile* tile) dd->end(); } -void duDebugDrawNavMeshPortals(duDebugDraw* dd, const dtNavMesh& mesh) +void duDebugDrawNavMeshPortals(duDebugDraw* dd, const dtNavMesh& mesh, const float* offset) { if (!dd) return; @@ -449,12 +449,12 @@ void duDebugDrawNavMeshPortals(duDebugDraw* dd, const dtNavMesh& mesh) { const dtMeshTile* tile = mesh.getTile(i); if (!tile->header) continue; - drawMeshTilePortal(dd, tile); + drawMeshTilePortal(dd, tile, offset); } } -void duDebugDrawNavMeshPolysWithFlags(struct duDebugDraw* dd, const dtNavMesh& mesh, - const unsigned short polyFlags, const unsigned int col) +void duDebugDrawNavMeshPolysWithFlags(struct duDebugDraw* dd, const dtNavMesh& mesh, const unsigned short polyFlags, + const float* offset, const unsigned int drawFlags, const unsigned int col) { if (!dd) return; @@ -468,12 +468,12 @@ void duDebugDrawNavMeshPolysWithFlags(struct duDebugDraw* dd, const dtNavMesh& m { const dtPoly* p = &tile->polys[j]; if ((p->flags & polyFlags) == 0) continue; - duDebugDrawNavMeshPoly(dd, mesh, base|(dtPolyRef)j, col); + duDebugDrawNavMeshPoly(dd, mesh, base|(dtPolyRef)j, offset, col, drawFlags); } } } -void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef ref, const unsigned int col) +void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef ref, const float* offset, const unsigned int drawFlags, const unsigned int col) { if (!dd) return; @@ -489,24 +489,27 @@ void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef re if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION) { - dtOffMeshConnection* con = &tile->offMeshCons[ip - tile->header->offMeshBase]; + if (drawFlags & DU_DRAWNAVMESH_OFFMESHCONS) + { + dtOffMeshConnection* con = &tile->offMeshCons[ip - tile->header->offMeshBase]; - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); - // Connection arc. - duAppendArc(dd, con->pos[0],con->pos[1],con->pos[2], con->pos[3],con->pos[4],con->pos[5], 0.25f, - (con->flags & DT_OFFMESH_CON_BIDIR) ? 30.0f : 0.0f, 30.0f, c); + // Connection arc. + duAppendArc(dd, con->pos[0],con->pos[1],con->pos[2], con->pos[3],con->pos[4],con->pos[5], 0.25f, + (con->flags & DT_OFFMESH_CON_BIDIR) ? 30.0f : 0.0f, 30.0f, c); - // Reference positions. - drawOffMeshConnectionRefPosition(dd, con); + // Reference positions. + drawOffMeshConnectionRefPosition(dd, con); - dd->end(); + dd->end(); + } } else { const dtPolyDetail* pd = &tile->detailMeshes[ip]; - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < pd->triCount; ++i) { const unsigned char* t = &tile->detailTris[(pd->triBase+i)*4]; @@ -525,7 +528,7 @@ void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef re } -static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch) +static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch, const float* offset) { const int w = (int)layer.header->width; const int h = (int)layer.header->height; @@ -537,7 +540,7 @@ static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheL const int segs[4*4] = {0,0,0,1, 0,1,1,1, 1,1,1,0, 1,0,0,0}; // Layer portals - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) @@ -566,7 +569,7 @@ static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheL dd->end(); } -void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch) +void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch, const float* offset) { const int w = (int)layer.header->width; const int h = (int)layer.header->height; @@ -584,10 +587,10 @@ void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLay lbmax[0] = bmin[0] + (layer.header->maxx+1)*cs; lbmax[1] = bmax[1] + (layer.header->maxy+1)*cs; lbmax[2] = bmin[2]; - duDebugDrawBoxWire(dd, lbmin[0],lbmin[1],lbmin[2], lbmax[0],lbmax[1],lbmax[2], duTransCol(color,128), 2.0f); + duDebugDrawBoxWire(dd, lbmin[0],lbmin[1],lbmin[2], lbmax[0],lbmax[1],lbmax[2], duTransCol(color,128), 2.0f, offset); // Layer height - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) @@ -617,10 +620,10 @@ void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLay } dd->end(); - debugDrawTileCachePortals(dd, layer, cs, ch); + debugDrawTileCachePortals(dd, layer, cs, ch, offset); } -void duDebugDrawTileCacheLayerRegions(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch) +void duDebugDrawTileCacheLayerRegions(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch, const float* offset) { const int w = (int)layer.header->width; const int h = (int)layer.header->height; @@ -638,10 +641,10 @@ void duDebugDrawTileCacheLayerRegions(struct duDebugDraw* dd, const dtTileCacheL lbmax[0] = bmin[0] + (layer.header->maxx+1)*cs; lbmax[1] = bmax[1] + (layer.header->maxy+1)*cs; lbmax[2] = bmin[2]; - duDebugDrawBoxWire(dd, lbmin[0],lbmin[1],lbmin[2], lbmax[0],lbmax[1],lbmax[2], duTransCol(color,128), 2.0f); + duDebugDrawBoxWire(dd, lbmin[0],lbmin[1],lbmin[2], lbmax[0],lbmax[1],lbmax[2], duTransCol(color,128), 2.0f, offset); // Layer height - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) @@ -665,7 +668,7 @@ void duDebugDrawTileCacheLayerRegions(struct duDebugDraw* dd, const dtTileCacheL } dd->end(); - debugDrawTileCachePortals(dd, layer, cs, ch); + debugDrawTileCachePortals(dd, layer, cs, ch, offset); } @@ -686,7 +689,7 @@ struct dtTileCacheContourSet };*/ void duDebugDrawTileCacheContours(duDebugDraw* dd, const struct dtTileCacheContourSet& lcset, - const float* orig, const float cs, const float ch) + const float* orig, const float cs, const float ch, const float* offset) { if (!dd) return; @@ -694,7 +697,7 @@ void duDebugDrawTileCacheContours(duDebugDraw* dd, const struct dtTileCacheConto const int offs[2*4] = {-1,0, 0,1, 1,0, 0,-1}; - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int i = 0; i < lcset.nconts; ++i) { @@ -738,7 +741,7 @@ void duDebugDrawTileCacheContours(duDebugDraw* dd, const struct dtTileCacheConto } dd->end(); - dd->begin(DU_DRAW_POINTS, 4.0f); + dd->begin(DU_DRAW_POINTS, 4.0f, offset); for (int i = 0; i < lcset.nconts; ++i) { @@ -766,7 +769,7 @@ void duDebugDrawTileCacheContours(duDebugDraw* dd, const struct dtTileCacheConto } void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyMesh& lmesh, - const float* orig, const float cs, const float ch) + const float* orig, const float cs, const float ch, const float* offset) { if (!dd) return; @@ -774,7 +777,7 @@ void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyM const int offs[2*4] = {-1,0, 0,1, 1,0, 0,-1}; - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < lmesh.npolys; ++i) { @@ -810,7 +813,7 @@ void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyM // Draw neighbours edges const unsigned int coln = duRGBA(0,48,64,32); - dd->begin(DU_DRAW_LINES, 1.5f); + dd->begin(DU_DRAW_LINES, 1.5f, offset); for (int i = 0; i < lmesh.npolys; ++i) { const unsigned short* p = &lmesh.polys[i*nvp*2]; @@ -835,7 +838,7 @@ void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyM // Draw boundary edges const unsigned int colb = duRGBA(0,48,64,220); - dd->begin(DU_DRAW_LINES, 4.5f); + dd->begin(DU_DRAW_LINES, 4.5f, offset); for (int i = 0; i < lmesh.npolys; ++i) { const unsigned short* p = &lmesh.polys[i*nvp*2]; @@ -887,7 +890,7 @@ void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyM } dd->end(); - dd->begin(DU_DRAW_POINTS, 5.0f); + dd->begin(DU_DRAW_POINTS, 5.0f, offset); const unsigned int colv = duRGBA(0,0,0,220); for (int i = 0; i < lmesh.nverts; ++i) { diff --git a/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp index b0b9ac10..28deb048 100644 --- a/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp @@ -24,7 +24,7 @@ void duDebugDrawTriMesh(duDebugDraw* dd, const float* verts, int /*nverts*/, const int* tris, const float* normals, int ntris, - const unsigned char* flags, const float texScale) + const unsigned char* flags, const float texScale, const float* offset) { if (!dd) return; if (!verts) return; @@ -39,7 +39,7 @@ void duDebugDrawTriMesh(duDebugDraw* dd, const float* verts, int /*nverts*/, dd->texture(true); - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < ntris*3; i += 3) { const float* norm = &normals[i]; @@ -79,7 +79,7 @@ void duDebugDrawTriMesh(duDebugDraw* dd, const float* verts, int /*nverts*/, void duDebugDrawTriMeshSlope(duDebugDraw* dd, const float* verts, int /*nverts*/, const int* tris, const float* normals, int ntris, - const float walkableSlopeAngle, const float texScale) + const float walkableSlopeAngle, const float texScale, const float* offset) { if (!dd) return; if (!verts) return; @@ -96,7 +96,7 @@ void duDebugDrawTriMeshSlope(duDebugDraw* dd, const float* verts, int /*nverts*/ const unsigned int unwalkable = duRGBA(192,128,0,255); - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < ntris*3; i += 3) { const float* norm = &normals[i]; @@ -135,7 +135,7 @@ void duDebugDrawTriMeshSlope(duDebugDraw* dd, const float* verts, int /*nverts*/ dd->texture(false); } -void duDebugDrawHeightfieldSolid(duDebugDraw* dd, const rcHeightfield& hf) +void duDebugDrawHeightfieldSolid(duDebugDraw* dd, const rcHeightfield& hf, const float* offset) { if (!dd) return; @@ -149,7 +149,7 @@ void duDebugDrawHeightfieldSolid(duDebugDraw* dd, const rcHeightfield& hf) unsigned int fcol[6]; duCalcBoxColors(fcol, duRGBA(255,255,255,255), duRGBA(255,255,255,255)); - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < h; ++y) { @@ -168,7 +168,7 @@ void duDebugDrawHeightfieldSolid(duDebugDraw* dd, const rcHeightfield& hf) dd->end(); } -void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf) +void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf, const float* offset) { if (!dd) return; @@ -182,7 +182,7 @@ void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf) unsigned int fcol[6]; duCalcBoxColors(fcol, duRGBA(255,255,255,255), duRGBA(217,217,217,255)); - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < h; ++y) { @@ -209,14 +209,14 @@ void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf) dd->end(); } -void duDebugDrawCompactHeightfieldSolid(duDebugDraw* dd, const rcCompactHeightfield& chf) +void duDebugDrawCompactHeightfieldSolid(duDebugDraw* dd, const rcCompactHeightfield& chf, const float* offset) { if (!dd) return; const float cs = chf.cs; const float ch = chf.ch; - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < chf.height; ++y) { @@ -250,14 +250,14 @@ void duDebugDrawCompactHeightfieldSolid(duDebugDraw* dd, const rcCompactHeightfi dd->end(); } -void duDebugDrawCompactHeightfieldRegions(duDebugDraw* dd, const rcCompactHeightfield& chf) +void duDebugDrawCompactHeightfieldRegions(duDebugDraw* dd, const rcCompactHeightfield& chf, const float* offset) { if (!dd) return; const float cs = chf.cs; const float ch = chf.ch; - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < chf.height; ++y) { @@ -289,7 +289,7 @@ void duDebugDrawCompactHeightfieldRegions(duDebugDraw* dd, const rcCompactHeight } -void duDebugDrawCompactHeightfieldDistance(duDebugDraw* dd, const rcCompactHeightfield& chf) +void duDebugDrawCompactHeightfieldDistance(duDebugDraw* dd, const rcCompactHeightfield& chf, const float* offset) { if (!dd) return; if (!chf.dist) return; @@ -301,7 +301,7 @@ void duDebugDrawCompactHeightfieldDistance(duDebugDraw* dd, const rcCompactHeigh if (maxd < 1.0f) maxd = 1; const float dscale = 255.0f / maxd; - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < chf.height; ++y) { @@ -327,7 +327,7 @@ void duDebugDrawCompactHeightfieldDistance(duDebugDraw* dd, const rcCompactHeigh dd->end(); } -static void drawLayerPortals(duDebugDraw* dd, const rcHeightfieldLayer* layer) +static void drawLayerPortals(duDebugDraw* dd, const rcHeightfieldLayer* layer, const float* offset) { const float cs = layer->cs; const float ch = layer->ch; @@ -339,7 +339,7 @@ static void drawLayerPortals(duDebugDraw* dd, const rcHeightfieldLayer* layer) const int segs[4*4] = {0,0,0,1, 0,1,1,1, 1,1,1,0, 1,0,0,0}; // Layer portals - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) @@ -368,7 +368,7 @@ static void drawLayerPortals(duDebugDraw* dd, const rcHeightfieldLayer* layer) dd->end(); } -void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLayer& layer, const int idx) +void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLayer& layer, const int idx, const float* offset) { const float cs = layer.cs; const float ch = layer.ch; @@ -385,10 +385,10 @@ void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLaye bmax[0] = layer.bmin[0] + (layer.maxx+1)*cs; bmax[1] = layer.bmax[1] + (layer.maxy+1)*cs; bmax[2] = layer.bmin[2]; - duDebugDrawBoxWire(dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duTransCol(color,128), 2.0f); + duDebugDrawBoxWire(dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duTransCol(color,128), 2.0f, 0); // Layer height - dd->begin(DU_DRAW_QUADS); + dd->begin(DU_DRAW_QUADS, 1.0f, offset); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) @@ -419,14 +419,14 @@ void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLaye dd->end(); // Portals - drawLayerPortals(dd, &layer); + drawLayerPortals(dd, &layer, offset); } -void duDebugDrawHeightfieldLayers(duDebugDraw* dd, const struct rcHeightfieldLayerSet& lset) +void duDebugDrawHeightfieldLayers(duDebugDraw* dd, const struct rcHeightfieldLayerSet& lset, const float* offset) { if (!dd) return; for (int i = 0; i < lset.nlayers; ++i) - duDebugDrawHeightfieldLayer(dd, lset.layers[i], i); + duDebugDrawHeightfieldLayer(dd, lset.layers[i], i, offset); } static void getContourCenter(const rcContour* cont, const float* orig, float cs, float ch, float* center) @@ -462,7 +462,7 @@ static const rcContour* findContourFromSet(const rcContourSet& cset, unsigned sh return 0; } -void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, const float alpha) +void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, const float* offset, const float alpha) { if (!dd) return; @@ -475,7 +475,7 @@ void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, con unsigned int color = duRGBA(0,0,0,196); - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int i = 0; i < cset.nconts; ++i) { @@ -498,7 +498,7 @@ void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, con unsigned char a = (unsigned char)(alpha * 255.0f); - dd->begin(DU_DRAW_POINTS, 7.0f); + dd->begin(DU_DRAW_POINTS, 7.0f, offset); for (int i = 0; i < cset.nconts; ++i) { @@ -510,7 +510,7 @@ void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, con dd->end(); } -void duDebugDrawRawContours(duDebugDraw* dd, const rcContourSet& cset, const float alpha) +void duDebugDrawRawContours(duDebugDraw* dd, const rcContourSet& cset, const float* offset, const float alpha) { if (!dd) return; @@ -520,7 +520,7 @@ void duDebugDrawRawContours(duDebugDraw* dd, const rcContourSet& cset, const flo const unsigned char a = (unsigned char)(alpha*255.0f); - dd->begin(DU_DRAW_LINES, 2.0f); + dd->begin(DU_DRAW_LINES, 2.0f, offset); for (int i = 0; i < cset.nconts; ++i) { @@ -546,7 +546,7 @@ void duDebugDrawRawContours(duDebugDraw* dd, const rcContourSet& cset, const flo } dd->end(); - dd->begin(DU_DRAW_POINTS, 2.0f); + dd->begin(DU_DRAW_POINTS, 2.0f, offset); for (int i = 0; i < cset.nconts; ++i) { @@ -573,7 +573,7 @@ void duDebugDrawRawContours(duDebugDraw* dd, const rcContourSet& cset, const flo dd->end(); } -void duDebugDrawContours(duDebugDraw* dd, const rcContourSet& cset, const float alpha) +void duDebugDrawContours(duDebugDraw* dd, const rcContourSet& cset, const float* offset, const float alpha) { if (!dd) return; @@ -583,7 +583,7 @@ void duDebugDrawContours(duDebugDraw* dd, const rcContourSet& cset, const float const unsigned char a = (unsigned char)(alpha*255.0f); - dd->begin(DU_DRAW_LINES, 4.5f); + dd->begin(DU_DRAW_LINES, 4.5f, offset); for (int i = 0; i < cset.nconts; ++i) { @@ -610,7 +610,7 @@ void duDebugDrawContours(duDebugDraw* dd, const rcContourSet& cset, const float } dd->end(); - dd->begin(DU_DRAW_POINTS, 5.0f); + dd->begin(DU_DRAW_POINTS, 5.0f, offset); for (int i = 0; i < cset.nconts; ++i) { @@ -636,7 +636,7 @@ void duDebugDrawContours(duDebugDraw* dd, const rcContourSet& cset, const float dd->end(); } -void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh) +void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh, const float* offset) { if (!dd) return; @@ -645,7 +645,7 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh) const float ch = mesh.ch; const float* orig = mesh.bmin; - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < mesh.npolys; ++i) { @@ -681,7 +681,7 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh) // Draw neighbours edges const unsigned int coln = duRGBA(0,48,64,32); - dd->begin(DU_DRAW_LINES, 1.5f); + dd->begin(DU_DRAW_LINES, 1.5f, offset); for (int i = 0; i < mesh.npolys; ++i) { const unsigned short* p = &mesh.polys[i*nvp*2]; @@ -706,7 +706,7 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh) // Draw boundary edges const unsigned int colb = duRGBA(0,48,64,220); - dd->begin(DU_DRAW_LINES, 4.5f); + dd->begin(DU_DRAW_LINES, 4.5f, offset); for (int i = 0; i < mesh.npolys; ++i) { const unsigned short* p = &mesh.polys[i*nvp*2]; @@ -732,7 +732,7 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh) } dd->end(); - dd->begin(DU_DRAW_POINTS, 5.0f); + dd->begin(DU_DRAW_POINTS, 5.0f, offset); const unsigned int colv = duRGBA(0,0,0,220); for (int i = 0; i < mesh.nverts; ++i) { @@ -745,11 +745,11 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh) dd->end(); } -void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& dmesh) +void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& dmesh, const float* offset) { if (!dd) return; - dd->begin(DU_DRAW_TRIS); + dd->begin(DU_DRAW_TRIS, 1.0f, offset); for (int i = 0; i < dmesh.nmeshes; ++i) { @@ -772,7 +772,7 @@ void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& d dd->end(); // Internal edges. - dd->begin(DU_DRAW_LINES, 0.8f); + dd->begin(DU_DRAW_LINES, 0.8f, offset); const unsigned int coli = duRGBA(0,0,0,64); for (int i = 0; i < dmesh.nmeshes; ++i) { @@ -804,7 +804,7 @@ void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& d dd->end(); // External edges. - dd->begin(DU_DRAW_LINES, 4.5f); + dd->begin(DU_DRAW_LINES, 4.5f, offset); const unsigned int cole = duRGBA(0,0,0,64); for (int i = 0; i < dmesh.nmeshes; ++i) { @@ -832,7 +832,7 @@ void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& d } dd->end(); - dd->begin(DU_DRAW_POINTS, 5.0f); + dd->begin(DU_DRAW_POINTS, 5.0f, offset); const unsigned int colv = duRGBA(0,0,0,64); for (int i = 0; i < dmesh.nmeshes; ++i) {