diff --git a/src/DotRecast.Detour.TileCache/DtTileCache.cs b/src/DotRecast.Detour.TileCache/DtTileCache.cs index 356d8e1..c9568af 100644 --- a/src/DotRecast.Detour.TileCache/DtTileCache.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCache.cs @@ -348,7 +348,7 @@ namespace DotRecast.Detour.TileCache public long AddObstacle(RcVec3f pos, float radius, float height) { DtTileCacheObstacle ob = AllocObstacle(); - ob.type = DtTileCacheObstacleType.CYLINDER; + ob.type = DtTileCacheObstacleType.DT_OBSTACLE_CYLINDER; ob.pos = pos; ob.radius = radius; @@ -361,7 +361,7 @@ namespace DotRecast.Detour.TileCache public long AddBoxObstacle(RcVec3f bmin, RcVec3f bmax) { DtTileCacheObstacle ob = AllocObstacle(); - ob.type = DtTileCacheObstacleType.BOX; + ob.type = DtTileCacheObstacleType.DT_OBSTACLE_BOX; ob.bmin = bmin; ob.bmax = bmax; @@ -373,7 +373,7 @@ namespace DotRecast.Detour.TileCache public long AddBoxObstacle(RcVec3f center, RcVec3f extents, float yRadians) { DtTileCacheObstacle ob = AllocObstacle(); - ob.type = DtTileCacheObstacleType.ORIENTED_BOX; + ob.type = DtTileCacheObstacleType.DT_OBSTACLE_ORIENTED_BOX; ob.center = center; ob.extents = extents; float coshalf = MathF.Cos(0.5f * yRadians); @@ -612,15 +612,15 @@ namespace DotRecast.Detour.TileCache if (Contains(ob.touched, refs)) { - if (ob.type == DtTileCacheObstacleType.CYLINDER) + if (ob.type == DtTileCacheObstacleType.DT_OBSTACLE_CYLINDER) { DtTileCacheBuilder.MarkCylinderArea(layer, tile.header.bmin, m_params.cs, m_params.ch, ob.pos, ob.radius, ob.height, 0); } - else if (ob.type == DtTileCacheObstacleType.BOX) + else if (ob.type == DtTileCacheObstacleType.DT_OBSTACLE_BOX) { DtTileCacheBuilder.MarkBoxArea(layer, tile.header.bmin, m_params.cs, m_params.ch, ob.bmin, ob.bmax, 0); } - else if (ob.type == DtTileCacheObstacleType.ORIENTED_BOX) + else if (ob.type == DtTileCacheObstacleType.DT_OBSTACLE_ORIENTED_BOX) { DtTileCacheBuilder.MarkBoxArea(layer, tile.header.bmin, m_params.cs, m_params.ch, ob.center, ob.extents, ob.rotAux, 0); } @@ -692,7 +692,7 @@ namespace DotRecast.Detour.TileCache public void GetObstacleBounds(DtTileCacheObstacle ob, ref RcVec3f bmin, ref RcVec3f bmax) { - if (ob.type == DtTileCacheObstacleType.CYLINDER) + if (ob.type == DtTileCacheObstacleType.DT_OBSTACLE_CYLINDER) { bmin.X = ob.pos.X - ob.radius; bmin.Y = ob.pos.Y; @@ -701,12 +701,12 @@ namespace DotRecast.Detour.TileCache bmax.Y = ob.pos.Y + ob.height; bmax.Z = ob.pos.Z + ob.radius; } - else if (ob.type == DtTileCacheObstacleType.BOX) + else if (ob.type == DtTileCacheObstacleType.DT_OBSTACLE_BOX) { bmin = ob.bmin; bmax = ob.bmax; } - else if (ob.type == DtTileCacheObstacleType.ORIENTED_BOX) + else if (ob.type == DtTileCacheObstacleType.DT_OBSTACLE_ORIENTED_BOX) { float maxr = 1.41f * Math.Max(ob.extents.X, ob.extents.Z); bmin.X = ob.center.X - maxr; diff --git a/src/DotRecast.Detour.TileCache/DtTileCacheObstacle.cs b/src/DotRecast.Detour.TileCache/DtTileCacheObstacle.cs index ff79ef4..0458922 100644 --- a/src/DotRecast.Detour.TileCache/DtTileCacheObstacle.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCacheObstacle.cs @@ -26,11 +26,13 @@ namespace DotRecast.Detour.TileCache public class DtTileCacheObstacle { public readonly int index; - public DtTileCacheObstacleType type; public RcVec3f pos = new RcVec3f(); + public float radius; + public float height; + public RcVec3f bmin = new RcVec3f(); public RcVec3f bmax = new RcVec3f(); - public float radius, height; + public RcVec3f center = new RcVec3f(); public RcVec3f extents = new RcVec3f(); public readonly float[] rotAux = new float[2]; // { Cos(0.5f*angle)*Sin(-0.5f*angle); Cos(0.5f*angle)*Cos(0.5f*angle) - 0.5 } @@ -38,13 +40,14 @@ namespace DotRecast.Detour.TileCache public List touched = new List(); public readonly List pending = new List(); public int salt; + public DtTileCacheObstacleType type; public DtObstacleState state = DtObstacleState.DT_OBSTACLE_EMPTY; public DtTileCacheObstacle next; public DtTileCacheObstacle(int index) { - salt = 1; this.index = index; + salt = 1; } } } \ No newline at end of file diff --git a/src/DotRecast.Detour.TileCache/DtTileCacheObstacleType.cs b/src/DotRecast.Detour.TileCache/DtTileCacheObstacleType.cs index 622ef00..3aa75f7 100644 --- a/src/DotRecast.Detour.TileCache/DtTileCacheObstacleType.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCacheObstacleType.cs @@ -2,8 +2,8 @@ { public enum DtTileCacheObstacleType { - CYLINDER, - BOX, - ORIENTED_BOX + DT_OBSTACLE_CYLINDER, + DT_OBSTACLE_BOX, // AABB + DT_OBSTACLE_ORIENTED_BOX // OBB }; } \ No newline at end of file