reorder the member variables of DtTileCacheObstacle

This commit is contained in:
ikpil 2024-06-20 23:52:33 +09:00
parent 0092761742
commit 35ef64d9b4
3 changed files with 18 additions and 15 deletions

View File

@ -348,7 +348,7 @@ namespace DotRecast.Detour.TileCache
public long AddObstacle(RcVec3f pos, float radius, float height) public long AddObstacle(RcVec3f pos, float radius, float height)
{ {
DtTileCacheObstacle ob = AllocObstacle(); DtTileCacheObstacle ob = AllocObstacle();
ob.type = DtTileCacheObstacleType.CYLINDER; ob.type = DtTileCacheObstacleType.DT_OBSTACLE_CYLINDER;
ob.pos = pos; ob.pos = pos;
ob.radius = radius; ob.radius = radius;
@ -361,7 +361,7 @@ namespace DotRecast.Detour.TileCache
public long AddBoxObstacle(RcVec3f bmin, RcVec3f bmax) public long AddBoxObstacle(RcVec3f bmin, RcVec3f bmax)
{ {
DtTileCacheObstacle ob = AllocObstacle(); DtTileCacheObstacle ob = AllocObstacle();
ob.type = DtTileCacheObstacleType.BOX; ob.type = DtTileCacheObstacleType.DT_OBSTACLE_BOX;
ob.bmin = bmin; ob.bmin = bmin;
ob.bmax = bmax; ob.bmax = bmax;
@ -373,7 +373,7 @@ namespace DotRecast.Detour.TileCache
public long AddBoxObstacle(RcVec3f center, RcVec3f extents, float yRadians) public long AddBoxObstacle(RcVec3f center, RcVec3f extents, float yRadians)
{ {
DtTileCacheObstacle ob = AllocObstacle(); DtTileCacheObstacle ob = AllocObstacle();
ob.type = DtTileCacheObstacleType.ORIENTED_BOX; ob.type = DtTileCacheObstacleType.DT_OBSTACLE_ORIENTED_BOX;
ob.center = center; ob.center = center;
ob.extents = extents; ob.extents = extents;
float coshalf = MathF.Cos(0.5f * yRadians); float coshalf = MathF.Cos(0.5f * yRadians);
@ -612,15 +612,15 @@ namespace DotRecast.Detour.TileCache
if (Contains(ob.touched, refs)) 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); 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); 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); 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) 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.X = ob.pos.X - ob.radius;
bmin.Y = ob.pos.Y; bmin.Y = ob.pos.Y;
@ -701,12 +701,12 @@ namespace DotRecast.Detour.TileCache
bmax.Y = ob.pos.Y + ob.height; bmax.Y = ob.pos.Y + ob.height;
bmax.Z = ob.pos.Z + ob.radius; bmax.Z = ob.pos.Z + ob.radius;
} }
else if (ob.type == DtTileCacheObstacleType.BOX) else if (ob.type == DtTileCacheObstacleType.DT_OBSTACLE_BOX)
{ {
bmin = ob.bmin; bmin = ob.bmin;
bmax = ob.bmax; 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); float maxr = 1.41f * Math.Max(ob.extents.X, ob.extents.Z);
bmin.X = ob.center.X - maxr; bmin.X = ob.center.X - maxr;

View File

@ -26,11 +26,13 @@ namespace DotRecast.Detour.TileCache
public class DtTileCacheObstacle public class DtTileCacheObstacle
{ {
public readonly int index; public readonly int index;
public DtTileCacheObstacleType type;
public RcVec3f pos = new RcVec3f(); public RcVec3f pos = new RcVec3f();
public float radius;
public float height;
public RcVec3f bmin = new RcVec3f(); public RcVec3f bmin = new RcVec3f();
public RcVec3f bmax = new RcVec3f(); public RcVec3f bmax = new RcVec3f();
public float radius, height;
public RcVec3f center = new RcVec3f(); public RcVec3f center = new RcVec3f();
public RcVec3f extents = 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 } 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<long> touched = new List<long>(); public List<long> touched = new List<long>();
public readonly List<long> pending = new List<long>(); public readonly List<long> pending = new List<long>();
public int salt; public int salt;
public DtTileCacheObstacleType type;
public DtObstacleState state = DtObstacleState.DT_OBSTACLE_EMPTY; public DtObstacleState state = DtObstacleState.DT_OBSTACLE_EMPTY;
public DtTileCacheObstacle next; public DtTileCacheObstacle next;
public DtTileCacheObstacle(int index) public DtTileCacheObstacle(int index)
{ {
salt = 1;
this.index = index; this.index = index;
salt = 1;
} }
} }
} }

View File

@ -2,8 +2,8 @@
{ {
public enum DtTileCacheObstacleType public enum DtTileCacheObstacleType
{ {
CYLINDER, DT_OBSTACLE_CYLINDER,
BOX, DT_OBSTACLE_BOX, // AABB
ORIENTED_BOX DT_OBSTACLE_ORIENTED_BOX // OBB
}; };
} }