From 8a6c7ed8e11099e90afc8d80528cc745a84a57f3 Mon Sep 17 00:00:00 2001 From: Graham Pentheny Date: Fri, 30 May 2025 01:58:52 -0400 Subject: [PATCH] removing hungarian notation from sample class field names --- RecastDemo/Include/Sample.h | 78 ++--- RecastDemo/Source/Sample.cpp | 224 ++++++------ RecastDemo/Source/Sample_SoloMesh.cpp | 284 +++++++-------- RecastDemo/Source/Sample_TempObstacles.cpp | 264 +++++++------- RecastDemo/Source/Sample_TileMesh.cpp | 388 ++++++++++----------- 5 files changed, 619 insertions(+), 619 deletions(-) diff --git a/RecastDemo/Include/Sample.h b/RecastDemo/Include/Sample.h index 1d8296e0..2c577081 100644 --- a/RecastDemo/Include/Sample.h +++ b/RecastDemo/Include/Sample.h @@ -108,38 +108,38 @@ struct SampleToolState class Sample { protected: - InputGeom* m_inputGeometry = nullptr; - dtNavMesh* m_navMesh = nullptr; - dtNavMeshQuery* m_navQuery = nullptr; - dtCrowd* m_crowd = nullptr; + InputGeom* inputGeometry = nullptr; + dtNavMesh* navMesh = nullptr; + dtNavMeshQuery* navQuery = nullptr; + dtCrowd* crowd = nullptr; - unsigned char m_navMeshDrawFlags; + unsigned char navMeshDrawFlags; - float m_cellSize; - float m_cellHeight; - float m_agentHeight; - float m_agentRadius; - float m_agentMaxClimb; - float m_agentMaxSlope; - float m_regionMinSize; - float m_regionMergeSize; - float m_edgeMaxLen; - float m_edgeMaxError; - float m_vertsPerPoly; - float m_detailSampleDist; - float m_detailSampleMaxError; - int m_partitionType; + float cellSize; + float cellHeight; + float agentHeight; + float agentRadius; + float agentMaxClimb; + float agentMaxSlope; + float regionMinSize; + float regionMergeSize; + float edgeMaxLen; + float edgeMaxError; + float vertsPerPoly; + float detailSampleDist; + float detailSampleMaxError; + int partitionType; - bool m_filterLowHangingObstacles = true; - bool m_filterLedgeSpans = true; - bool m_filterWalkableLowHeightSpans = true; + bool filterLowHangingObstacles = true; + bool filterLedgeSpans = true; + bool filterWalkableLowHeightSpans = true; - SampleTool* m_tool = nullptr; - SampleToolState* m_toolStates[static_cast(SampleToolType::MAX_TOOLS)]; + SampleTool* tool = nullptr; + SampleToolState* toolStates[static_cast(SampleToolType::MAX_TOOLS)]; - BuildContext* m_buildContext = nullptr; + BuildContext* buildContext = nullptr; - SampleDebugDraw m_debugDraw; + SampleDebugDraw debugDraw; dtNavMesh* loadAll(const char* path); void saveAll(const char* path, const dtNavMesh* mesh); @@ -152,13 +152,13 @@ public: Sample& operator=(const Sample&) = delete; Sample& operator=(const Sample&&) = delete; - void setContext(BuildContext* ctx) { m_buildContext = ctx; } + void setContext(BuildContext* ctx) { buildContext = ctx; } void setTool(SampleTool* tool); - SampleToolState* getToolState(const int type) const { return m_toolStates[type]; } - void setToolState(const int type, SampleToolState* s) { m_toolStates[type] = s; } + SampleToolState* getToolState(const int type) const { return toolStates[type]; } + void setToolState(const int type, SampleToolState* s) { toolStates[type] = s; } - SampleDebugDraw& getDebugDraw() { return m_debugDraw; } + SampleDebugDraw& getDebugDraw() { return debugDraw; } virtual void handleSettings(); virtual void handleTools(); @@ -173,16 +173,16 @@ public: virtual void handleUpdate(float dt); virtual void collectSettings(struct BuildSettings& settings); - virtual InputGeom* getInputGeom() { return m_inputGeometry; } - virtual dtNavMesh* getNavMesh() { return m_navMesh; } - virtual dtNavMeshQuery* getNavMeshQuery() { return m_navQuery; } - virtual dtCrowd* getCrowd() { return m_crowd; } - virtual float getAgentRadius() { return m_agentRadius; } - virtual float getAgentHeight() { return m_agentHeight; } - virtual float getAgentClimb() { return m_agentMaxClimb; } + virtual InputGeom* getInputGeom() { return inputGeometry; } + virtual dtNavMesh* getNavMesh() { return navMesh; } + virtual dtNavMeshQuery* getNavMeshQuery() { return navQuery; } + virtual dtCrowd* getCrowd() { return crowd; } + virtual float getAgentRadius() { return agentRadius; } + virtual float getAgentHeight() { return agentHeight; } + virtual float getAgentClimb() { return agentMaxClimb; } - unsigned char getNavMeshDrawFlags() const { return m_navMeshDrawFlags; } - void setNavMeshDrawFlags(unsigned char flags) { m_navMeshDrawFlags = flags; } + unsigned char getNavMeshDrawFlags() const { return navMeshDrawFlags; } + void setNavMeshDrawFlags(unsigned char flags) { navMeshDrawFlags = flags; } void updateToolStates(float dt); void initToolStates(Sample* sample); diff --git a/RecastDemo/Source/Sample.cpp b/RecastDemo/Source/Sample.cpp index 6a3d35ba..a6ef0bb2 100644 --- a/RecastDemo/Source/Sample.cpp +++ b/RecastDemo/Source/Sample.cpp @@ -74,37 +74,37 @@ unsigned int SampleDebugDraw::areaToCol(unsigned int area) } } -Sample::Sample() : m_navMeshDrawFlags(DU_DRAWNAVMESH_OFFMESHCONS | DU_DRAWNAVMESH_CLOSEDLIST) +Sample::Sample() : navMeshDrawFlags(DU_DRAWNAVMESH_OFFMESHCONS | DU_DRAWNAVMESH_CLOSEDLIST) { resetCommonSettings(); - m_navQuery = dtAllocNavMeshQuery(); - m_crowd = dtAllocCrowd(); + navQuery = dtAllocNavMeshQuery(); + crowd = dtAllocCrowd(); for (int i = 0; i < static_cast(SampleToolType::MAX_TOOLS); i++) { - m_toolStates[i] = 0; + toolStates[i] = 0; } } Sample::~Sample() { - dtFreeNavMeshQuery(m_navQuery); - dtFreeNavMesh(m_navMesh); - dtFreeCrowd(m_crowd); - delete m_tool; + dtFreeNavMeshQuery(navQuery); + dtFreeNavMesh(navMesh); + dtFreeCrowd(crowd); + delete tool; for (int i = 0; i < static_cast(SampleToolType::MAX_TOOLS); i++) { - delete m_toolStates[i]; + delete toolStates[i]; } } void Sample::setTool(SampleTool* tool) { - delete m_tool; - m_tool = tool; + delete tool; + tool = tool; if (tool) { - m_tool->init(this); + tool->init(this); } } @@ -116,101 +116,101 @@ void Sample::handleDebugMode() {} void Sample::handleRender() { - if (!m_inputGeometry) + if (!inputGeometry) { return; } // Draw mesh duDebugDrawTriMesh( - &m_debugDraw, - m_inputGeometry->getMesh()->getVerts(), - m_inputGeometry->getMesh()->getVertCount(), - m_inputGeometry->getMesh()->getTris(), - m_inputGeometry->getMesh()->getNormals(), - m_inputGeometry->getMesh()->getTriCount(), + &debugDraw, + inputGeometry->getMesh()->getVerts(), + inputGeometry->getMesh()->getVertCount(), + inputGeometry->getMesh()->getTris(), + inputGeometry->getMesh()->getNormals(), + inputGeometry->getMesh()->getTriCount(), 0, 1.0f); // Draw bounds - const float* bmin = m_inputGeometry->getMeshBoundsMin(); - const float* bmax = m_inputGeometry->getMeshBoundsMax(); - duDebugDrawBoxWire(&m_debugDraw, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duRGBA(255, 255, 255, 128), 1.0f); + const float* bmin = inputGeometry->getMeshBoundsMin(); + const float* bmax = inputGeometry->getMeshBoundsMax(); + duDebugDrawBoxWire(&debugDraw, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duRGBA(255, 255, 255, 128), 1.0f); } void Sample::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/) {} void Sample::handleMeshChanged(InputGeom* geom) { - m_inputGeometry = geom; + inputGeometry = geom; const BuildSettings* buildSettings = geom->getBuildSettings(); if (buildSettings) { - m_cellSize = buildSettings->cellSize; - m_cellHeight = buildSettings->cellHeight; - m_agentHeight = buildSettings->agentHeight; - m_agentRadius = buildSettings->agentRadius; - m_agentMaxClimb = buildSettings->agentMaxClimb; - m_agentMaxSlope = buildSettings->agentMaxSlope; - m_regionMinSize = buildSettings->regionMinSize; - m_regionMergeSize = buildSettings->regionMergeSize; - m_edgeMaxLen = buildSettings->edgeMaxLen; - m_edgeMaxError = buildSettings->edgeMaxError; - m_vertsPerPoly = buildSettings->vertsPerPoly; - m_detailSampleDist = buildSettings->detailSampleDist; - m_detailSampleMaxError = buildSettings->detailSampleMaxError; - m_partitionType = buildSettings->partitionType; + cellSize = buildSettings->cellSize; + cellHeight = buildSettings->cellHeight; + agentHeight = buildSettings->agentHeight; + agentRadius = buildSettings->agentRadius; + agentMaxClimb = buildSettings->agentMaxClimb; + agentMaxSlope = buildSettings->agentMaxSlope; + regionMinSize = buildSettings->regionMinSize; + regionMergeSize = buildSettings->regionMergeSize; + edgeMaxLen = buildSettings->edgeMaxLen; + edgeMaxError = buildSettings->edgeMaxError; + vertsPerPoly = buildSettings->vertsPerPoly; + detailSampleDist = buildSettings->detailSampleDist; + detailSampleMaxError = buildSettings->detailSampleMaxError; + partitionType = buildSettings->partitionType; } } void Sample::collectSettings(BuildSettings& settings) { - settings.cellSize = m_cellSize; - settings.cellHeight = m_cellHeight; - settings.agentHeight = m_agentHeight; - settings.agentRadius = m_agentRadius; - settings.agentMaxClimb = m_agentMaxClimb; - settings.agentMaxSlope = m_agentMaxSlope; - settings.regionMinSize = m_regionMinSize; - settings.regionMergeSize = m_regionMergeSize; - settings.edgeMaxLen = m_edgeMaxLen; - settings.edgeMaxError = m_edgeMaxError; - settings.vertsPerPoly = m_vertsPerPoly; - settings.detailSampleDist = m_detailSampleDist; - settings.detailSampleMaxError = m_detailSampleMaxError; - settings.partitionType = m_partitionType; + settings.cellSize = cellSize; + settings.cellHeight = cellHeight; + settings.agentHeight = agentHeight; + settings.agentRadius = agentRadius; + settings.agentMaxClimb = agentMaxClimb; + settings.agentMaxSlope = agentMaxSlope; + settings.regionMinSize = regionMinSize; + settings.regionMergeSize = regionMergeSize; + settings.edgeMaxLen = edgeMaxLen; + settings.edgeMaxError = edgeMaxError; + settings.vertsPerPoly = vertsPerPoly; + settings.detailSampleDist = detailSampleDist; + settings.detailSampleMaxError = detailSampleMaxError; + settings.partitionType = partitionType; } void Sample::resetCommonSettings() { - m_cellSize = 0.3f; - m_cellHeight = 0.2f; - m_agentHeight = 2.0f; - m_agentRadius = 0.6f; - m_agentMaxClimb = 0.9f; - m_agentMaxSlope = 45.0f; - m_regionMinSize = 8; - m_regionMergeSize = 20; - m_edgeMaxLen = 12.0f; - m_edgeMaxError = 1.3f; - m_vertsPerPoly = 6.0f; - m_detailSampleDist = 6.0f; - m_detailSampleMaxError = 1.0f; - m_partitionType = SAMPLE_PARTITION_WATERSHED; + cellSize = 0.3f; + cellHeight = 0.2f; + agentHeight = 2.0f; + agentRadius = 0.6f; + agentMaxClimb = 0.9f; + agentMaxSlope = 45.0f; + regionMinSize = 8; + regionMergeSize = 20; + edgeMaxLen = 12.0f; + edgeMaxError = 1.3f; + vertsPerPoly = 6.0f; + detailSampleDist = 6.0f; + detailSampleMaxError = 1.0f; + partitionType = SAMPLE_PARTITION_WATERSHED; } void Sample::handleCommonSettings() { imguiLabel("Rasterization"); - imguiSlider("Cell Size", &m_cellSize, 0.1f, 1.0f, 0.01f); - imguiSlider("Cell Height", &m_cellHeight, 0.1f, 1.0f, 0.01f); + imguiSlider("Cell Size", &cellSize, 0.1f, 1.0f, 0.01f); + imguiSlider("Cell Height", &cellHeight, 0.1f, 1.0f, 0.01f); - if (m_inputGeometry) + if (inputGeometry) { - const float* bmin = m_inputGeometry->getNavMeshBoundsMin(); - const float* bmax = m_inputGeometry->getNavMeshBoundsMax(); + const float* bmin = inputGeometry->getNavMeshBoundsMin(); + const float* bmax = inputGeometry->getNavMeshBoundsMax(); int gw = 0, gh = 0; - rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh); + rcCalcGridSize(bmin, bmax, cellSize, &gw, &gh); char text[64]; snprintf(text, 64, "Voxels %d x %d", gw, gh); imguiValue(text); @@ -218,81 +218,81 @@ void Sample::handleCommonSettings() imguiSeparator(); imguiLabel("Agent"); - imguiSlider("Height", &m_agentHeight, 0.1f, 5.0f, 0.1f); - imguiSlider("Radius", &m_agentRadius, 0.0f, 5.0f, 0.1f); - imguiSlider("Max Climb", &m_agentMaxClimb, 0.1f, 5.0f, 0.1f); - imguiSlider("Max Slope", &m_agentMaxSlope, 0.0f, 90.0f, 1.0f); + imguiSlider("Height", &agentHeight, 0.1f, 5.0f, 0.1f); + imguiSlider("Radius", &agentRadius, 0.0f, 5.0f, 0.1f); + imguiSlider("Max Climb", &agentMaxClimb, 0.1f, 5.0f, 0.1f); + imguiSlider("Max Slope", &agentMaxSlope, 0.0f, 90.0f, 1.0f); imguiSeparator(); imguiLabel("Region"); - imguiSlider("Min Region Size", &m_regionMinSize, 0.0f, 150.0f, 1.0f); - imguiSlider("Merged Region Size", &m_regionMergeSize, 0.0f, 150.0f, 1.0f); + imguiSlider("Min Region Size", ®ionMinSize, 0.0f, 150.0f, 1.0f); + imguiSlider("Merged Region Size", ®ionMergeSize, 0.0f, 150.0f, 1.0f); imguiSeparator(); imguiLabel("Partitioning"); - if (imguiCheck("Watershed", m_partitionType == SAMPLE_PARTITION_WATERSHED)) + if (imguiCheck("Watershed", partitionType == SAMPLE_PARTITION_WATERSHED)) { - m_partitionType = SAMPLE_PARTITION_WATERSHED; + partitionType = SAMPLE_PARTITION_WATERSHED; } - if (imguiCheck("Monotone", m_partitionType == SAMPLE_PARTITION_MONOTONE)) + if (imguiCheck("Monotone", partitionType == SAMPLE_PARTITION_MONOTONE)) { - m_partitionType = SAMPLE_PARTITION_MONOTONE; + partitionType = SAMPLE_PARTITION_MONOTONE; } - if (imguiCheck("Layers", m_partitionType == SAMPLE_PARTITION_LAYERS)) + if (imguiCheck("Layers", partitionType == SAMPLE_PARTITION_LAYERS)) { - m_partitionType = SAMPLE_PARTITION_LAYERS; + partitionType = SAMPLE_PARTITION_LAYERS; } imguiSeparator(); imguiLabel("Filtering"); - if (imguiCheck("Low Hanging Obstacles", m_filterLowHangingObstacles)) + if (imguiCheck("Low Hanging Obstacles", filterLowHangingObstacles)) { - m_filterLowHangingObstacles = !m_filterLowHangingObstacles; + filterLowHangingObstacles = !filterLowHangingObstacles; } - if (imguiCheck("Ledge Spans", m_filterLedgeSpans)) + if (imguiCheck("Ledge Spans", filterLedgeSpans)) { - m_filterLedgeSpans = !m_filterLedgeSpans; + filterLedgeSpans = !filterLedgeSpans; } - if (imguiCheck("Walkable Low Height Spans", m_filterWalkableLowHeightSpans)) + if (imguiCheck("Walkable Low Height Spans", filterWalkableLowHeightSpans)) { - m_filterWalkableLowHeightSpans = !m_filterWalkableLowHeightSpans; + filterWalkableLowHeightSpans = !filterWalkableLowHeightSpans; } imguiSeparator(); imguiLabel("Polygonization"); - imguiSlider("Max Edge Length", &m_edgeMaxLen, 0.0f, 50.0f, 1.0f); - imguiSlider("Max Edge Error", &m_edgeMaxError, 0.1f, 3.0f, 0.1f); - imguiSlider("Verts Per Poly", &m_vertsPerPoly, 3.0f, 12.0f, 1.0f); + imguiSlider("Max Edge Length", &edgeMaxLen, 0.0f, 50.0f, 1.0f); + imguiSlider("Max Edge Error", &edgeMaxError, 0.1f, 3.0f, 0.1f); + imguiSlider("Verts Per Poly", &vertsPerPoly, 3.0f, 12.0f, 1.0f); imguiSeparator(); imguiLabel("Detail Mesh"); - imguiSlider("Sample Distance", &m_detailSampleDist, 0.0f, 16.0f, 1.0f); - imguiSlider("Max Sample Error", &m_detailSampleMaxError, 0.0f, 16.0f, 1.0f); + imguiSlider("Sample Distance", &detailSampleDist, 0.0f, 16.0f, 1.0f); + imguiSlider("Max Sample Error", &detailSampleMaxError, 0.0f, 16.0f, 1.0f); imguiSeparator(); } void Sample::handleClick(const float* s, const float* p, bool shift) { - if (m_tool) + if (tool) { - m_tool->handleClick(s, p, shift); + tool->handleClick(s, p, shift); } } void Sample::handleToggle() { - if (m_tool) + if (tool) { - m_tool->handleToggle(); + tool->handleToggle(); } } void Sample::handleStep() { - if (m_tool) + if (tool) { - m_tool->handleStep(); + tool->handleStep(); } } @@ -303,9 +303,9 @@ bool Sample::handleBuild() void Sample::handleUpdate(const float dt) { - if (m_tool) + if (tool) { - m_tool->handleUpdate(dt); + tool->handleUpdate(dt); } updateToolStates(dt); } @@ -314,9 +314,9 @@ void Sample::updateToolStates(const float dt) { for (int i = 0; i < static_cast(SampleToolType::MAX_TOOLS); i++) { - if (m_toolStates[i]) + if (toolStates[i]) { - m_toolStates[i]->handleUpdate(dt); + toolStates[i]->handleUpdate(dt); } } } @@ -325,9 +325,9 @@ void Sample::initToolStates(Sample* sample) { for (int i = 0; i < static_cast(SampleToolType::MAX_TOOLS); i++) { - if (m_toolStates[i]) + if (toolStates[i]) { - m_toolStates[i]->init(sample); + toolStates[i]->init(sample); } } } @@ -336,9 +336,9 @@ void Sample::resetToolStates() { for (int i = 0; i < static_cast(SampleToolType::MAX_TOOLS); i++) { - if (m_toolStates[i]) + if (toolStates[i]) { - m_toolStates[i]->reset(); + toolStates[i]->reset(); } } } @@ -347,9 +347,9 @@ void Sample::renderToolStates() { for (int i = 0; i < static_cast(SampleToolType::MAX_TOOLS); i++) { - if (m_toolStates[i]) + if (toolStates[i]) { - m_toolStates[i]->handleRender(); + toolStates[i]->handleRender(); } } } @@ -358,9 +358,9 @@ void Sample::renderOverlayToolStates(double* proj, double* model, int* view) { for (int i = 0; i < static_cast(SampleToolType::MAX_TOOLS); i++) { - if (m_toolStates[i]) + if (toolStates[i]) { - m_toolStates[i]->handleRenderOverlay(proj, model, view); + toolStates[i]->handleRenderOverlay(proj, model, view); } } } diff --git a/RecastDemo/Source/Sample_SoloMesh.cpp b/RecastDemo/Source/Sample_SoloMesh.cpp index 58eef9ab..af938296 100644 --- a/RecastDemo/Source/Sample_SoloMesh.cpp +++ b/RecastDemo/Source/Sample_SoloMesh.cpp @@ -60,7 +60,7 @@ void Sample_SoloMesh::cleanup() rcFreeContourSet(m_contourSet); m_contourSet = 0; rcFreePolyMesh(m_polyMesh); m_polyMesh = 0; rcFreePolyMeshDetail(m_detailMesh); m_detailMesh = 0; - dtFreeNavMesh(m_navMesh); m_navMesh = 0; + dtFreeNavMesh(navMesh); navMesh = 0; } void Sample_SoloMesh::handleSettings() @@ -74,14 +74,14 @@ void Sample_SoloMesh::handleSettings() if (imguiButton("Save")) { - saveAll("solo_navmesh.bin", m_navMesh); + saveAll("solo_navmesh.bin", navMesh); } if (imguiButton("Load")) { - dtFreeNavMesh(m_navMesh); - m_navMesh = loadAll("solo_navmesh.bin"); - m_navQuery->init(m_navMesh, 2048); + dtFreeNavMesh(navMesh); + navMesh = loadAll("solo_navmesh.bin"); + navQuery->init(navMesh, 2048); } imguiUnindent(); @@ -96,7 +96,7 @@ void Sample_SoloMesh::handleSettings() void Sample_SoloMesh::handleTools() { - const SampleToolType type = !m_tool ? SampleToolType::NONE : m_tool->type(); + const SampleToolType type = !tool ? SampleToolType::NONE : tool->type(); if (imguiCheck("Test Navmesh", type == SampleToolType::NAVMESH_TESTER)) { setTool(new NavMeshTesterTool); } if (imguiCheck("Prune Navmesh", type == SampleToolType::NAVMESH_PRUNE)) { setTool(new NavMeshPruneTool); } @@ -108,9 +108,9 @@ void Sample_SoloMesh::handleTools() imguiIndent(); - if (m_tool) + if (tool) { - m_tool->handleMenu(); + tool->handleMenu(); } imguiUnindent(); @@ -128,11 +128,11 @@ void Sample_SoloMesh::handleDebugMode() { imguiLabel("Draw"); UI_DrawModeOption("Input Mesh", DrawMode::MESH, true); - UI_DrawModeOption("Navmesh", DrawMode::NAVMESH, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh Invis", DrawMode::NAVMESH_INVIS, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh Trans", DrawMode::NAVMESH_TRANS, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh BVTree", DrawMode::NAVMESH_BVTREE, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh Nodes", DrawMode::NAVMESH_NODES, m_navQuery != nullptr); + UI_DrawModeOption("Navmesh", DrawMode::NAVMESH, navMesh != nullptr); + UI_DrawModeOption("Navmesh Invis", DrawMode::NAVMESH_INVIS, navMesh != nullptr); + UI_DrawModeOption("Navmesh Trans", DrawMode::NAVMESH_TRANS, navMesh != nullptr); + UI_DrawModeOption("Navmesh BVTree", DrawMode::NAVMESH_BVTREE, navMesh != nullptr); + UI_DrawModeOption("Navmesh Nodes", DrawMode::NAVMESH_NODES, navQuery != nullptr); UI_DrawModeOption("Voxels", DrawMode::VOXELS, m_heightfield != nullptr); UI_DrawModeOption("Walkable Voxels", DrawMode::VOXELS_WALKABLE, m_heightfield != nullptr); UI_DrawModeOption("Compact", DrawMode::COMPACT, m_compactHeightfield != nullptr); @@ -148,7 +148,7 @@ void Sample_SoloMesh::handleDebugMode() void Sample_SoloMesh::handleRender() { - if (!m_inputGeometry || !m_inputGeometry->getMesh()) + if (!inputGeometry || !inputGeometry->getMesh()) { return; } @@ -156,29 +156,29 @@ void Sample_SoloMesh::handleRender() glEnable(GL_FOG); glDepthMask(GL_TRUE); - const float texScale = 1.0f / (m_cellSize * 10.0f); + const float texScale = 1.0f / (cellSize * 10.0f); if (m_drawMode != DrawMode::NAVMESH_TRANS) { // Draw mesh - duDebugDrawTriMeshSlope(&m_debugDraw, m_inputGeometry->getMesh()->getVerts(), m_inputGeometry->getMesh()->getVertCount(), - m_inputGeometry->getMesh()->getTris(), m_inputGeometry->getMesh()->getNormals(), m_inputGeometry->getMesh()->getTriCount(), - m_agentMaxSlope, texScale); - m_inputGeometry->drawOffMeshConnections(&m_debugDraw); + duDebugDrawTriMeshSlope(&debugDraw, inputGeometry->getMesh()->getVerts(), inputGeometry->getMesh()->getVertCount(), + inputGeometry->getMesh()->getTris(), inputGeometry->getMesh()->getNormals(), inputGeometry->getMesh()->getTriCount(), + agentMaxSlope, texScale); + inputGeometry->drawOffMeshConnections(&debugDraw); } glDisable(GL_FOG); glDepthMask(GL_FALSE); // Draw bounds - const float* navmeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* navmeshBoundsMax = m_inputGeometry->getNavMeshBoundsMax(); - duDebugDrawBoxWire(&m_debugDraw, navmeshBoundsMin[0],navmeshBoundsMin[1],navmeshBoundsMin[2], navmeshBoundsMax[0],navmeshBoundsMax[1],navmeshBoundsMax[2], duRGBA(255,255,255,128), 1.0f); - m_debugDraw.begin(DU_DRAW_POINTS, 5.0f); - m_debugDraw.vertex(navmeshBoundsMin[0],navmeshBoundsMin[1],navmeshBoundsMin[2],duRGBA(255,255,255,128)); - m_debugDraw.end(); + const float* navmeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* navmeshBoundsMax = inputGeometry->getNavMeshBoundsMax(); + duDebugDrawBoxWire(&debugDraw, navmeshBoundsMin[0],navmeshBoundsMin[1],navmeshBoundsMin[2], navmeshBoundsMax[0],navmeshBoundsMax[1],navmeshBoundsMax[2], duRGBA(255,255,255,128), 1.0f); + debugDraw.begin(DU_DRAW_POINTS, 5.0f); + debugDraw.vertex(navmeshBoundsMin[0],navmeshBoundsMin[1],navmeshBoundsMin[2],duRGBA(255,255,255,128)); + debugDraw.end(); - if (m_navMesh && m_navQuery && + if (navMesh && navQuery && (m_drawMode == DrawMode::NAVMESH || m_drawMode == DrawMode::NAVMESH_TRANS || m_drawMode == DrawMode::NAVMESH_BVTREE || @@ -187,91 +187,91 @@ void Sample_SoloMesh::handleRender() { if (m_drawMode != DrawMode::NAVMESH_INVIS) { - duDebugDrawNavMeshWithClosedList(&m_debugDraw, *m_navMesh, *m_navQuery, m_navMeshDrawFlags); + duDebugDrawNavMeshWithClosedList(&debugDraw, *navMesh, *navQuery, navMeshDrawFlags); } if (m_drawMode == DrawMode::NAVMESH_BVTREE) { - duDebugDrawNavMeshBVTree(&m_debugDraw, *m_navMesh); + duDebugDrawNavMeshBVTree(&debugDraw, *navMesh); } if (m_drawMode == DrawMode::NAVMESH_NODES) { - duDebugDrawNavMeshNodes(&m_debugDraw, *m_navQuery); + duDebugDrawNavMeshNodes(&debugDraw, *navQuery); } - duDebugDrawNavMeshPolysWithFlags(&m_debugDraw, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128)); + duDebugDrawNavMeshPolysWithFlags(&debugDraw, *navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128)); } glDepthMask(GL_TRUE); if (m_compactHeightfield && m_drawMode == DrawMode::COMPACT) { - duDebugDrawCompactHeightfieldSolid(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldSolid(&debugDraw, *m_compactHeightfield); } if (m_compactHeightfield && m_drawMode == DrawMode::COMPACT_DISTANCE) { - duDebugDrawCompactHeightfieldDistance(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldDistance(&debugDraw, *m_compactHeightfield); } if (m_compactHeightfield && m_drawMode == DrawMode::COMPACT_REGIONS) { - duDebugDrawCompactHeightfieldRegions(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldRegions(&debugDraw, *m_compactHeightfield); } if (m_heightfield && m_drawMode == DrawMode::VOXELS) { glEnable(GL_FOG); - duDebugDrawHeightfieldSolid(&m_debugDraw, *m_heightfield); + duDebugDrawHeightfieldSolid(&debugDraw, *m_heightfield); glDisable(GL_FOG); } if (m_heightfield && m_drawMode == DrawMode::VOXELS_WALKABLE) { glEnable(GL_FOG); - duDebugDrawHeightfieldWalkable(&m_debugDraw, *m_heightfield); + duDebugDrawHeightfieldWalkable(&debugDraw, *m_heightfield); glDisable(GL_FOG); } if (m_contourSet && m_drawMode == DrawMode::RAW_CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawRawContours(&m_debugDraw, *m_contourSet); + duDebugDrawRawContours(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_contourSet && m_drawMode == DrawMode::BOTH_CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawRawContours(&m_debugDraw, *m_contourSet, 0.5f); - duDebugDrawContours(&m_debugDraw, *m_contourSet); + duDebugDrawRawContours(&debugDraw, *m_contourSet, 0.5f); + duDebugDrawContours(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_contourSet && m_drawMode == DrawMode::CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawContours(&m_debugDraw, *m_contourSet); + duDebugDrawContours(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_compactHeightfield && m_contourSet && m_drawMode == DrawMode::REGION_CONNECTIONS) { - duDebugDrawCompactHeightfieldRegions(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldRegions(&debugDraw, *m_compactHeightfield); glDepthMask(GL_FALSE); - duDebugDrawRegionConnections(&m_debugDraw, *m_contourSet); + duDebugDrawRegionConnections(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_polyMesh && m_drawMode == DrawMode::POLYMESH) { glDepthMask(GL_FALSE); - duDebugDrawPolyMesh(&m_debugDraw, *m_polyMesh); + duDebugDrawPolyMesh(&debugDraw, *m_polyMesh); glDepthMask(GL_TRUE); } if (m_detailMesh && m_drawMode == DrawMode::POLYMESH_DETAIL) { glDepthMask(GL_FALSE); - duDebugDrawPolyMeshDetail(&m_debugDraw, *m_detailMesh); + duDebugDrawPolyMeshDetail(&debugDraw, *m_detailMesh); glDepthMask(GL_TRUE); } - m_inputGeometry->drawConvexVolumes(&m_debugDraw); + inputGeometry->drawConvexVolumes(&debugDraw); - if (m_tool) + if (tool) { - m_tool->handleRender(); + tool->handleRender(); } renderToolStates(); @@ -280,9 +280,9 @@ void Sample_SoloMesh::handleRender() void Sample_SoloMesh::handleRenderOverlay(double* proj, double* model, int* view) { - if (m_tool) + if (tool) { - m_tool->handleRenderOverlay(proj, model, view); + tool->handleRenderOverlay(proj, model, view); } renderOverlayToolStates(proj, model, view); } @@ -291,12 +291,12 @@ void Sample_SoloMesh::handleMeshChanged(InputGeom* geom) { Sample::handleMeshChanged(geom); - dtFreeNavMesh(m_navMesh); m_navMesh = 0; + dtFreeNavMesh(navMesh); navMesh = 0; - if (m_tool) + if (tool) { - m_tool->reset(); - m_tool->init(this); + tool->reset(); + tool->init(this); } resetToolStates(); initToolStates(this); @@ -304,20 +304,20 @@ void Sample_SoloMesh::handleMeshChanged(InputGeom* geom) bool Sample_SoloMesh::handleBuild() { - if (!m_inputGeometry || !m_inputGeometry->getMesh()) + if (!inputGeometry || !inputGeometry->getMesh()) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified."); return false; } cleanup(); - const float* boundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* boundsMax = m_inputGeometry->getNavMeshBoundsMax(); - const float* verts = m_inputGeometry->getMesh()->getVerts(); - const int numVerts = m_inputGeometry->getMesh()->getVertCount(); - const int* tris = m_inputGeometry->getMesh()->getTris(); - const int numTris = m_inputGeometry->getMesh()->getTriCount(); + const float* boundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* boundsMax = inputGeometry->getNavMeshBoundsMax(); + const float* verts = inputGeometry->getMesh()->getVerts(); + const int numVerts = inputGeometry->getMesh()->getVertCount(); + const int* tris = inputGeometry->getMesh()->getTris(); + const int numTris = inputGeometry->getMesh()->getTriCount(); // // Step 1. Initialize build config. @@ -325,19 +325,19 @@ bool Sample_SoloMesh::handleBuild() // Init build configuration from GUI memset(&m_config, 0, sizeof(m_config)); - m_config.cs = m_cellSize; - m_config.ch = m_cellHeight; - m_config.walkableSlopeAngle = m_agentMaxSlope; - m_config.walkableHeight = static_cast(ceilf(m_agentHeight / m_config.ch)); - m_config.walkableClimb = static_cast(floorf(m_agentMaxClimb / m_config.ch)); - m_config.walkableRadius = static_cast(ceilf(m_agentRadius / m_config.cs)); - m_config.maxEdgeLen = static_cast(m_edgeMaxLen / m_cellSize); - m_config.maxSimplificationError = m_edgeMaxError; - m_config.minRegionArea = static_cast(rcSqr(m_regionMinSize)); // Note: area = size*size - m_config.mergeRegionArea = static_cast(rcSqr(m_regionMergeSize)); // Note: area = size*size - m_config.maxVertsPerPoly = static_cast(m_vertsPerPoly); - m_config.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist; - m_config.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError; + m_config.cs = cellSize; + m_config.ch = cellHeight; + m_config.walkableSlopeAngle = agentMaxSlope; + m_config.walkableHeight = static_cast(ceilf(agentHeight / m_config.ch)); + m_config.walkableClimb = static_cast(floorf(agentMaxClimb / m_config.ch)); + m_config.walkableRadius = static_cast(ceilf(agentRadius / m_config.cs)); + m_config.maxEdgeLen = static_cast(edgeMaxLen / cellSize); + m_config.maxSimplificationError = edgeMaxError; + m_config.minRegionArea = static_cast(rcSqr(regionMinSize)); // Note: area = size*size + m_config.mergeRegionArea = static_cast(rcSqr(regionMergeSize)); // Note: area = size*size + m_config.maxVertsPerPoly = static_cast(vertsPerPoly); + m_config.detailSampleDist = detailSampleDist < 0.9f ? 0 : cellSize * detailSampleDist; + m_config.detailSampleMaxError = cellHeight * detailSampleMaxError; // Set the area where the navigation will be built. // Here the bounds of the input mesh are used, but the @@ -347,13 +347,13 @@ bool Sample_SoloMesh::handleBuild() rcCalcGridSize(m_config.bmin, m_config.bmax, m_config.cs, &m_config.width, &m_config.height); // Reset build times gathering. - m_buildContext->resetTimers(); - m_buildContext->startTimer(RC_TIMER_TOTAL); + buildContext->resetTimers(); + buildContext->startTimer(RC_TIMER_TOTAL); // Start the build process. - m_buildContext->log(RC_LOG_PROGRESS, "Building navigation:"); - m_buildContext->log(RC_LOG_PROGRESS, " - %d x %d cells", m_config.width, m_config.height); - m_buildContext->log(RC_LOG_PROGRESS, " - %.1fK verts, %.1fK tris", static_cast(numVerts) / 1000.0f, static_cast(numTris) / 1000.0f); + buildContext->log(RC_LOG_PROGRESS, "Building navigation:"); + buildContext->log(RC_LOG_PROGRESS, " - %d x %d cells", m_config.width, m_config.height); + buildContext->log(RC_LOG_PROGRESS, " - %.1fK verts, %.1fK tris", static_cast(numVerts) / 1000.0f, static_cast(numTris) / 1000.0f); // // Step 2. Rasterize input meshes. @@ -363,12 +363,12 @@ bool Sample_SoloMesh::handleBuild() m_heightfield = rcAllocHeightfield(); if (!m_heightfield) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_heightfield'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_heightfield'."); return false; } - if (!rcCreateHeightfield(m_buildContext, *m_heightfield, m_config.width, m_config.height, m_config.bmin, m_config.bmax, m_config.cs, m_config.ch)) + if (!rcCreateHeightfield(buildContext, *m_heightfield, m_config.width, m_config.height, m_config.bmin, m_config.bmax, m_config.cs, m_config.ch)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); return false; } @@ -380,21 +380,21 @@ bool Sample_SoloMesh::handleBuild() m_triareas = new unsigned char[numTris]; if (!m_triareas) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", numTris); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", numTris); return false; } memset(m_triareas, 0, numTris * sizeof(unsigned char)); // Record which triangles in the input mesh are walkable. // This information is recorded in m_triareas - rcMarkWalkableTriangles(m_buildContext, m_config.walkableSlopeAngle, verts, numVerts, tris, numTris, m_triareas); + rcMarkWalkableTriangles(buildContext, m_config.walkableSlopeAngle, verts, numVerts, tris, numTris, m_triareas); // Rasterize the input mesh // If your have multiple meshes, you can transform them, calculate the // terrain type for each mesh and rasterize them here. - if (!rcRasterizeTriangles(m_buildContext, verts, numVerts, tris, m_triareas, numTris, *m_heightfield, m_config.walkableClimb)) + if (!rcRasterizeTriangles(buildContext, verts, numVerts, tris, m_triareas, numTris, *m_heightfield, m_config.walkableClimb)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not rasterize triangles."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not rasterize triangles."); return false; } @@ -405,17 +405,17 @@ bool Sample_SoloMesh::handleBuild() // Once all geometry is rasterized, we do initial pass of filtering to // remove unwanted overhangs caused by the conservative rasterization // as well as spans where the character cannot possibly stand. - if (m_filterLowHangingObstacles) + if (filterLowHangingObstacles) { - rcFilterLowHangingWalkableObstacles(m_buildContext, m_config.walkableClimb, *m_heightfield); + rcFilterLowHangingWalkableObstacles(buildContext, m_config.walkableClimb, *m_heightfield); } - if (m_filterLedgeSpans) + if (filterLedgeSpans) { - rcFilterLedgeSpans(m_buildContext, m_config.walkableHeight, m_config.walkableClimb, *m_heightfield); + rcFilterLedgeSpans(buildContext, m_config.walkableHeight, m_config.walkableClimb, *m_heightfield); } - if (m_filterWalkableLowHeightSpans) + if (filterWalkableLowHeightSpans) { - rcFilterWalkableLowHeightSpans(m_buildContext, m_config.walkableHeight, *m_heightfield); + rcFilterWalkableLowHeightSpans(buildContext, m_config.walkableHeight, *m_heightfield); } // @@ -428,29 +428,29 @@ bool Sample_SoloMesh::handleBuild() m_compactHeightfield = rcAllocCompactHeightfield(); if (!m_compactHeightfield) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); return false; } - if (!rcBuildCompactHeightfield(m_buildContext, m_config.walkableHeight, m_config.walkableClimb, *m_heightfield, *m_compactHeightfield)) + if (!rcBuildCompactHeightfield(buildContext, m_config.walkableHeight, m_config.walkableClimb, *m_heightfield, *m_compactHeightfield)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); return false; } // Erode the walkable area by agent radius. // This allows us to path an agent through the navmesh as if it was a single point - if (!rcErodeWalkableArea(m_buildContext, m_config.walkableRadius, *m_compactHeightfield)) + if (!rcErodeWalkableArea(buildContext, m_config.walkableRadius, *m_compactHeightfield)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); return false; } // (Optional) Marks the surface type of voxels in an area defined by a convex volume. // Useful to mark areas of differing cost. - const ConvexVolume* vols = m_inputGeometry->getConvexVolumes(); - for (int i = 0; i < m_inputGeometry->getConvexVolumeCount(); ++i) + const ConvexVolume* vols = inputGeometry->getConvexVolumes(); + for (int i = 0; i < inputGeometry->getConvexVolumeCount(); ++i) { - rcMarkConvexPolyArea(m_buildContext, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_compactHeightfield); + rcMarkConvexPolyArea(buildContext, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_compactHeightfield); } // Partition the heightfield into contiguous regions that will each be @@ -487,29 +487,29 @@ bool Sample_SoloMesh::handleBuild() // This is less of a problem if you use a tiled navmesh. // * A good choice for a tiled navmesh with small to medium-sized tiles - if (m_partitionType == SAMPLE_PARTITION_WATERSHED) + if (partitionType == SAMPLE_PARTITION_WATERSHED) { // Prepare for region partitioning, by calculating distance field along the walkable surface. - if (!rcBuildDistanceField(m_buildContext, *m_compactHeightfield)) + if (!rcBuildDistanceField(buildContext, *m_compactHeightfield)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field."); return false; } // Partition the walkable surface into contiguous regions. - if (!rcBuildRegions(m_buildContext, *m_compactHeightfield, 0, m_config.minRegionArea, m_config.mergeRegionArea)) + if (!rcBuildRegions(buildContext, *m_compactHeightfield, 0, m_config.minRegionArea, m_config.mergeRegionArea)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build watershed regions."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build watershed regions."); return false; } } - else if (m_partitionType == SAMPLE_PARTITION_MONOTONE) + else if (partitionType == SAMPLE_PARTITION_MONOTONE) { // Partition the walkable surface into contiguous regions. // Monotone partitioning does not need distancefield. - if (!rcBuildRegionsMonotone(m_buildContext, *m_compactHeightfield, 0, m_config.minRegionArea, m_config.mergeRegionArea)) + if (!rcBuildRegionsMonotone(buildContext, *m_compactHeightfield, 0, m_config.minRegionArea, m_config.mergeRegionArea)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build monotone regions."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build monotone regions."); return false; } } @@ -517,9 +517,9 @@ bool Sample_SoloMesh::handleBuild() { // Partition the walkable surface into contiguous regions. // Layer partitioning does not need distancefield. - if (!rcBuildLayerRegions(m_buildContext, *m_compactHeightfield, 0, m_config.minRegionArea)) + if (!rcBuildLayerRegions(buildContext, *m_compactHeightfield, 0, m_config.minRegionArea)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build layer regions."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build layer regions."); return false; } } @@ -532,12 +532,12 @@ bool Sample_SoloMesh::handleBuild() m_contourSet = rcAllocContourSet(); if (!m_contourSet) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'."); return false; } - if (!rcBuildContours(m_buildContext, *m_compactHeightfield, m_config.maxSimplificationError, m_config.maxEdgeLen, *m_contourSet)) + if (!rcBuildContours(buildContext, *m_compactHeightfield, m_config.maxSimplificationError, m_config.maxEdgeLen, *m_contourSet)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create contours."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create contours."); return false; } @@ -548,12 +548,12 @@ bool Sample_SoloMesh::handleBuild() m_polyMesh = rcAllocPolyMesh(); if (!m_polyMesh) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'."); return false; } - if (!rcBuildPolyMesh(m_buildContext, *m_contourSet, m_config.maxVertsPerPoly, *m_polyMesh)) + if (!rcBuildPolyMesh(buildContext, *m_contourSet, m_config.maxVertsPerPoly, *m_polyMesh)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not triangulate contours."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not triangulate contours."); return false; } @@ -566,12 +566,12 @@ bool Sample_SoloMesh::handleBuild() m_detailMesh = rcAllocPolyMeshDetail(); if (!m_detailMesh) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmdtl'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmdtl'."); return false; } - if (!rcBuildPolyMeshDetail(m_buildContext, *m_polyMesh, *m_compactHeightfield, m_config.detailSampleDist, m_config.detailSampleMaxError, *m_detailMesh)) + if (!rcBuildPolyMeshDetail(buildContext, *m_polyMesh, *m_compactHeightfield, m_config.detailSampleDist, m_config.detailSampleMaxError, *m_detailMesh)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build detail mesh."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build detail mesh."); return false; } @@ -628,16 +628,16 @@ bool Sample_SoloMesh::handleBuild() params.detailVertsCount = m_detailMesh->nverts; params.detailTris = m_detailMesh->tris; params.detailTriCount = m_detailMesh->ntris; - params.offMeshConVerts = m_inputGeometry->getOffMeshConnectionVerts(); - params.offMeshConRad = m_inputGeometry->getOffMeshConnectionRads(); - params.offMeshConDir = m_inputGeometry->getOffMeshConnectionDirs(); - params.offMeshConAreas = m_inputGeometry->getOffMeshConnectionAreas(); - params.offMeshConFlags = m_inputGeometry->getOffMeshConnectionFlags(); - params.offMeshConUserID = m_inputGeometry->getOffMeshConnectionId(); - params.offMeshConCount = m_inputGeometry->getOffMeshConnectionCount(); - params.walkableHeight = m_agentHeight; - params.walkableRadius = m_agentRadius; - params.walkableClimb = m_agentMaxClimb; + params.offMeshConVerts = inputGeometry->getOffMeshConnectionVerts(); + params.offMeshConRad = inputGeometry->getOffMeshConnectionRads(); + params.offMeshConDir = inputGeometry->getOffMeshConnectionDirs(); + params.offMeshConAreas = inputGeometry->getOffMeshConnectionAreas(); + params.offMeshConFlags = inputGeometry->getOffMeshConnectionFlags(); + params.offMeshConUserID = inputGeometry->getOffMeshConnectionId(); + params.offMeshConCount = inputGeometry->getOffMeshConnectionCount(); + params.walkableHeight = agentHeight; + params.walkableRadius = agentRadius; + params.walkableClimb = agentMaxClimb; rcVcopy(params.bmin, m_polyMesh->bmin); rcVcopy(params.bmax, m_polyMesh->bmax); params.cs = m_config.cs; @@ -646,46 +646,46 @@ bool Sample_SoloMesh::handleBuild() if (!dtCreateNavMeshData(¶ms, &navData, &navDataSize)) { - m_buildContext->log(RC_LOG_ERROR, "Could not build Detour navmesh."); + buildContext->log(RC_LOG_ERROR, "Could not build Detour navmesh."); return false; } - m_navMesh = dtAllocNavMesh(); - if (!m_navMesh) + navMesh = dtAllocNavMesh(); + if (!navMesh) { dtFree(navData); - m_buildContext->log(RC_LOG_ERROR, "Could not create Detour navmesh"); + buildContext->log(RC_LOG_ERROR, "Could not create Detour navmesh"); return false; } - dtStatus status = m_navMesh->init(navData, navDataSize, DT_TILE_FREE_DATA); + dtStatus status = navMesh->init(navData, navDataSize, DT_TILE_FREE_DATA); if (dtStatusFailed(status)) { dtFree(navData); - m_buildContext->log(RC_LOG_ERROR, "Could not init Detour navmesh"); + buildContext->log(RC_LOG_ERROR, "Could not init Detour navmesh"); return false; } - status = m_navQuery->init(m_navMesh, 2048); + status = navQuery->init(navMesh, 2048); if (dtStatusFailed(status)) { - m_buildContext->log(RC_LOG_ERROR, "Could not init Detour navmesh query"); + buildContext->log(RC_LOG_ERROR, "Could not init Detour navmesh query"); return false; } } // Stop build timers - m_buildContext->stopTimer(RC_TIMER_TOTAL); - auto totalTime = m_buildContext->getAccumulatedTime(RC_TIMER_TOTAL); + buildContext->stopTimer(RC_TIMER_TOTAL); + auto totalTime = buildContext->getAccumulatedTime(RC_TIMER_TOTAL); m_totalBuildTimeMs = static_cast(totalTime) / 1000.0f; // Show performance stats. - duLogBuildTimes(*m_buildContext, totalTime); - m_buildContext->log(RC_LOG_PROGRESS, ">> Polymesh: %d vertices %d polygons", m_polyMesh->nverts, m_polyMesh->npolys); + duLogBuildTimes(*buildContext, totalTime); + buildContext->log(RC_LOG_PROGRESS, ">> Polymesh: %d vertices %d polygons", m_polyMesh->nverts, m_polyMesh->npolys); - if (m_tool) + if (tool) { - m_tool->init(this); + tool->init(this); } initToolStates(this); diff --git a/RecastDemo/Source/Sample_TempObstacles.cpp b/RecastDemo/Source/Sample_TempObstacles.cpp index b9286799..f0ef1dd1 100644 --- a/RecastDemo/Source/Sample_TempObstacles.cpp +++ b/RecastDemo/Source/Sample_TempObstacles.cpp @@ -256,18 +256,18 @@ struct RasterizationContext int Sample_TempObstacles::rasterizeTileLayers(const int tileX, const int tileY, const rcConfig& cfg, TileCacheData* tiles, const int maxTiles) { - if (!m_inputGeometry || !m_inputGeometry->getMesh() || !m_inputGeometry->getChunkyMesh()) + if (!inputGeometry || !inputGeometry->getMesh() || !inputGeometry->getChunkyMesh()) { - m_buildContext->log(RC_LOG_ERROR, "buildTile: Input mesh is not specified."); + buildContext->log(RC_LOG_ERROR, "buildTile: Input mesh is not specified."); return 0; } FastLZCompressor comp; RasterizationContext rasterContext; - const float* verts = m_inputGeometry->getMesh()->getVerts(); - const int nverts = m_inputGeometry->getMesh()->getVertCount(); - const rcChunkyTriMesh* chunkyMesh = m_inputGeometry->getChunkyMesh(); + const float* verts = inputGeometry->getMesh()->getVerts(); + const int nverts = inputGeometry->getMesh()->getVertCount(); + const rcChunkyTriMesh* chunkyMesh = inputGeometry->getChunkyMesh(); // Tile bounds. const float tcs = cfg.tileSize * cfg.cs; @@ -290,12 +290,12 @@ int Sample_TempObstacles::rasterizeTileLayers(const int tileX, const int tileY, rasterContext.solid = rcAllocHeightfield(); if (!rasterContext.solid) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'."); return 0; } - if (!rcCreateHeightfield(m_buildContext, *rasterContext.solid, tcfg.width, tcfg.height, tcfg.bmin, tcfg.bmax, tcfg.cs, tcfg.ch)) + if (!rcCreateHeightfield(buildContext, *rasterContext.solid, tcfg.width, tcfg.height, tcfg.bmin, tcfg.bmax, tcfg.cs, tcfg.ch)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); return 0; } @@ -305,7 +305,7 @@ int Sample_TempObstacles::rasterizeTileLayers(const int tileX, const int tileY, rasterContext.triareas = new unsigned char[chunkyMesh->maxTrisPerChunk]; if (!rasterContext.triareas) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk); return 0; } @@ -328,8 +328,8 @@ int Sample_TempObstacles::rasterizeTileLayers(const int tileX, const int tileY, const int ntris = node.n; memset(rasterContext.triareas, 0, ntris * sizeof(unsigned char)); - rcMarkWalkableTriangles(m_buildContext, tcfg.walkableSlopeAngle, verts, nverts, tris, ntris, rasterContext.triareas); - if (!rcRasterizeTriangles(m_buildContext, verts, nverts, tris, rasterContext.triareas, ntris, *rasterContext.solid, tcfg.walkableClimb)) + rcMarkWalkableTriangles(buildContext, tcfg.walkableSlopeAngle, verts, nverts, tris, ntris, rasterContext.triareas); + if (!rcRasterizeTriangles(buildContext, verts, nverts, tris, rasterContext.triareas, ntris, *rasterContext.solid, tcfg.walkableClimb)) { return 0; } @@ -338,43 +338,43 @@ int Sample_TempObstacles::rasterizeTileLayers(const int tileX, const int tileY, // Once all geometry is rasterized, we do initial pass of filtering to // remove unwanted overhangs caused by the conservative rasterization // as well as filter spans where the character cannot possibly stand. - if (m_filterLowHangingObstacles) + if (filterLowHangingObstacles) { - rcFilterLowHangingWalkableObstacles(m_buildContext, tcfg.walkableClimb, *rasterContext.solid); + rcFilterLowHangingWalkableObstacles(buildContext, tcfg.walkableClimb, *rasterContext.solid); } - if (m_filterLedgeSpans) + if (filterLedgeSpans) { - rcFilterLedgeSpans(m_buildContext, tcfg.walkableHeight, tcfg.walkableClimb, *rasterContext.solid); + rcFilterLedgeSpans(buildContext, tcfg.walkableHeight, tcfg.walkableClimb, *rasterContext.solid); } - if (m_filterWalkableLowHeightSpans) + if (filterWalkableLowHeightSpans) { - rcFilterWalkableLowHeightSpans(m_buildContext, tcfg.walkableHeight, *rasterContext.solid); + rcFilterWalkableLowHeightSpans(buildContext, tcfg.walkableHeight, *rasterContext.solid); } rasterContext.chf = rcAllocCompactHeightfield(); if (!rasterContext.chf) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); return 0; } - if (!rcBuildCompactHeightfield(m_buildContext, tcfg.walkableHeight, tcfg.walkableClimb, *rasterContext.solid, *rasterContext.chf)) + if (!rcBuildCompactHeightfield(buildContext, tcfg.walkableHeight, tcfg.walkableClimb, *rasterContext.solid, *rasterContext.chf)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); return 0; } // Erode the walkable area by agent radius. - if (!rcErodeWalkableArea(m_buildContext, tcfg.walkableRadius, *rasterContext.chf)) + if (!rcErodeWalkableArea(buildContext, tcfg.walkableRadius, *rasterContext.chf)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); return 0; } // (Optional) Mark areas. - const ConvexVolume* vols = m_inputGeometry->getConvexVolumes(); - for (int i = 0; i < m_inputGeometry->getConvexVolumeCount(); ++i) + const ConvexVolume* vols = inputGeometry->getConvexVolumes(); + for (int i = 0; i < inputGeometry->getConvexVolumeCount(); ++i) { - rcMarkConvexPolyArea(m_buildContext, vols[i].verts, vols[i].nverts, + rcMarkConvexPolyArea(buildContext, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *rasterContext.chf); } @@ -382,12 +382,12 @@ int Sample_TempObstacles::rasterizeTileLayers(const int tileX, const int tileY, rasterContext.lset = rcAllocHeightfieldLayerSet(); if (!rasterContext.lset) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'lset'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'lset'."); return 0; } - if (!rcBuildHeightfieldLayers(m_buildContext, *rasterContext.chf, tcfg.borderSize, tcfg.walkableHeight, *rasterContext.lset)) + if (!rcBuildHeightfieldLayers(buildContext, *rasterContext.chf, tcfg.borderSize, tcfg.walkableHeight, *rasterContext.lset)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build heighfield layers."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build heighfield layers."); return 0; } @@ -804,7 +804,7 @@ Sample_TempObstacles::Sample_TempObstacles() Sample_TempObstacles::~Sample_TempObstacles() { - dtFreeNavMesh(m_navMesh); m_navMesh = 0; + dtFreeNavMesh(navMesh); navMesh = 0; dtFreeTileCache(m_tileCache); } @@ -821,13 +821,13 @@ void Sample_TempObstacles::handleSettings() imguiSlider("TileSize", &m_tileSize, 16.0f, 128.0f, 8.0f); int gridSize = 1; - if (m_inputGeometry) + if (inputGeometry) { - const float* bmin = m_inputGeometry->getNavMeshBoundsMin(); - const float* bmax = m_inputGeometry->getNavMeshBoundsMax(); + const float* bmin = inputGeometry->getNavMeshBoundsMin(); + const float* bmax = inputGeometry->getNavMeshBoundsMax(); char text[64]; int gw = 0, gh = 0; - rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh); + rcCalcGridSize(bmin, bmax, cellSize, &gw, &gh); const int ts = (int)m_tileSize; const int tw = (gw + ts-1) / ts; const int th = (gh + ts-1) / ts; @@ -884,10 +884,10 @@ void Sample_TempObstacles::handleSettings() if (imguiButton("Load")) { - dtFreeNavMesh(m_navMesh); + dtFreeNavMesh(navMesh); dtFreeTileCache(m_tileCache); loadAll("all_tiles_tilecache.bin"); - m_navQuery->init(m_navMesh, 2048); + navQuery->init(navMesh, 2048); } imguiUnindent(); @@ -898,7 +898,7 @@ void Sample_TempObstacles::handleSettings() void Sample_TempObstacles::handleTools() { - const SampleToolType type = !m_tool ? SampleToolType::NONE : m_tool->type(); + const SampleToolType type = !tool ? SampleToolType::NONE : tool->type(); if (imguiCheck("Test Navmesh", type == SampleToolType::NAVMESH_TESTER)) { @@ -929,9 +929,9 @@ void Sample_TempObstacles::handleTools() imguiIndent(); - if (m_tool) + if (tool) { - m_tool->handleMenu(); + tool->handleMenu(); } imguiUnindent(); @@ -946,14 +946,14 @@ void Sample_TempObstacles::handleDebugMode() valid[i] = false; } - if (m_inputGeometry) + if (inputGeometry) { - valid[DRAWMODE_NAVMESH] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_TRANS] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_BVTREE] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_NODES] = m_navQuery != 0; - valid[DRAWMODE_NAVMESH_PORTALS] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_INVIS] = m_navMesh != 0; + valid[DRAWMODE_NAVMESH] = navMesh != 0; + valid[DRAWMODE_NAVMESH_TRANS] = navMesh != 0; + valid[DRAWMODE_NAVMESH_BVTREE] = navMesh != 0; + valid[DRAWMODE_NAVMESH_NODES] = navQuery != 0; + valid[DRAWMODE_NAVMESH_PORTALS] = navMesh != 0; + valid[DRAWMODE_NAVMESH_INVIS] = navMesh != 0; valid[DRAWMODE_MESH] = true; valid[DRAWMODE_CACHE_BOUNDS] = true; } @@ -1016,47 +1016,47 @@ void Sample_TempObstacles::handleDebugMode() void Sample_TempObstacles::handleRender() { - if (!m_inputGeometry || !m_inputGeometry->getMesh()) { return; } + if (!inputGeometry || !inputGeometry->getMesh()) { return; } - const float texScale = 1.0f / (m_cellSize * 10.0f); + const float texScale = 1.0f / (cellSize * 10.0f); // Draw mesh if (m_drawMode != DRAWMODE_NAVMESH_TRANS) { // Draw mesh - duDebugDrawTriMeshSlope(&m_debugDraw, m_inputGeometry->getMesh()->getVerts(), m_inputGeometry->getMesh()->getVertCount(), - m_inputGeometry->getMesh()->getTris(), m_inputGeometry->getMesh()->getNormals(), m_inputGeometry->getMesh()->getTriCount(), - m_agentMaxSlope, texScale); - m_inputGeometry->drawOffMeshConnections(&m_debugDraw); + duDebugDrawTriMeshSlope(&debugDraw, inputGeometry->getMesh()->getVerts(), inputGeometry->getMesh()->getVertCount(), + inputGeometry->getMesh()->getTris(), inputGeometry->getMesh()->getNormals(), inputGeometry->getMesh()->getTriCount(), + agentMaxSlope, texScale); + inputGeometry->drawOffMeshConnections(&debugDraw); } if (m_tileCache && m_drawMode == DRAWMODE_CACHE_BOUNDS) { - drawTiles(&m_debugDraw, m_tileCache); + drawTiles(&debugDraw, m_tileCache); } if (m_tileCache) { - drawObstacles(&m_debugDraw, m_tileCache); + drawObstacles(&debugDraw, m_tileCache); } glDepthMask(GL_FALSE); // Draw bounds - const float* bmin = m_inputGeometry->getNavMeshBoundsMin(); - const float* bmax = m_inputGeometry->getNavMeshBoundsMax(); - duDebugDrawBoxWire(&m_debugDraw, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f); + const float* bmin = inputGeometry->getNavMeshBoundsMin(); + const float* bmax = inputGeometry->getNavMeshBoundsMax(); + duDebugDrawBoxWire(&debugDraw, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f); // Tiling grid. int gw = 0; int gh = 0; - rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh); + rcCalcGridSize(bmin, bmax, cellSize, &gw, &gh); const int tw = (gw + (int)m_tileSize-1) / (int)m_tileSize; const int th = (gh + (int)m_tileSize-1) / (int)m_tileSize; - const float s = m_tileSize*m_cellSize; - duDebugDrawGridXZ(&m_debugDraw, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f); + const float s = m_tileSize*cellSize; + duDebugDrawGridXZ(&debugDraw, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f); - if (m_navMesh && m_navQuery && + if (navMesh && navQuery && (m_drawMode == DRAWMODE_NAVMESH || m_drawMode == DRAWMODE_NAVMESH_TRANS || m_drawMode == DRAWMODE_NAVMESH_BVTREE || @@ -1066,30 +1066,30 @@ void Sample_TempObstacles::handleRender() { if (m_drawMode != DRAWMODE_NAVMESH_INVIS) { - duDebugDrawNavMeshWithClosedList(&m_debugDraw, *m_navMesh, *m_navQuery, m_navMeshDrawFlags/*|DU_DRAWNAVMESH_COLOR_TILES*/); + duDebugDrawNavMeshWithClosedList(&debugDraw, *navMesh, *navQuery, navMeshDrawFlags/*|DU_DRAWNAVMESH_COLOR_TILES*/); } if (m_drawMode == DRAWMODE_NAVMESH_BVTREE) { - duDebugDrawNavMeshBVTree(&m_debugDraw, *m_navMesh); + duDebugDrawNavMeshBVTree(&debugDraw, *navMesh); } if (m_drawMode == DRAWMODE_NAVMESH_PORTALS) { - duDebugDrawNavMeshPortals(&m_debugDraw, *m_navMesh); + duDebugDrawNavMeshPortals(&debugDraw, *navMesh); } if (m_drawMode == DRAWMODE_NAVMESH_NODES) { - duDebugDrawNavMeshNodes(&m_debugDraw, *m_navQuery); + duDebugDrawNavMeshNodes(&debugDraw, *navQuery); } - duDebugDrawNavMeshPolysWithFlags(&m_debugDraw, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128)); + duDebugDrawNavMeshPolysWithFlags(&debugDraw, *navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128)); } glDepthMask(GL_TRUE); - m_inputGeometry->drawConvexVolumes(&m_debugDraw); + inputGeometry->drawConvexVolumes(&debugDraw); - if (m_tool) + if (tool) { - m_tool->handleRender(); + tool->handleRender(); } renderToolStates(); @@ -1100,7 +1100,7 @@ void Sample_TempObstacles::renderCachedTile(const int tileX, const int tileY, co { if (m_tileCache) { - drawDetail(&m_debugDraw,m_tileCache,tileX,tileY,type); + drawDetail(&debugDraw,m_tileCache,tileX,tileY,type); } } @@ -1114,9 +1114,9 @@ void Sample_TempObstacles::renderCachedTileOverlay(const int tileX, const int ti void Sample_TempObstacles::handleRenderOverlay(double* proj, double* model, int* view) { - if (m_tool) + if (tool) { - m_tool->handleRenderOverlay(proj, model, view); + tool->handleRenderOverlay(proj, model, view); } renderOverlayToolStates(proj, model, view); @@ -1151,14 +1151,14 @@ void Sample_TempObstacles::handleMeshChanged(class InputGeom* geom) dtFreeTileCache(m_tileCache); m_tileCache = 0; - dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + dtFreeNavMesh(navMesh); + navMesh = 0; - if (m_tool) + if (tool) { - m_tool->reset(); - m_tool->init(this); - m_tmproc->init(m_inputGeometry); + tool->reset(); + tool->init(this); + m_tmproc->init(inputGeometry); } resetToolStates(); initToolStates(this); @@ -1199,19 +1199,19 @@ bool Sample_TempObstacles::handleBuild() { dtStatus status; - if (!m_inputGeometry || !m_inputGeometry->getMesh()) + if (!inputGeometry || !inputGeometry->getMesh()) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: No vertices and triangles."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: No vertices and triangles."); return false; } - m_tmproc->init(m_inputGeometry); + m_tmproc->init(inputGeometry); // Init cache - const float* bmin = m_inputGeometry->getNavMeshBoundsMin(); - const float* bmax = m_inputGeometry->getNavMeshBoundsMax(); + const float* bmin = inputGeometry->getNavMeshBoundsMin(); + const float* bmax = inputGeometry->getNavMeshBoundsMax(); int gw = 0, gh = 0; - rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh); + rcCalcGridSize(bmin, bmax, cellSize, &gw, &gh); const int ts = (int)m_tileSize; const int tw = (gw + ts-1) / ts; const int th = (gh + ts-1) / ts; @@ -1219,23 +1219,23 @@ bool Sample_TempObstacles::handleBuild() // Generation params. rcConfig cfg; memset(&cfg, 0, sizeof(cfg)); - cfg.cs = m_cellSize; - cfg.ch = m_cellHeight; - cfg.walkableSlopeAngle = m_agentMaxSlope; - cfg.walkableHeight = (int)ceilf(m_agentHeight / cfg.ch); - cfg.walkableClimb = (int)floorf(m_agentMaxClimb / cfg.ch); - cfg.walkableRadius = (int)ceilf(m_agentRadius / cfg.cs); - cfg.maxEdgeLen = (int)(m_edgeMaxLen / m_cellSize); - cfg.maxSimplificationError = m_edgeMaxError; - cfg.minRegionArea = (int)rcSqr(m_regionMinSize); // Note: area = size*size - cfg.mergeRegionArea = (int)rcSqr(m_regionMergeSize); // Note: area = size*size - cfg.maxVertsPerPoly = (int)m_vertsPerPoly; + cfg.cs = cellSize; + cfg.ch = cellHeight; + cfg.walkableSlopeAngle = agentMaxSlope; + cfg.walkableHeight = (int)ceilf(agentHeight / cfg.ch); + cfg.walkableClimb = (int)floorf(agentMaxClimb / cfg.ch); + cfg.walkableRadius = (int)ceilf(agentRadius / cfg.cs); + cfg.maxEdgeLen = (int)(edgeMaxLen / cellSize); + cfg.maxSimplificationError = edgeMaxError; + cfg.minRegionArea = (int)rcSqr(regionMinSize); // Note: area = size*size + cfg.mergeRegionArea = (int)rcSqr(regionMergeSize); // Note: area = size*size + cfg.maxVertsPerPoly = (int)vertsPerPoly; cfg.tileSize = (int)m_tileSize; cfg.borderSize = cfg.walkableRadius + 3; // Reserve enough padding. cfg.width = cfg.tileSize + cfg.borderSize*2; cfg.height = cfg.tileSize + cfg.borderSize*2; - cfg.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist; - cfg.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError; + cfg.detailSampleDist = detailSampleDist < 0.9f ? 0 : cellSize * detailSampleDist; + cfg.detailSampleMaxError = cellHeight * detailSampleMaxError; rcVcopy(cfg.bmin, bmin); rcVcopy(cfg.bmax, bmax); @@ -1243,14 +1243,14 @@ bool Sample_TempObstacles::handleBuild() dtTileCacheParams tcparams; memset(&tcparams, 0, sizeof(tcparams)); rcVcopy(tcparams.orig, bmin); - tcparams.cs = m_cellSize; - tcparams.ch = m_cellHeight; + tcparams.cs = cellSize; + tcparams.ch = cellHeight; tcparams.width = (int)m_tileSize; tcparams.height = (int)m_tileSize; - tcparams.walkableHeight = m_agentHeight; - tcparams.walkableRadius = m_agentRadius; - tcparams.walkableClimb = m_agentMaxClimb; - tcparams.maxSimplificationError = m_edgeMaxError; + tcparams.walkableHeight = agentHeight; + tcparams.walkableRadius = agentRadius; + tcparams.walkableClimb = agentMaxClimb; + tcparams.maxSimplificationError = edgeMaxError; tcparams.maxTiles = tw*th*EXPECTED_LAYERS_PER_TILE; tcparams.maxObstacles = 128; @@ -1259,50 +1259,50 @@ bool Sample_TempObstacles::handleBuild() m_tileCache = dtAllocTileCache(); if (!m_tileCache) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not allocate tile cache."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not allocate tile cache."); return false; } status = m_tileCache->init(&tcparams, m_talloc, m_tcomp, m_tmproc); if (dtStatusFailed(status)) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init tile cache."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init tile cache."); return false; } - dtFreeNavMesh(m_navMesh); + dtFreeNavMesh(navMesh); - m_navMesh = dtAllocNavMesh(); - if (!m_navMesh) + navMesh = dtAllocNavMesh(); + if (!navMesh) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not allocate navmesh."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not allocate navmesh."); return false; } dtNavMeshParams params; memset(¶ms, 0, sizeof(params)); rcVcopy(params.orig, bmin); - params.tileWidth = m_tileSize*m_cellSize; - params.tileHeight = m_tileSize*m_cellSize; + params.tileWidth = m_tileSize*cellSize; + params.tileHeight = m_tileSize*cellSize; params.maxTiles = m_maxTiles; params.maxPolys = m_maxPolysPerTile; - status = m_navMesh->init(¶ms); + status = navMesh->init(¶ms); if (dtStatusFailed(status)) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init navmesh."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init navmesh."); return false; } - status = m_navQuery->init(m_navMesh, 2048); + status = navQuery->init(navMesh, 2048); if (dtStatusFailed(status)) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init Detour navmesh query"); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init Detour navmesh query"); return false; } // Preprocess tiles. - m_buildContext->resetTimers(); + buildContext->resetTimers(); m_cacheLayerCount = 0; m_cacheCompressedSize = 0; @@ -1335,20 +1335,20 @@ bool Sample_TempObstacles::handleBuild() } // Build initial meshes - m_buildContext->startTimer(RC_TIMER_TOTAL); + buildContext->startTimer(RC_TIMER_TOTAL); for (int y = 0; y < th; ++y) { for (int x = 0; x < tw; ++x) { - m_tileCache->buildNavMeshTilesAt(x,y, m_navMesh); + m_tileCache->buildNavMeshTilesAt(x,y, navMesh); } } - m_buildContext->stopTimer(RC_TIMER_TOTAL); + buildContext->stopTimer(RC_TIMER_TOTAL); - m_cacheBuildTimeMs = m_buildContext->getAccumulatedTime(RC_TIMER_TOTAL)/1000.0f; + m_cacheBuildTimeMs = buildContext->getAccumulatedTime(RC_TIMER_TOTAL)/1000.0f; m_cacheBuildMemUsage = static_cast(m_talloc->high); - const dtNavMesh* nav = m_navMesh; + const dtNavMesh* nav = navMesh; int navmeshMemUsage = 0; for (int i = 0; i < nav->getMaxTiles(); ++i) { @@ -1360,9 +1360,9 @@ bool Sample_TempObstacles::handleBuild() } printf("navmeshMemUsage = %.1f kB", navmeshMemUsage/1024.0f); - if (m_tool) + if (tool) { - m_tool->init(this); + tool->init(this); } initToolStates(this); @@ -1373,19 +1373,19 @@ void Sample_TempObstacles::handleUpdate(const float dt) { Sample::handleUpdate(dt); - if (!m_navMesh) { return; } + if (!navMesh) { return; } if (!m_tileCache) { return; } - m_tileCache->update(dt, m_navMesh); + m_tileCache->update(dt, navMesh); } void Sample_TempObstacles::getTilePos(const float* pos, int& tileX, int& tileY) { - if (!m_inputGeometry) { return; } + if (!inputGeometry) { return; } - const float* bmin = m_inputGeometry->getNavMeshBoundsMin(); + const float* bmin = inputGeometry->getNavMeshBoundsMin(); - const float ts = m_tileSize * m_cellSize; + const float ts = m_tileSize * cellSize; tileX = (int)((pos[0] - bmin[0]) / ts); tileY = (int)((pos[2] - bmin[2]) / ts); } @@ -1427,7 +1427,7 @@ void Sample_TempObstacles::saveAll(const char* path) header.numTiles++; } memcpy(&header.cacheParams, m_tileCache->getParams(), sizeof(dtTileCacheParams)); - memcpy(&header.meshParams, m_navMesh->getParams(), sizeof(dtNavMeshParams)); + memcpy(&header.meshParams, navMesh->getParams(), sizeof(dtNavMeshParams)); fwrite(&header, sizeof(TileCacheSetHeader), 1, fp); // Store tiles. @@ -1472,13 +1472,13 @@ void Sample_TempObstacles::loadAll(const char* path) return; } - m_navMesh = dtAllocNavMesh(); - if (!m_navMesh) + navMesh = dtAllocNavMesh(); + if (!navMesh) { fclose(fp); return; } - dtStatus status = m_navMesh->init(&header.meshParams); + dtStatus status = navMesh->init(&header.meshParams); if (dtStatusFailed(status)) { fclose(fp); @@ -1535,7 +1535,7 @@ void Sample_TempObstacles::loadAll(const char* path) if (tile) { - m_tileCache->buildNavMeshTile(tile, m_navMesh); + m_tileCache->buildNavMeshTile(tile, navMesh); } } diff --git a/RecastDemo/Source/Sample_TileMesh.cpp b/RecastDemo/Source/Sample_TileMesh.cpp index 785edc81..29a4dbb6 100644 --- a/RecastDemo/Source/Sample_TileMesh.cpp +++ b/RecastDemo/Source/Sample_TileMesh.cpp @@ -187,8 +187,8 @@ Sample_TileMesh::Sample_TileMesh() Sample_TileMesh::~Sample_TileMesh() { cleanup(); - dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + dtFreeNavMesh(navMesh); + navMesh = 0; } void Sample_TileMesh::cleanup() @@ -219,13 +219,13 @@ void Sample_TileMesh::handleSettings() imguiLabel("Tiling"); imguiSlider("TileSize", &m_tileSize, 16.0f, 1024.0f, 16.0f); - if (m_inputGeometry) + if (inputGeometry) { - const float* navMeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* navMeshBoundsMax = m_inputGeometry->getNavMeshBoundsMax(); + const float* navMeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* navMeshBoundsMax = inputGeometry->getNavMeshBoundsMax(); int gridWidth = 0; int gridHeight = 0; - rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, m_cellSize, &gridWidth, &gridHeight); + rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, cellSize, &gridWidth, &gridHeight); const int tileSize = static_cast(m_tileSize); const int tileWidth = (gridWidth + tileSize - 1) / tileSize; const int tileHeight = (gridHeight + tileSize - 1) / tileSize; @@ -259,14 +259,14 @@ void Sample_TileMesh::handleSettings() if (imguiButton("Save")) { - Sample::saveAll("all_tiles_navmesh.bin", m_navMesh); + Sample::saveAll("all_tiles_navmesh.bin", navMesh); } if (imguiButton("Load")) { - dtFreeNavMesh(m_navMesh); - m_navMesh = Sample::loadAll("all_tiles_navmesh.bin"); - m_navQuery->init(m_navMesh, 2048); + dtFreeNavMesh(navMesh); + navMesh = Sample::loadAll("all_tiles_navmesh.bin"); + navQuery->init(navMesh, 2048); } imguiUnindent(); @@ -282,7 +282,7 @@ void Sample_TileMesh::handleSettings() void Sample_TileMesh::handleTools() { - const SampleToolType type = !m_tool ? SampleToolType::NONE : m_tool->type(); + const SampleToolType type = !tool ? SampleToolType::NONE : tool->type(); if (imguiCheck("Test Navmesh", type == SampleToolType::NAVMESH_TESTER)) { @@ -313,9 +313,9 @@ void Sample_TileMesh::handleTools() imguiIndent(); - if (m_tool) + if (tool) { - m_tool->handleMenu(); + tool->handleMenu(); } imguiUnindent(); @@ -333,12 +333,12 @@ void Sample_TileMesh::handleDebugMode() { imguiLabel("Draw"); UI_DrawModeOption("Input Mesh", DrawMode::MESH, true); - UI_DrawModeOption("Navmesh", DrawMode::NAVMESH, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh Invis", DrawMode::NAVMESH_INVIS, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh Trans", DrawMode::NAVMESH_TRANS, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh BVTree", DrawMode::NAVMESH_BVTREE, m_navMesh != nullptr); - UI_DrawModeOption("Navmesh Nodes", DrawMode::NAVMESH_NODES, m_navQuery != nullptr); - UI_DrawModeOption("Navmesh Portals", DrawMode::NAVMESH_PORTALS, m_navMesh != nullptr); + UI_DrawModeOption("Navmesh", DrawMode::NAVMESH, navMesh != nullptr); + UI_DrawModeOption("Navmesh Invis", DrawMode::NAVMESH_INVIS, navMesh != nullptr); + UI_DrawModeOption("Navmesh Trans", DrawMode::NAVMESH_TRANS, navMesh != nullptr); + UI_DrawModeOption("Navmesh BVTree", DrawMode::NAVMESH_BVTREE, navMesh != nullptr); + UI_DrawModeOption("Navmesh Nodes", DrawMode::NAVMESH_NODES, navQuery != nullptr); + UI_DrawModeOption("Navmesh Portals", DrawMode::NAVMESH_PORTALS, navMesh != nullptr); UI_DrawModeOption("Voxels", DrawMode::VOXELS, m_heightfield != nullptr); UI_DrawModeOption("Walkable Voxels", DrawMode::VOXELS_WALKABLE, m_heightfield != nullptr); UI_DrawModeOption("Compact", DrawMode::COMPACT, m_compactHeightfield != nullptr); @@ -354,36 +354,36 @@ void Sample_TileMesh::handleDebugMode() void Sample_TileMesh::handleRender() { - if (!m_inputGeometry || !m_inputGeometry->getMesh()) + if (!inputGeometry || !inputGeometry->getMesh()) { return; } - const float texScale = 1.0f / (m_cellSize * 10.0f); + const float texScale = 1.0f / (cellSize * 10.0f); // Draw mesh if (m_drawMode != DrawMode::NAVMESH_TRANS) { // Draw mesh duDebugDrawTriMeshSlope( - &m_debugDraw, - m_inputGeometry->getMesh()->getVerts(), - m_inputGeometry->getMesh()->getVertCount(), - m_inputGeometry->getMesh()->getTris(), - m_inputGeometry->getMesh()->getNormals(), - m_inputGeometry->getMesh()->getTriCount(), - m_agentMaxSlope, + &debugDraw, + inputGeometry->getMesh()->getVerts(), + inputGeometry->getMesh()->getVertCount(), + inputGeometry->getMesh()->getTris(), + inputGeometry->getMesh()->getNormals(), + inputGeometry->getMesh()->getTriCount(), + agentMaxSlope, texScale); - m_inputGeometry->drawOffMeshConnections(&m_debugDraw); + inputGeometry->drawOffMeshConnections(&debugDraw); } glDepthMask(GL_FALSE); // Draw bounds - const float* navMeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* navMeshBoundsMax = m_inputGeometry->getNavMeshBoundsMax(); + const float* navMeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* navMeshBoundsMax = inputGeometry->getNavMeshBoundsMax(); duDebugDrawBoxWire( - &m_debugDraw, + &debugDraw, navMeshBoundsMin[0], navMeshBoundsMin[1], navMeshBoundsMin[2], @@ -396,12 +396,12 @@ void Sample_TileMesh::handleRender() // Tiling grid. int gridWith = 0; int gridHeight = 0; - rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, m_cellSize, &gridWith, &gridHeight); + rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, cellSize, &gridWith, &gridHeight); const int tileWidth = (gridWith + static_cast(m_tileSize) - 1) / static_cast(m_tileSize); const int tileHeight = (gridHeight + static_cast(m_tileSize) - 1) / static_cast(m_tileSize); - const float size = m_tileSize * m_cellSize; + const float size = m_tileSize * cellSize; duDebugDrawGridXZ( - &m_debugDraw, + &debugDraw, navMeshBoundsMin[0], navMeshBoundsMin[1], navMeshBoundsMin[2], @@ -413,7 +413,7 @@ void Sample_TileMesh::handleRender() // Draw active tile duDebugDrawBoxWire( - &m_debugDraw, + &debugDraw, m_lastBuiltTileBoundsMin[0], m_lastBuiltTileBoundsMin[1], m_lastBuiltTileBoundsMin[2], @@ -423,104 +423,104 @@ void Sample_TileMesh::handleRender() m_tileColor, 1.0f); - if (m_navMesh && m_navQuery && + if (navMesh && navQuery && (m_drawMode == DrawMode::NAVMESH || m_drawMode == DrawMode::NAVMESH_TRANS || m_drawMode == DrawMode::NAVMESH_BVTREE || m_drawMode == DrawMode::NAVMESH_NODES || m_drawMode == DrawMode::NAVMESH_PORTALS || m_drawMode == DrawMode::NAVMESH_INVIS)) { if (m_drawMode != DrawMode::NAVMESH_INVIS) { - duDebugDrawNavMeshWithClosedList(&m_debugDraw, *m_navMesh, *m_navQuery, m_navMeshDrawFlags); + duDebugDrawNavMeshWithClosedList(&debugDraw, *navMesh, *navQuery, navMeshDrawFlags); } if (m_drawMode == DrawMode::NAVMESH_BVTREE) { - duDebugDrawNavMeshBVTree(&m_debugDraw, *m_navMesh); + duDebugDrawNavMeshBVTree(&debugDraw, *navMesh); } if (m_drawMode == DrawMode::NAVMESH_PORTALS) { - duDebugDrawNavMeshPortals(&m_debugDraw, *m_navMesh); + duDebugDrawNavMeshPortals(&debugDraw, *navMesh); } if (m_drawMode == DrawMode::NAVMESH_NODES) { - duDebugDrawNavMeshNodes(&m_debugDraw, *m_navQuery); + duDebugDrawNavMeshNodes(&debugDraw, *navQuery); } - duDebugDrawNavMeshPolysWithFlags(&m_debugDraw, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0, 0, 0, 128)); + duDebugDrawNavMeshPolysWithFlags(&debugDraw, *navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0, 0, 0, 128)); } glDepthMask(GL_TRUE); if (m_compactHeightfield && m_drawMode == DrawMode::COMPACT) { - duDebugDrawCompactHeightfieldSolid(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldSolid(&debugDraw, *m_compactHeightfield); } if (m_compactHeightfield && m_drawMode == DrawMode::COMPACT_DISTANCE) { - duDebugDrawCompactHeightfieldDistance(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldDistance(&debugDraw, *m_compactHeightfield); } if (m_compactHeightfield && m_drawMode == DrawMode::COMPACT_REGIONS) { - duDebugDrawCompactHeightfieldRegions(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldRegions(&debugDraw, *m_compactHeightfield); } if (m_heightfield && m_drawMode == DrawMode::VOXELS) { glEnable(GL_FOG); - duDebugDrawHeightfieldSolid(&m_debugDraw, *m_heightfield); + duDebugDrawHeightfieldSolid(&debugDraw, *m_heightfield); glDisable(GL_FOG); } if (m_heightfield && m_drawMode == DrawMode::VOXELS_WALKABLE) { glEnable(GL_FOG); - duDebugDrawHeightfieldWalkable(&m_debugDraw, *m_heightfield); + duDebugDrawHeightfieldWalkable(&debugDraw, *m_heightfield); glDisable(GL_FOG); } if (m_contourSet && m_drawMode == DrawMode::RAW_CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawRawContours(&m_debugDraw, *m_contourSet); + duDebugDrawRawContours(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_contourSet && m_drawMode == DrawMode::BOTH_CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawRawContours(&m_debugDraw, *m_contourSet, 0.5f); - duDebugDrawContours(&m_debugDraw, *m_contourSet); + duDebugDrawRawContours(&debugDraw, *m_contourSet, 0.5f); + duDebugDrawContours(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_contourSet && m_drawMode == DrawMode::CONTOURS) { glDepthMask(GL_FALSE); - duDebugDrawContours(&m_debugDraw, *m_contourSet); + duDebugDrawContours(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_compactHeightfield && m_contourSet && m_drawMode == DrawMode::REGION_CONNECTIONS) { - duDebugDrawCompactHeightfieldRegions(&m_debugDraw, *m_compactHeightfield); + duDebugDrawCompactHeightfieldRegions(&debugDraw, *m_compactHeightfield); glDepthMask(GL_FALSE); - duDebugDrawRegionConnections(&m_debugDraw, *m_contourSet); + duDebugDrawRegionConnections(&debugDraw, *m_contourSet); glDepthMask(GL_TRUE); } if (m_polyMesh && m_drawMode == DrawMode::POLYMESH) { glDepthMask(GL_FALSE); - duDebugDrawPolyMesh(&m_debugDraw, *m_polyMesh); + duDebugDrawPolyMesh(&debugDraw, *m_polyMesh); glDepthMask(GL_TRUE); } if (m_detailPolyMesh && m_drawMode == DrawMode::POLYMESH_DETAIL) { glDepthMask(GL_FALSE); - duDebugDrawPolyMeshDetail(&m_debugDraw, *m_detailPolyMesh); + duDebugDrawPolyMeshDetail(&debugDraw, *m_detailPolyMesh); glDepthMask(GL_TRUE); } - m_inputGeometry->drawConvexVolumes(&m_debugDraw); + inputGeometry->drawConvexVolumes(&debugDraw); - if (m_tool) + if (tool) { - m_tool->handleRender(); + tool->handleRender(); } renderToolStates(); @@ -549,9 +549,9 @@ void Sample_TileMesh::handleRenderOverlay(double* proj, double* model, int* view imguiDrawText(static_cast(x), static_cast(y) - 25, IMGUI_ALIGN_CENTER, text, imguiRGBA(0, 0, 0, 220)); } - if (m_tool) + if (tool) { - m_tool->handleRenderOverlay(proj, model, view); + tool->handleRenderOverlay(proj, model, view); } renderOverlayToolStates(proj, model, view); } @@ -568,13 +568,13 @@ void Sample_TileMesh::handleMeshChanged(InputGeom* geom) cleanup(); - dtFreeNavMesh(m_navMesh); - m_navMesh = nullptr; + dtFreeNavMesh(navMesh); + navMesh = nullptr; - if (m_tool) + if (tool) { - m_tool->reset(); - m_tool->init(this); + tool->reset(); + tool->init(this); } resetToolStates(); initToolStates(this); @@ -582,39 +582,39 @@ void Sample_TileMesh::handleMeshChanged(InputGeom* geom) bool Sample_TileMesh::handleBuild() { - if (!m_inputGeometry || !m_inputGeometry->getMesh()) + if (!inputGeometry || !inputGeometry->getMesh()) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: No vertices and triangles."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: No vertices and triangles."); return false; } - dtFreeNavMesh(m_navMesh); + dtFreeNavMesh(navMesh); - m_navMesh = dtAllocNavMesh(); - if (!m_navMesh) + navMesh = dtAllocNavMesh(); + if (!navMesh) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not allocate navmesh."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not allocate navmesh."); return false; } dtNavMeshParams params; - rcVcopy(params.orig, m_inputGeometry->getNavMeshBoundsMin()); - params.tileWidth = m_tileSize * m_cellSize; - params.tileHeight = m_tileSize * m_cellSize; + rcVcopy(params.orig, inputGeometry->getNavMeshBoundsMin()); + params.tileWidth = m_tileSize * cellSize; + params.tileHeight = m_tileSize * cellSize; params.maxTiles = m_maxTiles; params.maxPolys = m_maxPolysPerTile; - dtStatus status = m_navMesh->init(¶ms); + dtStatus status = navMesh->init(¶ms); if (dtStatusFailed(status)) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init navmesh."); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init navmesh."); return false; } - status = m_navQuery->init(m_navMesh, 2048); + status = navQuery->init(navMesh, 2048); if (dtStatusFailed(status)) { - m_buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init Detour navmesh query"); + buildContext->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init Detour navmesh query"); return false; } @@ -623,9 +623,9 @@ bool Sample_TileMesh::handleBuild() buildAllTiles(); } - if (m_tool) + if (tool) { - m_tool->init(this); + tool->init(this); } initToolStates(this); @@ -641,19 +641,19 @@ void Sample_TileMesh::collectSettings(BuildSettings& settings) void Sample_TileMesh::buildTile(const float* pos) { - if (!m_inputGeometry) + if (!inputGeometry) { return; } - if (!m_navMesh) + if (!navMesh) { return; } - const float* navMeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* navMeshBoundsMax = m_inputGeometry->getNavMeshBoundsMax(); + const float* navMeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* navMeshBoundsMax = inputGeometry->getNavMeshBoundsMax(); - const float tileSize = m_tileSize * m_cellSize; + const float tileSize = m_tileSize * cellSize; const int tileX = static_cast((pos[0] - navMeshBoundsMin[0]) / tileSize); const int tileY = static_cast((pos[2] - navMeshBoundsMin[2]) / tileSize); @@ -667,58 +667,58 @@ void Sample_TileMesh::buildTile(const float* pos) m_tileColor = duRGBA(255, 255, 255, 64); - m_buildContext->resetLog(); + buildContext->resetLog(); int tileMeshDataSize = 0; unsigned char* tileMeshData = buildTileMesh(tileX, tileY, m_lastBuiltTileBoundsMin, m_lastBuiltTileBoundsMax, tileMeshDataSize); // Remove any previous data (navmesh owns and deletes the data). - m_navMesh->removeTile(m_navMesh->getTileRefAt(tileX, tileY, 0), 0, 0); + navMesh->removeTile(navMesh->getTileRefAt(tileX, tileY, 0), 0, 0); // Add tile, or leave the location empty. if (tileMeshData) { // Let the navmesh own the data. - const dtStatus status = m_navMesh->addTile(tileMeshData, tileMeshDataSize, DT_TILE_FREE_DATA, 0, 0); + const dtStatus status = navMesh->addTile(tileMeshData, tileMeshDataSize, DT_TILE_FREE_DATA, 0, 0); if (dtStatusFailed(status)) { dtFree(tileMeshData); } } - m_buildContext->dumpLog("Build Tile (%d,%d):", tileX, tileY); + buildContext->dumpLog("Build Tile (%d,%d):", tileX, tileY); } void Sample_TileMesh::getTilePos(const float* pos, int& outTileX, int& outTileY) const { - if (!m_inputGeometry) + if (!inputGeometry) { return; } - const float* navMeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); + const float* navMeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); - const float tileSize = m_tileSize * m_cellSize; + const float tileSize = m_tileSize * cellSize; outTileX = static_cast((pos[0] - navMeshBoundsMin[0]) / tileSize); outTileY = static_cast((pos[2] - navMeshBoundsMin[2]) / tileSize); } void Sample_TileMesh::removeTile(const float* pos) { - if (!m_inputGeometry) + if (!inputGeometry) { return; } - if (!m_navMesh) + if (!navMesh) { return; } - const float* navMeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* navmeshBoundsMax = m_inputGeometry->getNavMeshBoundsMax(); + const float* navMeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* navmeshBoundsMax = inputGeometry->getNavMeshBoundsMax(); - const float tileSize = m_tileSize * m_cellSize; + const float tileSize = m_tileSize * cellSize; const int tileX = static_cast((pos[0] - navMeshBoundsMin[0]) / tileSize); const int tileY = static_cast((pos[2] - navMeshBoundsMin[2]) / tileSize); @@ -732,32 +732,32 @@ void Sample_TileMesh::removeTile(const float* pos) m_tileColor = duRGBA(128, 32, 16, 64); - m_navMesh->removeTile(m_navMesh->getTileRefAt(tileX, tileY, 0), 0, 0); + navMesh->removeTile(navMesh->getTileRefAt(tileX, tileY, 0), 0, 0); } void Sample_TileMesh::buildAllTiles() { - if (!m_inputGeometry) + if (!inputGeometry) { return; } - if (!m_navMesh) + if (!navMesh) { return; } - const float* navMeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* navMeshBoundsMax = m_inputGeometry->getNavMeshBoundsMax(); + const float* navMeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* navMeshBoundsMax = inputGeometry->getNavMeshBoundsMax(); int gridWidth = 0; int gridHeight = 0; - rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, m_cellSize, &gridWidth, &gridHeight); + rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, cellSize, &gridWidth, &gridHeight); const int tileSize = static_cast(m_tileSize); const int tileWidth = (gridWidth + tileSize - 1) / tileSize; const int tileHeight = (gridHeight + tileSize - 1) / tileSize; - const float tileCellSize = m_tileSize * m_cellSize; + const float tileCellSize = m_tileSize * cellSize; // Start the build process. - m_buildContext->startTimer(RC_TIMER_TEMP); + buildContext->startTimer(RC_TIMER_TEMP); for (int y = 0; y < tileHeight; ++y) { @@ -780,9 +780,9 @@ void Sample_TileMesh::buildAllTiles() } // Remove any previous data (navmesh owns and deletes the data). - m_navMesh->removeTile(m_navMesh->getTileRefAt(x, y, 0), 0, 0); + navMesh->removeTile(navMesh->getTileRefAt(x, y, 0), 0, 0); // Let the navmesh own the data. - const dtStatus status = m_navMesh->addTile(tileMeshData, tileMeshDataSize, DT_TILE_FREE_DATA, 0, 0); + const dtStatus status = navMesh->addTile(tileMeshData, tileMeshDataSize, DT_TILE_FREE_DATA, 0, 0); if (dtStatusFailed(status)) { dtFree(tileMeshData); @@ -791,26 +791,26 @@ void Sample_TileMesh::buildAllTiles() } // Record the total build time. - m_buildContext->stopTimer(RC_TIMER_TEMP); - m_totalBuildTimeMs = static_cast(m_buildContext->getAccumulatedTime(RC_TIMER_TEMP)) / 1000.0f; + buildContext->stopTimer(RC_TIMER_TEMP); + m_totalBuildTimeMs = static_cast(buildContext->getAccumulatedTime(RC_TIMER_TEMP)) / 1000.0f; } void Sample_TileMesh::removeAllTiles() const { - if (m_inputGeometry == nullptr) + if (inputGeometry == nullptr) { return; } - if (m_navMesh == nullptr) + if (navMesh == nullptr) { return; } - const float* navMeshBoundsMin = m_inputGeometry->getNavMeshBoundsMin(); - const float* navMeshBoundsMax = m_inputGeometry->getNavMeshBoundsMax(); + const float* navMeshBoundsMin = inputGeometry->getNavMeshBoundsMin(); + const float* navMeshBoundsMax = inputGeometry->getNavMeshBoundsMax(); int gridWidth = 0; int gridHeight = 0; - rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, m_cellSize, &gridWidth, &gridHeight); + rcCalcGridSize(navMeshBoundsMin, navMeshBoundsMax, cellSize, &gridWidth, &gridHeight); const int tileSize = static_cast(m_tileSize); const int tileWidth = (gridWidth + tileSize - 1) / tileSize; const int tileHeight = (gridHeight + tileSize - 1) / tileSize; @@ -819,7 +819,7 @@ void Sample_TileMesh::removeAllTiles() const { for (int tileX = 0; tileX < tileWidth; ++tileX) { - m_navMesh->removeTile(m_navMesh->getTileRefAt(tileX, tileY, 0), 0, 0); + navMesh->removeTile(navMesh->getTileRefAt(tileX, tileY, 0), 0, 0); } } } @@ -831,9 +831,9 @@ unsigned char* Sample_TileMesh::buildTileMesh( const float* boundsMax, int& outDataSize) { - if (!m_inputGeometry || !m_inputGeometry->getMesh() || !m_inputGeometry->getChunkyMesh()) + if (!inputGeometry || !inputGeometry->getMesh() || !inputGeometry->getChunkyMesh()) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified."); return 0; } @@ -842,30 +842,30 @@ unsigned char* Sample_TileMesh::buildTileMesh( cleanup(); - const float* verts = m_inputGeometry->getMesh()->getVerts(); - const int numVerts = m_inputGeometry->getMesh()->getVertCount(); - const int numTris = m_inputGeometry->getMesh()->getTriCount(); - const rcChunkyTriMesh* chunkyMesh = m_inputGeometry->getChunkyMesh(); + const float* verts = inputGeometry->getMesh()->getVerts(); + const int numVerts = inputGeometry->getMesh()->getVertCount(); + const int numTris = inputGeometry->getMesh()->getTriCount(); + const rcChunkyTriMesh* chunkyMesh = inputGeometry->getChunkyMesh(); // Init build configuration from GUI memset(&m_config, 0, sizeof(m_config)); - m_config.cs = m_cellSize; - m_config.ch = m_cellHeight; - m_config.walkableSlopeAngle = m_agentMaxSlope; - m_config.walkableHeight = static_cast(ceilf(m_agentHeight / m_config.ch)); - m_config.walkableClimb = static_cast(floorf(m_agentMaxClimb / m_config.ch)); - m_config.walkableRadius = static_cast(ceilf(m_agentRadius / m_config.cs)); - m_config.maxEdgeLen = static_cast(m_edgeMaxLen / m_cellSize); - m_config.maxSimplificationError = m_edgeMaxError; - m_config.minRegionArea = static_cast(rcSqr(m_regionMinSize)); // Note: area = size*size - m_config.mergeRegionArea = static_cast(rcSqr(m_regionMergeSize)); // Note: area = size*size - m_config.maxVertsPerPoly = static_cast(m_vertsPerPoly); + m_config.cs = cellSize; + m_config.ch = cellHeight; + m_config.walkableSlopeAngle = agentMaxSlope; + m_config.walkableHeight = static_cast(ceilf(agentHeight / m_config.ch)); + m_config.walkableClimb = static_cast(floorf(agentMaxClimb / m_config.ch)); + m_config.walkableRadius = static_cast(ceilf(agentRadius / m_config.cs)); + m_config.maxEdgeLen = static_cast(edgeMaxLen / cellSize); + m_config.maxSimplificationError = edgeMaxError; + m_config.minRegionArea = static_cast(rcSqr(regionMinSize)); // Note: area = size*size + m_config.mergeRegionArea = static_cast(rcSqr(regionMergeSize)); // Note: area = size*size + m_config.maxVertsPerPoly = static_cast(vertsPerPoly); m_config.tileSize = static_cast(m_tileSize); m_config.borderSize = m_config.walkableRadius + 3; // Reserve enough padding. m_config.width = m_config.tileSize + m_config.borderSize * 2; m_config.height = m_config.tileSize + m_config.borderSize * 2; - m_config.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist; - m_config.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError; + m_config.detailSampleDist = detailSampleDist < 0.9f ? 0 : cellSize * detailSampleDist; + m_config.detailSampleMaxError = cellHeight * detailSampleMaxError; // Expand the heightfield bounding box by border size to find the extents of geometry we need to build this tile. // @@ -896,14 +896,14 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_config.bmax[2] += static_cast(m_config.borderSize) * m_config.cs; // Reset build times gathering. - m_buildContext->resetTimers(); + buildContext->resetTimers(); // Start the build process. - m_buildContext->startTimer(RC_TIMER_TOTAL); + buildContext->startTimer(RC_TIMER_TOTAL); - m_buildContext->log(RC_LOG_PROGRESS, "Building navigation:"); - m_buildContext->log(RC_LOG_PROGRESS, " - %d x %d cells", m_config.width, m_config.height); - m_buildContext->log( + buildContext->log(RC_LOG_PROGRESS, "Building navigation:"); + buildContext->log(RC_LOG_PROGRESS, " - %d x %d cells", m_config.width, m_config.height); + buildContext->log( RC_LOG_PROGRESS, " - %.1fK verts, %.1fK tris", static_cast(numVerts) / 1000.0f, @@ -913,11 +913,11 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_heightfield = rcAllocHeightfield(); if (!m_heightfield) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'."); return 0; } if (!rcCreateHeightfield( - m_buildContext, + buildContext, *m_heightfield, m_config.width, m_config.height, @@ -926,7 +926,7 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_config.cs, m_config.ch)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); return 0; } @@ -936,7 +936,7 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_triareas = new unsigned char[chunkyMesh->maxTrisPerChunk]; if (!m_triareas) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk); return 0; } @@ -966,7 +966,7 @@ unsigned char* Sample_TileMesh::buildTileMesh( memset(m_triareas, 0, numNodeTris * sizeof(unsigned char)); rcMarkWalkableTriangles( - m_buildContext, + buildContext, m_config.walkableSlopeAngle, verts, numVerts, @@ -975,7 +975,7 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_triareas); if (!rcRasterizeTriangles( - m_buildContext, + buildContext, verts, numVerts, nodeTris, @@ -991,17 +991,17 @@ unsigned char* Sample_TileMesh::buildTileMesh( // Once all geometry is rasterized, we do initial pass of filtering to // remove unwanted overhangs caused by the conservative rasterization // as well as filter spans where the character cannot possibly stand. - if (m_filterLowHangingObstacles) + if (filterLowHangingObstacles) { - rcFilterLowHangingWalkableObstacles(m_buildContext, m_config.walkableClimb, *m_heightfield); + rcFilterLowHangingWalkableObstacles(buildContext, m_config.walkableClimb, *m_heightfield); } - if (m_filterLedgeSpans) + if (filterLedgeSpans) { - rcFilterLedgeSpans(m_buildContext, m_config.walkableHeight, m_config.walkableClimb, *m_heightfield); + rcFilterLedgeSpans(buildContext, m_config.walkableHeight, m_config.walkableClimb, *m_heightfield); } - if (m_filterWalkableLowHeightSpans) + if (filterWalkableLowHeightSpans) { - rcFilterWalkableLowHeightSpans(m_buildContext, m_config.walkableHeight, *m_heightfield); + rcFilterWalkableLowHeightSpans(buildContext, m_config.walkableHeight, *m_heightfield); } // Compact the heightfield so that it is faster to handle from now on. @@ -1010,33 +1010,33 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_compactHeightfield = rcAllocCompactHeightfield(); if (!m_compactHeightfield) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); return 0; } if (!rcBuildCompactHeightfield( - m_buildContext, + buildContext, m_config.walkableHeight, m_config.walkableClimb, *m_heightfield, *m_compactHeightfield)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); return 0; } // Erode the walkable area by agent radius. - if (!rcErodeWalkableArea(m_buildContext, m_config.walkableRadius, *m_compactHeightfield)) + if (!rcErodeWalkableArea(buildContext, m_config.walkableRadius, *m_compactHeightfield)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); return 0; } // (Optional) Mark areas. - const ConvexVolume* convexVolumes = m_inputGeometry->getConvexVolumes(); - for (int i = 0; i < m_inputGeometry->getConvexVolumeCount(); ++i) + const ConvexVolume* convexVolumes = inputGeometry->getConvexVolumes(); + for (int i = 0; i < inputGeometry->getConvexVolumeCount(); ++i) { rcMarkConvexPolyArea( - m_buildContext, + buildContext, convexVolumes[i].verts, convexVolumes[i].nverts, convexVolumes[i].hmin, @@ -1071,48 +1071,48 @@ unsigned char* Sample_TileMesh::buildTileMesh( // if you have large open areas with small obstacles (not a problem if you use tiles) // * good choice to use for tiled navmesh with medium and small sized tiles - if (m_partitionType == SAMPLE_PARTITION_WATERSHED) + if (partitionType == SAMPLE_PARTITION_WATERSHED) { // Prepare for region partitioning, by calculating distance field along the walkable surface. - if (!rcBuildDistanceField(m_buildContext, *m_compactHeightfield)) + if (!rcBuildDistanceField(buildContext, *m_compactHeightfield)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field."); return 0; } // Partition the walkable surface into simple regions without holes. if (!rcBuildRegions( - m_buildContext, + buildContext, *m_compactHeightfield, m_config.borderSize, m_config.minRegionArea, m_config.mergeRegionArea)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build watershed regions."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build watershed regions."); return 0; } } - else if (m_partitionType == SAMPLE_PARTITION_MONOTONE) + else if (partitionType == SAMPLE_PARTITION_MONOTONE) { // Partition the walkable surface into simple regions without holes. // Monotone partitioning does not need distancefield. if (!rcBuildRegionsMonotone( - m_buildContext, + buildContext, *m_compactHeightfield, m_config.borderSize, m_config.minRegionArea, m_config.mergeRegionArea)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build monotone regions."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build monotone regions."); return 0; } } else // SAMPLE_PARTITION_LAYERS { // Partition the walkable surface into simple regions without holes. - if (!rcBuildLayerRegions(m_buildContext, *m_compactHeightfield, m_config.borderSize, m_config.minRegionArea)) + if (!rcBuildLayerRegions(buildContext, *m_compactHeightfield, m_config.borderSize, m_config.minRegionArea)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build layer regions."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not build layer regions."); return 0; } } @@ -1121,17 +1121,17 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_contourSet = rcAllocContourSet(); if (!m_contourSet) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'."); return 0; } if (!rcBuildContours( - m_buildContext, + buildContext, *m_compactHeightfield, m_config.maxSimplificationError, m_config.maxEdgeLen, *m_contourSet)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create contours."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not create contours."); return 0; } @@ -1144,12 +1144,12 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_polyMesh = rcAllocPolyMesh(); if (!m_polyMesh) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'."); return 0; } - if (!rcBuildPolyMesh(m_buildContext, *m_contourSet, m_config.maxVertsPerPoly, *m_polyMesh)) + if (!rcBuildPolyMesh(buildContext, *m_contourSet, m_config.maxVertsPerPoly, *m_polyMesh)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not triangulate contours."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could not triangulate contours."); return 0; } @@ -1157,19 +1157,19 @@ unsigned char* Sample_TileMesh::buildTileMesh( m_detailPolyMesh = rcAllocPolyMeshDetail(); if (!m_detailPolyMesh) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'dmesh'."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'dmesh'."); return 0; } if (!rcBuildPolyMeshDetail( - m_buildContext, + buildContext, *m_polyMesh, *m_compactHeightfield, m_config.detailSampleDist, m_config.detailSampleMaxError, *m_detailPolyMesh)) { - m_buildContext->log(RC_LOG_ERROR, "buildNavigation: Could build polymesh detail."); + buildContext->log(RC_LOG_ERROR, "buildNavigation: Could build polymesh detail."); return 0; } @@ -1180,7 +1180,7 @@ unsigned char* Sample_TileMesh::buildTileMesh( if (m_polyMesh->nverts >= 0xffff) { // The vertex indices are ushorts, and cannot point to more than 0xffff vertices. - m_buildContext->log(RC_LOG_ERROR, "Too many vertices per tile %d (max: %d).", m_polyMesh->nverts, 0xffff); + buildContext->log(RC_LOG_ERROR, "Too many vertices per tile %d (max: %d).", m_polyMesh->nverts, 0xffff); return 0; } @@ -1221,16 +1221,16 @@ unsigned char* Sample_TileMesh::buildTileMesh( params.detailVertsCount = m_detailPolyMesh->nverts; params.detailTris = m_detailPolyMesh->tris; params.detailTriCount = m_detailPolyMesh->ntris; - params.offMeshConVerts = m_inputGeometry->getOffMeshConnectionVerts(); - params.offMeshConRad = m_inputGeometry->getOffMeshConnectionRads(); - params.offMeshConDir = m_inputGeometry->getOffMeshConnectionDirs(); - params.offMeshConAreas = m_inputGeometry->getOffMeshConnectionAreas(); - params.offMeshConFlags = m_inputGeometry->getOffMeshConnectionFlags(); - params.offMeshConUserID = m_inputGeometry->getOffMeshConnectionId(); - params.offMeshConCount = m_inputGeometry->getOffMeshConnectionCount(); - params.walkableHeight = m_agentHeight; - params.walkableRadius = m_agentRadius; - params.walkableClimb = m_agentMaxClimb; + params.offMeshConVerts = inputGeometry->getOffMeshConnectionVerts(); + params.offMeshConRad = inputGeometry->getOffMeshConnectionRads(); + params.offMeshConDir = inputGeometry->getOffMeshConnectionDirs(); + params.offMeshConAreas = inputGeometry->getOffMeshConnectionAreas(); + params.offMeshConFlags = inputGeometry->getOffMeshConnectionFlags(); + params.offMeshConUserID = inputGeometry->getOffMeshConnectionId(); + params.offMeshConCount = inputGeometry->getOffMeshConnectionCount(); + params.walkableHeight = agentHeight; + params.walkableRadius = agentRadius; + params.walkableClimb = agentMaxClimb; params.tileX = tileX; params.tileY = tileY; params.tileLayer = 0; @@ -1242,19 +1242,19 @@ unsigned char* Sample_TileMesh::buildTileMesh( if (!dtCreateNavMeshData(¶ms, &navData, &navDataSize)) { - m_buildContext->log(RC_LOG_ERROR, "Could not build Detour navmesh."); + buildContext->log(RC_LOG_ERROR, "Could not build Detour navmesh."); return 0; } } m_tileMemUsage = static_cast(navDataSize) / 1024.0f; - m_buildContext->stopTimer(RC_TIMER_TOTAL); + buildContext->stopTimer(RC_TIMER_TOTAL); // Show performance stats. - duLogBuildTimes(*m_buildContext, m_buildContext->getAccumulatedTime(RC_TIMER_TOTAL)); - m_buildContext->log(RC_LOG_PROGRESS, ">> Polymesh: %d vertices %d polygons", m_polyMesh->nverts, m_polyMesh->npolys); + duLogBuildTimes(*buildContext, buildContext->getAccumulatedTime(RC_TIMER_TOTAL)); + buildContext->log(RC_LOG_PROGRESS, ">> Polymesh: %d vertices %d polygons", m_polyMesh->nverts, m_polyMesh->npolys); - m_tileBuildTime = static_cast(m_buildContext->getAccumulatedTime(RC_TIMER_TOTAL)) / 1000.0f; + m_tileBuildTime = static_cast(buildContext->getAccumulatedTime(RC_TIMER_TOTAL)) / 1000.0f; outDataSize = navDataSize; return navData;