diff --git a/Editor/src/ComponentsPanel/NavMeshVolumePanel.h b/Editor/src/ComponentsPanel/NavMeshVolumePanel.h index fa251b3f..c0b21ff4 100644 --- a/Editor/src/ComponentsPanel/NavMeshVolumePanel.h +++ b/Editor/src/ComponentsPanel/NavMeshVolumePanel.h @@ -368,7 +368,9 @@ public: } } - NavManager::Get().BuildNavMesh(RecastConfig(component)); + auto recastConfig = RecastConfig(component); + recastConfig.Position = volumeTransformComponent.GetGlobalPosition(); + NavManager::Get().BuildNavMesh(std::move(recastConfig)); } } } diff --git a/Nuake/src/AI/NavManager.cpp b/Nuake/src/AI/NavManager.cpp index d5d04b80..01cb9d12 100644 --- a/Nuake/src/AI/NavManager.cpp +++ b/Nuake/src/AI/NavManager.cpp @@ -58,8 +58,8 @@ namespace Nuake { currentVertexOffset = std::size(vertices); } - float bmin[3] = { -config.Bound.x, -config.Bound.y, -config.Bound.z }; - float bmax[3] = { config.Bound.x, config.Bound.y, config.Bound.z }; + float bmin[3] = { config.Position.x - config.Bound.x, config.Position.y - config.Bound.y, config.Position.z - config.Bound.z }; + float bmax[3] = { config.Position.x + config.Bound.x, config.Position.y + config.Bound.y, config.Position.z + config.Bound.z }; rcConfig recastConfig; recastConfig.cs = config.CellSize; recastConfig.ch = config.CellHeight; diff --git a/Nuake/src/AI/RecastConfig.h b/Nuake/src/AI/RecastConfig.h index 1be023b3..9fceeae4 100644 --- a/Nuake/src/AI/RecastConfig.h +++ b/Nuake/src/AI/RecastConfig.h @@ -8,6 +8,7 @@ namespace Nuake { class RecastConfig { public: + Vector3 Position = { 0, 0, 0 }; Vector3 Bound = Vector3(100, 100, 100); float CellSize = 0.2f; float CellHeight = 0.2f;