From 85e2484505f3009e8a763eab77e13153dc1f2ec3 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 21 Sep 2024 03:13:51 +0900 Subject: [PATCH] fix: Support non-tiled dynamic nav meshes (@ppiastucki) [Upstream] from recast4j - fe071aa - fix: Support non-tiled dynamic nav meshes (#205) --- CHANGELOG.md | 1 + src/DotRecast.Detour.Dynamic/DtDynamicNavMesh.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d09eff3..febdd1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix raycast shortcuts ([@Sarofc](https://github.com/Sarofc)) [#72](https://github.com/ikpil/DotRecast/issues/72) - Fix dynamic mesh bounds calculation ([@ppiastucki](https://github.com/ppiastucki)) [#77](https://github.com/ikpil/DotRecast/issues/77) - issuer : [@OhJeongrok](https://github.com/OhJeongrok) +- Fix Support non-tiled dynamic nav meshes ([@ppiastucki](https://github.com/ppiastucki)) ### Changed - Changed data structure of 'neis' from List to byte[] for optimized memory usage and improved access speed in `DtLayerMonotoneRegion` diff --git a/src/DotRecast.Detour.Dynamic/DtDynamicNavMesh.cs b/src/DotRecast.Detour.Dynamic/DtDynamicNavMesh.cs index 82a0104..5c5a253 100644 --- a/src/DotRecast.Detour.Dynamic/DtDynamicNavMesh.cs +++ b/src/DotRecast.Detour.Dynamic/DtDynamicNavMesh.cs @@ -62,8 +62,8 @@ namespace DotRecast.Detour.Dynamic navMeshParams.orig.X = voxelFile.bounds[0]; navMeshParams.orig.Y = voxelFile.bounds[1]; navMeshParams.orig.Z = voxelFile.bounds[2]; - navMeshParams.tileWidth = voxelFile.cellSize * voxelFile.tileSizeX; - navMeshParams.tileHeight = voxelFile.cellSize * voxelFile.tileSizeZ; + navMeshParams.tileWidth = voxelFile.useTiles ? voxelFile.cellSize * voxelFile.tileSizeX : voxelFile.bounds[3] - voxelFile.bounds[0]; + navMeshParams.tileHeight = voxelFile.useTiles ? voxelFile.cellSize * voxelFile.tileSizeZ: voxelFile.bounds[5] - voxelFile.bounds[2]; navMeshParams.maxTiles = voxelFile.tiles.Count; navMeshParams.maxPolys = 0x8000; foreach (var t in voxelFile.tiles)