Core/MMaps: updated detour to be current with tc (still doesn't find the right path sometimes)

This commit is contained in:
hondacrx
2018-08-28 14:42:01 -04:00
parent 8c35e4f830
commit a187bfd169
7 changed files with 521 additions and 268 deletions
+1 -1
View File
@@ -172,7 +172,7 @@ namespace Game.Chat
for (int i = 0; i < navmesh.getMaxTiles(); ++i)
{
Detour.dtMeshTile tile = navmesh.getTile(i);
if (tile == null)
if (tile.header == null)
continue;
handler.SendSysMessage("[{0:D2}, {1:D2}]", tile.header.x, tile.header.y);
+1 -5
View File
@@ -16,12 +16,9 @@
*/
using Framework.Constants;
using Game.DataStorage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Game
@@ -152,13 +149,12 @@ namespace Game
}
var bytes = reader.ReadBytes((int)fileHeader.size);
Detour.dtRawTileData data = new Detour.dtRawTileData();
data.FromBytes(bytes, 0);
ulong tileRef = 0;
// memory allocated for data is now managed by detour, and will be deallocated when the tile is removed
if (Detour.dtStatusSucceed(mmap.navMesh.addTile(data, 0, 0, ref tileRef)))
if (Detour.dtStatusSucceed(mmap.navMesh.addTile(data, 1, 0, ref tileRef)))
{
mmap.loadedTileRefs.Add(packedGridPos, tileRef);
++loadedTiles;
@@ -340,6 +340,7 @@ namespace Game.Movement
// generate suffix
uint suffixPolyLength = 0;
ulong[] tempPolyRefs = new ulong[_pathPolyRefs.Length];
uint dtResult;
if (_straightLine)
@@ -354,7 +355,7 @@ namespace Game.Movement
_filter,
ref hit,
hitNormal,
_pathPolyRefs,
tempPolyRefs,
ref suffixPolyLength,
74 - (int)prefixPolyLength);
@@ -374,7 +375,7 @@ namespace Game.Movement
suffixEndPoint, // start position
endPoint, // end position
_filter, // polygon search filter
_pathPolyRefs,
tempPolyRefs,
ref suffixPolyLength,
74 - (int)prefixPolyLength);
}
@@ -389,6 +390,9 @@ namespace Game.Movement
Log.outDebug(LogFilter.Maps, "m_polyLength={0} prefixPolyLength={1} suffixPolyLength={2} \n", _polyLength, prefixPolyLength, suffixPolyLength);
for (var i = 0; i < _pathPolyRefs.Length - (prefixPolyLength - 1); ++i)
_pathPolyRefs[(prefixPolyLength - 1) + i] = tempPolyRefs[i];
// new path = prefix + suffix - overlap
_polyLength = prefixPolyLength + suffixPolyLength - 1;
}
@@ -797,21 +801,21 @@ namespace Game.Movement
void CreateFilter()
{
NavArea includeFlags = 0;
NavArea excludeFlags = 0;
NavTerrainFlag includeFlags = 0;
NavTerrainFlag excludeFlags = 0;
if (_sourceUnit.IsTypeId(TypeId.Unit))
{
Creature creature = _sourceUnit.ToCreature();
if (creature.CanWalk())
includeFlags |= NavArea.Ground;
includeFlags |= NavTerrainFlag.Ground;
// creatures don't take environmental damage
if (creature.CanSwim())
includeFlags |= (NavArea.Water | NavArea.MagmaSlime);
includeFlags |= (NavTerrainFlag.Water | NavTerrainFlag.MagmaSlime);
}
else
includeFlags = (NavArea.Ground | NavArea.Water | NavArea.MagmaSlime);
includeFlags = (NavTerrainFlag.Ground | NavTerrainFlag.Water | NavTerrainFlag.MagmaSlime);
_filter.setIncludeFlags((ushort)includeFlags);
_filter.setExcludeFlags((ushort)excludeFlags);