changed class names by c++ recastnavigation

This commit is contained in:
ikpil 2023-06-08 21:38:02 +09:00
parent b2a631a8fc
commit 5457bb04e5
125 changed files with 1406 additions and 1409 deletions

View File

@ -121,7 +121,7 @@ namespace DotRecast.Detour.Crowd
*
* @see DtAllocCrowd(), DtFreeCrowd(), Init(), dtCrowdAgent
*/
public class Crowd
public class DtCrowd
{
/// The maximum number of corners a crowd agent will look ahead in the path.
/// This value is used for sizing the crowd agent corner buffers.
@ -144,30 +144,30 @@ namespace DotRecast.Detour.Crowd
public const int DT_CROWD_MAX_QUERY_FILTER_TYPE = 16;
private readonly RcAtomicInteger _agentId = new RcAtomicInteger();
private readonly List<CrowdAgent> _agents;
private readonly PathQueue _pathQ;
private readonly ObstacleAvoidanceParams[] _obstacleQueryParams = new ObstacleAvoidanceParams[DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS];
private readonly ObstacleAvoidanceQuery _obstacleQuery;
private ProximityGrid _grid;
private readonly List<DtCrowdAgent> _agents;
private readonly DtPathQueue _pathQ;
private readonly DtObstacleAvoidanceParams[] _obstacleQueryParams = new DtObstacleAvoidanceParams[DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS];
private readonly DtObstacleAvoidanceQuery _obstacleQuery;
private DtProximityGrid _grid;
private readonly RcVec3f _ext = new RcVec3f();
private readonly IQueryFilter[] _filters = new IQueryFilter[DT_CROWD_MAX_QUERY_FILTER_TYPE];
private NavMeshQuery _navQuery;
private NavMesh _navMesh;
private readonly CrowdConfig _config;
private readonly CrowdTelemetry _telemetry = new CrowdTelemetry();
private readonly IDtQueryFilter[] _filters = new IDtQueryFilter[DT_CROWD_MAX_QUERY_FILTER_TYPE];
private DtNavMeshQuery _navQuery;
private DtNavMesh _navMesh;
private readonly DtCrowdConfig _config;
private readonly DtCrowdTelemetry _telemetry = new DtCrowdTelemetry();
private int _velocitySampleCount;
public Crowd(CrowdConfig config, NavMesh nav) :
this(config, nav, i => new DefaultQueryFilter())
public DtCrowd(DtCrowdConfig config, DtNavMesh nav) :
this(config, nav, i => new DtQueryDefaultFilter())
{
}
public Crowd(CrowdConfig config, NavMesh nav, Func<int, IQueryFilter> queryFilterFactory)
public DtCrowd(DtCrowdConfig config, DtNavMesh nav, Func<int, IDtQueryFilter> queryFilterFactory)
{
_config = config;
_ext.Set(config.maxAgentRadius * 2.0f, config.maxAgentRadius * 1.5f, config.maxAgentRadius * 2.0f);
_obstacleQuery = new ObstacleAvoidanceQuery(config.maxObstacleAvoidanceCircles, config.maxObstacleAvoidanceSegments);
_obstacleQuery = new DtObstacleAvoidanceQuery(config.maxObstacleAvoidanceCircles, config.maxObstacleAvoidanceSegments);
for (int i = 0; i < DT_CROWD_MAX_QUERY_FILTER_TYPE; i++)
{
@ -177,33 +177,33 @@ namespace DotRecast.Detour.Crowd
// Init obstacle query option.
for (int i = 0; i < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS; ++i)
{
_obstacleQueryParams[i] = new ObstacleAvoidanceParams();
_obstacleQueryParams[i] = new DtObstacleAvoidanceParams();
}
// Allocate temp buffer for merging paths.
_pathQ = new PathQueue(config);
_agents = new List<CrowdAgent>();
_pathQ = new DtPathQueue(config);
_agents = new List<DtCrowdAgent>();
// The navQuery is mostly used for local searches, no need for large node pool.
_navMesh = nav;
_navQuery = new NavMeshQuery(nav);
_navQuery = new DtNavMeshQuery(nav);
}
public void SetNavMesh(NavMesh nav)
public void SetNavMesh(DtNavMesh nav)
{
_navMesh = nav;
_navQuery = new NavMeshQuery(nav);
_navQuery = new DtNavMeshQuery(nav);
}
/// Sets the shared avoidance configuration for the specified index.
/// @param[in] idx The index. [Limits: 0 <= value <
/// #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
/// @param[in] option The new configuration.
public void SetObstacleAvoidanceParams(int idx, ObstacleAvoidanceParams option)
public void SetObstacleAvoidanceParams(int idx, DtObstacleAvoidanceParams option)
{
if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS)
{
_obstacleQueryParams[idx] = new ObstacleAvoidanceParams(option);
_obstacleQueryParams[idx] = new DtObstacleAvoidanceParams(option);
}
}
@ -211,7 +211,7 @@ namespace DotRecast.Detour.Crowd
/// @param[in] idx The index of the configuration to retreive.
/// [Limits: 0 <= value < #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]
/// @return The requested configuration.
public ObstacleAvoidanceParams GetObstacleAvoidanceParams(int idx)
public DtObstacleAvoidanceParams GetObstacleAvoidanceParams(int idx)
{
if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS)
{
@ -224,7 +224,7 @@ namespace DotRecast.Detour.Crowd
/// Updates the specified agent's configuration.
/// @param[in] idx The agent index. [Limits: 0 <= value < #GetAgentCount()]
/// @param[in] params The new agent configuration.
public void UpdateAgentParameters(CrowdAgent agent, CrowdAgentParams option)
public void UpdateAgentParameters(DtCrowdAgent agent, DtCrowdAgentParams option)
{
agent.option = option;
}
@ -238,9 +238,9 @@ namespace DotRecast.Detour.Crowd
* The configutation of the agent.
* @return The newly created agent object
*/
public CrowdAgent AddAgent(RcVec3f pos, CrowdAgentParams option)
public DtCrowdAgent AddAgent(RcVec3f pos, DtCrowdAgentParams option)
{
CrowdAgent ag = new CrowdAgent(_agentId.GetAndIncrement());
DtCrowdAgent ag = new DtCrowdAgent(_agentId.GetAndIncrement());
_agents.Add(ag);
UpdateAgentParameters(ag, option);
@ -283,12 +283,12 @@ namespace DotRecast.Detour.Crowd
* @param agent
* Agent to be removed
*/
public void RemoveAgent(CrowdAgent agent)
public void RemoveAgent(DtCrowdAgent agent)
{
_agents.Remove(agent);
}
private bool RequestMoveTargetReplan(CrowdAgent ag, long refs, RcVec3f pos)
private bool RequestMoveTargetReplan(DtCrowdAgent ag, long refs, RcVec3f pos)
{
ag.SetTarget(refs, pos);
ag.targetReplan = true;
@ -306,7 +306,7 @@ namespace DotRecast.Detour.Crowd
/// The position will be constrained to the surface of the navigation mesh.
///
/// The request will be processed during the next #Update().
public bool RequestMoveTarget(CrowdAgent agent, long refs, RcVec3f pos)
public bool RequestMoveTarget(DtCrowdAgent agent, long refs, RcVec3f pos)
{
if (refs == 0)
{
@ -323,7 +323,7 @@ namespace DotRecast.Detour.Crowd
/// @param[in] idx The agent index. [Limits: 0 <= value < #GetAgentCount()]
/// @param[in] vel The movement velocity. [(x, y, z)]
/// @return True if the request was successfully submitted.
public bool RequestMoveVelocity(CrowdAgent agent, RcVec3f vel)
public bool RequestMoveVelocity(DtCrowdAgent agent, RcVec3f vel)
{
// Initialize request.
agent.targetRef = 0;
@ -338,7 +338,7 @@ namespace DotRecast.Detour.Crowd
/// Resets any request for the specified agent.
/// @param[in] idx The agent index. [Limits: 0 <= value < #GetAgentCount()]
/// @return True if the request was successfully reseted.
public bool ResetMoveTarget(CrowdAgent agent)
public bool ResetMoveTarget(DtCrowdAgent agent)
{
// Initialize request.
agent.targetRef = 0;
@ -355,7 +355,7 @@ namespace DotRecast.Detour.Crowd
*
* @return List of active agents
*/
public IList<CrowdAgent> GetActiveAgents()
public IList<DtCrowdAgent> GetActiveAgents()
{
return _agents;
}
@ -365,38 +365,38 @@ namespace DotRecast.Detour.Crowd
return _ext;
}
public IQueryFilter GetFilter(int i)
public IDtQueryFilter GetFilter(int i)
{
return i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE ? _filters[i] : null;
}
public ProximityGrid GetGrid()
public DtProximityGrid GetGrid()
{
return _grid;
}
public PathQueue GetPathQueue()
public DtPathQueue GetPathQueue()
{
return _pathQ;
}
public CrowdTelemetry Telemetry()
public DtCrowdTelemetry Telemetry()
{
return _telemetry;
}
public CrowdConfig Config()
public DtCrowdConfig Config()
{
return _config;
}
public CrowdTelemetry Update(float dt, CrowdAgentDebugInfo debug)
public DtCrowdTelemetry Update(float dt, DtCrowdAgentDebugInfo debug)
{
_velocitySampleCount = 0;
_telemetry.Start();
IList<CrowdAgent> agents = GetActiveAgents();
IList<DtCrowdAgent> agents = GetActiveAgents();
// Check that all agents still have valid paths.
CheckPathValidity(agents, dt);
@ -439,11 +439,11 @@ namespace DotRecast.Detour.Crowd
}
private void CheckPathValidity(IList<CrowdAgent> agents, float dt)
private void CheckPathValidity(IList<DtCrowdAgent> agents, float dt)
{
_telemetry.Start("checkPathValidity");
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -561,14 +561,14 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("checkPathValidity");
}
private void UpdateMoveRequest(IList<CrowdAgent> agents, float dt)
private void UpdateMoveRequest(IList<DtCrowdAgent> agents, float dt)
{
_telemetry.Start("updateMoveRequest");
RcSortedQueue<CrowdAgent> queue = new RcSortedQueue<CrowdAgent>((a1, a2) => a2.targetReplanTime.CompareTo(a1.targetReplanTime));
RcSortedQueue<DtCrowdAgent> queue = new RcSortedQueue<DtCrowdAgent>((a1, a2) => a2.targetReplanTime.CompareTo(a1.targetReplanTime));
// Fire off new requests.
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state == CrowdAgentState.DT_CROWDAGENT_STATE_INVALID)
{
@ -666,7 +666,7 @@ namespace DotRecast.Detour.Crowd
while (!queue.IsEmpty())
{
CrowdAgent ag = queue.Dequeue();
DtCrowdAgent ag = queue.Dequeue();
ag.targetPathQueryResult = _pathQ.Request(ag.corridor.GetLastPoly(), ag.targetRef, ag.corridor.GetTarget(),
ag.targetPos, _filters[ag.option.queryFilterType]);
if (ag.targetPathQueryResult != null)
@ -686,7 +686,7 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("pathQueueUpdate");
// Process path results.
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
@ -698,7 +698,7 @@ namespace DotRecast.Detour.Crowd
{
// _telemetry.RecordPathWaitTime(ag.targetReplanTime);
// Poll path queue.
Status status = ag.targetPathQueryResult.status;
DtStatus status = ag.targetPathQueryResult.status;
if (status != null && status.IsFailed())
{
// Path find failed, retry if the target location is still
@ -821,13 +821,13 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("updateMoveRequest");
}
private void UpdateTopologyOptimization(IList<CrowdAgent> agents, float dt)
private void UpdateTopologyOptimization(IList<DtCrowdAgent> agents, float dt)
{
_telemetry.Start("updateTopologyOptimization");
RcSortedQueue<CrowdAgent> queue = new RcSortedQueue<CrowdAgent>((a1, a2) => a2.topologyOptTime.CompareTo(a1.topologyOptTime));
RcSortedQueue<DtCrowdAgent> queue = new RcSortedQueue<DtCrowdAgent>((a1, a2) => a2.topologyOptTime.CompareTo(a1.topologyOptTime));
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -840,7 +840,7 @@ namespace DotRecast.Detour.Crowd
continue;
}
if ((ag.option.updateFlags & CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO) == 0)
if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO) == 0)
{
continue;
}
@ -854,7 +854,7 @@ namespace DotRecast.Detour.Crowd
while (!queue.IsEmpty())
{
CrowdAgent ag = queue.Dequeue();
DtCrowdAgent ag = queue.Dequeue();
ag.corridor.OptimizePathTopology(_navQuery, _filters[ag.option.queryFilterType], _config.maxTopologyOptimizationIterations);
ag.topologyOptTime = 0;
}
@ -862,12 +862,12 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("updateTopologyOptimization");
}
private void BuildProximityGrid(IList<CrowdAgent> agents)
private void BuildProximityGrid(IList<DtCrowdAgent> agents)
{
_telemetry.Start("buildProximityGrid");
_grid = new ProximityGrid(_config.maxAgentRadius * 3);
_grid = new DtProximityGrid(_config.maxAgentRadius * 3);
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
RcVec3f p = ag.npos;
float r = ag.option.radius;
@ -877,10 +877,10 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("buildProximityGrid");
}
private void BuildNeighbours(IList<CrowdAgent> agents)
private void BuildNeighbours(IList<DtCrowdAgent> agents)
{
_telemetry.Start("buildNeighbours");
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -905,11 +905,11 @@ namespace DotRecast.Detour.Crowd
}
private List<CrowdNeighbour> GetNeighbours(RcVec3f pos, float height, float range, CrowdAgent skip, ProximityGrid grid)
private List<DtCrowdNeighbour> GetNeighbours(RcVec3f pos, float height, float range, DtCrowdAgent skip, DtProximityGrid grid)
{
HashSet<CrowdAgent> proxAgents = grid.QueryItems(pos.x - range, pos.z - range, pos.x + range, pos.z + range);
List<CrowdNeighbour> result = new List<CrowdNeighbour>(proxAgents.Count);
foreach (CrowdAgent ag in proxAgents)
HashSet<DtCrowdAgent> proxAgents = grid.QueryItems(pos.x - range, pos.z - range, pos.x + range, pos.z + range);
List<DtCrowdNeighbour> result = new List<DtCrowdNeighbour>(proxAgents.Count);
foreach (DtCrowdAgent ag in proxAgents)
{
if (ag == skip)
{
@ -930,18 +930,18 @@ namespace DotRecast.Detour.Crowd
continue;
}
result.Add(new CrowdNeighbour(ag, distSqr));
result.Add(new DtCrowdNeighbour(ag, distSqr));
}
result.Sort((o1, o2) => o1.dist.CompareTo(o2.dist));
return result;
}
private void FindCorners(IList<CrowdAgent> agents, CrowdAgentDebugInfo debug)
private void FindCorners(IList<DtCrowdAgent> agents, DtCrowdAgentDebugInfo debug)
{
_telemetry.Start("findCorners");
CrowdAgent debugAgent = debug != null ? debug.agent : null;
foreach (CrowdAgent ag in agents)
DtCrowdAgent debugAgent = debug != null ? debug.agent : null;
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -959,7 +959,7 @@ namespace DotRecast.Detour.Crowd
// Check to see if the corner after the next corner is directly visible,
// and short cut to there.
if ((ag.option.updateFlags & CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS) != 0 && ag.corners.Count > 0)
if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS) != 0 && ag.corners.Count > 0)
{
RcVec3f target = ag.corners[Math.Min(1, ag.corners.Count - 1)].GetPos();
ag.corridor.OptimizePathVisibility(target, ag.option.pathOptimizationRange, _navQuery,
@ -986,10 +986,10 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("findCorners");
}
private void TriggerOffMeshConnections(IList<CrowdAgent> agents)
private void TriggerOffMeshConnections(IList<DtCrowdAgent> agents)
{
_telemetry.Start("triggerOffMeshConnections");
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -1007,7 +1007,7 @@ namespace DotRecast.Detour.Crowd
if (ag.OverOffmeshConnection(triggerRadius))
{
// Prepare to off-mesh connection.
CrowdAgentAnimation anim = ag.animation;
DtCrowdAgentAnimation anim = ag.animation;
// Adjust the path over the off-mesh connection.
long[] refs = new long[2];
@ -1035,10 +1035,10 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("triggerOffMeshConnections");
}
private void CalculateSteering(IList<CrowdAgent> agents)
private void CalculateSteering(IList<DtCrowdAgent> agents)
{
_telemetry.Start("calculateSteering");
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -1060,7 +1060,7 @@ namespace DotRecast.Detour.Crowd
else
{
// Calculate steering direction.
if ((ag.option.updateFlags & CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS) != 0)
if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS) != 0)
{
dvel = ag.CalcSmoothSteerDirection();
}
@ -1078,7 +1078,7 @@ namespace DotRecast.Detour.Crowd
}
// Separation
if ((ag.option.updateFlags & CrowdAgentParams.DT_CROWD_SEPARATION) != 0)
if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_SEPARATION) != 0)
{
float separationDist = ag.option.collisionQueryRange;
float invSeparationDist = 1.0f / separationDist;
@ -1089,7 +1089,7 @@ namespace DotRecast.Detour.Crowd
for (int j = 0; j < ag.neis.Count; ++j)
{
CrowdAgent nei = ag.neis[j].agent;
DtCrowdAgent nei = ag.neis[j].agent;
RcVec3f diff = ag.npos.Subtract(nei.npos);
diff.y = 0;
@ -1133,25 +1133,25 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("calculateSteering");
}
private void PlanVelocity(CrowdAgentDebugInfo debug, IList<CrowdAgent> agents)
private void PlanVelocity(DtCrowdAgentDebugInfo debug, IList<DtCrowdAgent> agents)
{
_telemetry.Start("planVelocity");
CrowdAgent debugAgent = debug != null ? debug.agent : null;
foreach (CrowdAgent ag in agents)
DtCrowdAgent debugAgent = debug != null ? debug.agent : null;
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
continue;
}
if ((ag.option.updateFlags & CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE) != 0)
if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE) != 0)
{
_obstacleQuery.Reset();
// Add neighbours as obstacles.
for (int j = 0; j < ag.neis.Count; ++j)
{
CrowdAgent nei = ag.neis[j].agent;
DtCrowdAgent nei = ag.neis[j].agent;
_obstacleQuery.AddCircle(nei.npos, nei.option.radius, nei.vel, nei.dvel);
}
@ -1169,7 +1169,7 @@ namespace DotRecast.Detour.Crowd
_obstacleQuery.AddSegment(s[0], s3);
}
ObstacleAvoidanceDebugData vod = null;
DtObstacleAvoidanceDebugData vod = null;
if (debugAgent == ag)
{
vod = debug.vod;
@ -1179,7 +1179,7 @@ namespace DotRecast.Detour.Crowd
bool adaptive = true;
int ns = 0;
ObstacleAvoidanceParams option = _obstacleQueryParams[ag.option.obstacleAvoidanceType];
DtObstacleAvoidanceParams option = _obstacleQueryParams[ag.option.obstacleAvoidanceType];
if (adaptive)
{
@ -1206,10 +1206,10 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("planVelocity");
}
private void Integrate(float dt, IList<CrowdAgent> agents)
private void Integrate(float dt, IList<DtCrowdAgent> agents)
{
_telemetry.Start("integrate");
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -1222,12 +1222,12 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("integrate");
}
private void HandleCollisions(IList<CrowdAgent> agents)
private void HandleCollisions(IList<DtCrowdAgent> agents)
{
_telemetry.Start("handleCollisions");
for (int iter = 0; iter < 4; ++iter)
{
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
long idx0 = ag.idx;
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
@ -1241,7 +1241,7 @@ namespace DotRecast.Detour.Crowd
for (int j = 0; j < ag.neis.Count; ++j)
{
CrowdAgent nei = ag.neis[j].agent;
DtCrowdAgent nei = ag.neis[j].agent;
long idx1 = nei.idx;
RcVec3f diff = ag.npos.Subtract(nei.npos);
diff.y = 0;
@ -1285,7 +1285,7 @@ namespace DotRecast.Detour.Crowd
}
}
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -1299,10 +1299,10 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("handleCollisions");
}
private void MoveAgents(IList<CrowdAgent> agents)
private void MoveAgents(IList<DtCrowdAgent> agents)
{
_telemetry.Start("moveAgents");
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
if (ag.state != CrowdAgentState.DT_CROWDAGENT_STATE_WALKING)
{
@ -1326,12 +1326,12 @@ namespace DotRecast.Detour.Crowd
_telemetry.Stop("moveAgents");
}
private void UpdateOffMeshConnections(IList<CrowdAgent> agents, float dt)
private void UpdateOffMeshConnections(IList<DtCrowdAgent> agents, float dt)
{
_telemetry.Start("updateOffMeshConnections");
foreach (CrowdAgent ag in agents)
foreach (DtCrowdAgent ag in agents)
{
CrowdAgentAnimation anim = ag.animation;
DtCrowdAgentAnimation anim = ag.animation;
if (!anim.active)
{
continue;

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour.Crowd
{
/// Represents an agent managed by a #dtCrowd object.
/// @ingroup crowd
public class CrowdAgent
public class DtCrowdAgent
{
public readonly long idx;
@ -38,16 +38,16 @@ namespace DotRecast.Detour.Crowd
public bool partial;
/// The path corridor the agent is using.
public PathCorridor corridor;
public DtPathCorridor corridor;
/// The local boundary data for the agent.
public LocalBoundary boundary;
public DtLocalBoundary boundary;
/// Time since the agent's path corridor was optimized.
public float topologyOptTime;
/// The known neighbors of the agent.
public List<CrowdNeighbour> neis = new List<CrowdNeighbour>();
public List<DtCrowdNeighbour> neis = new List<DtCrowdNeighbour>();
/// The desired speed.
public float desiredSpeed;
@ -73,7 +73,7 @@ namespace DotRecast.Detour.Crowd
/// < The actual velocity of the agent. The change from nvel -> vel is
/// constrained by max acceleration. [(x, y, z)]
/// The agent's configuration parameters.
public CrowdAgentParams option;
public DtCrowdAgentParams option;
/// The local path corridor corners for the agent.
public List<StraightPathItem> corners = new List<StraightPathItem>();
@ -88,7 +88,7 @@ namespace DotRecast.Detour.Crowd
/// < Target position of the movement request (or velocity in case of
/// DT_CROWDAGENT_TARGET_VELOCITY).
public PathQueryResult targetPathQueryResult;
public DtPathQueryResult targetPathQueryResult;
/// < Path finder query
public bool targetReplan;
@ -99,14 +99,14 @@ namespace DotRecast.Detour.Crowd
/// <Time since the agent's target was replanned.
public float targetReplanWaitTime;
public CrowdAgentAnimation animation;
public DtCrowdAgentAnimation animation;
public CrowdAgent(int idx)
public DtCrowdAgent(int idx)
{
this.idx = idx;
corridor = new PathCorridor();
boundary = new LocalBoundary();
animation = new CrowdAgentAnimation();
corridor = new DtPathCorridor();
boundary = new DtLocalBoundary();
animation = new DtCrowdAgentAnimation();
}
public void Integrate(float dt)
@ -132,7 +132,7 @@ namespace DotRecast.Detour.Crowd
return false;
bool offMeshConnection = ((corners[corners.Count - 1].GetFlags()
& NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
& DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
? true
: false;
if (offMeshConnection)
@ -150,7 +150,7 @@ namespace DotRecast.Detour.Crowd
if (0 == corners.Count)
return range;
bool endOfPath = ((corners[corners.Count - 1].GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_END) != 0) ? true : false;
bool endOfPath = ((corners[corners.Count - 1].GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_END) != 0) ? true : false;
if (endOfPath)
return Math.Min(RcVec3f.Dist2D(npos, corners[corners.Count - 1].GetPos()), range);

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Crowd
{
public class CrowdAgentAnimation
public class DtCrowdAgentAnimation
{
public bool active;
public RcVec3f initPos = new RcVec3f();

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour.Crowd
{
/// Configuration parameters for a crowd agent.
/// @ingroup crowd
public class CrowdAgentParams
public class DtCrowdAgentParams
{
public float radius;

View File

@ -18,7 +18,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.Crowd
{
public class CrowdConfig
public class DtCrowdConfig
{
public readonly float maxAgentRadius;
@ -69,7 +69,7 @@ namespace DotRecast.Detour.Crowd
*/
public int maxObstacleAvoidanceSegments = 8;
public CrowdConfig(float maxAgentRadius)
public DtCrowdConfig(float maxAgentRadius)
{
this.maxAgentRadius = maxAgentRadius;
}

View File

@ -3,15 +3,15 @@
/// Provides neighbor data for agents managed by the crowd.
/// @ingroup crowd
/// @see dtCrowdAgent::neis, dtCrowd
public class CrowdNeighbour
public class DtCrowdNeighbour
{
public readonly CrowdAgent agent;
public readonly DtCrowdAgent agent;
/// < The index of the neighbor in the crowd.
public readonly float dist;
/// < The distance between the current agent and the neighbor.
public CrowdNeighbour(CrowdAgent agent, float dist)
public DtCrowdNeighbour(DtCrowdAgent agent, float dist)
{
this.agent = agent;
this.dist = dist;

View File

@ -24,7 +24,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Crowd
{
public class CrowdTelemetry
public class DtCrowdTelemetry
{
public const int TIMING_SAMPLES = 10;
private float _maxTimeToEnqueueRequest;

View File

@ -25,18 +25,18 @@ using DotRecast.Detour.QueryResults;
namespace DotRecast.Detour.Crowd
{
using static DotRecast.Core.RcMath;
using static RcMath;
public class LocalBoundary
public class DtLocalBoundary
{
public const int MAX_LOCAL_SEGS = 8;
RcVec3f m_center = new RcVec3f();
List<Segment> m_segs = new List<Segment>();
List<DtSegment> m_segs = new List<DtSegment>();
List<long> m_polys = new List<long>();
public LocalBoundary()
public DtLocalBoundary()
{
m_center.x = m_center.y = m_center.z = float.MaxValue;
}
@ -51,7 +51,7 @@ namespace DotRecast.Detour.Crowd
protected void AddSegment(float dist, SegmentVert s)
{
// Insert neighbour based on the distance.
Segment seg = new Segment();
DtSegment seg = new DtSegment();
seg.s[0] = s.vmin;
seg.s[1] = s.vmax;
//Array.Copy(s, seg.s, 6);
@ -90,7 +90,7 @@ namespace DotRecast.Detour.Crowd
}
}
public void Update(long refs, RcVec3f pos, float collisionQueryRange, NavMeshQuery navquery, IQueryFilter filter)
public void Update(long refs, RcVec3f pos, float collisionQueryRange, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
if (refs == 0)
{
@ -133,7 +133,7 @@ namespace DotRecast.Detour.Crowd
}
}
public bool IsValid(NavMeshQuery navquery, IQueryFilter filter)
public bool IsValid(DtNavMeshQuery navquery, IDtQueryFilter filter)
{
if (m_polys.Count == 0)
{

View File

@ -1,6 +1,6 @@
namespace DotRecast.Detour.Crowd
{
public class ObstacleAvoidanceParams
public class DtObstacleAvoidanceParams
{
public float velBias;
public float weightDesVel;
@ -20,7 +20,7 @@
public int adaptiveDepth;
/// < adaptive
public ObstacleAvoidanceParams()
public DtObstacleAvoidanceParams()
{
velBias = 0.4f;
weightDesVel = 2.0f;
@ -34,7 +34,7 @@
adaptiveDepth = 5;
}
public ObstacleAvoidanceParams(ObstacleAvoidanceParams option)
public DtObstacleAvoidanceParams(DtObstacleAvoidanceParams option)
{
velBias = option.velBias;
weightDesVel = option.weightDesVel;

View File

@ -24,9 +24,9 @@ using DotRecast.Detour.Crowd.Tracking;
namespace DotRecast.Detour.Crowd
{
using static DotRecast.Core.RcMath;
using static RcMath;
public class ObstacleAvoidanceQuery
public class DtObstacleAvoidanceQuery
{
public const int DT_MAX_PATTERN_DIVS = 32;
@ -34,35 +34,35 @@ namespace DotRecast.Detour.Crowd
public const int DT_MAX_PATTERN_RINGS = 4;
private ObstacleAvoidanceParams m_params;
private DtObstacleAvoidanceParams m_params;
private float m_invHorizTime;
private float m_vmax;
private float m_invVmax;
private readonly int m_maxCircles;
private readonly ObstacleCircle[] m_circles;
private readonly DtObstacleCircle[] m_circles;
private int m_ncircles;
private readonly int m_maxSegments;
private readonly ObstacleSegment[] m_segments;
private readonly DtObstacleSegment[] m_segments;
private int m_nsegments;
public ObstacleAvoidanceQuery(int maxCircles, int maxSegments)
public DtObstacleAvoidanceQuery(int maxCircles, int maxSegments)
{
m_maxCircles = maxCircles;
m_ncircles = 0;
m_circles = new ObstacleCircle[m_maxCircles];
m_circles = new DtObstacleCircle[m_maxCircles];
for (int i = 0; i < m_maxCircles; i++)
{
m_circles[i] = new ObstacleCircle();
m_circles[i] = new DtObstacleCircle();
}
m_maxSegments = maxSegments;
m_nsegments = 0;
m_segments = new ObstacleSegment[m_maxSegments];
m_segments = new DtObstacleSegment[m_maxSegments];
for (int i = 0; i < m_maxSegments; i++)
{
m_segments[i] = new ObstacleSegment();
m_segments[i] = new DtObstacleSegment();
}
}
@ -77,7 +77,7 @@ namespace DotRecast.Detour.Crowd
if (m_ncircles >= m_maxCircles)
return;
ObstacleCircle cir = m_circles[m_ncircles++];
DtObstacleCircle cir = m_circles[m_ncircles++];
cir.p = pos;
cir.rad = rad;
cir.vel = vel;
@ -89,7 +89,7 @@ namespace DotRecast.Detour.Crowd
if (m_nsegments >= m_maxSegments)
return;
ObstacleSegment seg = m_segments[m_nsegments++];
DtObstacleSegment seg = m_segments[m_nsegments++];
seg.p = p;
seg.q = q;
}
@ -99,7 +99,7 @@ namespace DotRecast.Detour.Crowd
return m_ncircles;
}
public ObstacleCircle GetObstacleCircle(int i)
public DtObstacleCircle GetObstacleCircle(int i)
{
return m_circles[i];
}
@ -109,7 +109,7 @@ namespace DotRecast.Detour.Crowd
return m_nsegments;
}
public ObstacleSegment GetObstacleSegment(int i)
public DtObstacleSegment GetObstacleSegment(int i)
{
return m_segments[i];
}
@ -119,7 +119,7 @@ namespace DotRecast.Detour.Crowd
// Prepare obstacles
for (int i = 0; i < m_ncircles; ++i)
{
ObstacleCircle cir = m_circles[i];
DtObstacleCircle cir = m_circles[i];
// Side
RcVec3f pa = pos;
@ -146,7 +146,7 @@ namespace DotRecast.Detour.Crowd
for (int i = 0; i < m_nsegments; ++i)
{
ObstacleSegment seg = m_segments[i];
DtObstacleSegment seg = m_segments[i];
// Precalc if the agent is really close to the segment.
float r = 0.01f;
@ -206,7 +206,7 @@ namespace DotRecast.Detour.Crowd
* threshold penalty for early out
*/
private float ProcessSample(RcVec3f vcand, float cs, RcVec3f pos, float rad, RcVec3f vel, RcVec3f dvel,
float minPenalty, ObstacleAvoidanceDebugData debug)
float minPenalty, DtObstacleAvoidanceDebugData debug)
{
// penalty for straying away from the desired and current velocities
float vpen = m_params.weightDesVel * (RcVec3f.Dist2D(vcand, dvel) * m_invVmax);
@ -226,7 +226,7 @@ namespace DotRecast.Detour.Crowd
for (int i = 0; i < m_ncircles; ++i)
{
ObstacleCircle cir = m_circles[i];
DtObstacleCircle cir = m_circles[i];
// RVO
RcVec3f vab = vcand.Scale(2);
@ -263,7 +263,7 @@ namespace DotRecast.Detour.Crowd
for (int i = 0; i < m_nsegments; ++i)
{
ObstacleSegment seg = m_segments[i];
DtObstacleSegment seg = m_segments[i];
float htmin = 0;
if (seg.touch)
@ -316,7 +316,7 @@ namespace DotRecast.Detour.Crowd
}
public Tuple<int, RcVec3f> SampleVelocityGrid(RcVec3f pos, float rad, float vmax, RcVec3f vel, RcVec3f dvel,
ObstacleAvoidanceParams option, ObstacleAvoidanceDebugData debug)
DtObstacleAvoidanceParams option, DtObstacleAvoidanceDebugData debug)
{
Prepare(pos, dvel);
m_params = option;
@ -384,8 +384,8 @@ namespace DotRecast.Detour.Crowd
static readonly float DT_PI = 3.14159265f;
public int SampleVelocityAdaptive(RcVec3f pos, float rad, float vmax, RcVec3f vel, RcVec3f dvel, out RcVec3f nvel,
ObstacleAvoidanceParams option,
ObstacleAvoidanceDebugData debug)
DtObstacleAvoidanceParams option,
DtObstacleAvoidanceDebugData debug)
{
Prepare(pos, dvel);
m_params = option;

View File

@ -3,7 +3,7 @@
namespace DotRecast.Detour.Crowd
{
/// < Max number of adaptive rings.
public class ObstacleCircle
public class DtObstacleCircle
{
/** Position of the obstacle */
public RcVec3f p = new RcVec3f();

View File

@ -2,7 +2,7 @@
namespace DotRecast.Detour.Crowd
{
public class ObstacleSegment
public class DtObstacleSegment
{
/** End points of the obstacle segment */
public RcVec3f p = new RcVec3f();

View File

@ -64,7 +64,7 @@ namespace DotRecast.Detour.Crowd
* replanning may be needed. E.g. If you move the target, check #GetLastPoly() to see if it is the expected polygon.
*
*/
public class PathCorridor
public class DtPathCorridor
{
private RcVec3f m_pos = new RcVec3f();
private RcVec3f m_target = new RcVec3f();
@ -194,7 +194,7 @@ namespace DotRecast.Detour.Crowd
/**
* Allocates the corridor's path buffer.
*/
public PathCorridor()
public DtPathCorridor()
{
m_path = new List<long>();
}
@ -234,7 +234,7 @@ namespace DotRecast.Detour.Crowd
* @param[in] navquery The query object used to build the corridor.
* @return Corners
*/
public List<StraightPathItem> FindCorners(int maxCorners, NavMeshQuery navquery, IQueryFilter filter)
public List<StraightPathItem> FindCorners(int maxCorners, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
List<StraightPathItem> path = new List<StraightPathItem>();
Result<List<StraightPathItem>> result = navquery.FindStraightPath(m_pos, m_target, m_path, maxCorners, 0);
@ -245,7 +245,7 @@ namespace DotRecast.Detour.Crowd
int start = 0;
foreach (StraightPathItem spi in path)
{
if ((spi.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0
if ((spi.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0
|| RcVec3f.Dist2DSqr(spi.GetPos(), m_pos) > MIN_TARGET_DIST)
{
break;
@ -259,7 +259,7 @@ namespace DotRecast.Detour.Crowd
for (int i = start; i < path.Count; i++)
{
StraightPathItem spi = path[i];
if ((spi.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
if ((spi.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
{
end = i + 1;
break;
@ -299,7 +299,7 @@ namespace DotRecast.Detour.Crowd
* @param filter
* The filter to apply to the operation.
*/
public void OptimizePathVisibility(RcVec3f next, float pathOptimizationRange, NavMeshQuery navquery, IQueryFilter filter)
public void OptimizePathVisibility(RcVec3f next, float pathOptimizationRange, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
// Clamp the ray to max distance.
float dist = RcVec3f.Dist2D(m_pos, next);
@ -318,7 +318,7 @@ namespace DotRecast.Detour.Crowd
var delta = next.Subtract(m_pos);
RcVec3f goal = RcVec3f.Mad(m_pos, delta, pathOptimizationRange / dist);
Result<RaycastHit> rc = navquery.Raycast(m_path[0], m_pos, goal, filter, 0, 0);
Result<DtRaycastHit> rc = navquery.Raycast(m_path[0], m_pos, goal, filter, 0, 0);
if (rc.Succeeded())
{
if (rc.result.path.Count > 1 && rc.result.t > 0.99f)
@ -344,7 +344,7 @@ namespace DotRecast.Detour.Crowd
* The filter to apply to the operation.
*
*/
public bool OptimizePathTopology(NavMeshQuery navquery, IQueryFilter filter, int maxIterations)
public bool OptimizePathTopology(DtNavMeshQuery navquery, IDtQueryFilter filter, int maxIterations)
{
if (m_path.Count < 3)
{
@ -364,7 +364,7 @@ namespace DotRecast.Detour.Crowd
return false;
}
public bool MoveOverOffmeshConnection(long offMeshConRef, long[] refs, ref RcVec3f start, ref RcVec3f end, NavMeshQuery navquery)
public bool MoveOverOffmeshConnection(long offMeshConRef, long[] refs, ref RcVec3f start, ref RcVec3f end, DtNavMeshQuery navquery)
{
// Advance the path up to and over the off-mesh connection.
long prevRef = 0, polyRef = m_path[0];
@ -387,7 +387,7 @@ namespace DotRecast.Detour.Crowd
refs[0] = prevRef;
refs[1] = polyRef;
NavMesh nav = navquery.GetAttachedNavMesh();
DtNavMesh nav = navquery.GetAttachedNavMesh();
var startEnd = nav.GetOffMeshConnectionPolyEndPoints(refs[0], refs[1]);
if (startEnd.Succeeded())
{
@ -423,7 +423,7 @@ namespace DotRecast.Detour.Crowd
* @param filter
* The filter to apply to the operation.
*/
public bool MovePosition(RcVec3f npos, NavMeshQuery navquery, IQueryFilter filter)
public bool MovePosition(RcVec3f npos, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
// Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter);
@ -461,7 +461,7 @@ namespace DotRecast.Detour.Crowd
* @param filter
* The filter to apply to the operation.
*/
public bool MoveTargetPosition(RcVec3f npos, NavMeshQuery navquery, IQueryFilter filter)
public bool MoveTargetPosition(RcVec3f npos, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
// Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter);
@ -516,7 +516,7 @@ namespace DotRecast.Detour.Crowd
}
}
public void TrimInvalidPath(long safeRef, float[] safePos, NavMeshQuery navquery, IQueryFilter filter)
public void TrimInvalidPath(long safeRef, float[] safePos, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
// Keep valid path as far as possible.
int n = 0;
@ -559,7 +559,7 @@ namespace DotRecast.Detour.Crowd
* The filter to apply to the operation.
* @return
*/
public bool IsValid(int maxLookAhead, NavMeshQuery navquery, IQueryFilter filter)
public bool IsValid(int maxLookAhead, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
// Check that all polygons still pass query filter.
int n = Math.Min(m_path.Count, maxLookAhead);

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Crowd
{
public class PathQuery
public class DtPathQuery
{
/// Path find start and end location.
public RcVec3f startPos = new RcVec3f();
@ -30,11 +30,11 @@ namespace DotRecast.Detour.Crowd
public RcVec3f endPos = new RcVec3f();
public long startRef;
public long endRef;
public IQueryFilter filter;
public IDtQueryFilter filter;
/// < TODO: This is potentially dangerous!
public readonly PathQueryResult result = new PathQueryResult();
public readonly DtPathQueryResult result = new DtPathQueryResult();
public NavMeshQuery navQuery;
public DtNavMeshQuery navQuery;
}
}

View File

@ -20,9 +20,9 @@ using System.Collections.Generic;
namespace DotRecast.Detour.Crowd
{
public class PathQueryResult
public class DtPathQueryResult
{
public Status status;
public DtStatus status;
public List<long> path = new List<long>();
}
}

View File

@ -24,26 +24,24 @@ using DotRecast.Detour.QueryResults;
namespace DotRecast.Detour.Crowd
{
using static DotRecast.Core.RcMath;
public class PathQueue
public class DtPathQueue
{
private readonly CrowdConfig config;
private readonly LinkedList<PathQuery> queue = new LinkedList<PathQuery>();
private readonly DtCrowdConfig config;
private readonly LinkedList<DtPathQuery> queue = new LinkedList<DtPathQuery>();
public PathQueue(CrowdConfig config)
public DtPathQueue(DtCrowdConfig config)
{
this.config = config;
}
public void Update(NavMesh navMesh)
public void Update(DtNavMesh navMesh)
{
// Update path request until there is nothing to update or up to maxIters pathfinder iterations has been
// consumed.
int iterCount = config.maxFindPathIterations;
while (iterCount > 0)
{
PathQuery q = queue.First?.Value;
DtPathQuery q = queue.First?.Value;
if (q == null)
{
break;
@ -53,7 +51,7 @@ namespace DotRecast.Detour.Crowd
// Handle query start.
if (q.result.status == null)
{
q.navQuery = new NavMeshQuery(navMesh);
q.navQuery = new DtNavMeshQuery(navMesh);
q.result.status = q.navQuery.InitSlicedFindPath(q.startRef, q.endRef, q.startPos, q.endPos, q.filter, 0);
}
@ -79,14 +77,14 @@ namespace DotRecast.Detour.Crowd
}
}
public PathQueryResult Request(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter)
public DtPathQueryResult Request(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter)
{
if (queue.Count >= config.pathQueueSize)
{
return null;
}
PathQuery q = new PathQuery();
DtPathQuery q = new DtPathQuery();
q.startPos = startPos;
q.startRef = startRef;
q.endPos = endPos;

View File

@ -24,17 +24,17 @@ using System.Linq;
namespace DotRecast.Detour.Crowd
{
public class ProximityGrid
public class DtProximityGrid
{
private readonly float _cellSize;
private readonly float _invCellSize;
private readonly Dictionary<long, List<CrowdAgent>> _items;
private readonly Dictionary<long, List<DtCrowdAgent>> _items;
public ProximityGrid(float cellSize)
public DtProximityGrid(float cellSize)
{
_cellSize = cellSize;
_invCellSize = 1.0f / cellSize;
_items = new Dictionary<long, List<CrowdAgent>>();
_items = new Dictionary<long, List<DtCrowdAgent>>();
}
public static long CombineKey(int x, int y)
@ -57,7 +57,7 @@ namespace DotRecast.Detour.Crowd
_items.Clear();
}
public void AddItem(CrowdAgent agent, float minx, float miny, float maxx, float maxy)
public void AddItem(DtCrowdAgent agent, float minx, float miny, float maxx, float maxy)
{
int iminx = (int)Math.Floor(minx * _invCellSize);
int iminy = (int)Math.Floor(miny * _invCellSize);
@ -71,7 +71,7 @@ namespace DotRecast.Detour.Crowd
long key = CombineKey(x, y);
if (!_items.TryGetValue(key, out var ids))
{
ids = new List<CrowdAgent>();
ids = new List<DtCrowdAgent>();
_items.Add(key, ids);
}
@ -81,14 +81,14 @@ namespace DotRecast.Detour.Crowd
}
// 해당 셀 사이즈의 크기로 x ~ y 영역을 찾아, 군집 에이전트를 가져오는 코드
public HashSet<CrowdAgent> QueryItems(float minx, float miny, float maxx, float maxy)
public HashSet<DtCrowdAgent> QueryItems(float minx, float miny, float maxx, float maxy)
{
int iminx = (int)Math.Floor(minx * _invCellSize);
int iminy = (int)Math.Floor(miny * _invCellSize);
int imaxx = (int)Math.Floor(maxx * _invCellSize);
int imaxy = (int)Math.Floor(maxy * _invCellSize);
HashSet<CrowdAgent> result = new HashSet<CrowdAgent>();
HashSet<DtCrowdAgent> result = new HashSet<DtCrowdAgent>();
for (int y = iminy; y <= imaxy; ++y)
{
for (int x = iminx; x <= imaxx; ++x)

View File

@ -2,7 +2,7 @@
namespace DotRecast.Detour.Crowd
{
public class Segment
public class DtSegment
{
/** Segment start/end */
public RcVec3f[] s = new RcVec3f[2];

View File

@ -22,11 +22,11 @@ using DotRecast.Core;
namespace DotRecast.Detour.Crowd.Tracking
{
public class CrowdAgentDebugInfo
public class DtCrowdAgentDebugInfo
{
public CrowdAgent agent;
public DtCrowdAgent agent;
public RcVec3f optStart = new RcVec3f();
public RcVec3f optEnd = new RcVec3f();
public ObstacleAvoidanceDebugData vod;
public DtObstacleAvoidanceDebugData vod;
}
}

View File

@ -23,9 +23,9 @@ using DotRecast.Core;
namespace DotRecast.Detour.Crowd.Tracking
{
using static DotRecast.Core.RcMath;
using static RcMath;
public class ObstacleAvoidanceDebugData
public class DtObstacleAvoidanceDebugData
{
private int m_nsamples;
private int m_maxSamples;
@ -37,7 +37,7 @@ namespace DotRecast.Detour.Crowd.Tracking
private float[] m_spen;
private float[] m_tpen;
public ObstacleAvoidanceDebugData(int maxSamples)
public DtObstacleAvoidanceDebugData(int maxSamples)
{
m_maxSamples = maxSamples;
m_vel = new float[3 * m_maxSamples];

View File

@ -36,10 +36,10 @@ namespace DotRecast.Detour.Dynamic
private readonly RecastBuilder builder;
private readonly Dictionary<long, DynamicTile> _tiles = new Dictionary<long, DynamicTile>();
private readonly Telemetry telemetry;
private readonly NavMeshParams navMeshParams;
private readonly DtNavMeshParams navMeshParams;
private readonly BlockingCollection<IUpdateQueueItem> updateQueue = new BlockingCollection<IUpdateQueueItem>();
private readonly RcAtomicLong currentColliderId = new RcAtomicLong(0);
private NavMesh _navMesh;
private DtNavMesh _navMesh;
private bool dirty = true;
public DynamicNavMesh(VoxelFile voxelFile)
@ -58,7 +58,7 @@ namespace DotRecast.Detour.Dynamic
config.detailSampleDistance = voxelFile.detailSampleDistance;
config.detailSampleMaxError = voxelFile.detailSampleMaxError;
builder = new RecastBuilder();
navMeshParams = new NavMeshParams();
navMeshParams = new DtNavMeshParams();
navMeshParams.orig.x = voxelFile.bounds[0];
navMeshParams.orig.y = voxelFile.bounds[1];
navMeshParams.orig.z = voxelFile.bounds[2];
@ -75,7 +75,7 @@ namespace DotRecast.Detour.Dynamic
telemetry = new Telemetry();
}
public NavMesh NavMesh()
public DtNavMesh NavMesh()
{
return _navMesh;
}
@ -216,7 +216,7 @@ namespace DotRecast.Detour.Dynamic
private void Rebuild(DynamicTile tile)
{
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
option.walkableHeight = config.walkableHeight;
dirty = dirty | tile.Build(builder, config, telemetry);
}
@ -225,7 +225,7 @@ namespace DotRecast.Detour.Dynamic
{
if (dirty)
{
NavMesh navMesh = new NavMesh(navMeshParams, MAX_VERTS_PER_POLY);
DtNavMesh navMesh = new DtNavMesh(navMeshParams, MAX_VERTS_PER_POLY);
foreach (var t in _tiles.Values)
t.AddTo(navMesh);

View File

@ -32,7 +32,7 @@ namespace DotRecast.Detour.Dynamic
public readonly VoxelTile voxelTile;
public DynamicTileCheckpoint checkpoint;
public RecastBuilderResult recastResult;
MeshData meshData;
DtMeshData meshData;
private readonly ConcurrentDictionary<long, ICollider> colliders = new ConcurrentDictionary<long, ICollider>();
private bool dirty = true;
private long id;
@ -48,7 +48,7 @@ namespace DotRecast.Detour.Dynamic
{
RcHeightfield heightfield = BuildHeightfield(config, telemetry);
RecastBuilderResult r = BuildRecast(builder, config, voxelTile, heightfield, telemetry);
NavMeshDataCreateParams option = NavMeshCreateParams(voxelTile.tileX, voxelTile.tileZ, voxelTile.cellSize,
DtNavMeshCreateParams option = NavMeshCreateParams(voxelTile.tileX, voxelTile.tileZ, voxelTile.cellSize,
voxelTile.cellHeight, config, r);
meshData = NavMeshBuilder.CreateNavMeshData(option);
return true;
@ -116,12 +116,12 @@ namespace DotRecast.Detour.Dynamic
}
}
private NavMeshDataCreateParams NavMeshCreateParams(int tilex, int tileZ, float cellSize, float cellHeight,
private DtNavMeshCreateParams NavMeshCreateParams(int tilex, int tileZ, float cellSize, float cellHeight,
DynamicNavMeshConfig config, RecastBuilderResult rcResult)
{
RcPolyMesh m_pmesh = rcResult.GetMesh();
RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
for (int i = 0; i < m_pmesh.npolys; ++i)
{
m_pmesh.flags[i] = 1;
@ -164,7 +164,7 @@ namespace DotRecast.Detour.Dynamic
return option;
}
public void AddTo(NavMesh navMesh)
public void AddTo(DtNavMesh navMesh)
{
if (meshData != null)
{

View File

@ -23,15 +23,15 @@ namespace DotRecast.Detour.Extras
{
public class BVTreeBuilder
{
public void Build(MeshData data)
public void Build(DtMeshData data)
{
data.bvTree = new BVNode[data.header.polyCount * 2];
data.bvTree = new DtBVNode[data.header.polyCount * 2];
data.header.bvNodeCount = data.bvTree.Length == 0
? 0
: CreateBVTree(data, data.bvTree, data.header.bvQuantFactor);
}
private static int CreateBVTree(MeshData data, BVNode[] nodes, float quantFactor)
private static int CreateBVTree(DtMeshData data, DtBVNode[] nodes, float quantFactor)
{
BVItem[] items = new BVItem[data.header.polyCount];
for (int i = 0; i < data.header.polyCount; i++)

View File

@ -7,17 +7,17 @@ namespace DotRecast.Detour.Extras.Jumplink
{
class NavMeshGroundSampler : AbstractGroundSampler
{
private readonly IQueryFilter filter = new NoOpFilter();
private readonly IDtQueryFilter filter = new DtQueryNoOpFilter();
public override void Sample(JumpLinkBuilderConfig acfg, RecastBuilderResult result, EdgeSampler es)
{
NavMeshQuery navMeshQuery = CreateNavMesh(result, acfg.agentRadius, acfg.agentHeight, acfg.agentClimb);
DtNavMeshQuery navMeshQuery = CreateNavMesh(result, acfg.agentRadius, acfg.agentHeight, acfg.agentClimb);
SampleGround(acfg, es, (pt, h) => GetNavMeshHeight(navMeshQuery, pt, acfg.cellSize, h));
}
private NavMeshQuery CreateNavMesh(RecastBuilderResult r, float agentRadius, float agentHeight, float agentClimb)
private DtNavMeshQuery CreateNavMesh(RecastBuilderResult r, float agentRadius, float agentHeight, float agentClimb)
{
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
option.verts = r.GetMesh().verts;
option.vertCount = r.GetMesh().nverts;
option.polys = r.GetMesh().polys;
@ -38,11 +38,11 @@ namespace DotRecast.Detour.Extras.Jumplink
option.cs = r.GetMesh().cs;
option.ch = r.GetMesh().ch;
option.buildBvTree = true;
return new NavMeshQuery(new NavMesh(NavMeshBuilder.CreateNavMeshData(option), option.nvp, 0));
return new DtNavMeshQuery(new DtNavMesh(NavMeshBuilder.CreateNavMeshData(option), option.nvp, 0));
}
private Tuple<bool, float> GetNavMeshHeight(NavMeshQuery navMeshQuery, RcVec3f pt, float cs, float heightRange)
private Tuple<bool, float> GetNavMeshHeight(DtNavMeshQuery navMeshQuery, RcVec3f pt, float cs, float heightRange)
{
RcVec3f halfExtents = new RcVec3f { x = cs, y = heightRange, z = cs };
float maxHeight = pt.y + heightRange;

View File

@ -1,18 +0,0 @@
using DotRecast.Core;
namespace DotRecast.Detour.Extras.Jumplink
{
public class NoOpFilter : IQueryFilter
{
public bool PassFilter(long refs, MeshTile tile, Poly poly)
{
return true;
}
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef,
MeshTile curTile, Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly)
{
return 0;
}
}
}

View File

@ -2,16 +2,16 @@
namespace DotRecast.Detour.Extras.Jumplink
{
public class PolyQueryInvoker : IPolyQuery
public class PolyQueryInvoker : IDtPolyQuery
{
public readonly Action<MeshTile, Poly, long> _callback;
public readonly Action<DtMeshTile, DtPoly, long> _callback;
public PolyQueryInvoker(Action<MeshTile, Poly, long> callback)
public PolyQueryInvoker(Action<DtMeshTile, DtPoly, long> callback)
{
_callback = callback;
}
public void Process(MeshTile tile, Poly poly, long refs)
public void Process(DtMeshTile tile, DtPoly poly, long refs)
{
_callback?.Invoke(tile, poly, refs);
}

View File

@ -22,14 +22,14 @@ namespace DotRecast.Detour.Extras
{
public class ObjExporter
{
public void Export(NavMesh mesh)
public void Export(DtNavMesh mesh)
{
string filename = Path.Combine(Directory.GetCurrentDirectory(), "Demo", "astar.obj");
using var fs = new FileStream(filename, FileMode.CreateNew);
using var fw = new StreamWriter(fs);
for (int i = 0; i < mesh.GetTileCount(); i++)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile != null)
{
for (int v = 0; v < tile.data.header.vertCount; v++)
@ -43,13 +43,13 @@ namespace DotRecast.Detour.Extras
int vertexOffset = 1;
for (int i = 0; i < mesh.GetTileCount(); i++)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile != null)
{
for (int p = 0; p < tile.data.header.polyCount; p++)
{
fw.Write("f ");
Poly poly = tile.data.polys[p];
DtPoly poly = tile.data.polys[p];
for (int v = 0; v < poly.vertCount; v++)
{
fw.Write(poly.verts[v] + vertexOffset + " ");

View File

@ -23,7 +23,7 @@ namespace DotRecast.Detour.Extras
/**
* Find edge shared by 2 polygons within the same tile
*/
public static int FindEdge(Poly node, Poly neighbour, MeshData tile, MeshData neighbourTile)
public static int FindEdge(DtPoly node, DtPoly neighbour, DtMeshData tile, DtMeshData neighbourTile)
{
// Compare indices first assuming there are no duplicate vertices
for (int i = 0; i < node.vertCount; i++)
@ -76,7 +76,7 @@ namespace DotRecast.Detour.Extras
/**
* Find edge closest to the given coordinate
*/
public static int FindEdge(Poly node, MeshData tile, float value, int comp)
public static int FindEdge(DtPoly node, DtMeshData tile, float value, int comp)
{
float error = float.MaxValue;
int edge = 0;

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
public void Build(GraphMeshData graphData)
{
foreach (MeshData d in graphData.tiles)
foreach (DtMeshData d in graphData.tiles)
{
builder.Build(d);
}

View File

@ -22,9 +22,9 @@ namespace DotRecast.Detour.Extras.Unity.Astar
{
public readonly int tileXCount;
public readonly int tileZCount;
public readonly MeshData[] tiles;
public readonly DtMeshData[] tiles;
public GraphMeshData(int tileXCount, int tileZCount, MeshData[] tiles)
public GraphMeshData(int tileXCount, int tileZCount, DtMeshData[] tiles)
{
this.tileXCount = tileXCount;
this.tileZCount = tileZCount;
@ -34,7 +34,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
public int CountNodes()
{
int polyCount = 0;
foreach (MeshData t in tiles)
foreach (DtMeshData t in tiles)
{
polyCount += t.header.polyCount;
}
@ -42,10 +42,10 @@ namespace DotRecast.Detour.Extras.Unity.Astar
return polyCount;
}
public Poly GetNode(int node)
public DtPoly GetNode(int node)
{
int index = 0;
foreach (MeshData t in tiles)
foreach (DtMeshData t in tiles)
{
if (node - index >= 0 && node - index < t.header.polyCount)
{
@ -58,10 +58,10 @@ namespace DotRecast.Detour.Extras.Unity.Astar
return null;
}
public MeshData GetTile(int node)
public DtMeshData GetTile(int node)
{
int index = 0;
foreach (MeshData t in tiles)
foreach (DtMeshData t in tiles)
{
if (node - index >= 0 && node - index < t.header.polyCount)
{

View File

@ -37,7 +37,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
}
int tileZCount = buffer.GetInt();
MeshData[] tiles = new MeshData[tileXCount * tileZCount];
DtMeshData[] tiles = new DtMeshData[tileXCount * tileZCount];
for (int z = 0; z < tileZCount; z++)
{
for (int x = 0; x < tileXCount; x++)
@ -50,7 +50,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
throw new ArgumentException("Inconsistent tile positions");
}
tiles[tileIndex] = new MeshData();
tiles[tileIndex] = new DtMeshData();
int width = buffer.GetInt();
int depth = buffer.GetInt();
@ -75,8 +75,8 @@ namespace DotRecast.Detour.Extras.Unity.Astar
}
int nodeCount = buffer.GetInt();
Poly[] nodes = new Poly[nodeCount];
PolyDetail[] detailNodes = new PolyDetail[nodeCount];
DtPoly[] nodes = new DtPoly[nodeCount];
DtPolyDetail[] detailNodes = new DtPolyDetail[nodeCount];
float[] detailVerts = new float[0];
int[] detailTris = new int[4 * nodeCount];
int vertMask = GetVertMask(vertsCount);
@ -84,7 +84,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
float ymax = float.NegativeInfinity;
for (int i = 0; i < nodes.Length; i++)
{
nodes[i] = new Poly(i, maxVertPerPoly);
nodes[i] = new DtPoly(i, maxVertPerPoly);
nodes[i].vertCount = 3;
// XXX: What can we do with the penalty?
int penalty = buffer.GetInt();
@ -98,7 +98,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
ymax = Math.Max(ymax, verts[nodes[i].verts[0] * 3 + 1]);
ymax = Math.Max(ymax, verts[nodes[i].verts[1] * 3 + 1]);
ymax = Math.Max(ymax, verts[nodes[i].verts[2] * 3 + 1]);
detailNodes[i] = new PolyDetail();
detailNodes[i] = new DtPolyDetail();
detailNodes[i].vertBase = 0;
detailNodes[i].vertCount = 0;
detailNodes[i].triBase = i;
@ -116,9 +116,9 @@ namespace DotRecast.Detour.Extras.Unity.Astar
tiles[tileIndex].detailMeshes = detailNodes;
tiles[tileIndex].detailVerts = detailVerts;
tiles[tileIndex].detailTris = detailTris;
MeshHeader header = new MeshHeader();
header.magic = MeshHeader.DT_NAVMESH_MAGIC;
header.version = MeshHeader.DT_NAVMESH_VERSION;
DtMeshHeader header = new DtMeshHeader();
header.magic = DtMeshHeader.DT_NAVMESH_MAGIC;
header.version = DtMeshHeader.DT_NAVMESH_VERSION;
header.x = x;
header.y = z;
header.polyCount = nodeCount;

View File

@ -29,25 +29,25 @@ namespace DotRecast.Detour.Extras.Unity.Astar
for (int n = 0; n < connections.Count; n++)
{
int[] nodeConnections = connections[n];
MeshData tile = graphData.GetTile(n);
Poly node = graphData.GetNode(n);
DtMeshData tile = graphData.GetTile(n);
DtPoly node = graphData.GetNode(n);
foreach (int connection in nodeConnections)
{
MeshData neighbourTile = graphData.GetTile(connection - nodeOffset);
DtMeshData neighbourTile = graphData.GetTile(connection - nodeOffset);
if (neighbourTile != tile)
{
BuildExternalLink(tile, node, neighbourTile);
}
else
{
Poly neighbour = graphData.GetNode(connection - nodeOffset);
DtPoly neighbour = graphData.GetNode(connection - nodeOffset);
BuildInternalLink(tile, node, neighbourTile, neighbour);
}
}
}
}
private void BuildInternalLink(MeshData tile, Poly node, MeshData neighbourTile, Poly neighbour)
private void BuildInternalLink(DtMeshData tile, DtPoly node, DtMeshData neighbourTile, DtPoly neighbour)
{
int edge = PolyUtils.FindEdge(node, neighbour, tile, neighbourTile);
if (edge >= 0)
@ -61,23 +61,23 @@ namespace DotRecast.Detour.Extras.Unity.Astar
}
// In case of external link to other tiles we must find the direction
private void BuildExternalLink(MeshData tile, Poly node, MeshData neighbourTile)
private void BuildExternalLink(DtMeshData tile, DtPoly node, DtMeshData neighbourTile)
{
if (neighbourTile.header.bmin.x > tile.header.bmin.x)
{
node.neis[PolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.x, 0)] = NavMesh.DT_EXT_LINK;
node.neis[PolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.x, 0)] = DtNavMesh.DT_EXT_LINK;
}
else if (neighbourTile.header.bmin.x < tile.header.bmin.x)
{
node.neis[PolyUtils.FindEdge(node, tile, tile.header.bmin.x, 0)] = NavMesh.DT_EXT_LINK | 4;
node.neis[PolyUtils.FindEdge(node, tile, tile.header.bmin.x, 0)] = DtNavMesh.DT_EXT_LINK | 4;
}
else if (neighbourTile.header.bmin.z > tile.header.bmin.z)
{
node.neis[PolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.z, 2)] = NavMesh.DT_EXT_LINK | 2;
node.neis[PolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.z, 2)] = DtNavMesh.DT_EXT_LINK | 2;
}
else
{
node.neis[PolyUtils.FindEdge(node, tile, tile.header.bmin.z, 2)] = NavMesh.DT_EXT_LINK | 6;
node.neis[PolyUtils.FindEdge(node, tile, tile.header.bmin.z, 2)] = DtNavMesh.DT_EXT_LINK | 6;
}
}
}

View File

@ -28,23 +28,23 @@ namespace DotRecast.Detour.Extras.Unity.Astar
{
foreach (NodeLink2 l in links)
{
MeshData startTile = graphData.GetTile(l.startNode - nodeOffset);
Poly startNode = graphData.GetNode(l.startNode - nodeOffset);
MeshData endTile = graphData.GetTile(l.endNode - nodeOffset);
Poly endNode = graphData.GetNode(l.endNode - nodeOffset);
DtMeshData startTile = graphData.GetTile(l.startNode - nodeOffset);
DtPoly startNode = graphData.GetNode(l.startNode - nodeOffset);
DtMeshData endTile = graphData.GetTile(l.endNode - nodeOffset);
DtPoly endNode = graphData.GetNode(l.endNode - nodeOffset);
if (startNode != null && endNode != null)
{
// FIXME: Optimise
startTile.polys = RcArrayUtils.CopyOf(startTile.polys, startTile.polys.Length + 1);
int poly = startTile.header.polyCount;
startTile.polys[poly] = new Poly(poly, 2);
startTile.polys[poly] = new DtPoly(poly, 2);
startTile.polys[poly].verts[0] = startTile.header.vertCount;
startTile.polys[poly].verts[1] = startTile.header.vertCount + 1;
startTile.polys[poly].SetType(Poly.DT_POLYTYPE_OFFMESH_CONNECTION);
startTile.polys[poly].SetType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION);
startTile.verts = RcArrayUtils.CopyOf(startTile.verts, startTile.verts.Length + 6);
startTile.header.polyCount++;
startTile.header.vertCount += 2;
OffMeshConnection connection = new OffMeshConnection();
DtOffMeshConnection connection = new DtOffMeshConnection();
connection.poly = poly;
connection.pos = new float[]
{
@ -58,7 +58,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
connection.userId = (int)l.linkID;
if (startTile.offMeshCons == null)
{
startTile.offMeshCons = new OffMeshConnection[1];
startTile.offMeshCons = new DtOffMeshConnection[1];
}
else
{

View File

@ -33,12 +33,12 @@ namespace DotRecast.Detour.Extras.Unity.Astar
private readonly LinkBuilder linkCreator = new LinkBuilder();
private readonly OffMeshLinkCreator offMeshLinkCreator = new OffMeshLinkCreator();
public NavMesh[] Load(FileStream zipFile)
public DtNavMesh[] Load(FileStream zipFile)
{
GraphData graphData = reader.Read(zipFile);
Meta meta = graphData.meta;
NodeLink2[] nodeLinks2 = graphData.nodeLinks2;
NavMesh[] meshes = new NavMesh[meta.graphs];
DtNavMesh[] meshes = new DtNavMesh[meta.graphs];
int nodeOffset = 0;
for (int graphIndex = 0; graphIndex < meta.graphs; graphIndex++)
{
@ -58,7 +58,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
linkCreator.Build(nodeOffset, graphMeshData, connections);
// Finally, process all the off-mesh links that can be actually converted to detour data
offMeshLinkCreator.Build(graphMeshData, nodeLinks2, nodeOffset);
NavMeshParams option = new NavMeshParams();
DtNavMeshParams option = new DtNavMeshParams();
option.maxTiles = graphMeshData.tiles.Length;
option.maxPolys = 32768;
option.tileWidth = graphMeta.tileSizeX * graphMeta.cellSize;
@ -66,8 +66,8 @@ namespace DotRecast.Detour.Extras.Unity.Astar
option.orig.x = -0.5f * graphMeta.forcedBoundsSize.x + graphMeta.forcedBoundsCenter.x;
option.orig.y = -0.5f * graphMeta.forcedBoundsSize.y + graphMeta.forcedBoundsCenter.y;
option.orig.z = -0.5f * graphMeta.forcedBoundsSize.z + graphMeta.forcedBoundsCenter.z;
NavMesh mesh = new NavMesh(option, 3);
foreach (MeshData t in graphMeshData.tiles)
DtNavMesh mesh = new DtNavMesh(option, 3);
foreach (DtMeshData t in graphMeshData.tiles)
{
mesh.AddTile(t, 0, 0);
}

View File

@ -22,6 +22,6 @@ namespace DotRecast.Detour.TileCache
{
public interface ITileCacheMeshProcess
{
void Process(NavMeshDataCreateParams option);
void Process(DtNavMeshCreateParams option);
}
}

View File

@ -63,7 +63,7 @@ namespace DotRecast.Detour.TileCache.Io
header.numTiles = bb.GetInt();
header.meshParams = paramReader.Read(bb);
header.cacheParams = ReadCacheParams(bb, cCompatibility);
NavMesh mesh = new NavMesh(header.meshParams, maxVertPerPoly);
DtNavMesh mesh = new DtNavMesh(header.meshParams, maxVertPerPoly);
ITileCacheCompressor compressor = TileCacheCompressorFactory.Get(cCompatibility);
TileCache tc = new TileCache(header.cacheParams, new TileCacheStorageParams(bb.Order(), cCompatibility), mesh,
compressor, meshProcessor);

View File

@ -29,7 +29,7 @@ namespace DotRecast.Detour.TileCache.Io
public int magic;
public int version;
public int numTiles;
public NavMeshParams meshParams = new NavMeshParams();
public DtNavMeshParams meshParams = new DtNavMeshParams();
public TileCacheParams cacheParams = new TileCacheParams();
}
}

View File

@ -49,7 +49,7 @@ namespace DotRecast.Detour.TileCache
private readonly int m_tileBits;
/// < Number of tile bits in the tile ID.
private readonly NavMesh m_navmesh;
private readonly DtNavMesh m_navmesh;
private readonly TileCacheParams m_params;
private readonly TileCacheStorageParams m_storageParams;
@ -111,7 +111,7 @@ namespace DotRecast.Detour.TileCache
return (int)(refs & tileMask);
}
public TileCache(TileCacheParams option, TileCacheStorageParams storageParams, NavMesh navmesh,
public TileCache(TileCacheParams option, TileCacheStorageParams storageParams, DtNavMesh navmesh,
ITileCacheCompressor tcomp, ITileCacheMeshProcess tmprocs)
{
m_params = option;
@ -172,7 +172,7 @@ namespace DotRecast.Detour.TileCache
List<long> tiles = new List<long>();
// Find tile based on hash.
int h = NavMesh.ComputeTileHash(tx, ty, m_tileLutMask);
int h = DtNavMesh.ComputeTileHash(tx, ty, m_tileLutMask);
CompressedTile tile = m_posLookup[h];
while (tile != null)
{
@ -190,7 +190,7 @@ namespace DotRecast.Detour.TileCache
CompressedTile GetTileAt(int tx, int ty, int tlayer)
{
// Find tile based on hash.
int h = NavMesh.ComputeTileHash(tx, ty, m_tileLutMask);
int h = DtNavMesh.ComputeTileHash(tx, ty, m_tileLutMask);
CompressedTile tile = m_posLookup[h];
while (tile != null)
{
@ -278,7 +278,7 @@ namespace DotRecast.Detour.TileCache
}
// Insert tile into the position lut.
int h = NavMesh.ComputeTileHash(header.tx, header.ty, m_tileLutMask);
int h = DtNavMesh.ComputeTileHash(header.tx, header.ty, m_tileLutMask);
tile.next = m_posLookup[h];
m_posLookup[h] = tile;
@ -317,7 +317,7 @@ namespace DotRecast.Detour.TileCache
}
// Remove tile from hash lookup.
int h = NavMesh.ComputeTileHash(tile.header.tx, tile.header.ty, m_tileLutMask);
int h = DtNavMesh.ComputeTileHash(tile.header.tx, tile.header.ty, m_tileLutMask);
CompressedTile prev = null;
CompressedTile cur = m_posLookup[h];
while (cur != null)
@ -641,7 +641,7 @@ namespace DotRecast.Detour.TileCache
return;
}
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
option.verts = polyMesh.verts;
option.vertCount = polyMesh.nverts;
option.polys = polyMesh.polys;
@ -665,7 +665,7 @@ namespace DotRecast.Detour.TileCache
m_tmproc.Process(option);
}
MeshData meshData = NavMeshBuilder.CreateNavMeshData(option);
DtMeshData meshData = NavMeshBuilder.CreateNavMeshData(option);
// Remove existing tile.
m_navmesh.RemoveTile(m_navmesh.GetTileRefAt(tile.header.tx, tile.header.ty, tile.header.tlayer));
// Add new tile, or leave the location empty. if (navData) { // Let the
@ -741,7 +741,7 @@ namespace DotRecast.Detour.TileCache
return m_tiles[i];
}
public NavMesh GetNavMesh()
public DtNavMesh GetNavMesh()
{
return m_navmesh;
}

View File

@ -22,9 +22,9 @@ namespace DotRecast.Detour
{
public class DetourBuilder
{
public MeshData Build(NavMeshDataCreateParams option, int tileX, int tileY)
public DtMeshData Build(DtNavMeshCreateParams option, int tileX, int tileY)
{
MeshData data = NavMeshBuilder.CreateNavMeshData(option);
DtMeshData data = NavMeshBuilder.CreateNavMeshData(option);
if (data != null)
{
data.header.x = tileX;

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour
* @note This structure is rarely if ever used by the end user.
* @see MeshTile
*/
public class BVNode
public class DtBVNode
{
/** Minimum bounds of the node's AABB. [(x, y, z)] */
public int[] bmin = new int[3];

View File

@ -4,16 +4,16 @@ using DotRecast.Detour.QueryResults;
namespace DotRecast.Detour
{
public class FindNearestPolyQuery : IPolyQuery
public class DtFindNearestPolyQuery : IDtPolyQuery
{
private readonly NavMeshQuery query;
private readonly DtNavMeshQuery query;
private readonly RcVec3f center;
private long nearestRef;
private RcVec3f nearestPt;
private bool overPoly;
private float nearestDistanceSqr;
public FindNearestPolyQuery(NavMeshQuery query, RcVec3f center)
public DtFindNearestPolyQuery(DtNavMeshQuery query, RcVec3f center)
{
this.query = query;
this.center = center;
@ -21,7 +21,7 @@ namespace DotRecast.Detour
nearestPt = center;
}
public void Process(MeshTile tile, Poly poly, long refs)
public void Process(DtMeshTile tile, DtPoly poly, long refs)
{
// Find nearest polygon amongst the nearby polygons.
Result<ClosestPointOnPolyResult> closest = query.ClosestPointOnPoly(refs, center);

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour
* @note This structure is rarely if ever used by the end user.
* @see MeshTile
*/
public class Link
public class DtLink
{
/** Neighbour reference. (The neighbor that is linked to.) */
public long refs;

View File

@ -20,19 +20,19 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour
{
public class MeshData
public class DtMeshData
{
/** The tile header. */
public MeshHeader header;
public DtMeshHeader header;
/** The tile vertices. [Size: MeshHeader::vertCount] */
public float[] verts;
/** The tile polygons. [Size: MeshHeader::polyCount] */
public Poly[] polys;
public DtPoly[] polys;
/** The tile's detail sub-meshes. [Size: MeshHeader::detailMeshCount] */
public PolyDetail[] detailMeshes;
public DtPolyDetail[] detailMeshes;
/** The detail mesh's unique vertices. [(x, y, z) * MeshHeader::detailVertCount] */
public float[] detailVerts;
@ -46,9 +46,9 @@ namespace DotRecast.Detour
/**
* The tile bounding volume nodes. [Size: MeshHeader::bvNodeCount] (Will be null if bounding volumes are disabled.)
*/
public BVNode[] bvTree;
public DtBVNode[] bvTree;
/** The tile off-mesh connections. [Size: MeshHeader::offMeshConCount] */
public OffMeshConnection[] offMeshCons;
public DtOffMeshConnection[] offMeshCons;
}
}

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
/** Provides high level information related to a dtMeshTile object. */
public class MeshHeader
public class DtMeshHeader
{
/** A magic number used to detect compatibility of navigation tile data. */
public const int DT_NAVMESH_MAGIC = 'D' << 24 | 'N' << 16 | 'A' << 8 | 'V';

View File

@ -25,7 +25,7 @@ namespace DotRecast.Detour
/**
* Defines a navigation mesh tile.
*/
public class MeshTile
public class DtMeshTile
{
public readonly int index;
@ -33,20 +33,20 @@ namespace DotRecast.Detour
public int salt;
/** The tile data. */
public MeshData data;
public DtMeshData data;
public int[] polyLinks;
/** The tile links. */
public readonly List<Link> links = new List<Link>();
public readonly List<DtLink> links = new List<DtLink>();
/** Index to the next free link. */
public int linksFreeList = NavMesh.DT_NULL_LINK; // FIXME: Remove
public int linksFreeList = DtNavMesh.DT_NULL_LINK; // FIXME: Remove
/** Tile flags. (See: #dtTileFlags) */
public int flags;
public MeshTile(int index)
public DtMeshTile(int index)
{
this.index = index;
}

View File

@ -26,9 +26,9 @@ using DotRecast.Detour.QueryResults;
namespace DotRecast.Detour
{
using static DotRecast.Core.RcMath;
using static RcMath;
public class NavMesh
public class DtNavMesh
{
public const int DT_SALT_BITS = 16;
public const int DT_TILE_BITS = 28;
@ -53,7 +53,7 @@ namespace DotRecast.Detour
/// The limit is given as a multiple of the character radius
public const float DT_RAY_CAST_LIMIT_PROPORTIONS = 50.0f;
private readonly NavMeshParams m_params;
private readonly DtNavMeshParams m_params;
/// < Current initialization params. TODO: do not store this info twice.
private readonly RcVec3f m_orig;
@ -69,10 +69,10 @@ namespace DotRecast.Detour
private readonly int m_tileLutMask;
/// < Tile hash lookup mask.
private readonly Dictionary<int, List<MeshTile>> posLookup = new Dictionary<int, List<MeshTile>>();
private readonly Dictionary<int, List<DtMeshTile>> posLookup = new Dictionary<int, List<DtMeshTile>>();
private readonly LinkedList<MeshTile> availableTiles = new LinkedList<MeshTile>();
private readonly MeshTile[] m_tiles;
private readonly LinkedList<DtMeshTile> availableTiles = new LinkedList<DtMeshTile>();
private readonly DtMeshTile[] m_tiles;
/// < List of tiles.
/** The maximum number of vertices per navigation polygon. */
@ -93,7 +93,7 @@ namespace DotRecast.Detour
/**
* Returns tile in the tile array.
*/
public MeshTile GetTile(int i)
public DtMeshTile GetTile(int i)
{
return m_tiles[i];
}
@ -105,7 +105,7 @@ namespace DotRecast.Detour
* The tile.
* @return The polygon reference for the base polygon in the specified tile.
*/
public long GetPolyRefBase(MeshTile tile)
public long GetPolyRefBase(DtMeshTile tile)
{
if (tile == null)
{
@ -177,11 +177,11 @@ namespace DotRecast.Detour
return (int)(refs & polyMask);
}
private int AllocLink(MeshTile tile)
private int AllocLink(DtMeshTile tile)
{
if (tile.linksFreeList == DT_NULL_LINK)
{
Link link = new Link();
DtLink link = new DtLink();
link.next = DT_NULL_LINK;
tile.links.Add(link);
return tile.links.Count - 1;
@ -192,7 +192,7 @@ namespace DotRecast.Detour
return linkIdx;
}
private void FreeLink(MeshTile tile, int link)
private void FreeLink(DtMeshTile tile, int link)
{
tile.links[link].next = tile.linksFreeList;
tile.linksFreeList = link;
@ -211,27 +211,27 @@ namespace DotRecast.Detour
ty = (int)Math.Floor((pos.z - m_orig.z) / m_tileHeight);
}
public Result<Tuple<MeshTile, Poly>> GetTileAndPolyByRef(long refs)
public Result<Tuple<DtMeshTile, DtPoly>> GetTileAndPolyByRef(long refs)
{
if (refs == 0)
{
return Results.InvalidParam<Tuple<MeshTile, Poly>>("ref = 0");
return Results.InvalidParam<Tuple<DtMeshTile, DtPoly>>("ref = 0");
}
DecodePolyId(refs, out var salt, out var it, out var ip);
if (it >= m_maxTiles)
{
return Results.InvalidParam<Tuple<MeshTile, Poly>>("tile > m_maxTiles");
return Results.InvalidParam<Tuple<DtMeshTile, DtPoly>>("tile > m_maxTiles");
}
if (m_tiles[it].salt != salt || m_tiles[it].data.header == null)
{
return Results.InvalidParam<Tuple<MeshTile, Poly>>("Invalid salt or header");
return Results.InvalidParam<Tuple<DtMeshTile, DtPoly>>("Invalid salt or header");
}
if (ip >= m_tiles[it].data.header.polyCount)
{
return Results.InvalidParam<Tuple<MeshTile, Poly>>("poly > polyCount");
return Results.InvalidParam<Tuple<DtMeshTile, DtPoly>>("poly > polyCount");
}
return Results.Success(Tuple.Create(m_tiles[it], m_tiles[it].data.polys[ip]));
@ -243,7 +243,7 @@ namespace DotRecast.Detour
/// reference is valid. This function is faster than #getTileAndPolyByRef,
/// but
/// it does not validate the reference.
public Tuple<MeshTile, Poly> GetTileAndPolyByRefUnsafe(long refs)
public Tuple<DtMeshTile, DtPoly> GetTileAndPolyByRefUnsafe(long refs)
{
DecodePolyId(refs, out var salt, out var it, out var ip);
return Tuple.Create(m_tiles[it], m_tiles[it].data.polys[ip]);
@ -275,18 +275,18 @@ namespace DotRecast.Detour
return true;
}
public NavMeshParams GetParams()
public DtNavMeshParams GetParams()
{
return m_params;
}
public NavMesh(MeshData data, int maxVertsPerPoly, int flags)
public DtNavMesh(DtMeshData data, int maxVertsPerPoly, int flags)
: this(GetNavMeshParams(data), maxVertsPerPoly)
{
AddTile(data, flags, 0);
}
public NavMesh(NavMeshParams option, int maxVertsPerPoly)
public DtNavMesh(DtNavMeshParams option, int maxVertsPerPoly)
{
m_params = option;
m_orig = option.orig;
@ -296,18 +296,18 @@ namespace DotRecast.Detour
m_maxTiles = option.maxTiles;
m_maxVertPerPoly = maxVertsPerPoly;
m_tileLutMask = Math.Max(1, DetourCommon.NextPow2(option.maxTiles)) - 1;
m_tiles = new MeshTile[m_maxTiles];
m_tiles = new DtMeshTile[m_maxTiles];
for (int i = 0; i < m_maxTiles; i++)
{
m_tiles[i] = new MeshTile(i);
m_tiles[i] = new DtMeshTile(i);
m_tiles[i].salt = 1;
availableTiles.AddLast(m_tiles[i]);
}
}
private static NavMeshParams GetNavMeshParams(MeshData data)
private static DtNavMeshParams GetNavMeshParams(DtMeshData data)
{
NavMeshParams option = new NavMeshParams();
DtNavMeshParams option = new DtNavMeshParams();
option.orig = data.header.bmin;
option.tileWidth = data.header.bmax.x - data.header.bmin.x;
option.tileHeight = data.header.bmax.z - data.header.bmin.z;
@ -319,7 +319,7 @@ namespace DotRecast.Detour
// TODO: These methods are duplicates from dtNavMeshQuery, but are needed
// for off-mesh connection finding.
List<long> QueryPolygonsInTile(MeshTile tile, RcVec3f qmin, RcVec3f qmax)
List<long> QueryPolygonsInTile(DtMeshTile tile, RcVec3f qmin, RcVec3f qmax)
{
List<long> polys = new List<long>();
if (tile.data.bvTree != null)
@ -351,7 +351,7 @@ namespace DotRecast.Detour
int end = tile.data.header.bvNodeCount;
while (nodeIndex < end)
{
BVNode node = tile.data.bvTree[nodeIndex];
DtBVNode node = tile.data.bvTree[nodeIndex];
bool overlap = DetourCommon.OverlapQuantBounds(bmin, bmax, node.bmin, node.bmax);
bool isLeafNode = node.i >= 0;
@ -380,9 +380,9 @@ namespace DotRecast.Detour
long @base = GetPolyRefBase(tile);
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly p = tile.data.polys[i];
DtPoly p = tile.data.polys[i];
// Do not return off-mesh connection polygons.
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
continue;
}
@ -408,7 +408,7 @@ namespace DotRecast.Detour
}
}
public long UpdateTile(MeshData data, int flags)
public long UpdateTile(DtMeshData data, int flags)
{
long refs = GetTileRefAt(data.header.x, data.header.y, data.header.layer);
refs = RemoveTile(refs);
@ -441,10 +441,10 @@ namespace DotRecast.Detour
/// removed from this nav mesh.
///
/// @see dtCreateNavMeshData, #removeTile
public long AddTile(MeshData data, int flags, long lastRef)
public long AddTile(DtMeshData data, int flags, long lastRef)
{
// Make sure the data is in right format.
MeshHeader header = data.header;
DtMeshHeader header = data.header;
// Make sure the location is free.
if (GetTileAt(header.x, header.y, header.layer) != null)
@ -453,7 +453,7 @@ namespace DotRecast.Detour
}
// Allocate a tile.
MeshTile tile = null;
DtMeshTile tile = null;
if (lastRef == 0)
{
// Make sure we could allocate a tile.
@ -476,7 +476,7 @@ namespace DotRecast.Detour
}
// Try to find the specific tile id from the free list.
MeshTile target = m_tiles[tileIndex];
DtMeshTile target = m_tiles[tileIndex];
// Remove from freelist
if (!availableTiles.Remove(target))
{
@ -493,7 +493,7 @@ namespace DotRecast.Detour
tile.flags = flags;
tile.links.Clear();
tile.polyLinks = new int[data.polys.Length];
Array.Fill(tile.polyLinks, NavMesh.DT_NULL_LINK);
Array.Fill(tile.polyLinks, DtNavMesh.DT_NULL_LINK);
// Insert tile into the position lut.
GetTileListByPos(header.x, header.y).Add(tile);
@ -514,7 +514,7 @@ namespace DotRecast.Detour
ConnectExtOffMeshLinks(tile, tile, -1);
// Connect with layers in current tile.
List<MeshTile> neis = GetTilesAt(header.x, header.y);
List<DtMeshTile> neis = GetTilesAt(header.x, header.y);
for (int j = 0; j < neis.Count; ++j)
{
if (neis[j] == tile)
@ -567,7 +567,7 @@ namespace DotRecast.Detour
throw new Exception("Invalid tile index");
}
MeshTile tile = m_tiles[tileIndex];
DtMeshTile tile = m_tiles[tileIndex];
if (tile.salt != tileSalt)
{
throw new Exception("Invalid tile salt");
@ -580,8 +580,8 @@ namespace DotRecast.Detour
// Create connections with neighbour tiles.
// Disconnect from other layers in current tile.
List<MeshTile> nneis = GetTilesAt(tile.data.header.x, tile.data.header.y);
foreach (MeshTile j in nneis)
List<DtMeshTile> nneis = GetTilesAt(tile.data.header.x, tile.data.header.y);
foreach (DtMeshTile j in nneis)
{
if (j == tile)
{
@ -595,7 +595,7 @@ namespace DotRecast.Detour
for (int i = 0; i < 8; ++i)
{
nneis = GetNeighbourTilesAt(tile.data.header.x, tile.data.header.y, i);
foreach (MeshTile j in nneis)
foreach (DtMeshTile j in nneis)
{
UnconnectLinks(j, tile);
}
@ -606,7 +606,7 @@ namespace DotRecast.Detour
tile.flags = 0;
tile.links.Clear();
tile.linksFreeList = NavMesh.DT_NULL_LINK;
tile.linksFreeList = DtNavMesh.DT_NULL_LINK;
// Update salt, salt should never be zero.
tile.salt = (tile.salt + 1) & ((1 << DT_SALT_BITS) - 1);
@ -622,7 +622,7 @@ namespace DotRecast.Detour
}
/// Builds internal polygons links for a tile.
void ConnectIntLinks(MeshTile tile)
void ConnectIntLinks(DtMeshTile tile)
{
if (tile == null)
{
@ -633,10 +633,10 @@ namespace DotRecast.Detour
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly poly = tile.data.polys[i];
DtPoly poly = tile.data.polys[i];
tile.polyLinks[poly.index] = DT_NULL_LINK;
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
continue;
}
@ -652,7 +652,7 @@ namespace DotRecast.Detour
}
int idx = AllocLink(tile);
Link link = tile.links[idx];
DtLink link = tile.links[idx];
link.refs = @base | (long)(poly.neis[j] - 1);
link.edge = j;
link.side = 0xff;
@ -664,7 +664,7 @@ namespace DotRecast.Detour
}
}
void UnconnectLinks(MeshTile tile, MeshTile target)
void UnconnectLinks(DtMeshTile tile, DtMeshTile target)
{
if (tile == null || target == null)
{
@ -675,7 +675,7 @@ namespace DotRecast.Detour
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly poly = tile.data.polys[i];
DtPoly poly = tile.data.polys[i];
int j = tile.polyLinks[poly.index];
int pj = DT_NULL_LINK;
while (j != DT_NULL_LINK)
@ -706,7 +706,7 @@ namespace DotRecast.Detour
}
}
void ConnectExtLinks(MeshTile tile, MeshTile target, int side)
void ConnectExtLinks(DtMeshTile tile, DtMeshTile target, int side)
{
if (tile == null)
{
@ -716,7 +716,7 @@ namespace DotRecast.Detour
// Connect border links.
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly poly = tile.data.polys[i];
DtPoly poly = tile.data.polys[i];
// Create new links.
// short m = DT_EXT_LINK | (short)side;
@ -743,7 +743,7 @@ namespace DotRecast.Detour
foreach (Tuple<long, float, float> connectedPoly in connectedPolys)
{
int idx = AllocLink(tile);
Link link = tile.links[idx];
DtLink link = tile.links[idx];
link.refs = connectedPoly.Item1;
link.edge = j;
link.side = dir;
@ -789,7 +789,7 @@ namespace DotRecast.Detour
}
}
void ConnectExtOffMeshLinks(MeshTile tile, MeshTile target, int side)
void ConnectExtOffMeshLinks(DtMeshTile tile, DtMeshTile target, int side)
{
if (tile == null)
{
@ -802,13 +802,13 @@ namespace DotRecast.Detour
for (int i = 0; i < target.data.header.offMeshConCount; ++i)
{
OffMeshConnection targetCon = target.data.offMeshCons[i];
DtOffMeshConnection targetCon = target.data.offMeshCons[i];
if (targetCon.side != oppositeSide)
{
continue;
}
Poly targetPoly = target.data.polys[targetCon.poly];
DtPoly targetPoly = target.data.polys[targetCon.poly];
// Skip off-mesh connections which start location could not be
// connected at all.
if (target.polyLinks[targetPoly.index] == DT_NULL_LINK)
@ -851,7 +851,7 @@ namespace DotRecast.Detour
// Link off-mesh connection to target poly.
int idx = AllocLink(target);
Link link = target.links[idx];
DtLink link = target.links[idx];
link.refs = refs;
link.edge = 1;
link.side = oppositeSide;
@ -865,7 +865,7 @@ namespace DotRecast.Detour
{
int tidx = AllocLink(tile);
int landPolyIdx = DecodePolyIdPoly(refs);
Poly landPoly = tile.data.polys[landPolyIdx];
DtPoly landPoly = tile.data.polys[landPolyIdx];
link = tile.links[tidx];
link.refs = GetPolyRefBase(target) | (long)targetCon.poly;
link.edge = 0xff;
@ -878,7 +878,7 @@ namespace DotRecast.Detour
}
}
private IList<Tuple<long, float, float>> FindConnectingPolys(float[] verts, int va, int vb, MeshTile tile, int side)
private IList<Tuple<long, float, float>> FindConnectingPolys(float[] verts, int va, int vb, DtMeshTile tile, int side)
{
if (tile == null)
{
@ -899,7 +899,7 @@ namespace DotRecast.Detour
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly poly = tile.data.polys[i];
DtPoly poly = tile.data.polys[i];
int nv = poly.vertCount;
for (int j = 0; j < nv; ++j)
{
@ -1035,7 +1035,7 @@ namespace DotRecast.Detour
*
* @param tile
*/
void BaseOffMeshLinks(MeshTile tile)
void BaseOffMeshLinks(DtMeshTile tile)
{
if (tile == null)
{
@ -1047,8 +1047,8 @@ namespace DotRecast.Detour
// Base off-mesh connection start points.
for (int i = 0; i < tile.data.header.offMeshConCount; ++i)
{
OffMeshConnection con = tile.data.offMeshCons[i];
Poly poly = tile.data.polys[con.poly];
DtOffMeshConnection con = tile.data.offMeshCons[i];
DtPoly poly = tile.data.polys[con.poly];
var ext = new RcVec3f()
{
@ -1081,7 +1081,7 @@ namespace DotRecast.Detour
// Link off-mesh connection to target poly.
int idx = AllocLink(tile);
Link link = tile.links[idx];
DtLink link = tile.links[idx];
link.refs = refs;
link.edge = 0;
link.side = 0xff;
@ -1093,7 +1093,7 @@ namespace DotRecast.Detour
// Start end-point is always connect back to off-mesh connection.
int tidx = AllocLink(tile);
int landPolyIdx = DecodePolyIdPoly(refs);
Poly landPoly = tile.data.polys[landPolyIdx];
DtPoly landPoly = tile.data.polys[landPolyIdx];
link = tile.links[tidx];
link.refs = @base | (long)con.poly;
link.edge = 0xff;
@ -1112,7 +1112,7 @@ namespace DotRecast.Detour
* @param pos
* @return
*/
RcVec3f ClosestPointOnDetailEdges(MeshTile tile, Poly poly, RcVec3f pos, bool onlyBoundary)
RcVec3f ClosestPointOnDetailEdges(DtMeshTile tile, DtPoly poly, RcVec3f pos, bool onlyBoundary)
{
int ANY_BOUNDARY_EDGE = (DT_DETAIL_EDGE_BOUNDARY << 0) | (DT_DETAIL_EDGE_BOUNDARY << 2)
| (DT_DETAIL_EDGE_BOUNDARY << 4);
@ -1124,7 +1124,7 @@ namespace DotRecast.Detour
if (tile.data.detailMeshes != null)
{
PolyDetail pd = tile.data.detailMeshes[ip];
DtPolyDetail pd = tile.data.detailMeshes[ip];
for (int i = 0; i < pd.triCount; i++)
{
int ti = (pd.triBase + i) * 4;
@ -1207,11 +1207,11 @@ namespace DotRecast.Detour
return RcVec3f.Lerp(pmin, pmax, tmin);
}
public float? GetPolyHeight(MeshTile tile, Poly poly, RcVec3f pos)
public float? GetPolyHeight(DtMeshTile tile, DtPoly poly, RcVec3f pos)
{
// Off-mesh connections do not have detail polys and getting height
// over them does not make sense.
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
return null;
}
@ -1233,7 +1233,7 @@ namespace DotRecast.Detour
// Find height at the location.
if (tile.data.detailMeshes != null)
{
PolyDetail pd = tile.data.detailMeshes[ip];
DtPolyDetail pd = tile.data.detailMeshes[ip];
for (int j = 0; j < pd.triCount; ++j)
{
int t = (pd.triBase + j) * 4;
@ -1302,9 +1302,9 @@ namespace DotRecast.Detour
public ClosestPointOnPolyResult ClosestPointOnPoly(long refs, RcVec3f pos)
{
Tuple<MeshTile, Poly> tileAndPoly = GetTileAndPolyByRefUnsafe(refs);
MeshTile tile = tileAndPoly.Item1;
Poly poly = tileAndPoly.Item2;
Tuple<DtMeshTile, DtPoly> tileAndPoly = GetTileAndPolyByRefUnsafe(refs);
DtMeshTile tile = tileAndPoly.Item1;
DtPoly poly = tileAndPoly.Item2;
RcVec3f closest = new RcVec3f();
closest = pos;
float? h = GetPolyHeight(tile, poly, pos);
@ -1315,7 +1315,7 @@ namespace DotRecast.Detour
}
// Off-mesh connections don't have detail polygons.
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
int i = poly.verts[0] * 3;
var v0 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
@ -1329,7 +1329,7 @@ namespace DotRecast.Detour
return new ClosestPointOnPolyResult(false, ClosestPointOnDetailEdges(tile, poly, pos, true));
}
FindNearestPolyResult FindNearestPolyInTile(MeshTile tile, RcVec3f center, RcVec3f extents)
FindNearestPolyResult FindNearestPolyInTile(DtMeshTile tile, RcVec3f center, RcVec3f extents)
{
RcVec3f nearestPt = new RcVec3f();
bool overPoly = false;
@ -1375,9 +1375,9 @@ namespace DotRecast.Detour
return new FindNearestPolyResult(nearest, nearestPt, overPoly);
}
MeshTile GetTileAt(int x, int y, int layer)
DtMeshTile GetTileAt(int x, int y, int layer)
{
foreach (MeshTile tile in GetTileListByPos(x, y))
foreach (DtMeshTile tile in GetTileListByPos(x, y))
{
if (tile.data.header != null && tile.data.header.x == x && tile.data.header.y == y
&& tile.data.header.layer == layer)
@ -1389,7 +1389,7 @@ namespace DotRecast.Detour
return null;
}
List<MeshTile> GetNeighbourTilesAt(int x, int y, int side)
List<DtMeshTile> GetNeighbourTilesAt(int x, int y, int side)
{
int nx = x, ny = y;
switch (side)
@ -1427,10 +1427,10 @@ namespace DotRecast.Detour
return GetTilesAt(nx, ny);
}
public List<MeshTile> GetTilesAt(int x, int y)
public List<DtMeshTile> GetTilesAt(int x, int y)
{
List<MeshTile> tiles = new List<MeshTile>();
foreach (MeshTile tile in GetTileListByPos(x, y))
List<DtMeshTile> tiles = new List<DtMeshTile>();
foreach (DtMeshTile tile in GetTileListByPos(x, y))
{
if (tile.data.header != null && tile.data.header.x == x && tile.data.header.y == y)
{
@ -1446,7 +1446,7 @@ namespace DotRecast.Detour
return GetTileRef(GetTileAt(x, y, layer));
}
public MeshTile GetTileByRef(long refs)
public DtMeshTile GetTileByRef(long refs)
{
if (refs == 0)
{
@ -1460,7 +1460,7 @@ namespace DotRecast.Detour
return null;
}
MeshTile tile = m_tiles[tileIndex];
DtMeshTile tile = m_tiles[tileIndex];
if (tile.salt != tileSalt)
{
return null;
@ -1469,7 +1469,7 @@ namespace DotRecast.Detour
return tile;
}
public long GetTileRef(MeshTile tile)
public long GetTileRef(DtMeshTile tile)
{
if (tile == null)
{
@ -1516,16 +1516,16 @@ namespace DotRecast.Detour
return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("Invalid salt or missing tile header");
}
MeshTile tile = m_tiles[it];
DtMeshTile tile = m_tiles[it];
if (ip >= tile.data.header.polyCount)
{
return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("Invalid poly ID > poly count");
}
Poly poly = tile.data.polys[ip];
DtPoly poly = tile.data.polys[ip];
// Make sure that the current poly is indeed off-mesh link.
if (poly.GetPolyType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (poly.GetPolyType() != DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("Invalid poly type");
}
@ -1565,35 +1565,35 @@ namespace DotRecast.Detour
return m_tileCount;
}
public Status SetPolyFlags(long refs, int flags)
public DtStatus SetPolyFlags(long refs, int flags)
{
if (refs == 0)
{
return Status.FAILURE;
return DtStatus.FAILURE;
}
DecodePolyId(refs, out var salt, out var it, out var ip);
if (it >= m_maxTiles)
{
return Status.FAILURE_INVALID_PARAM;
return DtStatus.FAILURE_INVALID_PARAM;
}
if (m_tiles[it].salt != salt || m_tiles[it].data == null || m_tiles[it].data.header == null)
{
return Status.FAILURE_INVALID_PARAM;
return DtStatus.FAILURE_INVALID_PARAM;
}
MeshTile tile = m_tiles[it];
DtMeshTile tile = m_tiles[it];
if (ip >= tile.data.header.polyCount)
{
return Status.FAILURE_INVALID_PARAM;
return DtStatus.FAILURE_INVALID_PARAM;
}
Poly poly = tile.data.polys[ip];
DtPoly poly = tile.data.polys[ip];
// Change flags.
poly.flags = flags;
return Status.SUCCSESS;
return DtStatus.SUCCSESS;
}
public Result<int> GetPolyFlags(long refs)
@ -1614,46 +1614,46 @@ namespace DotRecast.Detour
return Results.InvalidParam<int>();
}
MeshTile tile = m_tiles[it];
DtMeshTile tile = m_tiles[it];
if (ip >= tile.data.header.polyCount)
{
return Results.InvalidParam<int>();
}
Poly poly = tile.data.polys[ip];
DtPoly poly = tile.data.polys[ip];
return Results.Success(poly.flags);
}
public Status SetPolyArea(long refs, char area)
public DtStatus SetPolyArea(long refs, char area)
{
if (refs == 0)
{
return Status.FAILURE;
return DtStatus.FAILURE;
}
DecodePolyId(refs, out var salt, out var it, out var ip);
if (it >= m_maxTiles)
{
return Status.FAILURE;
return DtStatus.FAILURE;
}
if (m_tiles[it].salt != salt || m_tiles[it].data == null || m_tiles[it].data.header == null)
{
return Status.FAILURE_INVALID_PARAM;
return DtStatus.FAILURE_INVALID_PARAM;
}
MeshTile tile = m_tiles[it];
DtMeshTile tile = m_tiles[it];
if (ip >= tile.data.header.polyCount)
{
return Status.FAILURE_INVALID_PARAM;
return DtStatus.FAILURE_INVALID_PARAM;
}
Poly poly = tile.data.polys[ip];
DtPoly poly = tile.data.polys[ip];
poly.SetArea(area);
return Status.SUCCSESS;
return DtStatus.SUCCSESS;
}
public Result<int> GetPolyArea(long refs)
@ -1674,13 +1674,13 @@ namespace DotRecast.Detour
return Results.InvalidParam<int>();
}
MeshTile tile = m_tiles[it];
DtMeshTile tile = m_tiles[it];
if (ip >= tile.data.header.polyCount)
{
return Results.InvalidParam<int>();
}
Poly poly = tile.data.polys[ip];
DtPoly poly = tile.data.polys[ip];
return Results.Success(poly.GetArea());
}
@ -1699,12 +1699,12 @@ namespace DotRecast.Detour
return (triFlags >> (edgeIndex * 2)) & 0x3;
}
private List<MeshTile> GetTileListByPos(int x, int z)
private List<DtMeshTile> GetTileListByPos(int x, int z)
{
var tileHash = ComputeTileHash(x, z, m_tileLutMask);
if (!posLookup.TryGetValue(tileHash, out var tiles))
{
tiles = new List<MeshTile>();
tiles = new List<DtMeshTile>();
posLookup.Add(tileHash, tiles);
}

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
/// Represents the source data used to build an navigation mesh tile.
public class NavMeshDataCreateParams
public class DtNavMeshCreateParams
{
/// @name Polygon Mesh Attributes
/// Used to create the base navigation graph.

View File

@ -28,7 +28,7 @@ namespace DotRecast.Detour
*
* @see NavMesh
*/
public class NavMeshParams
public class DtNavMeshParams
{
/** The world space origin of the navigation mesh's tile space. [(x, y, z)] */
public RcVec3f orig = new RcVec3f();

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
public class Node
public class DtNode
{
public const int DT_NODE_OPEN = 0x01;
public const int DT_NODE_CLOSED = 0x02;
@ -59,7 +59,7 @@ namespace DotRecast.Detour
/** Shortcut found by raycast. */
public List<long> shortcut;
public Node(int index)
public DtNode(int index)
{
this.index = index;
}

View File

@ -22,12 +22,12 @@ using System.Collections.Generic;
namespace DotRecast.Detour
{
public class NodePool
public class DtNodePool
{
private readonly Dictionary<long, List<Node>> m_map = new Dictionary<long, List<Node>>();
private readonly List<Node> m_nodes = new List<Node>();
private readonly Dictionary<long, List<DtNode>> m_map = new Dictionary<long, List<DtNode>>();
private readonly List<DtNode> m_nodes = new List<DtNode>();
public NodePool()
public DtNodePool()
{
}
@ -37,19 +37,19 @@ namespace DotRecast.Detour
m_map.Clear();
}
public List<Node> FindNodes(long id)
public List<DtNode> FindNodes(long id)
{
var hasNode = m_map.TryGetValue(id, out var nodes);
;
if (nodes == null)
{
nodes = new List<Node>();
nodes = new List<DtNode>();
}
return nodes;
}
public Node FindNode(long id)
public DtNode FindNode(long id)
{
var hasNode = m_map.TryGetValue(id, out var nodes);
;
@ -61,13 +61,13 @@ namespace DotRecast.Detour
return null;
}
public Node GetNode(long id, int state)
public DtNode GetNode(long id, int state)
{
var hasNode = m_map.TryGetValue(id, out var nodes);
;
if (nodes != null)
{
foreach (Node node in nodes)
foreach (DtNode node in nodes)
{
if (node.state == state)
{
@ -79,9 +79,9 @@ namespace DotRecast.Detour
return Create(id, state);
}
protected Node Create(long id, int state)
protected DtNode Create(long id, int state)
{
Node node = new Node(m_nodes.Count + 1);
DtNode node = new DtNode(m_nodes.Count + 1);
node.id = id;
node.state = state;
m_nodes.Add(node);
@ -89,7 +89,7 @@ namespace DotRecast.Detour
;
if (nodes == null)
{
nodes = new List<Node>();
nodes = new List<DtNode>();
m_map.Add(id, nodes);
}
@ -97,22 +97,22 @@ namespace DotRecast.Detour
return node;
}
public int GetNodeIdx(Node node)
public int GetNodeIdx(DtNode node)
{
return node != null ? node.index : 0;
}
public Node GetNodeAtIdx(int idx)
public DtNode GetNodeAtIdx(int idx)
{
return idx != 0 ? m_nodes[idx - 1] : null;
}
public Node GetNode(long refs)
public DtNode GetNode(long refs)
{
return GetNode(refs, 0);
}
public Dictionary<long, List<Node>> GetNodeMap()
public Dictionary<long, List<DtNode>> GetNodeMap()
{
return m_map;
}

View File

@ -22,9 +22,9 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
public class NodeQueue
public class DtNodeQueue
{
private readonly RcSortedQueue<Node> m_heap = new RcSortedQueue<Node>((n1, n2) => n1.total.CompareTo(n2.total));
private readonly RcSortedQueue<DtNode> m_heap = new RcSortedQueue<DtNode>((n1, n2) => n1.total.CompareTo(n2.total));
public int Count()
{
@ -36,24 +36,24 @@ namespace DotRecast.Detour
m_heap.Clear();
}
public Node Top()
public DtNode Top()
{
return m_heap.Top();
}
public Node Pop()
public DtNode Pop()
{
var node = Top();
m_heap.Remove(node);
return node;
}
public void Push(Node node)
public void Push(DtNode node)
{
m_heap.Enqueue(node);
}
public void Modify(Node node)
public void Modify(DtNode node)
{
m_heap.Remove(node);
Push(node);

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour
* Defines an navigation mesh off-mesh connection within a dtMeshTile object. An off-mesh connection is a user defined
* traversable connection made up to two vertices.
*/
public class OffMeshConnection
public class DtOffMeshConnection
{
/** The endpoints of the connection. [(ax, ay, az, bx, by, bz)] */
public float[] pos = new float[6];

View File

@ -21,7 +21,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour
{
/** Defines a polygon within a MeshTile object. */
public class Poly
public class DtPoly
{
/** The polygon is a standard convex polygon that is part of the surface of the mesh. */
public const int DT_POLYTYPE_GROUND = 0;
@ -50,7 +50,7 @@ namespace DotRecast.Detour
*/
public int areaAndtype;
public Poly(int index, int maxVertsPerPoly)
public DtPoly(int index, int maxVertsPerPoly)
{
this.index = index;
verts = new int[maxVertsPerPoly];

View File

@ -21,7 +21,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour
{
/** Defines the location of detail sub-mesh data within a dtMeshTile. */
public class PolyDetail
public class DtPolyDetail
{
/** The offset of the vertices in the MeshTile::detailVerts array. */
public int vertBase;

View File

@ -22,15 +22,15 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
public class QueryData
public class DtQueryData
{
public Status status;
public Node lastBestNode;
public DtStatus status;
public DtNode lastBestNode;
public float lastBestNodeCost;
public long startRef, endRef;
public RcVec3f startPos = new RcVec3f();
public RcVec3f endPos = new RcVec3f();
public IQueryFilter filter;
public IDtQueryFilter filter;
public int options;
public float raycastLimitSqr;
public IQueryHeuristic heuristic;

View File

@ -23,8 +23,6 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
using static DotRecast.Core.RcMath;
/**
* <b>The Default Implementation</b>
*
@ -50,44 +48,44 @@ namespace DotRecast.Detour
*
* @see NavMeshQuery
*/
public class DefaultQueryFilter : IQueryFilter
public class DtQueryDefaultFilter : IDtQueryFilter
{
private int m_excludeFlags;
private int m_includeFlags;
private readonly float[] m_areaCost = new float[NavMesh.DT_MAX_AREAS];
private readonly float[] m_areaCost = new float[DtNavMesh.DT_MAX_AREAS];
public DefaultQueryFilter()
public DtQueryDefaultFilter()
{
m_includeFlags = 0xffff;
m_excludeFlags = 0;
for (int i = 0; i < NavMesh.DT_MAX_AREAS; ++i)
for (int i = 0; i < DtNavMesh.DT_MAX_AREAS; ++i)
{
m_areaCost[i] = 1.0f;
}
}
public DefaultQueryFilter(int includeFlags, int excludeFlags, float[] areaCost)
public DtQueryDefaultFilter(int includeFlags, int excludeFlags, float[] areaCost)
{
m_includeFlags = includeFlags;
m_excludeFlags = excludeFlags;
for (int i = 0; i < Math.Min(NavMesh.DT_MAX_AREAS, areaCost.Length); ++i)
for (int i = 0; i < Math.Min(DtNavMesh.DT_MAX_AREAS, areaCost.Length); ++i)
{
m_areaCost[i] = areaCost[i];
}
for (int i = areaCost.Length; i < NavMesh.DT_MAX_AREAS; ++i)
for (int i = areaCost.Length; i < DtNavMesh.DT_MAX_AREAS; ++i)
{
m_areaCost[i] = 1.0f;
}
}
public bool PassFilter(long refs, MeshTile tile, Poly poly)
public bool PassFilter(long refs, DtMeshTile tile, DtPoly poly)
{
return (poly.flags & m_includeFlags) != 0 && (poly.flags & m_excludeFlags) == 0;
}
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef,
MeshTile curTile, Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly)
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef,
DtMeshTile curTile, DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly)
{
return RcVec3f.Distance(pa, pb) * m_areaCost[curPoly.GetArea()];
}

View File

@ -0,0 +1,18 @@
using DotRecast.Core;
namespace DotRecast.Detour
{
public class DtQueryEmptyFilter : IDtQueryFilter
{
public bool PassFilter(long refs, DtMeshTile tile, DtPoly poly)
{
return false;
}
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef,
DtMeshTile curTile, DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly)
{
return 0;
}
}
}

View File

@ -0,0 +1,18 @@
using DotRecast.Core;
namespace DotRecast.Detour
{
public class DtQueryNoOpFilter : IDtQueryFilter
{
public bool PassFilter(long refs, DtMeshTile tile, DtPoly poly)
{
return true;
}
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef,
DtMeshTile curTile, DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly)
{
return 0;
}
}
}

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour
/**
* Provides information about raycast hit. Filled by NavMeshQuery::raycast
*/
public class RaycastHit
public class DtRaycastHit
{
/** The hit parameter. (float.MaxValue if no wall hit.) */
public float t;

View File

@ -1,12 +1,12 @@
namespace DotRecast.Detour
{
public class SegInterval
public class DtSegInterval
{
public long refs;
public int tmin;
public int tmax;
public SegInterval(long refs, int tmin, int tmax)
public DtSegInterval(long refs, int tmin, int tmax)
{
this.refs = refs;
this.tmin = tmin;

View File

@ -20,17 +20,17 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour
{
public class Status
public class DtStatus
{
public static readonly Status FAILURE = new Status(0);
public static readonly Status SUCCSESS = new Status(1);
public static readonly Status IN_PROGRESS = new Status(2);
public static readonly Status PARTIAL_RESULT = new Status(3);
public static readonly Status FAILURE_INVALID_PARAM = new Status(4);
public static readonly DtStatus FAILURE = new DtStatus(0);
public static readonly DtStatus SUCCSESS = new DtStatus(1);
public static readonly DtStatus IN_PROGRESS = new DtStatus(2);
public static readonly DtStatus PARTIAL_RESULT = new DtStatus(3);
public static readonly DtStatus FAILURE_INVALID_PARAM = new DtStatus(4);
public readonly int Value;
private Status(int value)
private DtStatus(int value)
{
Value = value;
}

View File

@ -0,0 +1,25 @@
namespace DotRecast.Detour
{
public static class DtStatusExtension
{
public static bool IsSuccess(this DtStatus @this)
{
return @this == DtStatus.SUCCSESS || @this == DtStatus.PARTIAL_RESULT;
}
public static bool IsFailed(this DtStatus @this)
{
return @this == DtStatus.FAILURE || @this == DtStatus.FAILURE_INVALID_PARAM;
}
public static bool IsInProgress(this DtStatus @this)
{
return @this == DtStatus.IN_PROGRESS;
}
public static bool IsPartial(this DtStatus @this)
{
return @this == DtStatus.PARTIAL_RESULT;
}
}
}

View File

@ -0,0 +1,7 @@
namespace DotRecast.Detour
{
public interface IDtPolyQuery
{
void Process(DtMeshTile tile, DtPoly poly, long refs);
}
}

View File

@ -22,11 +22,11 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
public interface IQueryFilter
public interface IDtQueryFilter
{
bool PassFilter(long refs, MeshTile tile, Poly poly);
bool PassFilter(long refs, DtMeshTile tile, DtPoly poly);
float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile,
Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly);
float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, DtMeshTile prevTile, DtPoly prevPoly, long curRef, DtMeshTile curTile,
DtPoly curPoly, long nextRef, DtMeshTile nextTile, DtPoly nextPoly);
}
}

View File

@ -1,7 +0,0 @@
namespace DotRecast.Detour
{
public interface IPolyQuery
{
void Process(MeshTile tile, Poly poly, long refs);
}
}

View File

@ -25,38 +25,38 @@ namespace DotRecast.Detour.Io
{
public const int DT_POLY_DETAIL_SIZE = 10;
public MeshData Read(BinaryReader stream, int maxVertPerPoly)
public DtMeshData Read(BinaryReader stream, int maxVertPerPoly)
{
RcByteBuffer buf = IOUtils.ToByteBuffer(stream);
return Read(buf, maxVertPerPoly, false);
}
public MeshData Read(RcByteBuffer buf, int maxVertPerPoly)
public DtMeshData Read(RcByteBuffer buf, int maxVertPerPoly)
{
return Read(buf, maxVertPerPoly, false);
}
public MeshData Read32Bit(BinaryReader stream, int maxVertPerPoly)
public DtMeshData Read32Bit(BinaryReader stream, int maxVertPerPoly)
{
RcByteBuffer buf = IOUtils.ToByteBuffer(stream);
return Read(buf, maxVertPerPoly, true);
}
public MeshData Read32Bit(RcByteBuffer buf, int maxVertPerPoly)
public DtMeshData Read32Bit(RcByteBuffer buf, int maxVertPerPoly)
{
return Read(buf, maxVertPerPoly, true);
}
public MeshData Read(RcByteBuffer buf, int maxVertPerPoly, bool is32Bit)
public DtMeshData Read(RcByteBuffer buf, int maxVertPerPoly, bool is32Bit)
{
MeshData data = new MeshData();
MeshHeader header = new MeshHeader();
DtMeshData data = new DtMeshData();
DtMeshHeader header = new DtMeshHeader();
data.header = header;
header.magic = buf.GetInt();
if (header.magic != MeshHeader.DT_NAVMESH_MAGIC)
if (header.magic != DtMeshHeader.DT_NAVMESH_MAGIC)
{
header.magic = IOUtils.SwapEndianness(header.magic);
if (header.magic != MeshHeader.DT_NAVMESH_MAGIC)
if (header.magic != DtMeshHeader.DT_NAVMESH_MAGIC)
{
throw new IOException("Invalid magic");
}
@ -65,16 +65,16 @@ namespace DotRecast.Detour.Io
}
header.version = buf.GetInt();
if (header.version != MeshHeader.DT_NAVMESH_VERSION)
if (header.version != DtMeshHeader.DT_NAVMESH_VERSION)
{
if (header.version < MeshHeader.DT_NAVMESH_VERSION_RECAST4J_FIRST
|| header.version > MeshHeader.DT_NAVMESH_VERSION_RECAST4J_LAST)
if (header.version < DtMeshHeader.DT_NAVMESH_VERSION_RECAST4J_FIRST
|| header.version > DtMeshHeader.DT_NAVMESH_VERSION_RECAST4J_LAST)
{
throw new IOException("Invalid version " + header.version);
}
}
bool cCompatibility = header.version == MeshHeader.DT_NAVMESH_VERSION;
bool cCompatibility = header.version == DtMeshHeader.DT_NAVMESH_VERSION;
header.x = buf.GetInt();
header.y = buf.GetInt();
header.layer = buf.GetInt();
@ -135,13 +135,13 @@ namespace DotRecast.Detour.Io
return verts;
}
private Poly[] ReadPolys(RcByteBuffer buf, MeshHeader header, int maxVertPerPoly)
private DtPoly[] ReadPolys(RcByteBuffer buf, DtMeshHeader header, int maxVertPerPoly)
{
Poly[] polys = new Poly[header.polyCount];
DtPoly[] polys = new DtPoly[header.polyCount];
for (int i = 0; i < polys.Length; i++)
{
polys[i] = new Poly(i, maxVertPerPoly);
if (header.version < MeshHeader.DT_NAVMESH_VERSION_RECAST4J_NO_POLY_FIRSTLINK)
polys[i] = new DtPoly(i, maxVertPerPoly);
if (header.version < DtMeshHeader.DT_NAVMESH_VERSION_RECAST4J_NO_POLY_FIRSTLINK)
{
buf.GetInt(); // polys[i].firstLink
}
@ -164,12 +164,12 @@ namespace DotRecast.Detour.Io
return polys;
}
private PolyDetail[] ReadPolyDetails(RcByteBuffer buf, MeshHeader header, bool cCompatibility)
private DtPolyDetail[] ReadPolyDetails(RcByteBuffer buf, DtMeshHeader header, bool cCompatibility)
{
PolyDetail[] polys = new PolyDetail[header.detailMeshCount];
DtPolyDetail[] polys = new DtPolyDetail[header.detailMeshCount];
for (int i = 0; i < polys.Length; i++)
{
polys[i] = new PolyDetail();
polys[i] = new DtPolyDetail();
polys[i].vertBase = buf.GetInt();
polys[i].triBase = buf.GetInt();
polys[i].vertCount = buf.Get() & 0xFF;
@ -183,7 +183,7 @@ namespace DotRecast.Detour.Io
return polys;
}
private int[] ReadDTris(RcByteBuffer buf, MeshHeader header)
private int[] ReadDTris(RcByteBuffer buf, DtMeshHeader header)
{
int[] tris = new int[4 * header.detailTriCount];
for (int i = 0; i < tris.Length; i++)
@ -194,13 +194,13 @@ namespace DotRecast.Detour.Io
return tris;
}
private BVNode[] ReadBVTree(RcByteBuffer buf, MeshHeader header)
private DtBVNode[] ReadBVTree(RcByteBuffer buf, DtMeshHeader header)
{
BVNode[] nodes = new BVNode[header.bvNodeCount];
DtBVNode[] nodes = new DtBVNode[header.bvNodeCount];
for (int i = 0; i < nodes.Length; i++)
{
nodes[i] = new BVNode();
if (header.version < MeshHeader.DT_NAVMESH_VERSION_RECAST4J_32BIT_BVTREE)
nodes[i] = new DtBVNode();
if (header.version < DtMeshHeader.DT_NAVMESH_VERSION_RECAST4J_32BIT_BVTREE)
{
for (int j = 0; j < 3; j++)
{
@ -231,12 +231,12 @@ namespace DotRecast.Detour.Io
return nodes;
}
private OffMeshConnection[] ReadOffMeshCons(RcByteBuffer buf, MeshHeader header)
private DtOffMeshConnection[] ReadOffMeshCons(RcByteBuffer buf, DtMeshHeader header)
{
OffMeshConnection[] cons = new OffMeshConnection[header.offMeshConCount];
DtOffMeshConnection[] cons = new DtOffMeshConnection[header.offMeshConCount];
for (int i = 0; i < cons.Length; i++)
{
cons[i] = new OffMeshConnection();
cons[i] = new DtOffMeshConnection();
for (int j = 0; j < 6; j++)
{
cons[i].pos[j] = buf.GetFloat();

View File

@ -23,11 +23,11 @@ namespace DotRecast.Detour.Io
{
public class MeshDataWriter : DetourWriter
{
public void Write(BinaryWriter stream, MeshData data, RcByteOrder order, bool cCompatibility)
public void Write(BinaryWriter stream, DtMeshData data, RcByteOrder order, bool cCompatibility)
{
MeshHeader header = data.header;
DtMeshHeader header = data.header;
Write(stream, header.magic, order);
Write(stream, cCompatibility ? MeshHeader.DT_NAVMESH_VERSION : MeshHeader.DT_NAVMESH_VERSION_RECAST4J_LAST, order);
Write(stream, cCompatibility ? DtMeshHeader.DT_NAVMESH_VERSION : DtMeshHeader.DT_NAVMESH_VERSION_RECAST4J_LAST, order);
Write(stream, header.x, order);
Write(stream, header.y, order);
Write(stream, header.layer, order);
@ -74,7 +74,7 @@ namespace DotRecast.Detour.Io
}
}
private void WritePolys(BinaryWriter stream, MeshData data, RcByteOrder order, bool cCompatibility)
private void WritePolys(BinaryWriter stream, DtMeshData data, RcByteOrder order, bool cCompatibility)
{
for (int i = 0; i < data.header.polyCount; i++)
{
@ -99,7 +99,7 @@ namespace DotRecast.Detour.Io
}
}
private void WritePolyDetails(BinaryWriter stream, MeshData data, RcByteOrder order, bool cCompatibility)
private void WritePolyDetails(BinaryWriter stream, DtMeshData data, RcByteOrder order, bool cCompatibility)
{
for (int i = 0; i < data.header.detailMeshCount; i++)
{
@ -114,7 +114,7 @@ namespace DotRecast.Detour.Io
}
}
private void WriteDTris(BinaryWriter stream, MeshData data)
private void WriteDTris(BinaryWriter stream, DtMeshData data)
{
for (int i = 0; i < data.header.detailTriCount * 4; i++)
{
@ -122,7 +122,7 @@ namespace DotRecast.Detour.Io
}
}
private void WriteBVTree(BinaryWriter stream, MeshData data, RcByteOrder order, bool cCompatibility)
private void WriteBVTree(BinaryWriter stream, DtMeshData data, RcByteOrder order, bool cCompatibility)
{
for (int i = 0; i < data.header.bvNodeCount; i++)
{
@ -155,7 +155,7 @@ namespace DotRecast.Detour.Io
}
}
private void WriteOffMeshCons(BinaryWriter stream, MeshData data, RcByteOrder order)
private void WriteOffMeshCons(BinaryWriter stream, DtMeshData data, RcByteOrder order)
{
for (int i = 0; i < data.header.offMeshConCount; i++)
{

View File

@ -30,37 +30,37 @@ namespace DotRecast.Detour.Io
private readonly MeshDataReader meshReader = new MeshDataReader();
private readonly NavMeshParamReader paramReader = new NavMeshParamReader();
public NavMesh Read(BinaryReader @is, int maxVertPerPoly)
public DtNavMesh Read(BinaryReader @is, int maxVertPerPoly)
{
return Read(IOUtils.ToByteBuffer(@is), maxVertPerPoly, false);
}
public NavMesh Read(RcByteBuffer bb, int maxVertPerPoly)
public DtNavMesh Read(RcByteBuffer bb, int maxVertPerPoly)
{
return Read(bb, maxVertPerPoly, false);
}
public NavMesh Read32Bit(BinaryReader @is, int maxVertPerPoly)
public DtNavMesh Read32Bit(BinaryReader @is, int maxVertPerPoly)
{
return Read(IOUtils.ToByteBuffer(@is), maxVertPerPoly, true);
}
public NavMesh Read32Bit(RcByteBuffer bb, int maxVertPerPoly)
public DtNavMesh Read32Bit(RcByteBuffer bb, int maxVertPerPoly)
{
return Read(bb, maxVertPerPoly, true);
}
public NavMesh Read(BinaryReader @is)
public DtNavMesh Read(BinaryReader @is)
{
return Read(IOUtils.ToByteBuffer(@is));
}
public NavMesh Read(RcByteBuffer bb)
public DtNavMesh Read(RcByteBuffer bb)
{
return Read(bb, -1, false);
}
NavMesh Read(RcByteBuffer bb, int maxVertPerPoly, bool is32Bit)
DtNavMesh Read(RcByteBuffer bb, int maxVertPerPoly, bool is32Bit)
{
NavMeshSetHeader header = ReadHeader(bb, maxVertPerPoly);
if (header.maxVertsPerPoly <= 0)
@ -69,7 +69,7 @@ namespace DotRecast.Detour.Io
}
bool cCompatibility = header.version == NavMeshSetHeader.NAVMESHSET_VERSION;
NavMesh mesh = new NavMesh(header.option, header.maxVertsPerPoly);
DtNavMesh mesh = new DtNavMesh(header.option, header.maxVertsPerPoly);
ReadTiles(bb, is32Bit, header, cCompatibility, mesh);
return mesh;
}
@ -107,7 +107,7 @@ namespace DotRecast.Detour.Io
return header;
}
private void ReadTiles(RcByteBuffer bb, bool is32Bit, NavMeshSetHeader header, bool cCompatibility, NavMesh mesh)
private void ReadTiles(RcByteBuffer bb, bool is32Bit, NavMeshSetHeader header, bool cCompatibility, DtNavMesh mesh)
{
// Read tiles.
for (int i = 0; i < header.numTiles; ++i)
@ -133,12 +133,12 @@ namespace DotRecast.Detour.Io
bb.GetInt(); // C struct padding
}
MeshData data = meshReader.Read(bb, mesh.GetMaxVertsPerPoly(), is32Bit);
DtMeshData data = meshReader.Read(bb, mesh.GetMaxVertsPerPoly(), is32Bit);
mesh.AddTile(data, i, tileHeader.tileRef);
}
}
private long Convert32BitRef(int refs, NavMeshParams option)
private long Convert32BitRef(int refs, DtNavMeshParams option)
{
int m_tileBits = DetourCommon.Ilog2(DetourCommon.NextPow2(option.maxTiles));
int m_polyBits = DetourCommon.Ilog2(DetourCommon.NextPow2(option.maxPolys));
@ -150,7 +150,7 @@ namespace DotRecast.Detour.Io
int salt = ((refs >> (m_polyBits + m_tileBits)) & saltMask);
int it = ((refs >> m_polyBits) & tileMask);
int ip = refs & polyMask;
return NavMesh.EncodePolyId(salt, it, ip);
return DtNavMesh.EncodePolyId(salt, it, ip);
}
}
}

View File

@ -26,20 +26,20 @@ namespace DotRecast.Detour.Io
private readonly MeshDataWriter writer = new MeshDataWriter();
private readonly NavMeshParamWriter paramWriter = new NavMeshParamWriter();
public void Write(BinaryWriter stream, NavMesh mesh, RcByteOrder order, bool cCompatibility)
public void Write(BinaryWriter stream, DtNavMesh mesh, RcByteOrder order, bool cCompatibility)
{
WriteHeader(stream, mesh, order, cCompatibility);
WriteTiles(stream, mesh, order, cCompatibility);
}
private void WriteHeader(BinaryWriter stream, NavMesh mesh, RcByteOrder order, bool cCompatibility)
private void WriteHeader(BinaryWriter stream, DtNavMesh mesh, RcByteOrder order, bool cCompatibility)
{
Write(stream, NavMeshSetHeader.NAVMESHSET_MAGIC, order);
Write(stream, cCompatibility ? NavMeshSetHeader.NAVMESHSET_VERSION : NavMeshSetHeader.NAVMESHSET_VERSION_RECAST4J, order);
int numTiles = 0;
for (int i = 0; i < mesh.GetMaxTiles(); ++i)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile == null || tile.data == null || tile.data.header == null)
{
continue;
@ -56,11 +56,11 @@ namespace DotRecast.Detour.Io
}
}
private void WriteTiles(BinaryWriter stream, NavMesh mesh, RcByteOrder order, bool cCompatibility)
private void WriteTiles(BinaryWriter stream, DtNavMesh mesh, RcByteOrder order, bool cCompatibility)
{
for (int i = 0; i < mesh.GetMaxTiles(); ++i)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile == null || tile.data == null || tile.data.header == null)
{
continue;

View File

@ -4,9 +4,9 @@ namespace DotRecast.Detour.Io
{
public class NavMeshParamReader
{
public NavMeshParams Read(RcByteBuffer bb)
public DtNavMeshParams Read(RcByteBuffer bb)
{
NavMeshParams option = new NavMeshParams();
DtNavMeshParams option = new DtNavMeshParams();
option.orig.x = bb.GetFloat();
option.orig.y = bb.GetFloat();
option.orig.z = bb.GetFloat();

View File

@ -5,7 +5,7 @@ namespace DotRecast.Detour.Io
{
public class NavMeshParamWriter : DetourWriter
{
public void Write(BinaryWriter stream, NavMeshParams option, RcByteOrder order)
public void Write(BinaryWriter stream, DtNavMeshParams option, RcByteOrder order)
{
Write(stream, option.orig.x, order);
Write(stream, option.orig.y, order);

View File

@ -28,7 +28,7 @@ namespace DotRecast.Detour.Io
public int magic;
public int version;
public int numTiles;
public NavMeshParams option = new NavMeshParams();
public DtNavMeshParams option = new DtNavMeshParams();
public int maxVertsPerPoly;
}
}

View File

@ -26,21 +26,21 @@ namespace DotRecast.Detour
using static DotRecast.Core.RcMath;
public class LegacyNavMeshQuery : NavMeshQuery
public class LegacyNavMeshQuery : DtNavMeshQuery
{
private static float H_SCALE = 0.999f; // Search heuristic scale.
public LegacyNavMeshQuery(NavMesh nav) : base(nav)
public LegacyNavMeshQuery(DtNavMesh nav) : base(nav)
{
}
public override Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter,
public override Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter,
int options, float raycastLimit)
{
return FindPath(startRef, endRef, startPos, endPos, filter);
}
public override Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter)
public override Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == filter)
@ -58,26 +58,26 @@ namespace DotRecast.Detour
m_nodePool.Clear();
m_openList.Clear();
Node startNode = m_nodePool.GetNode(startRef);
DtNode startNode = m_nodePool.GetNode(startRef);
startNode.pos = startPos;
startNode.pidx = 0;
startNode.cost = 0;
startNode.total = RcVec3f.Distance(startPos, endPos) * H_SCALE;
startNode.id = startRef;
startNode.flags = Node.DT_NODE_OPEN;
startNode.flags = DtNode.DT_NODE_OPEN;
m_openList.Push(startNode);
Node lastBestNode = startNode;
DtNode lastBestNode = startNode;
float lastBestNodeCost = startNode.total;
Status status = Status.SUCCSESS;
DtStatus status = DtStatus.SUCCSESS;
while (!m_openList.IsEmpty())
{
// Remove node from open list and put it in closed list.
Node bestNode = m_openList.Pop();
bestNode.flags &= ~Node.DT_NODE_OPEN;
bestNode.flags |= Node.DT_NODE_CLOSED;
DtNode bestNode = m_openList.Pop();
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
bestNode.flags |= DtNode.DT_NODE_CLOSED;
// Reached the goal, stop searching.
if (bestNode.id == endRef)
@ -89,14 +89,14 @@ namespace DotRecast.Detour
// Get current poly and tile.
// The API input has been cheked already, skip checking internal data.
long bestRef = bestNode.id;
Tuple<MeshTile, Poly> tileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(bestRef);
MeshTile bestTile = tileAndPoly.Item1;
Poly bestPoly = tileAndPoly.Item2;
Tuple<DtMeshTile, DtPoly> tileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(bestRef);
DtMeshTile bestTile = tileAndPoly.Item1;
DtPoly bestPoly = tileAndPoly.Item2;
// Get parent poly and tile.
long parentRef = 0;
MeshTile parentTile = null;
Poly parentPoly = null;
DtMeshTile parentTile = null;
DtPoly parentPoly = null;
if (bestNode.pidx != 0)
{
parentRef = m_nodePool.GetNodeAtIdx(bestNode.pidx).id;
@ -109,7 +109,7 @@ namespace DotRecast.Detour
parentPoly = tileAndPoly.Item2;
}
for (int i = bestTile.polyLinks[bestPoly.index]; i != NavMesh.DT_NULL_LINK; i = bestTile.links[i].next)
for (int i = bestTile.polyLinks[bestPoly.index]; i != DtNavMesh.DT_NULL_LINK; i = bestTile.links[i].next)
{
long neighbourRef = bestTile.links[i].refs;
@ -122,8 +122,8 @@ namespace DotRecast.Detour
// Get neighbour poly and tile.
// The API input has been cheked already, skip checking internal data.
tileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(neighbourRef);
MeshTile neighbourTile = tileAndPoly.Item1;
Poly neighbourPoly = tileAndPoly.Item2;
DtMeshTile neighbourTile = tileAndPoly.Item1;
DtPoly neighbourPoly = tileAndPoly.Item2;
if (!filter.PassFilter(neighbourRef, neighbourTile, neighbourPoly))
{
@ -138,7 +138,7 @@ namespace DotRecast.Detour
}
// get the node
Node neighbourNode = m_nodePool.GetNode(neighbourRef, crossSide);
DtNode neighbourNode = m_nodePool.GetNode(neighbourRef, crossSide);
// If the node is visited the first time, calculate node position.
if (neighbourNode.flags == 0)
@ -179,13 +179,13 @@ namespace DotRecast.Detour
float total = cost + heuristic;
// The node is already in open list and the new result is worse, skip.
if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
{
continue;
}
// The node is already visited and process, and the new result is worse, skip.
if ((neighbourNode.flags & Node.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
{
continue;
}
@ -193,11 +193,11 @@ namespace DotRecast.Detour
// Add or update the node.
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
neighbourNode.id = neighbourRef;
neighbourNode.flags = (neighbourNode.flags & ~Node.DT_NODE_CLOSED);
neighbourNode.flags = (neighbourNode.flags & ~DtNode.DT_NODE_CLOSED);
neighbourNode.cost = cost;
neighbourNode.total = total;
if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0)
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
{
// Already in open, update node location.
m_openList.Modify(neighbourNode);
@ -205,7 +205,7 @@ namespace DotRecast.Detour
else
{
// Put the node in open list.
neighbourNode.flags |= Node.DT_NODE_OPEN;
neighbourNode.flags |= DtNode.DT_NODE_OPEN;
m_openList.Push(neighbourNode);
}
@ -222,7 +222,7 @@ namespace DotRecast.Detour
if (lastBestNode.id != endRef)
{
status = Status.PARTIAL_RESULT;
status = DtStatus.PARTIAL_RESULT;
}
return Results.Of(status, path);
@ -245,7 +245,7 @@ namespace DotRecast.Detour
// Make sure the request is still valid.
if (!m_nav.IsValidPolyRef(m_query.startRef) || !m_nav.IsValidPolyRef(m_query.endRef))
{
m_query.status = Status.FAILURE;
m_query.status = DtStatus.FAILURE;
return Results.Of(m_query.status, 0);
}
@ -255,15 +255,15 @@ namespace DotRecast.Detour
iter++;
// Remove node from open list and put it in closed list.
Node bestNode = m_openList.Pop();
bestNode.flags &= ~Node.DT_NODE_OPEN;
bestNode.flags |= Node.DT_NODE_CLOSED;
DtNode bestNode = m_openList.Pop();
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
bestNode.flags |= DtNode.DT_NODE_CLOSED;
// Reached the goal, stop searching.
if (bestNode.id == m_query.endRef)
{
m_query.lastBestNode = bestNode;
m_query.status = Status.SUCCSESS;
m_query.status = DtStatus.SUCCSESS;
return Results.Of(m_query.status, iter);
}
@ -271,21 +271,21 @@ namespace DotRecast.Detour
// The API input has been cheked already, skip checking internal
// data.
long bestRef = bestNode.id;
Result<Tuple<MeshTile, Poly>> tileAndPoly = m_nav.GetTileAndPolyByRef(bestRef);
Result<Tuple<DtMeshTile, DtPoly>> tileAndPoly = m_nav.GetTileAndPolyByRef(bestRef);
if (tileAndPoly.Failed())
{
m_query.status = Status.FAILURE;
m_query.status = DtStatus.FAILURE;
// The polygon has disappeared during the sliced query, fail.
return Results.Of(m_query.status, iter);
}
MeshTile bestTile = tileAndPoly.result.Item1;
Poly bestPoly = tileAndPoly.result.Item2;
DtMeshTile bestTile = tileAndPoly.result.Item1;
DtPoly bestPoly = tileAndPoly.result.Item2;
// Get parent and grand parent poly and tile.
long parentRef = 0, grandpaRef = 0;
MeshTile parentTile = null;
Poly parentPoly = null;
Node parentNode = null;
DtMeshTile parentTile = null;
DtPoly parentPoly = null;
DtNode parentNode = null;
if (bestNode.pidx != 0)
{
parentNode = m_nodePool.GetNodeAtIdx(bestNode.pidx);
@ -305,7 +305,7 @@ namespace DotRecast.Detour
{
// The polygon has disappeared during the sliced query,
// fail.
m_query.status = Status.FAILURE;
m_query.status = DtStatus.FAILURE;
return Results.Of(m_query.status, iter);
}
@ -323,7 +323,7 @@ namespace DotRecast.Detour
}
}
for (int i = bestTile.polyLinks[bestPoly.index]; i != NavMesh.DT_NULL_LINK; i = bestTile.links[i].next)
for (int i = bestTile.polyLinks[bestPoly.index]; i != DtNavMesh.DT_NULL_LINK; i = bestTile.links[i].next)
{
long neighbourRef = bestTile.links[i].refs;
@ -337,9 +337,9 @@ namespace DotRecast.Detour
// Get neighbour poly and tile.
// The API input has been cheked already, skip checking internal
// data.
Tuple<MeshTile, Poly> tileAndPolyUns = m_nav.GetTileAndPolyByRefUnsafe(neighbourRef);
MeshTile neighbourTile = tileAndPolyUns.Item1;
Poly neighbourPoly = tileAndPolyUns.Item2;
Tuple<DtMeshTile, DtPoly> tileAndPolyUns = m_nav.GetTileAndPolyByRefUnsafe(neighbourRef);
DtMeshTile neighbourTile = tileAndPolyUns.Item1;
DtPoly neighbourPoly = tileAndPolyUns.Item2;
if (!m_query.filter.PassFilter(neighbourRef, neighbourTile, neighbourPoly))
{
@ -347,7 +347,7 @@ namespace DotRecast.Detour
}
// get the neighbor node
Node neighbourNode = m_nodePool.GetNode(neighbourRef, 0);
DtNode neighbourNode = m_nodePool.GetNode(neighbourRef, 0);
// do not expand to nodes that were already visited from the
// same parent
@ -376,7 +376,7 @@ namespace DotRecast.Detour
bool foundShortCut = false;
if (tryLOS)
{
Result<RaycastHit> rayHit = Raycast(parentRef, parentNode.pos, neighbourNode.pos, m_query.filter,
Result<DtRaycastHit> rayHit = Raycast(parentRef, parentNode.pos, neighbourNode.pos, m_query.filter,
DT_RAYCAST_USE_COSTS, grandpaRef);
if (rayHit.Succeeded())
{
@ -417,14 +417,14 @@ namespace DotRecast.Detour
// The node is already in open list and the new result is worse,
// skip.
if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
{
continue;
}
// The node is already visited and process, and the new result
// is worse, skip.
if ((neighbourNode.flags & Node.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0 && total >= neighbourNode.total)
{
continue;
}
@ -432,15 +432,15 @@ namespace DotRecast.Detour
// Add or update the node.
neighbourNode.pidx = foundShortCut ? bestNode.pidx : m_nodePool.GetNodeIdx(bestNode);
neighbourNode.id = neighbourRef;
neighbourNode.flags = (neighbourNode.flags & ~(Node.DT_NODE_CLOSED | Node.DT_NODE_PARENT_DETACHED));
neighbourNode.flags = (neighbourNode.flags & ~(DtNode.DT_NODE_CLOSED | DtNode.DT_NODE_PARENT_DETACHED));
neighbourNode.cost = cost;
neighbourNode.total = total;
if (foundShortCut)
{
neighbourNode.flags = (neighbourNode.flags | Node.DT_NODE_PARENT_DETACHED);
neighbourNode.flags = (neighbourNode.flags | DtNode.DT_NODE_PARENT_DETACHED);
}
if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0)
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
{
// Already in open, update node location.
m_openList.Modify(neighbourNode);
@ -448,7 +448,7 @@ namespace DotRecast.Detour
else
{
// Put the node in open list.
neighbourNode.flags |= Node.DT_NODE_OPEN;
neighbourNode.flags |= DtNode.DT_NODE_OPEN;
m_openList.Push(neighbourNode);
}
@ -464,7 +464,7 @@ namespace DotRecast.Detour
// Exhausted all nodes, but could not find path.
if (m_openList.IsEmpty())
{
m_query.status = Status.PARTIAL_RESULT;
m_query.status = DtStatus.PARTIAL_RESULT;
}
return Results.Of(m_query.status, iter);
@ -480,7 +480,7 @@ namespace DotRecast.Detour
if (m_query.status.IsFailed())
{
// Reset query.
m_query = new QueryData();
m_query = new DtQueryData();
return Results.Failure(path);
}
@ -494,20 +494,20 @@ namespace DotRecast.Detour
// Reverse the path.
if (m_query.lastBestNode.id != m_query.endRef)
{
m_query.status = Status.PARTIAL_RESULT;
m_query.status = DtStatus.PARTIAL_RESULT;
}
Node prev = null;
Node node = m_query.lastBestNode;
DtNode prev = null;
DtNode node = m_query.lastBestNode;
int prevRay = 0;
do
{
Node next = m_nodePool.GetNodeAtIdx(node.pidx);
DtNode next = m_nodePool.GetNodeAtIdx(node.pidx);
node.pidx = m_nodePool.GetNodeIdx(prev);
prev = node;
int nextRay = node.flags & Node.DT_NODE_PARENT_DETACHED; // keep track of whether parent is not adjacent
int nextRay = node.flags & DtNode.DT_NODE_PARENT_DETACHED; // keep track of whether parent is not adjacent
// (i.e. due to raycast shortcut)
node.flags = (node.flags & ~Node.DT_NODE_PARENT_DETACHED) | prevRay; // and store it in the reversed
node.flags = (node.flags & ~DtNode.DT_NODE_PARENT_DETACHED) | prevRay; // and store it in the reversed
// path's node
prevRay = nextRay;
node = next;
@ -517,10 +517,10 @@ namespace DotRecast.Detour
node = prev;
do
{
Node next = m_nodePool.GetNodeAtIdx(node.pidx);
if ((node.flags & Node.DT_NODE_PARENT_DETACHED) != 0)
DtNode next = m_nodePool.GetNodeAtIdx(node.pidx);
if ((node.flags & DtNode.DT_NODE_PARENT_DETACHED) != 0)
{
Result<RaycastHit> iresult = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0);
Result<DtRaycastHit> iresult = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0);
if (iresult.Succeeded())
{
path.AddRange(iresult.result.path);
@ -541,9 +541,9 @@ namespace DotRecast.Detour
} while (node != null);
}
Status status = m_query.status;
DtStatus status = m_query.status;
// Reset query.
m_query = new QueryData();
m_query = new DtQueryData();
return Results.Of(status, path);
}
@ -566,7 +566,7 @@ namespace DotRecast.Detour
if (m_query.status.IsFailed())
{
// Reset query.
m_query = new QueryData();
m_query = new DtQueryData();
return Results.Failure(path);
}
@ -578,8 +578,8 @@ namespace DotRecast.Detour
else
{
// Find furthest existing node that was visited.
Node prev = null;
Node node = null;
DtNode prev = null;
DtNode node = null;
for (int i = existing.Count - 1; i >= 0; --i)
{
node = m_nodePool.FindNode(existing[i]);
@ -591,7 +591,7 @@ namespace DotRecast.Detour
if (node == null)
{
m_query.status = Status.PARTIAL_RESULT;
m_query.status = DtStatus.PARTIAL_RESULT;
node = m_query.lastBestNode;
}
@ -599,12 +599,12 @@ namespace DotRecast.Detour
int prevRay = 0;
do
{
Node next = m_nodePool.GetNodeAtIdx(node.pidx);
DtNode next = m_nodePool.GetNodeAtIdx(node.pidx);
node.pidx = m_nodePool.GetNodeIdx(prev);
prev = node;
int nextRay = node.flags & Node.DT_NODE_PARENT_DETACHED; // keep track of whether parent is not adjacent
int nextRay = node.flags & DtNode.DT_NODE_PARENT_DETACHED; // keep track of whether parent is not adjacent
// (i.e. due to raycast shortcut)
node.flags = (node.flags & ~Node.DT_NODE_PARENT_DETACHED) | prevRay; // and store it in the reversed
node.flags = (node.flags & ~DtNode.DT_NODE_PARENT_DETACHED) | prevRay; // and store it in the reversed
// path's node
prevRay = nextRay;
node = next;
@ -614,10 +614,10 @@ namespace DotRecast.Detour
node = prev;
do
{
Node next = m_nodePool.GetNodeAtIdx(node.pidx);
if ((node.flags & Node.DT_NODE_PARENT_DETACHED) != 0)
DtNode next = m_nodePool.GetNodeAtIdx(node.pidx);
if ((node.flags & DtNode.DT_NODE_PARENT_DETACHED) != 0)
{
Result<RaycastHit> iresult = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0);
Result<DtRaycastHit> iresult = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0);
if (iresult.Succeeded())
{
path.AddRange(iresult.result.path);
@ -638,14 +638,14 @@ namespace DotRecast.Detour
} while (node != null);
}
Status status = m_query.status;
DtStatus status = m_query.status;
// Reset query.
m_query = new QueryData();
m_query = new DtQueryData();
return Results.Of(status, path);
}
public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius, IQueryFilter filter)
public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius, IDtQueryFilter filter)
{
// Validate input
if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || maxRadius < 0
@ -657,13 +657,13 @@ namespace DotRecast.Detour
m_nodePool.Clear();
m_openList.Clear();
Node startNode = m_nodePool.GetNode(startRef);
DtNode startNode = m_nodePool.GetNode(startRef);
startNode.pos = centerPos;
startNode.pidx = 0;
startNode.cost = 0;
startNode.total = 0;
startNode.id = startRef;
startNode.flags = Node.DT_NODE_OPEN;
startNode.flags = DtNode.DT_NODE_OPEN;
m_openList.Push(startNode);
float radiusSqr = Sqr(maxRadius);
@ -673,16 +673,16 @@ namespace DotRecast.Detour
while (!m_openList.IsEmpty())
{
Node bestNode = m_openList.Pop();
bestNode.flags &= ~Node.DT_NODE_OPEN;
bestNode.flags |= Node.DT_NODE_CLOSED;
DtNode bestNode = m_openList.Pop();
bestNode.flags &= ~DtNode.DT_NODE_OPEN;
bestNode.flags |= DtNode.DT_NODE_CLOSED;
// Get poly and tile.
// The API input has been cheked already, skip checking internal data.
long bestRef = bestNode.id;
Tuple<MeshTile, Poly> tileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(bestRef);
MeshTile bestTile = tileAndPoly.Item1;
Poly bestPoly = tileAndPoly.Item2;
Tuple<DtMeshTile, DtPoly> tileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(bestRef);
DtMeshTile bestTile = tileAndPoly.Item1;
DtPoly bestPoly = tileAndPoly.Item2;
// Get parent poly and tile.
long parentRef = 0;
@ -695,20 +695,20 @@ namespace DotRecast.Detour
for (int i = 0, j = bestPoly.vertCount - 1; i < bestPoly.vertCount; j = i++)
{
// Skip non-solid edges.
if ((bestPoly.neis[j] & NavMesh.DT_EXT_LINK) != 0)
if ((bestPoly.neis[j] & DtNavMesh.DT_EXT_LINK) != 0)
{
// Tile border.
bool solid = true;
for (int k = bestTile.polyLinks[bestPoly.index]; k != NavMesh.DT_NULL_LINK; k = bestTile.links[k].next)
for (int k = bestTile.polyLinks[bestPoly.index]; k != DtNavMesh.DT_NULL_LINK; k = bestTile.links[k].next)
{
Link link = bestTile.links[k];
DtLink link = bestTile.links[k];
if (link.edge == j)
{
if (link.refs != 0)
{
Tuple<MeshTile, Poly> linkTileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(link.refs);
MeshTile neiTile = linkTileAndPoly.Item1;
Poly neiPoly = linkTileAndPoly.Item2;
Tuple<DtMeshTile, DtPoly> linkTileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(link.refs);
DtMeshTile neiTile = linkTileAndPoly.Item1;
DtPoly neiPoly = linkTileAndPoly.Item2;
if (filter.PassFilter(link.refs, neiTile, neiPoly))
{
solid = false;
@ -757,9 +757,9 @@ namespace DotRecast.Detour
bestvi = RcVec3f.Of(bestTile.data.verts, vi);
}
for (int i = bestTile.polyLinks[bestPoly.index]; i != NavMesh.DT_NULL_LINK; i = bestTile.links[i].next)
for (int i = bestTile.polyLinks[bestPoly.index]; i != DtNavMesh.DT_NULL_LINK; i = bestTile.links[i].next)
{
Link link = bestTile.links[i];
DtLink link = bestTile.links[i];
long neighbourRef = link.refs;
// Skip invalid neighbours and do not follow back to parent.
if (neighbourRef == 0 || neighbourRef == parentRef)
@ -768,12 +768,12 @@ namespace DotRecast.Detour
}
// Expand to neighbour.
Tuple<MeshTile, Poly> neighbourTileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(neighbourRef);
MeshTile neighbourTile = neighbourTileAndPoly.Item1;
Poly neighbourPoly = neighbourTileAndPoly.Item2;
Tuple<DtMeshTile, DtPoly> neighbourTileAndPoly = m_nav.GetTileAndPolyByRefUnsafe(neighbourRef);
DtMeshTile neighbourTile = neighbourTileAndPoly.Item1;
DtPoly neighbourPoly = neighbourTileAndPoly.Item2;
// Skip off-mesh connections.
if (neighbourPoly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (neighbourPoly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
continue;
}
@ -793,9 +793,9 @@ namespace DotRecast.Detour
continue;
}
Node neighbourNode = m_nodePool.GetNode(neighbourRef);
DtNode neighbourNode = m_nodePool.GetNode(neighbourRef);
if ((neighbourNode.flags & Node.DT_NODE_CLOSED) != 0)
if ((neighbourNode.flags & DtNode.DT_NODE_CLOSED) != 0)
{
continue;
}
@ -814,23 +814,23 @@ namespace DotRecast.Detour
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
// The node is already in open list and the new result is worse, skip.
if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
{
continue;
}
neighbourNode.id = neighbourRef;
neighbourNode.flags = (neighbourNode.flags & ~Node.DT_NODE_CLOSED);
neighbourNode.flags = (neighbourNode.flags & ~DtNode.DT_NODE_CLOSED);
neighbourNode.pidx = m_nodePool.GetNodeIdx(bestNode);
neighbourNode.total = total;
if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0)
if ((neighbourNode.flags & DtNode.DT_NODE_OPEN) != 0)
{
m_openList.Modify(neighbourNode);
}
else
{
neighbourNode.flags |= Node.DT_NODE_OPEN;
neighbourNode.flags |= DtNode.DT_NODE_OPEN;
m_openList.Push(neighbourNode);
}
}

View File

@ -25,7 +25,7 @@ namespace DotRecast.Detour
{
using static DotRecast.Core.RcMath;
public class NavMeshBuilder
public static class NavMeshBuilder
{
const int MESH_NULL_IDX = 0xffff;
@ -82,12 +82,12 @@ namespace DotRecast.Detour
return axis;
}
public static int Subdivide(BVItem[] items, int nitems, int imin, int imax, int curNode, BVNode[] nodes)
public static int Subdivide(BVItem[] items, int nitems, int imin, int imax, int curNode, DtBVNode[] nodes)
{
int inum = imax - imin;
int icur = curNode;
BVNode node = new BVNode();
DtBVNode node = new DtBVNode();
nodes[curNode++] = node;
if (inum == 1)
@ -144,7 +144,7 @@ namespace DotRecast.Detour
return curNode;
}
private static int CreateBVTree(NavMeshDataCreateParams option, BVNode[] nodes)
private static int CreateBVTree(DtNavMeshCreateParams option, DtBVNode[] nodes)
{
// Build tree
float quantFactor = 1 / option.cs;
@ -262,7 +262,7 @@ namespace DotRecast.Detour
*
* @return created tile data
*/
public static MeshData CreateNavMeshData(NavMeshDataCreateParams option)
public static DtMeshData CreateNavMeshData(DtNavMeshCreateParams option)
{
if (option.vertCount >= 0xffff)
return null;
@ -417,18 +417,18 @@ namespace DotRecast.Detour
}
int bvTreeSize = option.buildBvTree ? option.polyCount * 2 : 0;
MeshHeader header = new MeshHeader();
DtMeshHeader header = new DtMeshHeader();
float[] navVerts = new float[3 * totVertCount];
Poly[] navPolys = new Poly[totPolyCount];
PolyDetail[] navDMeshes = new PolyDetail[option.polyCount];
DtPoly[] navPolys = new DtPoly[totPolyCount];
DtPolyDetail[] navDMeshes = new DtPolyDetail[option.polyCount];
float[] navDVerts = new float[3 * uniqueDetailVertCount];
int[] navDTris = new int[4 * detailTriCount];
BVNode[] navBvtree = new BVNode[bvTreeSize];
OffMeshConnection[] offMeshCons = new OffMeshConnection[storedOffMeshConCount];
DtBVNode[] navBvtree = new DtBVNode[bvTreeSize];
DtOffMeshConnection[] offMeshCons = new DtOffMeshConnection[storedOffMeshConCount];
// Store header
header.magic = MeshHeader.DT_NAVMESH_MAGIC;
header.version = MeshHeader.DT_NAVMESH_VERSION;
header.magic = DtMeshHeader.DT_NAVMESH_MAGIC;
header.version = DtMeshHeader.DT_NAVMESH_VERSION;
header.x = option.tileX;
header.y = option.tileZ;
header.layer = option.tileLayer;
@ -482,12 +482,12 @@ namespace DotRecast.Detour
int src = 0;
for (int i = 0; i < option.polyCount; ++i)
{
Poly p = new Poly(i, nvp);
DtPoly p = new DtPoly(i, nvp);
navPolys[i] = p;
p.vertCount = 0;
p.flags = option.polyFlags[i];
p.SetArea(option.polyAreas[i]);
p.SetType(Poly.DT_POLYTYPE_GROUND);
p.SetType(DtPoly.DT_POLYTYPE_GROUND);
for (int j = 0; j < nvp; ++j)
{
if (option.polys[src + j] == MESH_NULL_IDX)
@ -500,13 +500,13 @@ namespace DotRecast.Detour
if (dir == 0xf) // Border
p.neis[j] = 0;
else if (dir == 0) // Portal x-
p.neis[j] = NavMesh.DT_EXT_LINK | 4;
p.neis[j] = DtNavMesh.DT_EXT_LINK | 4;
else if (dir == 1) // Portal z+
p.neis[j] = NavMesh.DT_EXT_LINK | 2;
p.neis[j] = DtNavMesh.DT_EXT_LINK | 2;
else if (dir == 2) // Portal x+
p.neis[j] = NavMesh.DT_EXT_LINK | 0;
p.neis[j] = DtNavMesh.DT_EXT_LINK | 0;
else if (dir == 3) // Portal z-
p.neis[j] = NavMesh.DT_EXT_LINK | 6;
p.neis[j] = DtNavMesh.DT_EXT_LINK | 6;
}
else
{
@ -527,14 +527,14 @@ namespace DotRecast.Detour
// Only store connections which start from this tile.
if (offMeshConClass[i * 2 + 0] == 0xff)
{
Poly p = new Poly(offMeshPolyBase + n, nvp);
DtPoly p = new DtPoly(offMeshPolyBase + n, nvp);
navPolys[offMeshPolyBase + n] = p;
p.vertCount = 2;
p.verts[0] = offMeshVertsBase + n * 2;
p.verts[1] = offMeshVertsBase + n * 2 + 1;
p.flags = option.offMeshConFlags[i];
p.SetArea(option.offMeshConAreas[i]);
p.SetType(Poly.DT_POLYTYPE_OFFMESH_CONNECTION);
p.SetType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION);
n++;
}
}
@ -549,7 +549,7 @@ namespace DotRecast.Detour
int vbase = 0;
for (int i = 0; i < option.polyCount; ++i)
{
PolyDetail dtl = new PolyDetail();
DtPolyDetail dtl = new DtPolyDetail();
navDMeshes[i] = dtl;
int vb = option.detailMeshes[i * 4 + 0];
int ndv = option.detailMeshes[i * 4 + 1];
@ -576,7 +576,7 @@ namespace DotRecast.Detour
int tbase = 0;
for (int i = 0; i < option.polyCount; ++i)
{
PolyDetail dtl = new PolyDetail();
DtPolyDetail dtl = new DtPolyDetail();
navDMeshes[i] = dtl;
int nv = navPolys[i].vertCount;
dtl.vertBase = 0;
@ -616,14 +616,14 @@ namespace DotRecast.Detour
// Only store connections which start from this tile.
if (offMeshConClass[i * 2 + 0] == 0xff)
{
OffMeshConnection con = new OffMeshConnection();
DtOffMeshConnection con = new DtOffMeshConnection();
offMeshCons[n] = con;
con.poly = (offMeshPolyBase + n);
// Copy connection end-points.
int endPts = i * 2 * 3;
Array.Copy(option.offMeshConVerts, endPts, con.pos, 0, 6);
con.rad = option.offMeshConRad[i];
con.flags = option.offMeshConDir[i] != 0 ? NavMesh.DT_OFFMESH_CON_BIDIR : 0;
con.flags = option.offMeshConDir[i] != 0 ? DtNavMesh.DT_OFFMESH_CON_BIDIR : 0;
con.side = offMeshConClass[i * 2 + 1];
if (option.offMeshConUserID != null)
con.userId = option.offMeshConUserID[i];
@ -631,7 +631,7 @@ namespace DotRecast.Detour
}
}
MeshData nmd = new MeshData();
DtMeshData nmd = new DtMeshData();
nmd.header = header;
nmd.verts = navVerts;
nmd.polys = navPolys;

View File

@ -26,11 +26,11 @@ namespace DotRecast.Detour
*/
public static class NavMeshRaycast
{
public static float? Raycast(NavMesh mesh, RcVec3f src, RcVec3f dst)
public static float? Raycast(DtNavMesh mesh, RcVec3f src, RcVec3f dst)
{
for (int t = 0; t < mesh.GetMaxTiles(); ++t)
{
MeshTile tile = mesh.GetTile(t);
DtMeshTile tile = mesh.GetTile(t);
if (tile != null && tile.data != null)
{
float? intersection = Raycast(tile, src, dst);
@ -44,17 +44,17 @@ namespace DotRecast.Detour
return null;
}
private static float? Raycast(MeshTile tile, RcVec3f sp, RcVec3f sq)
private static float? Raycast(DtMeshTile tile, RcVec3f sp, RcVec3f sq)
{
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly p = tile.data.polys[i];
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
DtPoly p = tile.data.polys[i];
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
continue;
}
PolyDetail pd = tile.data.detailMeshes[i];
DtPolyDetail pd = tile.data.detailMeshes[i];
if (pd != null)
{

View File

@ -24,13 +24,13 @@ namespace DotRecast.Detour
{
public static class NavMeshUtils
{
public static RcVec3f[] GetNavMeshBounds(NavMesh mesh)
public static RcVec3f[] GetNavMeshBounds(DtNavMesh mesh)
{
RcVec3f bmin = RcVec3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
RcVec3f bmax = RcVec3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity);
for (int t = 0; t < mesh.GetMaxTiles(); ++t)
{
MeshTile tile = mesh.GetTile(t);
DtMeshTile tile = mesh.GetTile(t);
if (tile != null && tile.data != null)
{
for (int i = 0; i < tile.data.verts.Length; i += 3)

View File

@ -30,7 +30,7 @@ namespace DotRecast.Detour
private const int MAX_STEER_POINTS = 3;
public static SteerTarget GetSteerTarget(NavMeshQuery navQuery, RcVec3f startPos, RcVec3f endPos,
public static SteerTarget GetSteerTarget(DtNavMeshQuery navQuery, RcVec3f startPos, RcVec3f endPos,
float minTargetDist, List<long> path)
{
// Find steer target.
@ -54,7 +54,7 @@ namespace DotRecast.Detour
while (ns < straightPath.Count)
{
// Stop at Off-Mesh link or when point is further than slop away.
if (((straightPath[ns].GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
if (((straightPath[ns].GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
|| !InRange(straightPath[ns].GetPos(), startPos, minTargetDist, 1000.0f))
break;
ns++;
@ -143,7 +143,7 @@ namespace DotRecast.Detour
// +-S-+-T-+
// |:::| | <-- the step can end up in here, resulting U-turn path.
// +---+---+
public static List<long> FixupShortcuts(List<long> path, NavMeshQuery navQuery)
public static List<long> FixupShortcuts(List<long> path, DtNavMeshQuery navQuery)
{
if (path.Count < 3)
{
@ -153,18 +153,18 @@ namespace DotRecast.Detour
// Get connected polygons
List<long> neis = new List<long>();
Result<Tuple<MeshTile, Poly>> tileAndPoly = navQuery.GetAttachedNavMesh().GetTileAndPolyByRef(path[0]);
Result<Tuple<DtMeshTile, DtPoly>> tileAndPoly = navQuery.GetAttachedNavMesh().GetTileAndPolyByRef(path[0]);
if (tileAndPoly.Failed())
{
return path;
}
MeshTile tile = tileAndPoly.result.Item1;
Poly poly = tileAndPoly.result.Item2;
DtMeshTile tile = tileAndPoly.result.Item1;
DtPoly poly = tileAndPoly.result.Item2;
for (int k = tile.polyLinks[poly.index]; k != NavMesh.DT_NULL_LINK; k = tile.links[k].next)
for (int k = tile.polyLinks[poly.index]; k != DtNavMesh.DT_NULL_LINK; k = tile.links[k].next)
{
Link link = tile.links[k];
DtLink link = tile.links[k];
if (link.refs != 0)
{
neis.Add(link.refs);

View File

@ -24,45 +24,45 @@ namespace DotRecast.Detour.QueryResults
{
public static Result<T> Success<T>(T result)
{
return new Result<T>(result, Status.SUCCSESS, null);
return new Result<T>(result, DtStatus.SUCCSESS, null);
}
public static Result<T> Failure<T>()
{
return new Result<T>(default, Status.FAILURE, null);
return new Result<T>(default, DtStatus.FAILURE, null);
}
public static Result<T> InvalidParam<T>()
{
return new Result<T>(default, Status.FAILURE_INVALID_PARAM, null);
return new Result<T>(default, DtStatus.FAILURE_INVALID_PARAM, null);
}
public static Result<T> Failure<T>(string message)
{
return new Result<T>(default, Status.FAILURE, message);
return new Result<T>(default, DtStatus.FAILURE, message);
}
public static Result<T> InvalidParam<T>(string message)
{
return new Result<T>(default, Status.FAILURE_INVALID_PARAM, message);
return new Result<T>(default, DtStatus.FAILURE_INVALID_PARAM, message);
}
public static Result<T> Failure<T>(T result)
{
return new Result<T>(result, Status.FAILURE, null);
return new Result<T>(result, DtStatus.FAILURE, null);
}
public static Result<T> Partial<T>(T result)
{
return new Result<T>(default, Status.PARTIAL_RESULT, null);
return new Result<T>(default, DtStatus.PARTIAL_RESULT, null);
}
public static Result<T> Of<T>(Status status, string message)
public static Result<T> Of<T>(DtStatus status, string message)
{
return new Result<T>(default, status, message);
}
public static Result<T> Of<T>(Status status, T result)
public static Result<T> Of<T>(DtStatus status, T result)
{
return new Result<T>(result, status, null);
}
@ -71,10 +71,10 @@ namespace DotRecast.Detour.QueryResults
public readonly struct Result<T>
{
public readonly T result;
public readonly Status status;
public readonly DtStatus status;
public readonly string message;
internal Result(T result, Status status, string message)
internal Result(T result, DtStatus status, string message)
{
this.result = result;
this.status = status;

View File

@ -1,25 +0,0 @@
namespace DotRecast.Detour
{
public static class StatusEx
{
public static bool IsFailed(this Status @this)
{
return @this == Status.FAILURE || @this == Status.FAILURE_INVALID_PARAM;
}
public static bool IsInProgress(this Status @this)
{
return @this == Status.IN_PROGRESS;
}
public static bool IsSuccess(this Status @this)
{
return @this == Status.SUCCSESS || @this == Status.PARTIAL_RESULT;
}
public static bool IsPartial(this Status @this)
{
return @this == Status.PARTIAL_RESULT;
}
}
}

View File

@ -22,8 +22,6 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
using static DotRecast.Core.RcMath;
//TODO: (PP) Add comments
public class StraightPathItem
{

View File

@ -3,8 +3,6 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
using static DotRecast.Core.RcMath;
/**
* Calculate the intersection between a polygon and a circle. A dodecagon is used as an approximation of the circle.
*/

View File

@ -51,10 +51,10 @@ public class NavMeshRenderer
return;
}
NavMeshQuery navQuery = sample.GetNavMeshQuery();
DtNavMeshQuery navQuery = sample.GetNavMeshQuery();
DemoInputGeomProvider geom = sample.GetInputGeom();
IList<RecastBuilderResult> rcBuilderResults = sample.GetRecastResults();
NavMesh navMesh = sample.GetNavMesh();
DtNavMesh navMesh = sample.GetNavMesh();
RcSettingsView rcSettingsView = sample.GetSettingsUI();
debugDraw.Fog(true);
debugDraw.DepthMask(true);

View File

@ -102,12 +102,12 @@ public class RecastDebugDraw : DebugDraw
Texture(false);
}
public void DebugDrawNavMeshWithClosedList(NavMesh mesh, NavMeshQuery query, int flags)
public void DebugDrawNavMeshWithClosedList(DtNavMesh mesh, DtNavMeshQuery query, int flags)
{
NavMeshQuery q = (flags & DRAWNAVMESH_CLOSEDLIST) != 0 ? query : null;
DtNavMeshQuery q = (flags & DRAWNAVMESH_CLOSEDLIST) != 0 ? query : null;
for (int i = 0; i < mesh.GetMaxTiles(); ++i)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile != null && tile.data != null)
{
DrawMeshTile(mesh, q, tile, flags);
@ -115,18 +115,18 @@ public class RecastDebugDraw : DebugDraw
}
}
private void DrawMeshTile(NavMesh mesh, NavMeshQuery query, MeshTile tile, int flags)
private void DrawMeshTile(DtNavMesh mesh, DtNavMeshQuery query, DtMeshTile tile, int flags)
{
long @base = mesh.GetPolyRefBase(tile);
int tileNum = NavMesh.DecodePolyIdTile(@base);
int tileNum = DtNavMesh.DecodePolyIdTile(@base);
int tileColor = DuIntToCol(tileNum, 128);
DepthMask(false);
Begin(DebugDrawPrimitives.TRIS);
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly p = tile.data.polys[i];
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
DtPoly p = tile.data.polys[i];
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
continue;
}
@ -171,9 +171,9 @@ public class RecastDebugDraw : DebugDraw
Begin(DebugDrawPrimitives.LINES, 2.0f);
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly p = tile.data.polys[i];
DtPoly p = tile.data.polys[i];
if (p.GetPolyType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (p.GetPolyType() != DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
continue;
}
@ -188,7 +188,7 @@ public class RecastDebugDraw : DebugDraw
col = DuDarkenCol(DuTransCol(AreaToCol(p.GetArea()), 220));
}
OffMeshConnection con = tile.data.offMeshCons[i - tile.data.header.offMeshBase];
DtOffMeshConnection con = tile.data.offMeshCons[i - tile.data.header.offMeshBase];
RcVec3f va = RcVec3f.Of(
tile.data.verts[p.verts[0] * 3], tile.data.verts[p.verts[0] * 3 + 1],
tile.data.verts[p.verts[0] * 3 + 2]
@ -201,7 +201,7 @@ public class RecastDebugDraw : DebugDraw
// Check to see if start and end end-points have links.
bool startSet = false;
bool endSet = false;
for (int k = tile.polyLinks[p.index]; k != NavMesh.DT_NULL_LINK; k = tile.links[k].next)
for (int k = tile.polyLinks[p.index]; k != DtNavMesh.DT_NULL_LINK; k = tile.links[k].next)
{
if (tile.links[k].edge == 0)
{
@ -253,12 +253,12 @@ public class RecastDebugDraw : DebugDraw
DepthMask(true);
}
private void DrawPoly(MeshTile tile, int index, int col)
private void DrawPoly(DtMeshTile tile, int index, int col)
{
Poly p = tile.data.polys[index];
DtPoly p = tile.data.polys[index];
if (tile.data.detailMeshes != null)
{
PolyDetail pd = tile.data.detailMeshes[index];
DtPolyDetail pd = tile.data.detailMeshes[index];
if (pd != null)
{
for (int j = 0; j < pd.triCount; ++j)
@ -297,7 +297,7 @@ public class RecastDebugDraw : DebugDraw
}
}
void DrawPolyBoundaries(MeshTile tile, int col, float linew, bool inner)
void DrawPolyBoundaries(DtMeshTile tile, int col, float linew, bool inner)
{
float thr = 0.01f * 0.01f;
@ -305,9 +305,9 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly p = tile.data.polys[i];
DtPoly p = tile.data.polys[i];
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
continue;
}
@ -322,10 +322,10 @@ public class RecastDebugDraw : DebugDraw
continue;
}
if ((p.neis[j] & NavMesh.DT_EXT_LINK) != 0)
if ((p.neis[j] & DtNavMesh.DT_EXT_LINK) != 0)
{
bool con = false;
for (int k = tile.polyLinks[p.index]; k != NavMesh.DT_NULL_LINK; k = tile.links[k].next)
for (int k = tile.polyLinks[p.index]; k != DtNavMesh.DT_NULL_LINK; k = tile.links[k].next)
{
if (tile.links[k].edge == j)
{
@ -370,7 +370,7 @@ public class RecastDebugDraw : DebugDraw
// This is really slow.
if (tile.data.detailMeshes != null)
{
PolyDetail pd = tile.data.detailMeshes[i];
DtPolyDetail pd = tile.data.detailMeshes[i];
for (int k = 0; k < pd.triCount; ++k)
{
int t = (pd.triBase + k) * 4;
@ -397,7 +397,7 @@ public class RecastDebugDraw : DebugDraw
for (int m = 0, n = 2; m < 3; n = m++)
{
if ((NavMesh.GetDetailTriEdgeFlags(tile.data.detailTris[t + 3], n) & NavMesh.DT_DETAIL_EDGE_BOUNDARY) == 0)
if ((DtNavMesh.GetDetailTriEdgeFlags(tile.data.detailTris[t + 3], n) & DtNavMesh.DT_DETAIL_EDGE_BOUNDARY) == 0)
continue;
if (((tile.data.detailTris[t + 3] >> (n * 2)) & 0x3) == 0)
@ -442,11 +442,11 @@ public class RecastDebugDraw : DebugDraw
return dx * dx + dz * dz;
}
public void DebugDrawNavMeshBVTree(NavMesh mesh)
public void DebugDrawNavMeshBVTree(DtNavMesh mesh)
{
for (int i = 0; i < mesh.GetMaxTiles(); ++i)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile != null && tile.data != null && tile.data.header != null)
{
DrawMeshTileBVTree(tile);
@ -454,14 +454,14 @@ public class RecastDebugDraw : DebugDraw
}
}
private void DrawMeshTileBVTree(MeshTile tile)
private void DrawMeshTileBVTree(DtMeshTile tile)
{
// Draw BV nodes.
float cs = 1.0f / tile.data.header.bvQuantFactor;
Begin(DebugDrawPrimitives.LINES, 1.0f);
for (int i = 0; i < tile.data.header.bvNodeCount; ++i)
{
BVNode n = tile.data.bvTree[i];
DtBVNode n = tile.data.bvTree[i];
if (n.i < 0)
{
continue;
@ -1196,17 +1196,17 @@ public class RecastDebugDraw : DebugDraw
End();
}
public void DebugDrawNavMeshNodes(NavMeshQuery query)
public void DebugDrawNavMeshNodes(DtNavMeshQuery query)
{
NodePool pool = query.GetNodePool();
DtNodePool pool = query.GetNodePool();
if (pool != null)
{
float off = 0.5f;
Begin(DebugDrawPrimitives.POINTS, 4.0f);
foreach (List<Node> nodes in pool.GetNodeMap().Values)
foreach (List<DtNode> nodes in pool.GetNodeMap().Values)
{
foreach (Node node in nodes)
foreach (DtNode node in nodes)
{
if (node == null)
{
@ -1220,9 +1220,9 @@ public class RecastDebugDraw : DebugDraw
End();
Begin(DebugDrawPrimitives.LINES, 2.0f);
foreach (List<Node> nodes in pool.GetNodeMap().Values)
foreach (List<DtNode> nodes in pool.GetNodeMap().Values)
{
foreach (Node node in nodes)
foreach (DtNode node in nodes)
{
if (node == null)
{
@ -1234,7 +1234,7 @@ public class RecastDebugDraw : DebugDraw
continue;
}
Node parent = pool.GetNodeAtIdx(node.pidx);
DtNode parent = pool.GetNodeAtIdx(node.pidx);
if (parent == null)
{
continue;
@ -1249,11 +1249,11 @@ public class RecastDebugDraw : DebugDraw
}
}
public void DebugDrawNavMeshPolysWithFlags(NavMesh mesh, int polyFlags, int col)
public void DebugDrawNavMeshPolysWithFlags(DtNavMesh mesh, int polyFlags, int col)
{
for (int i = 0; i < mesh.GetMaxTiles(); ++i)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile == null || tile.data == null || tile.data.header == null)
{
continue;
@ -1263,7 +1263,7 @@ public class RecastDebugDraw : DebugDraw
for (int j = 0; j < tile.data.header.polyCount; ++j)
{
Poly p = tile.data.polys[j];
DtPoly p = tile.data.polys[j];
if ((p.flags & polyFlags) == 0)
{
continue;
@ -1274,31 +1274,31 @@ public class RecastDebugDraw : DebugDraw
}
}
public void DebugDrawNavMeshPoly(NavMesh mesh, long refs, int col)
public void DebugDrawNavMeshPoly(DtNavMesh mesh, long refs, int col)
{
if (refs == 0)
{
return;
}
Result<Tuple<MeshTile, Poly>> tileAndPolyResult = mesh.GetTileAndPolyByRef(refs);
Result<Tuple<DtMeshTile, DtPoly>> tileAndPolyResult = mesh.GetTileAndPolyByRef(refs);
if (tileAndPolyResult.Failed())
{
return;
}
Tuple<MeshTile, Poly> tileAndPoly = tileAndPolyResult.result;
MeshTile tile = tileAndPoly.Item1;
Poly poly = tileAndPoly.Item2;
Tuple<DtMeshTile, DtPoly> tileAndPoly = tileAndPolyResult.result;
DtMeshTile tile = tileAndPoly.Item1;
DtPoly poly = tileAndPoly.Item2;
DepthMask(false);
int c = DuTransCol(col, 64);
int ip = poly.index;
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
{
OffMeshConnection con = tile.data.offMeshCons[ip - tile.data.header.offMeshBase];
DtOffMeshConnection con = tile.data.offMeshCons[ip - tile.data.header.offMeshBase];
Begin(DebugDrawPrimitives.LINES, 2.0f);
@ -1318,11 +1318,11 @@ public class RecastDebugDraw : DebugDraw
DepthMask(true);
}
public void DebugDrawNavMeshPortals(NavMesh mesh)
public void DebugDrawNavMeshPortals(DtNavMesh mesh)
{
for (int i = 0; i < mesh.GetMaxTiles(); ++i)
{
MeshTile tile = mesh.GetTile(i);
DtMeshTile tile = mesh.GetTile(i);
if (tile.data != null && tile.data.header != null)
{
DrawMeshTilePortal(tile);
@ -1330,7 +1330,7 @@ public class RecastDebugDraw : DebugDraw
}
}
private void DrawMeshTilePortal(MeshTile tile)
private void DrawMeshTilePortal(DtMeshTile tile)
{
float padx = 0.04f;
float pady = tile.data.header.walkableClimb;
@ -1339,11 +1339,11 @@ public class RecastDebugDraw : DebugDraw
for (int side = 0; side < 8; ++side)
{
int m = NavMesh.DT_EXT_LINK | (short)side;
int m = DtNavMesh.DT_EXT_LINK | (short)side;
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
Poly poly = tile.data.polys[i];
DtPoly poly = tile.data.polys[i];
// Create new links.
int nv = poly.vertCount;

View File

@ -307,7 +307,7 @@ public class RecastDemo
private void LoadNavMesh(FileStream file, string filename)
{
NavMesh mesh = null;
DtNavMesh mesh = null;
if (filename.EndsWith(".zip") || filename.EndsWith(".bytes"))
{
UnityAStarPathfindingImporter importer = new UnityAStarPathfindingImporter();
@ -533,7 +533,7 @@ public class RecastDemo
Logger.Information($"build");
Tuple<IList<RecastBuilderResult>, NavMesh> buildResult;
Tuple<IList<RecastBuilderResult>, DtNavMesh> buildResult;
if (settingsUI.IsTiled())
{
buildResult = tileNavMeshBuilder.Build(sample.GetInputGeom(), settingsUI.GetPartitioning(), m_cellSize,

View File

@ -30,13 +30,13 @@ namespace DotRecast.Recast.Demo;
public class Sample
{
private DemoInputGeomProvider inputGeom;
private NavMesh navMesh;
private NavMeshQuery navMeshQuery;
private DtNavMesh navMesh;
private DtNavMeshQuery navMeshQuery;
private readonly RcSettingsView _settingsView;
private IList<RecastBuilderResult> recastResults;
private bool changed;
public Sample(DemoInputGeomProvider inputGeom, IList<RecastBuilderResult> recastResults, NavMesh navMesh,
public Sample(DemoInputGeomProvider inputGeom, IList<RecastBuilderResult> recastResults, DtNavMesh navMesh,
RcSettingsView settingsView, RecastDebugDraw debugDraw)
{
this.inputGeom = inputGeom;
@ -47,9 +47,9 @@ public class Sample
changed = true;
}
private void SetQuery(NavMesh navMesh)
private void SetQuery(DtNavMesh navMesh)
{
navMeshQuery = navMesh != null ? new NavMeshQuery(navMesh) : null;
navMeshQuery = navMesh != null ? new DtNavMeshQuery(navMesh) : null;
}
public DemoInputGeomProvider GetInputGeom()
@ -62,7 +62,7 @@ public class Sample
return recastResults;
}
public NavMesh GetNavMesh()
public DtNavMesh GetNavMesh()
{
return navMesh;
}
@ -72,7 +72,7 @@ public class Sample
return _settingsView;
}
public NavMeshQuery GetNavMeshQuery()
public DtNavMeshQuery GetNavMeshQuery()
{
return navMeshQuery;
}
@ -87,7 +87,7 @@ public class Sample
this.changed = changed;
}
public void Update(DemoInputGeomProvider geom, IList<RecastBuilderResult> recastResults, NavMesh navMesh)
public void Update(DemoInputGeomProvider geom, IList<RecastBuilderResult> recastResults, DtNavMesh navMesh)
{
inputGeom = geom;
this.recastResults = recastResults;

View File

@ -33,7 +33,7 @@ namespace DotRecast.Recast.Demo.Tools;
public class CrowdProfilingTool
{
private readonly Func<CrowdAgentParams> agentParamsSupplier;
private readonly Func<DtCrowdAgentParams> agentParamsSupplier;
private int expandSimOptions = 1;
private int expandCrowdOptions = 1;
private int agents = 1000;
@ -44,14 +44,14 @@ public class CrowdProfilingTool
private float percentTravellers = 15f;
private int pathQueueSize = 32;
private int maxIterations = 300;
private Crowd crowd;
private NavMesh navMesh;
private CrowdConfig config;
private DtCrowd crowd;
private DtNavMesh navMesh;
private DtCrowdConfig config;
private FRand rnd;
private readonly List<FindRandomPointResult> zones = new();
private long crowdUpdateTime;
public CrowdProfilingTool(Func<CrowdAgentParams> agentParamsSupplier)
public CrowdProfilingTool(Func<DtCrowdAgentParams> agentParamsSupplier)
{
this.agentParamsSupplier = agentParamsSupplier;
}
@ -81,8 +81,8 @@ public class CrowdProfilingTool
rnd = new FRand(randomSeed);
CreateCrowd();
CreateZones();
NavMeshQuery navquery = new NavMeshQuery(navMesh);
IQueryFilter filter = new DefaultQueryFilter();
DtNavMeshQuery navquery = new DtNavMeshQuery(navMesh);
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < agents; i++)
{
float tr = rnd.Next();
@ -145,7 +145,7 @@ public class CrowdProfilingTool
}
}
private RcVec3f? GetMobPosition(NavMeshQuery navquery, IQueryFilter filter)
private RcVec3f? GetMobPosition(DtNavMeshQuery navquery, IDtQueryFilter filter)
{
Result<FindRandomPointResult> result = navquery.FindRandomPoint(filter, rnd);
if (result.Succeeded())
@ -156,7 +156,7 @@ public class CrowdProfilingTool
return null;
}
private RcVec3f? GetVillagerPosition(NavMeshQuery navquery, IQueryFilter filter)
private RcVec3f? GetVillagerPosition(DtNavMeshQuery navquery, IDtQueryFilter filter)
{
if (0 < zones.Count)
{
@ -175,8 +175,8 @@ public class CrowdProfilingTool
private void CreateZones()
{
zones.Clear();
IQueryFilter filter = new DefaultQueryFilter();
NavMeshQuery navquery = new NavMeshQuery(navMesh);
IDtQueryFilter filter = new DtQueryDefaultFilter();
DtNavMeshQuery navquery = new DtNavMeshQuery(navMesh);
for (int i = 0; i < numberOfZones; i++)
{
float zoneSeparation = zoneRadius * zoneRadius * 16;
@ -207,10 +207,10 @@ public class CrowdProfilingTool
private void CreateCrowd()
{
crowd = new Crowd(config, navMesh, __ => new DefaultQueryFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
crowd = new DtCrowd(config, navMesh, __ => new DtQueryDefaultFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 10f, 1f, 1f, 2f, 1.5f }));
ObstacleAvoidanceParams option = new ObstacleAvoidanceParams(crowd.GetObstacleAvoidanceParams(0));
DtObstacleAvoidanceParams option = new DtObstacleAvoidanceParams(crowd.GetObstacleAvoidanceParams(0));
// Low (11)
option.velBias = 0.5f;
option.adaptiveDivs = 5;
@ -250,9 +250,9 @@ public class CrowdProfilingTool
long endTime = RcFrequency.Ticks;
if (crowd != null)
{
NavMeshQuery navquery = new NavMeshQuery(navMesh);
IQueryFilter filter = new DefaultQueryFilter();
foreach (CrowdAgent ag in crowd.GetActiveAgents())
DtNavMeshQuery navquery = new DtNavMeshQuery(navMesh);
IDtQueryFilter filter = new DtQueryDefaultFilter();
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
if (NeedsNewTarget(ag))
{
@ -276,7 +276,7 @@ public class CrowdProfilingTool
crowdUpdateTime = (endTime - startTime) / TimeSpan.TicksPerMillisecond;
}
private void MoveMob(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, CrowdAgentData crowAgentData)
private void MoveMob(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, CrowdAgentData crowAgentData)
{
// Move somewhere
Result<FindNearestPolyResult> nearestPoly = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter);
@ -291,7 +291,7 @@ public class CrowdProfilingTool
}
}
private void MoveVillager(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, CrowdAgentData crowAgentData)
private void MoveVillager(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, CrowdAgentData crowAgentData)
{
// Move somewhere close
Result<FindNearestPolyResult> nearestPoly = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter);
@ -306,7 +306,7 @@ public class CrowdProfilingTool
}
}
private void MoveTraveller(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, CrowdAgentData crowAgentData)
private void MoveTraveller(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, CrowdAgentData crowAgentData)
{
// Move to another zone
List<FindRandomPointResult> potentialTargets = new();
@ -325,7 +325,7 @@ public class CrowdProfilingTool
}
}
private bool NeedsNewTarget(CrowdAgent ag)
private bool NeedsNewTarget(DtCrowdAgent ag)
{
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_NONE
|| ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_FAILED)
@ -344,12 +344,12 @@ public class CrowdProfilingTool
return false;
}
public void Setup(float maxAgentRadius, NavMesh nav)
public void Setup(float maxAgentRadius, DtNavMesh nav)
{
navMesh = nav;
if (nav != null)
{
config = new CrowdConfig(maxAgentRadius);
config = new DtCrowdConfig(maxAgentRadius);
}
}
@ -359,14 +359,14 @@ public class CrowdProfilingTool
dd.DepthMask(false);
if (crowd != null)
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
float radius = ag.option.radius;
RcVec3f pos = ag.npos;
dd.DebugDrawCircle(pos.x, pos.y, pos.z, radius, DuRGBA(0, 0, 0, 32), 2.0f);
}
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
CrowdAgentData crowAgentData = (CrowdAgentData)ag.option.userData;
@ -403,9 +403,9 @@ public class CrowdProfilingTool
dd.DepthMask(true);
}
private CrowdAgent AddAgent(RcVec3f p, CrowdAgentType type)
private DtCrowdAgent AddAgent(RcVec3f p, CrowdAgentType type)
{
CrowdAgentParams ap = agentParamsSupplier.Invoke();
DtCrowdAgentParams ap = agentParamsSupplier.Invoke();
ap.userData = new CrowdAgentData(type, p);
return crowd.AddAgent(p, ap);
}
@ -414,9 +414,9 @@ public class CrowdProfilingTool
{
if (crowd != null)
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
CrowdAgentParams option = new CrowdAgentParams();
DtCrowdAgentParams option = new DtCrowdAgentParams();
option.radius = ag.option.radius;
option.height = ag.option.height;
option.maxAcceleration = ag.option.maxAcceleration;

View File

@ -38,10 +38,10 @@ public class CrowdTool : Tool
{
private readonly CrowdToolParams toolParams = new CrowdToolParams();
private Sample sample;
private NavMesh m_nav;
private Crowd crowd;
private DtNavMesh m_nav;
private DtCrowd crowd;
private readonly CrowdProfilingTool profilingTool;
private readonly CrowdAgentDebugInfo m_agentDebug = new CrowdAgentDebugInfo();
private readonly DtCrowdAgentDebugInfo m_agentDebug = new DtCrowdAgentDebugInfo();
private readonly Dictionary<long, CrowdAgentTrail> m_trails = new();
private RcVec3f m_targetPos;
@ -52,7 +52,7 @@ public class CrowdTool : Tool
public CrowdTool()
{
m_agentDebug.vod = new ObstacleAvoidanceDebugData(2048);
m_agentDebug.vod = new DtObstacleAvoidanceDebugData(2048);
profilingTool = new CrowdProfilingTool(GetAgentParams);
}
@ -63,20 +63,20 @@ public class CrowdTool : Tool
sample = psample;
}
NavMesh nav = sample.GetNavMesh();
DtNavMesh nav = sample.GetNavMesh();
if (nav != null && m_nav != nav)
{
m_nav = nav;
CrowdConfig config = new CrowdConfig(sample.GetSettingsUI().GetAgentRadius());
DtCrowdConfig config = new DtCrowdConfig(sample.GetSettingsUI().GetAgentRadius());
crowd = new Crowd(config, nav, __ => new DefaultQueryFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
crowd = new DtCrowd(config, nav, __ => new DtQueryDefaultFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 10f, 1f, 1f, 2f, 1.5f }));
// Setup local avoidance option to different qualities.
// Use mostly default settings, copy from dtCrowd.
ObstacleAvoidanceParams option = new ObstacleAvoidanceParams(crowd.GetObstacleAvoidanceParams(0));
DtObstacleAvoidanceParams option = new DtObstacleAvoidanceParams(crowd.GetObstacleAvoidanceParams(0));
// Low (11)
option.velBias = 0.5f;
@ -128,7 +128,7 @@ public class CrowdTool : Tool
if (shift)
{
// Delete
CrowdAgent ahit = HitTestAgents(s, p);
DtCrowdAgent ahit = HitTestAgents(s, p);
if (ahit != null)
{
RemoveAgent(ahit);
@ -147,16 +147,16 @@ public class CrowdTool : Tool
else if (m_mode == CrowdToolMode.SELECT)
{
// Highlight
CrowdAgent ahit = HitTestAgents(s, p);
DtCrowdAgent ahit = HitTestAgents(s, p);
HilightAgent(ahit);
}
else if (m_mode == CrowdToolMode.TOGGLE_POLYS)
{
NavMesh nav = sample.GetNavMesh();
NavMeshQuery navquery = sample.GetNavMeshQuery();
DtNavMesh nav = sample.GetNavMesh();
DtNavMeshQuery navquery = sample.GetNavMeshQuery();
if (nav != null && navquery != null)
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
RcVec3f halfExtents = crowd.GetQueryExtents();
Result<FindNearestPolyResult> result = navquery.FindNearestPoly(p, halfExtents, filter);
long refs = result.result.GetNearestRef();
@ -172,7 +172,7 @@ public class CrowdTool : Tool
}
}
private void RemoveAgent(CrowdAgent agent)
private void RemoveAgent(DtCrowdAgent agent)
{
crowd.RemoveAgent(agent);
if (agent == m_agentDebug.agent)
@ -183,8 +183,8 @@ public class CrowdTool : Tool
private void AddAgent(RcVec3f p)
{
CrowdAgentParams ap = GetAgentParams();
CrowdAgent ag = crowd.AddAgent(p, ap);
DtCrowdAgentParams ap = GetAgentParams();
DtCrowdAgent ag = crowd.AddAgent(p, ap);
if (ag != null)
{
if (m_targetRef != 0)
@ -208,9 +208,9 @@ public class CrowdTool : Tool
}
}
private CrowdAgentParams GetAgentParams()
private DtCrowdAgentParams GetAgentParams()
{
CrowdAgentParams ap = new CrowdAgentParams();
DtCrowdAgentParams ap = new DtCrowdAgentParams();
ap.radius = sample.GetSettingsUI().GetAgentRadius();
ap.height = sample.GetSettingsUI().GetAgentHeight();
ap.maxAcceleration = 8.0f;
@ -223,12 +223,12 @@ public class CrowdTool : Tool
return ap;
}
private CrowdAgent HitTestAgents(RcVec3f s, RcVec3f p)
private DtCrowdAgent HitTestAgents(RcVec3f s, RcVec3f p)
{
CrowdAgent isel = null;
DtCrowdAgent isel = null;
float tsel = float.MaxValue;
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
RcVec3f bmin = new RcVec3f();
RcVec3f bmax = new RcVec3f();
@ -246,7 +246,7 @@ public class CrowdTool : Tool
return isel;
}
private void GetAgentBounds(CrowdAgent ag, ref RcVec3f bmin, ref RcVec3f bmax)
private void GetAgentBounds(DtCrowdAgent ag, ref RcVec3f bmin, ref RcVec3f bmax)
{
RcVec3f p = ag.npos;
float r = ag.option.radius;
@ -265,8 +265,8 @@ public class CrowdTool : Tool
return;
// Find nearest point on navmesh and set move request to that location.
NavMeshQuery navquery = sample.GetNavMeshQuery();
IQueryFilter filter = crowd.GetFilter(0);
DtNavMeshQuery navquery = sample.GetNavMeshQuery();
IDtQueryFilter filter = crowd.GetFilter(0);
RcVec3f halfExtents = crowd.GetQueryExtents();
if (adjust)
@ -279,7 +279,7 @@ public class CrowdTool : Tool
}
else
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
RcVec3f vel = CalcVel(ag.npos, p, ag.option.maxSpeed);
crowd.RequestMoveVelocity(ag, vel);
@ -297,7 +297,7 @@ public class CrowdTool : Tool
}
else
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
crowd.RequestMoveTarget(ag, m_targetRef, m_targetPos);
}
@ -323,7 +323,7 @@ public class CrowdTool : Tool
RecastDebugDraw dd = renderer.GetDebugDraw();
float rad = sample.GetSettingsUI().GetAgentRadius();
NavMesh nav = sample.GetNavMesh();
DtNavMesh nav = sample.GetNavMesh();
if (nav == null || crowd == null)
return;
@ -340,7 +340,7 @@ public class CrowdTool : Tool
// Draw paths
if (toolParams.m_showPath)
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
if (!toolParams.m_showDetailAll && ag != m_agentDebug.agent)
continue;
@ -360,7 +360,7 @@ public class CrowdTool : Tool
if (toolParams.m_showGrid)
{
float gridy = -float.MaxValue;
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
RcVec3f pos = ag.corridor.GetPos();
gridy = Math.Max(gridy, pos.y);
@ -369,11 +369,11 @@ public class CrowdTool : Tool
gridy += 1.0f;
dd.Begin(QUADS);
ProximityGrid grid = crowd.GetGrid();
DtProximityGrid grid = crowd.GetGrid();
float cs = grid.GetCellSize();
foreach (var (combinedKey, count) in grid.GetItemCounts())
{
ProximityGrid.DecomposeKey(combinedKey, out var x, out var y);
DtProximityGrid.DecomposeKey(combinedKey, out var x, out var y);
if (count != 0)
{
int col = DuRGBA(128, 0, 0, Math.Min(count * 40, 255));
@ -388,7 +388,7 @@ public class CrowdTool : Tool
}
// Trail
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
CrowdAgentTrail trail = m_trails[ag.idx];
RcVec3f pos = ag.npos;
@ -412,7 +412,7 @@ public class CrowdTool : Tool
}
// Corners & co
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
if (toolParams.m_showDetailAll == false && ag != m_agentDebug.agent)
continue;
@ -434,7 +434,7 @@ public class CrowdTool : Tool
}
if ((ag.corners[ag.corners.Count - 1].GetFlags()
& NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
& DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
{
RcVec3f v = ag.corners[ag.corners.Count - 1].GetPos();
dd.Vertex(v.x, v.y, v.z, DuRGBA(192, 0, 0, 192));
@ -498,7 +498,7 @@ public class CrowdTool : Tool
dd.Begin(LINES, 2.0f);
for (int j = 0; j < ag.neis.Count; ++j)
{
CrowdAgent nei = ag.neis[j].agent;
DtCrowdAgent nei = ag.neis[j].agent;
if (nei != null)
{
dd.Vertex(pos.x, pos.y + radius, pos.z, DuRGBA(0, 192, 128, 128));
@ -520,7 +520,7 @@ public class CrowdTool : Tool
}
// Agent cylinders.
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
float radius = ag.option.radius;
RcVec3f pos = ag.npos;
@ -532,7 +532,7 @@ public class CrowdTool : Tool
dd.DebugDrawCircle(pos.x, pos.y, pos.z, radius, col, 2.0f);
}
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
float height = ag.option.height;
float radius = ag.option.radius;
@ -555,13 +555,13 @@ public class CrowdTool : Tool
if (toolParams.m_showVO)
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
if (toolParams.m_showDetailAll == false && ag != m_agentDebug.agent)
continue;
// Draw detail about agent sela
ObstacleAvoidanceDebugData vod = m_agentDebug.vod;
DtObstacleAvoidanceDebugData vod = m_agentDebug.vod;
float dx = ag.npos.x;
float dy = ag.npos.y + ag.option.height;
@ -589,7 +589,7 @@ public class CrowdTool : Tool
}
// Velocity stuff.
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
float radius = ag.option.radius;
float height = ag.option.height;
@ -635,7 +635,7 @@ public class CrowdTool : Tool
if (crowd == null)
return;
NavMesh nav = sample.GetNavMesh();
DtNavMesh nav = sample.GetNavMesh();
if (nav == null)
return;
@ -644,7 +644,7 @@ public class CrowdTool : Tool
long endTime = RcFrequency.Ticks;
// Update agent trails
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
CrowdAgentTrail trail = m_trails[ag.idx];
// Update agent movement trail.
@ -660,7 +660,7 @@ public class CrowdTool : Tool
crowdUpdateTime = (endTime - startTime) / TimeSpan.TicksPerMillisecond;
}
private void HilightAgent(CrowdAgent agent)
private void HilightAgent(DtCrowdAgent agent)
{
m_agentDebug.agent = agent;
}
@ -744,9 +744,9 @@ public class CrowdTool : Tool
int updateFlags = GetUpdateFlags();
profilingTool.UpdateAgentParams(updateFlags, toolParams.m_obstacleAvoidanceType, toolParams.m_separationWeight);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
CrowdAgentParams option = new CrowdAgentParams();
DtCrowdAgentParams option = new DtCrowdAgentParams();
option.radius = ag.option.radius;
option.height = ag.option.height;
option.maxAcceleration = ag.option.maxAcceleration;
@ -768,27 +768,27 @@ public class CrowdTool : Tool
int updateFlags = 0;
if (toolParams.m_anticipateTurns)
{
updateFlags |= CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS;
updateFlags |= DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS;
}
if (toolParams.m_optimizeVis)
{
updateFlags |= CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS;
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS;
}
if (toolParams.m_optimizeTopo)
{
updateFlags |= CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
updateFlags |= DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
}
if (toolParams.m_obstacleAvoidance)
{
updateFlags |= CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
updateFlags |= DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
}
if (toolParams.m_separation)
{
updateFlags |= CrowdAgentParams.DT_CROWD_SEPARATION;
updateFlags |= DtCrowdAgentParams.DT_CROWD_SEPARATION;
}
return updateFlags;

View File

@ -25,7 +25,7 @@ public class TestNavmeshTool : Tool
private bool m_eposSet;
private RcVec3f m_spos;
private RcVec3f m_epos;
private readonly DefaultQueryFilter m_filter;
private readonly DtQueryDefaultFilter m_filter;
private readonly RcVec3f m_polyPickExt = RcVec3f.Of(2, 4, 2);
private long m_startRef;
private long m_endRef;
@ -40,7 +40,7 @@ public class TestNavmeshTool : Tool
private float m_neighbourhoodRadius;
private readonly float[] m_queryPoly = new float[12];
private List<RcVec3f> m_smoothPath;
private Status m_pathFindStatus = Status.FAILURE;
private DtStatus m_pathFindStatus = DtStatus.FAILURE;
private bool enableRaycast = true;
private readonly List<RcVec3f> randomPoints = new();
private bool constrainByCircle;
@ -50,7 +50,7 @@ public class TestNavmeshTool : Tool
public TestNavmeshTool()
{
m_filter = new DefaultQueryFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
m_filter = new DtQueryDefaultFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 1f, 1f, 1f, 2f, 1.5f });
}
@ -110,8 +110,8 @@ public class TestNavmeshTool : Tool
ImGui.Text("Vertices at crossings");
ImGui.Separator();
ImGui.RadioButton("None", ref m_straightPathOptions, 0);
ImGui.RadioButton("Area", ref m_straightPathOptions, NavMeshQuery.DT_STRAIGHTPATH_AREA_CROSSINGS);
ImGui.RadioButton("All", ref m_straightPathOptions, NavMeshQuery.DT_STRAIGHTPATH_ALL_CROSSINGS);
ImGui.RadioButton("Area", ref m_straightPathOptions, DtNavMeshQuery.DT_STRAIGHTPATH_AREA_CROSSINGS);
ImGui.RadioButton("All", ref m_straightPathOptions, DtNavMeshQuery.DT_STRAIGHTPATH_ALL_CROSSINGS);
}
if (m_toolMode == TestNavmeshToolMode.RANDOM_POINTS_IN_CIRCLE)
@ -165,7 +165,7 @@ public class TestNavmeshTool : Tool
return;
}
NavMeshQuery m_navQuery = m_sample.GetNavMeshQuery();
DtNavMeshQuery m_navQuery = m_sample.GetNavMeshQuery();
if (m_sposSet)
{
m_startRef = m_navQuery.FindNearestPoly(m_spos, m_polyPickExt, m_filter).result?.GetNearestRef() ?? 0;
@ -184,13 +184,13 @@ public class TestNavmeshTool : Tool
m_endRef = 0;
}
NavMesh m_navMesh = m_sample.GetNavMesh();
DtNavMesh m_navMesh = m_sample.GetNavMesh();
if (m_toolMode == TestNavmeshToolMode.PATHFIND_FOLLOW)
{
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
{
m_polys = m_navQuery.FindPath(m_startRef, m_endRef, m_spos, m_epos, m_filter,
enableRaycast ? NavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue).result;
enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue).result;
if (0 < m_polys.Count)
{
List<long> polys = new(m_polys);
@ -216,11 +216,11 @@ public class TestNavmeshTool : Tool
break;
}
bool endOfPath = (steerTarget.steerPosFlag & NavMeshQuery.DT_STRAIGHTPATH_END) != 0
bool endOfPath = (steerTarget.steerPosFlag & DtNavMeshQuery.DT_STRAIGHTPATH_END) != 0
? true
: false;
bool offMeshConnection = (steerTarget.steerPosFlag
& NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0
& DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0
? true
: false;
@ -327,7 +327,7 @@ public class TestNavmeshTool : Tool
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
{
m_polys = m_navQuery.FindPath(m_startRef, m_endRef, m_spos, m_epos, m_filter,
enableRaycast ? NavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue).result;
enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue).result;
if (0 < m_polys.Count)
{
// In case of partial path, make sure the end point is clamped to the last polygon.
@ -358,7 +358,7 @@ public class TestNavmeshTool : Tool
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
{
m_pathFindStatus = m_navQuery.InitSlicedFindPath(m_startRef, m_endRef, m_spos, m_epos, m_filter,
enableRaycast ? NavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue);
enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue);
}
}
else if (m_toolMode == TestNavmeshToolMode.RAYCAST)
@ -367,7 +367,7 @@ public class TestNavmeshTool : Tool
if (m_sposSet && m_eposSet && m_startRef != 0)
{
{
Result<RaycastHit> hit = m_navQuery.Raycast(m_startRef, m_spos, m_epos, m_filter, 0, 0);
Result<DtRaycastHit> hit = m_navQuery.Raycast(m_startRef, m_spos, m_epos, m_filter, 0, 0);
if (hit.Succeeded())
{
m_polys = hit.result.path;
@ -533,7 +533,7 @@ public class TestNavmeshTool : Tool
dd.DepthMask(true);
NavMesh m_navMesh = m_sample.GetNavMesh();
DtNavMesh m_navMesh = m_sample.GetNavMesh();
if (m_navMesh == null)
{
return;
@ -629,7 +629,7 @@ public class TestNavmeshTool : Tool
StraightPathItem straightPathItem = m_straightPath[i];
StraightPathItem straightPathItem2 = m_straightPath[i + 1];
int col;
if ((straightPathItem.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
{
col = offMeshCol;
}
@ -650,15 +650,15 @@ public class TestNavmeshTool : Tool
{
StraightPathItem straightPathItem = m_straightPath[i];
int col;
if ((straightPathItem.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_START) != 0)
if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_START) != 0)
{
col = startCol;
}
else if ((straightPathItem.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_END) != 0)
else if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_END) != 0)
{
col = endCol;
}
else if ((straightPathItem.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
else if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
{
col = offMeshCol;
}
@ -947,15 +947,15 @@ public class TestNavmeshTool : Tool
dd.DepthMask(true);
}
private RcVec3f GetPolyCenter(NavMesh navMesh, long refs)
private RcVec3f GetPolyCenter(DtNavMesh navMesh, long refs)
{
RcVec3f center = RcVec3f.Zero;
Result<Tuple<MeshTile, Poly>> tileAndPoly = navMesh.GetTileAndPolyByRef(refs);
Result<Tuple<DtMeshTile, DtPoly>> tileAndPoly = navMesh.GetTileAndPolyByRef(refs);
if (tileAndPoly.Succeeded())
{
MeshTile tile = tileAndPoly.result.Item1;
Poly poly = tileAndPoly.result.Item2;
DtMeshTile tile = tileAndPoly.result.Item1;
DtPoly poly = tileAndPoly.result.Item2;
for (int i = 0; i < poly.vertCount; ++i)
{
int v = poly.verts[i] * 3;
@ -978,7 +978,7 @@ public class TestNavmeshTool : Tool
// TODO Auto-generated method stub
if (m_toolMode == TestNavmeshToolMode.PATHFIND_SLICED)
{
NavMeshQuery m_navQuery = m_sample.GetNavMeshQuery();
DtNavMeshQuery m_navQuery = m_sample.GetNavMeshQuery();
if (m_pathFindStatus.IsInProgress())
{
m_pathFindStatus = m_navQuery.UpdateSlicedFindPath(1).status;
@ -1005,7 +1005,7 @@ public class TestNavmeshTool : Tool
{
Result<List<StraightPathItem>> result = m_navQuery.FindStraightPath(m_spos, epos, m_polys,
MAX_POLYS, NavMeshQuery.DT_STRAIGHTPATH_ALL_CROSSINGS);
MAX_POLYS, DtNavMeshQuery.DT_STRAIGHTPATH_ALL_CROSSINGS);
if (result.Succeeded())
{
m_straightPath = result.result;
@ -1013,7 +1013,7 @@ public class TestNavmeshTool : Tool
}
}
m_pathFindStatus = Status.FAILURE;
m_pathFindStatus = DtStatus.FAILURE;
}
}
}

View File

@ -5,13 +5,13 @@ namespace DotRecast.Recast.DemoTool.Builder
{
public abstract class AbstractNavMeshBuilder
{
protected NavMeshDataCreateParams GetNavMeshCreateParams(DemoInputGeomProvider m_geom, float m_cellSize,
protected DtNavMeshCreateParams GetNavMeshCreateParams(DemoInputGeomProvider m_geom, float m_cellSize,
float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb,
RecastBuilderResult rcResult)
{
RcPolyMesh m_pmesh = rcResult.GetMesh();
RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
for (int i = 0; i < m_pmesh.npolys; ++i)
{
m_pmesh.flags[i] = 1;
@ -66,7 +66,7 @@ namespace DotRecast.Recast.DemoTool.Builder
return option;
}
protected MeshData UpdateAreaAndFlags(MeshData meshData)
protected DtMeshData UpdateAreaAndFlags(DtMeshData meshData)
{
// Update poly flags from areas.
for (int i = 0; i < meshData.polys.Length; ++i)

View File

@ -26,7 +26,7 @@ namespace DotRecast.Recast.DemoTool.Builder
{
public class SoloNavMeshBuilder : AbstractNavMeshBuilder
{
public Tuple<IList<RecastBuilderResult>, NavMesh> Build(DemoInputGeomProvider geom, PartitionType partitionType,
public Tuple<IList<RecastBuilderResult>, DtNavMesh> Build(DemoInputGeomProvider geom, PartitionType partitionType,
float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb,
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
@ -42,9 +42,9 @@ namespace DotRecast.Recast.DemoTool.Builder
vertsPerPoly));
}
private NavMesh BuildNavMesh(MeshData meshData, int vertsPerPoly)
private DtNavMesh BuildNavMesh(DtMeshData meshData, int vertsPerPoly)
{
return new NavMesh(meshData, vertsPerPoly, 0);
return new DtNavMesh(meshData, vertsPerPoly, 0);
}
private RecastBuilderResult BuildRecastResult(DemoInputGeomProvider geom, PartitionType partitionType, float cellSize,
@ -62,10 +62,10 @@ namespace DotRecast.Recast.DemoTool.Builder
return rcBuilder.Build(geom, bcfg);
}
private MeshData BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
private DtMeshData BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
float agentRadius, float agentMaxClimb, RecastBuilderResult result)
{
NavMeshDataCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius,
DtNavMeshCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius,
agentMaxClimb, result);
return UpdateAreaAndFlags(NavMeshBuilder.CreateNavMeshData(option));
}

View File

@ -32,7 +32,7 @@ namespace DotRecast.Recast.DemoTool.Builder
{
}
public Tuple<IList<RecastBuilderResult>, NavMesh> Build(DemoInputGeomProvider geom, PartitionType partitionType,
public Tuple<IList<RecastBuilderResult>, DtNavMesh> Build(DemoInputGeomProvider geom, PartitionType partitionType,
float cellSize, float cellHeight, float agentHeight, float agentRadius, float agentMaxClimb,
float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
@ -64,10 +64,10 @@ namespace DotRecast.Recast.DemoTool.Builder
return rcBuilder.BuildTiles(geom, cfg, Task.Factory);
}
private NavMesh BuildNavMesh(DemoInputGeomProvider geom, List<MeshData> meshData, float cellSize, int tileSize,
private DtNavMesh BuildNavMesh(DemoInputGeomProvider geom, List<DtMeshData> meshData, float cellSize, int tileSize,
int vertsPerPoly)
{
NavMeshParams navMeshParams = new NavMeshParams();
DtNavMeshParams navMeshParams = new DtNavMeshParams();
navMeshParams.orig.x = geom.GetMeshBoundsMin().x;
navMeshParams.orig.y = geom.GetMeshBoundsMin().y;
navMeshParams.orig.z = geom.GetMeshBoundsMin().z;
@ -78,7 +78,7 @@ namespace DotRecast.Recast.DemoTool.Builder
navMeshParams.maxTiles = GetMaxTiles(geom, cellSize, tileSize);
navMeshParams.maxPolys = GetMaxPolysPerTile(geom, cellSize, tileSize);
NavMesh navMesh = new NavMesh(navMeshParams, vertsPerPoly);
DtNavMesh navMesh = new DtNavMesh(navMeshParams, vertsPerPoly);
meshData.ForEach(md => navMesh.AddTile(md, 0, 0));
return navMesh;
}
@ -112,20 +112,20 @@ namespace DotRecast.Recast.DemoTool.Builder
return new int[] { tw, th };
}
private List<MeshData> BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
private List<DtMeshData> BuildMeshData(DemoInputGeomProvider geom, float cellSize, float cellHeight, float agentHeight,
float agentRadius, float agentMaxClimb, List<RecastBuilderResult> results)
{
// Add tiles to nav mesh
List<MeshData> meshData = new List<MeshData>();
List<DtMeshData> meshData = new List<DtMeshData>();
foreach (RecastBuilderResult result in results)
{
int x = result.tileX;
int z = result.tileZ;
NavMeshDataCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight,
DtNavMeshCreateParams option = GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight,
agentRadius, agentMaxClimb, result);
option.tileX = x;
option.tileZ = z;
MeshData md = NavMeshBuilder.CreateNavMeshData(option);
DtMeshData md = NavMeshBuilder.CreateNavMeshData(option);
if (md != null)
{
meshData.Add(UpdateAreaAndFlags(md));

View File

@ -57,39 +57,39 @@ public class AbstractCrowdTest
RcVec3f.Of(18.784092f, 10.197294f, 3.0543678f),
};
protected MeshData nmd;
protected NavMeshQuery query;
protected NavMesh navmesh;
protected Crowd crowd;
protected List<CrowdAgent> agents;
protected DtMeshData nmd;
protected DtNavMeshQuery query;
protected DtNavMesh navmesh;
protected DtCrowd crowd;
protected List<DtCrowdAgent> agents;
[SetUp]
public void SetUp()
{
nmd = new RecastTestMeshBuilder().GetMeshData();
navmesh = new NavMesh(nmd, 6, 0);
query = new NavMeshQuery(navmesh);
CrowdConfig config = new CrowdConfig(0.6f);
crowd = new Crowd(config, navmesh);
ObstacleAvoidanceParams option = new ObstacleAvoidanceParams();
navmesh = new DtNavMesh(nmd, 6, 0);
query = new DtNavMeshQuery(navmesh);
DtCrowdConfig config = new DtCrowdConfig(0.6f);
crowd = new DtCrowd(config, navmesh);
DtObstacleAvoidanceParams option = new DtObstacleAvoidanceParams();
option.velBias = 0.5f;
option.adaptiveDivs = 5;
option.adaptiveRings = 2;
option.adaptiveDepth = 1;
crowd.SetObstacleAvoidanceParams(0, option);
option = new ObstacleAvoidanceParams();
option = new DtObstacleAvoidanceParams();
option.velBias = 0.5f;
option.adaptiveDivs = 5;
option.adaptiveRings = 2;
option.adaptiveDepth = 2;
crowd.SetObstacleAvoidanceParams(1, option);
option = new ObstacleAvoidanceParams();
option = new DtObstacleAvoidanceParams();
option.velBias = 0.5f;
option.adaptiveDivs = 7;
option.adaptiveRings = 2;
option.adaptiveDepth = 3;
crowd.SetObstacleAvoidanceParams(2, option);
option = new ObstacleAvoidanceParams();
option = new DtObstacleAvoidanceParams();
option.velBias = 0.5f;
option.adaptiveDivs = 7;
option.adaptiveRings = 3;
@ -98,9 +98,9 @@ public class AbstractCrowdTest
agents = new();
}
protected CrowdAgentParams GetAgentParams(int updateFlags, int obstacleAvoidanceType)
protected DtCrowdAgentParams GetAgentParams(int updateFlags, int obstacleAvoidanceType)
{
CrowdAgentParams ap = new CrowdAgentParams();
DtCrowdAgentParams ap = new DtCrowdAgentParams();
ap.radius = 0.6f;
ap.height = 2f;
ap.maxAcceleration = 8.0f;
@ -115,7 +115,7 @@ public class AbstractCrowdTest
protected void AddAgentGrid(int size, float distance, int updateFlags, int obstacleAvoidanceType, RcVec3f startPos)
{
CrowdAgentParams ap = GetAgentParams(updateFlags, obstacleAvoidanceType);
DtCrowdAgentParams ap = GetAgentParams(updateFlags, obstacleAvoidanceType);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
@ -132,10 +132,10 @@ public class AbstractCrowdTest
protected void SetMoveTarget(RcVec3f pos, bool adjust)
{
RcVec3f ext = crowd.GetQueryExtents();
IQueryFilter filter = crowd.GetFilter(0);
IDtQueryFilter filter = crowd.GetFilter(0);
if (adjust)
{
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
RcVec3f vel = CalcVel(ag.npos, pos, ag.option.maxSpeed);
crowd.RequestMoveVelocity(ag, vel);
@ -144,7 +144,7 @@ public class AbstractCrowdTest
else
{
Result<FindNearestPolyResult> nearest = query.FindNearestPoly(pos, ext, filter);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
crowd.RequestMoveTarget(ag, nearest.result.GetNearestRef(), nearest.result.GetNearestPos());
}
@ -163,7 +163,7 @@ public class AbstractCrowdTest
protected void DumpActiveAgents(int i)
{
Console.WriteLine(crowd.GetActiveAgents().Count);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Console.WriteLine(ag.state + ", " + ag.targetState);
Console.WriteLine(ag.npos.x + ", " + ag.npos.y + ", " + ag.npos.z);

View File

@ -565,15 +565,15 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality0TVTA()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q0TVTA.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q0TVTA[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q0TVTA[i][1]).Within(0.001f));
@ -588,15 +588,15 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality0TVT()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q0TVT.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q0TVT[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q0TVT[i][1]).Within(0.001f));
@ -611,14 +611,14 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality0TV()
{
int updateFlags = CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS;
int updateFlags = DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS;
AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q0TV.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q0TV[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q0TV[i][1]).Within(0.001f));
@ -633,14 +633,14 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality0T()
{
int updateFlags = CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
int updateFlags = DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
AddAgentGrid(1, 0.4f, updateFlags, 0, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q0T.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q0T[i][0]).Within(0.001));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q0T[i][1]).Within(0.001));
@ -655,15 +655,15 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality1TVTA()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
AddAgentGrid(1, 0.4f, updateFlags, 1, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q1TVTA.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q1TVTA[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q1TVTA[i][1]).Within(0.001f));
@ -678,15 +678,15 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality2TVTA()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
AddAgentGrid(1, 0.4f, updateFlags, 2, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q2TVTA.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q2TVTA[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q2TVTA[i][1]).Within(0.001f));
@ -701,15 +701,15 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality3TVTA()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
AddAgentGrid(1, 0.4f, updateFlags, 3, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q3TVTA.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q3TVTA[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q3TVTA[i][1]).Within(0.001f));
@ -724,16 +724,16 @@ public class Crowd1Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality3TVTAS()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE
| CrowdAgentParams.DT_CROWD_SEPARATION;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE
| DtCrowdAgentParams.DT_CROWD_SEPARATION;
AddAgentGrid(1, 0.4f, updateFlags, 3, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q3TVTAS.Length; i++)
{
crowd.Update(1 / 5f, null);
foreach (CrowdAgent ag in crowd.GetActiveAgents())
foreach (DtCrowdAgent ag in crowd.GetActiveAgents())
{
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q3TVTAS[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q3TVTAS[i][1]).Within(0.001f));

View File

@ -308,15 +308,15 @@ public class Crowd4Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality2TVTA()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
AddAgentGrid(2, 0.3f, updateFlags, 2, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q2TVTA.Length; i++)
{
crowd.Update(1 / 5f, null);
CrowdAgent ag = agents[2];
DtCrowdAgent ag = agents[2];
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q2TVTA[i][0]).Within(0.001f), $"{i}");
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q2TVTA[i][1]).Within(0.001f), $"{i}");
Assert.That(ag.npos.z, Is.EqualTo(EXPECTED_A1Q2TVTA[i][2]).Within(0.001f), $"{i}");
@ -329,16 +329,16 @@ public class Crowd4Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality2TVTAS()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE
| CrowdAgentParams.DT_CROWD_SEPARATION;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE
| DtCrowdAgentParams.DT_CROWD_SEPARATION;
AddAgentGrid(2, 0.3f, updateFlags, 2, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q2TVTAS.Length; i++)
{
crowd.Update(1 / 5f, null);
CrowdAgent ag = agents[2];
DtCrowdAgent ag = agents[2];
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q2TVTAS[i][0]).Within(0.001f), $"{i}");
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q2TVTAS[i][1]).Within(0.001f), $"{i}");
Assert.That(ag.npos.z, Is.EqualTo(EXPECTED_A1Q2TVTAS[i][2]).Within(0.001f), $"{i}");
@ -351,14 +351,14 @@ public class Crowd4Test : AbstractCrowdTest
[Test]
public void TestAgent1Quality2T()
{
int updateFlags = CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
int updateFlags = DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO;
AddAgentGrid(2, 0.3f, updateFlags, 2, startPoss[0]);
SetMoveTarget(endPoss[0], false);
for (int i = 0; i < EXPECTED_A1Q2T.Length; i++)
{
crowd.Update(1 / 5f, null);
CrowdAgent ag = agents[2];
DtCrowdAgent ag = agents[2];
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q2T[i][0]).Within(0.00001f), $"{i} - {ag.npos.x} {EXPECTED_A1Q2T[i][0]}");
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q2T[i][1]).Within(0.00001f), $"{i} - {ag.npos.y} {EXPECTED_A1Q2T[i][1]}");
Assert.That(ag.npos.z, Is.EqualTo(EXPECTED_A1Q2T[i][2]).Within(0.00001f), $"{i} - {ag.npos.z} {EXPECTED_A1Q2T[i][2]}");

View File

@ -99,8 +99,8 @@ public class Crowd4VelocityTest : AbstractCrowdTest
[Test]
public void TestAgent1Quality3TVTA()
{
int updateFlags = CrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| CrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | CrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
int updateFlags = DtCrowdAgentParams.DT_CROWD_ANTICIPATE_TURNS | DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS
| DtCrowdAgentParams.DT_CROWD_OPTIMIZE_TOPO | DtCrowdAgentParams.DT_CROWD_OBSTACLE_AVOIDANCE;
AddAgentGrid(2, 0.3f, updateFlags, 3, endPoss[0]);
SetMoveTarget(endPoss[4], false);
@ -112,7 +112,7 @@ public class Crowd4VelocityTest : AbstractCrowdTest
SetMoveTarget(startPoss[2], true);
}
CrowdAgent ag = agents[1];
DtCrowdAgent ag = agents[1];
Assert.That(ag.npos.x, Is.EqualTo(EXPECTED_A1Q3TVTA[i][0]).Within(0.001f));
Assert.That(ag.npos.y, Is.EqualTo(EXPECTED_A1Q3TVTA[i][1]).Within(0.001f));
Assert.That(ag.npos.z, Is.EqualTo(EXPECTED_A1Q3TVTA[i][2]).Within(0.001f));

View File

@ -27,8 +27,8 @@ namespace DotRecast.Detour.Crowd.Test;
[Parallelizable]
public class PathCorridorTest
{
private readonly PathCorridor corridor = new PathCorridor();
private readonly IQueryFilter filter = new DefaultQueryFilter();
private readonly DtPathCorridor corridor = new DtPathCorridor();
private readonly IDtQueryFilter filter = new DtQueryDefaultFilter();
[SetUp]
public void SetUp()
@ -45,7 +45,7 @@ public class PathCorridorTest
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
Result<List<StraightPathItem>> result = Results.Success(straightPath);
var mockQuery = new Mock<NavMeshQuery>(It.IsAny<NavMesh>());
var mockQuery = new Mock<DtNavMeshQuery>(It.IsAny<DtNavMesh>());
mockQuery.Setup(q => q.FindStraightPath(
It.IsAny<RcVec3f>(),
It.IsAny<RcVec3f>(),
@ -65,11 +65,11 @@ public class PathCorridorTest
straightPath.Add(new StraightPathItem(RcVec3f.Of(10, 20, 30.00001f), 0, 0)); // too close
straightPath.Add(new StraightPathItem(RcVec3f.Of(10, 20, 30.00002f), 0, 0)); // too close
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
straightPath.Add(new StraightPathItem(RcVec3f.Of(12f, 22, 33f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh
straightPath.Add(new StraightPathItem(RcVec3f.Of(12f, 22, 33f), DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh
Result<List<StraightPathItem>> result = Results.Success(straightPath);
var mockQuery = new Mock<NavMeshQuery>(It.IsAny<NavMesh>());
var mockQuery = new Mock<DtNavMeshQuery>(It.IsAny<DtNavMesh>());
var s = mockQuery.Setup(q => q.FindStraightPath(
It.IsAny<RcVec3f>(),
It.IsAny<RcVec3f>(),

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour.Crowd.Test;
public class RecastTestMeshBuilder
{
private readonly MeshData meshData;
private readonly DtMeshData meshData;
public const float m_cellSize = 0.3f;
public const float m_cellHeight = 0.2f;
public const float m_agentHeight = 2.0f;
@ -64,7 +64,7 @@ public class RecastTestMeshBuilder
}
RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
option.verts = m_pmesh.verts;
option.vertCount = m_pmesh.nverts;
option.polys = m_pmesh.polys;
@ -107,7 +107,7 @@ public class RecastTestMeshBuilder
meshData = NavMeshBuilder.CreateNavMeshData(option);
}
public MeshData GetMeshData()
public DtMeshData GetMeshData()
{
return meshData;
}

View File

@ -35,13 +35,13 @@ public class DynamicNavMeshTest
// wait for build to complete
bool _ = future.Result;
// create new query
NavMeshQuery query = new NavMeshQuery(mesh.NavMesh());
IQueryFilter filter = new DefaultQueryFilter();
DtNavMeshQuery query = new DtNavMeshQuery(mesh.NavMesh());
IDtQueryFilter filter = new DtQueryDefaultFilter();
// find path
FindNearestPolyResult start = query.FindNearestPoly(START_POS, EXTENT, filter).result;
FindNearestPolyResult end = query.FindNearestPoly(END_POS, EXTENT, filter).result;
List<long> path = query.FindPath(start.GetNearestRef(), end.GetNearestRef(), start.GetNearestPos(),
end.GetNearestPos(), filter, NavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue).result;
end.GetNearestPos(), filter, DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue).result;
// check path length without any obstacles
Assert.That(path.Count, Is.EqualTo(16));
// place obstacle
@ -52,12 +52,12 @@ public class DynamicNavMeshTest
// wait for update to complete
_ = future.Result;
// create new query
query = new NavMeshQuery(mesh.NavMesh());
query = new DtNavMeshQuery(mesh.NavMesh());
// find path again
start = query.FindNearestPoly(START_POS, EXTENT, filter).result;
end = query.FindNearestPoly(END_POS, EXTENT, filter).result;
path = query.FindPath(start.GetNearestRef(), end.GetNearestRef(), start.GetNearestPos(), end.GetNearestPos(), filter,
NavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue).result;
DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue).result;
// check path length with obstacles
Assert.That(path.Count, Is.EqualTo(19));
// remove obstacle
@ -67,12 +67,12 @@ public class DynamicNavMeshTest
// wait for update to complete
_ = future.Result;
// create new query
query = new NavMeshQuery(mesh.NavMesh());
query = new DtNavMeshQuery(mesh.NavMesh());
// find path one more time
start = query.FindNearestPoly(START_POS, EXTENT, filter).result;
end = query.FindNearestPoly(END_POS, EXTENT, filter).result;
path = query.FindPath(start.GetNearestRef(), end.GetNearestRef(), start.GetNearestPos(), end.GetNearestPos(), filter,
NavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue).result;
DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue).result;
// path length should be back to the initial value
Assert.That(path.Count, Is.EqualTo(16));
}

View File

@ -33,11 +33,11 @@ public class UnityAStarPathfindingImporterTest
[Test]
public void Test_v4_0_6()
{
NavMesh mesh = LoadNavMesh("graph.zip");
DtNavMesh mesh = LoadNavMesh("graph.zip");
RcVec3f startPos = RcVec3f.Of(8.200293f, 2.155071f, -26.176147f);
RcVec3f endPos = RcVec3f.Of(11.971109f, 0.000000f, 8.663261f);
Result<List<long>> path = FindPath(mesh, startPos, endPos);
Assert.That(path.status, Is.EqualTo(Status.SUCCSESS));
Assert.That(path.status, Is.EqualTo(DtStatus.SUCCSESS));
Assert.That(path.result.Count, Is.EqualTo(57));
SaveMesh(mesh, "v4_0_6");
}
@ -45,7 +45,7 @@ public class UnityAStarPathfindingImporterTest
[Test]
public void Test_v4_1_16()
{
NavMesh mesh = LoadNavMesh("graph_v4_1_16.zip");
DtNavMesh mesh = LoadNavMesh("graph_v4_1_16.zip");
RcVec3f startPos = RcVec3f.Of(22.93f, -2.37f, -5.11f);
RcVec3f endPos = RcVec3f.Of(16.81f, -2.37f, 25.52f);
Result<List<long>> path = FindPath(mesh, startPos, endPos);
@ -57,14 +57,14 @@ public class UnityAStarPathfindingImporterTest
[Test]
public void TestBoundsTree()
{
NavMesh mesh = LoadNavMesh("test_boundstree.zip");
DtNavMesh mesh = LoadNavMesh("test_boundstree.zip");
RcVec3f position = RcVec3f.Of(387.52988f, 19.997f, 368.86282f);
mesh.CalcTileLoc(position, out var tileX, out var tileY);
long tileRef = mesh.GetTileRefAt(tileX, tileY, 0);
MeshTile tile = mesh.GetTileByRef(tileRef);
MeshData data = tile.data;
BVNode[] bvNodes = data.bvTree;
DtMeshTile tile = mesh.GetTileByRef(tileRef);
DtMeshData data = tile.data;
DtBVNode[] bvNodes = data.bvTree;
data.bvTree = null; // set BV-Tree empty to get 'clear' search poly without BV
FindNearestPolyResult clearResult = GetNearestPolys(mesh, position)[0]; // check poly to exists
@ -77,7 +77,7 @@ public class UnityAStarPathfindingImporterTest
Assert.That(bvResult.GetNearestRef(), Is.EqualTo(clearResult.GetNearestRef()));
}
private NavMesh LoadNavMesh(string filename)
private DtNavMesh LoadNavMesh(string filename)
{
var filepath = Loader.ToRPath(filename);
using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
@ -85,24 +85,24 @@ public class UnityAStarPathfindingImporterTest
// Import the graphs
UnityAStarPathfindingImporter importer = new UnityAStarPathfindingImporter();
NavMesh[] meshes = importer.Load(fs);
DtNavMesh[] meshes = importer.Load(fs);
return meshes[0];
}
private Result<List<long>> FindPath(NavMesh mesh, RcVec3f startPos, RcVec3f endPos)
private Result<List<long>> FindPath(DtNavMesh mesh, RcVec3f startPos, RcVec3f endPos)
{
// Perform a simple pathfinding
NavMeshQuery query = new NavMeshQuery(mesh);
IQueryFilter filter = new DefaultQueryFilter();
DtNavMeshQuery query = new DtNavMeshQuery(mesh);
IDtQueryFilter filter = new DtQueryDefaultFilter();
FindNearestPolyResult[] polys = GetNearestPolys(mesh, startPos, endPos);
return query.FindPath(polys[0].GetNearestRef(), polys[1].GetNearestRef(), startPos, endPos, filter);
}
private FindNearestPolyResult[] GetNearestPolys(NavMesh mesh, params RcVec3f[] positions)
private FindNearestPolyResult[] GetNearestPolys(DtNavMesh mesh, params RcVec3f[] positions)
{
NavMeshQuery query = new NavMeshQuery(mesh);
IQueryFilter filter = new DefaultQueryFilter();
DtNavMeshQuery query = new DtNavMeshQuery(mesh);
IDtQueryFilter filter = new DtQueryDefaultFilter();
RcVec3f extents = RcVec3f.Of(0.1f, 0.1f, 0.1f);
FindNearestPolyResult[] results = new FindNearestPolyResult[positions.Length];
@ -118,12 +118,12 @@ public class UnityAStarPathfindingImporterTest
return results;
}
private void SaveMesh(NavMesh mesh, string filePostfix)
private void SaveMesh(DtNavMesh mesh, string filePostfix)
{
// Set the flag to RecastDemo work properly
for (int i = 0; i < mesh.GetTileCount(); i++)
{
foreach (Poly p in mesh.GetTile(i).data.polys)
foreach (DtPoly p in mesh.GetTile(i).data.polys)
{
p.flags = 1;
}

View File

@ -52,18 +52,18 @@ public abstract class AbstractDetourTest
RcVec3f.Of(18.784092f, 10.197294f, 3.0543678f),
};
protected NavMeshQuery query;
protected NavMesh navmesh;
protected DtNavMeshQuery query;
protected DtNavMesh navmesh;
[SetUp]
public void SetUp()
{
navmesh = CreateNavMesh();
query = new NavMeshQuery(navmesh);
query = new DtNavMeshQuery(navmesh);
}
protected NavMesh CreateNavMesh()
protected DtNavMesh CreateNavMesh()
{
return new NavMesh(new RecastTestMeshBuilder().GetMeshData(), 6, 0);
return new DtNavMesh(new RecastTestMeshBuilder().GetMeshData(), 6, 0);
}
}

View File

@ -48,7 +48,7 @@ public class FindDistanceToWallTest : AbstractDetourTest
[Test]
public void TestFindDistanceToWall()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
RcVec3f startPos = startPoss[i];

View File

@ -54,7 +54,7 @@ public class FindLocalNeighbourhoodTest : AbstractDetourTest
[Test]
public void TestFindNearestPoly()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
RcVec3f startPos = startPoss[i];

View File

@ -37,7 +37,7 @@ public class FindNearestPolyTest : AbstractDetourTest
[Test]
public void TestFindNearestPoly()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
RcVec3f extents = RcVec3f.Of(2, 4, 2);
for (int i = 0; i < startRefs.Length; i++)
{
@ -52,24 +52,11 @@ public class FindNearestPolyTest : AbstractDetourTest
}
}
public class EmptyQueryFilter : IQueryFilter
{
public bool PassFilter(long refs, MeshTile tile, Poly poly)
{
return false;
}
public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile,
Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly)
{
return 0;
}
}
[Test]
public void ShouldReturnStartPosWhenNoPolyIsValid()
{
var filter = new EmptyQueryFilter();
var filter = new DtQueryEmptyFilter();
RcVec3f extents = RcVec3f.Of(2, 4, 2);
for (int i = 0; i < startRefs.Length; i++)
{

View File

@ -26,10 +26,10 @@ namespace DotRecast.Detour.Test;
[Parallelizable]
public class FindPathTest : AbstractDetourTest
{
private static readonly Status[] STATUSES =
private static readonly DtStatus[] STATUSES =
{
Status.SUCCSESS, Status.PARTIAL_RESULT, Status.SUCCSESS, Status.SUCCSESS,
Status.SUCCSESS
DtStatus.SUCCSESS, DtStatus.PARTIAL_RESULT, DtStatus.SUCCSESS, DtStatus.SUCCSESS,
DtStatus.SUCCSESS
};
private static readonly long[][] RESULTS =
@ -131,7 +131,7 @@ public class FindPathTest : AbstractDetourTest
[Test]
public void TestFindPath()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];
@ -151,16 +151,16 @@ public class FindPathTest : AbstractDetourTest
[Test]
public void TestFindPathSliced()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];
long endRef = endRefs[i];
var startPos = startPoss[i];
var endPos = endPoss[i];
query.InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, NavMeshQuery.DT_FINDPATH_ANY_ANGLE);
Status status = Status.IN_PROGRESS;
while (status == Status.IN_PROGRESS)
query.InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE);
DtStatus status = DtStatus.IN_PROGRESS;
while (status == DtStatus.IN_PROGRESS)
{
Result<int> res = query.UpdateSlicedFindPath(10);
status = res.status;
@ -179,7 +179,7 @@ public class FindPathTest : AbstractDetourTest
[Test]
public void TestFindPathStraight()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < STRAIGHT_PATHS.Length; i++)
{
// startRefs.Length; i++) {

View File

@ -101,7 +101,7 @@ public class FindPolysAroundCircleTest : AbstractDetourTest
[Test]
public void TestFindPolysAroundCircle()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -128,7 +128,7 @@ public class FindPolysAroundShapeTest : AbstractDetourTest
[Test]
public void TestFindPolysAroundShape()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -77,7 +77,7 @@ public class GetPolyWallSegmentsTest : AbstractDetourTest
[Test]
public void TestFindDistanceToWall()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
Result<GetPolyWallSegmentsResult> result = query.GetPolyWallSegments(startRefs[i], true, filter);

View File

@ -27,7 +27,7 @@ namespace DotRecast.Detour.Test.Io;
public class MeshDataReaderWriterTest
{
private const int VERTS_PER_POLYGON = 6;
private MeshData meshData;
private DtMeshData meshData;
[SetUp]
public void SetUp()
@ -71,7 +71,7 @@ public class MeshDataReaderWriterTest
using var bris = new BinaryReader(ms);
MeshDataReader reader = new MeshDataReader();
MeshData readData = reader.Read(bris, VERTS_PER_POLYGON);
DtMeshData readData = reader.Read(bris, VERTS_PER_POLYGON);
Assert.That(readData.header.vertCount, Is.EqualTo(meshData.header.vertCount));
Assert.That(readData.header.polyCount, Is.EqualTo(meshData.header.polyCount));

View File

@ -35,11 +35,11 @@ public class MeshSetReaderTest
byte[] @is = Loader.ToBytes("all_tiles_navmesh.bin");
using var ms = new MemoryStream(@is);
using var bris = new BinaryReader(ms);
NavMesh mesh = reader.Read(bris, 6);
DtNavMesh mesh = reader.Read(bris, 6);
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));
List<MeshTile> tiles = mesh.GetTilesAt(4, 7);
List<DtMeshTile> tiles = mesh.GetTilesAt(4, 7);
Assert.That(tiles.Count, Is.EqualTo(1));
Assert.That(tiles[0].data.polys.Length, Is.EqualTo(7));
Assert.That(tiles[0].data.verts.Length, Is.EqualTo(22 * 3));
@ -64,11 +64,11 @@ public class MeshSetReaderTest
using var ms = new MemoryStream(@is);
using var bris = new BinaryReader(ms);
NavMesh mesh = reader.Read(bris, 6);
DtNavMesh mesh = reader.Read(bris, 6);
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));
List<MeshTile> tiles = mesh.GetTilesAt(6, 9);
List<DtMeshTile> tiles = mesh.GetTilesAt(6, 9);
Assert.That(tiles.Count, Is.EqualTo(1));
Assert.That(tiles[0].data.polys.Length, Is.EqualTo(2));
Assert.That(tiles[0].data.verts.Length, Is.EqualTo(7 * 3));
@ -93,11 +93,11 @@ public class MeshSetReaderTest
using var ms = new MemoryStream(@is);
using var bris = new BinaryReader(ms);
NavMesh mesh = reader.Read32Bit(bris, 6);
DtNavMesh mesh = reader.Read32Bit(bris, 6);
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));
List<MeshTile> tiles = mesh.GetTilesAt(6, 9);
List<DtMeshTile> tiles = mesh.GetTilesAt(6, 9);
Assert.That(tiles.Count, Is.EqualTo(1));
Assert.That(tiles[0].data.polys.Length, Is.EqualTo(2));
Assert.That(tiles[0].data.verts.Length, Is.EqualTo(7 * 3));

View File

@ -65,7 +65,7 @@ public class MeshSetReaderWriterTest
header.option.maxTiles = m_maxTiles;
header.option.maxPolys = m_maxPolysPerTile;
header.numTiles = 0;
NavMesh mesh = new NavMesh(header.option, 6);
DtNavMesh mesh = new DtNavMesh(header.option, 6);
RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax();
@ -81,7 +81,7 @@ public class MeshSetReaderWriterTest
m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, bmin, bmax, x, y);
TestDetourBuilder db = new TestDetourBuilder();
MeshData data = db.Build(geom, bcfg, m_agentHeight, m_agentRadius, m_agentMaxClimb, x, y, true);
DtMeshData data = db.Build(geom, bcfg, m_agentHeight, m_agentRadius, m_agentMaxClimb, x, y, true);
if (data != null)
{
mesh.RemoveTile(mesh.GetTileRefAt(x, y, 0));
@ -100,7 +100,7 @@ public class MeshSetReaderWriterTest
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));
List<MeshTile> tiles = mesh.GetTilesAt(6, 9);
List<DtMeshTile> tiles = mesh.GetTilesAt(6, 9);
Assert.That(tiles.Count, Is.EqualTo(1));
Assert.That(tiles[0].data.polys.Length, Is.EqualTo(2));
Assert.That(tiles[0].data.verts.Length, Is.EqualTo(7 * 3));

View File

@ -68,7 +68,7 @@ public class MoveAlongSurfaceTest : AbstractDetourTest
[Test]
public void TestMoveAlongSurface()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -23,7 +23,7 @@ namespace DotRecast.Detour.Test;
[Parallelizable]
public class NavMeshBuilderTest
{
private MeshData nmd;
private DtMeshData nmd;
[SetUp]
public void SetUp()
@ -56,7 +56,7 @@ public class NavMeshBuilderTest
Assert.That(nmd.offMeshCons[0].rad, Is.EqualTo(0.1f));
Assert.That(nmd.offMeshCons[0].poly, Is.EqualTo(118));
Assert.That(nmd.offMeshCons[0].flags, Is.EqualTo(NavMesh.DT_OFFMESH_CON_BIDIR));
Assert.That(nmd.offMeshCons[0].flags, Is.EqualTo(DtNavMesh.DT_OFFMESH_CON_BIDIR));
Assert.That(nmd.offMeshCons[0].side, Is.EqualTo(0xFF));
Assert.That(nmd.offMeshCons[0].userId, Is.EqualTo(0x4567));
Assert.That(nmd.polys[118].vertCount, Is.EqualTo(2));
@ -64,6 +64,6 @@ public class NavMeshBuilderTest
Assert.That(nmd.polys[118].verts[1], Is.EqualTo(224));
Assert.That(nmd.polys[118].flags, Is.EqualTo(12));
Assert.That(nmd.polys[118].GetArea(), Is.EqualTo(2));
Assert.That(nmd.polys[118].GetPolyType(), Is.EqualTo(Poly.DT_POLYTYPE_OFFMESH_CONNECTION));
Assert.That(nmd.polys[118].GetPolyType(), Is.EqualTo(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION));
}
}

View File

@ -32,12 +32,12 @@ public class RandomPointTest : AbstractDetourTest
public void TestRandom()
{
FRand f = new FRand(1);
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < 1000; i++)
{
Result<FindRandomPointResult> point = query.FindRandomPoint(filter, f);
Assert.That(point.Succeeded(), Is.True);
Tuple<MeshTile, Poly> tileAndPoly = navmesh.GetTileAndPolyByRef(point.result.GetRandomRef()).result;
Tuple<DtMeshTile, DtPoly> tileAndPoly = navmesh.GetTileAndPolyByRef(point.result.GetRandomRef()).result;
float[] bmin = new float[2];
float[] bmax = new float[2];
for (int j = 0; j < tileAndPoly.Item2.vertCount; j++)
@ -60,7 +60,7 @@ public class RandomPointTest : AbstractDetourTest
public void TestRandomAroundCircle()
{
FRand f = new FRand(1);
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
FindRandomPointResult point = query.FindRandomPoint(filter, f).result;
for (int i = 0; i < 1000; i++)
{
@ -68,7 +68,7 @@ public class RandomPointTest : AbstractDetourTest
5f, filter, f);
Assert.That(result.Failed(), Is.False);
point = result.result;
Tuple<MeshTile, Poly> tileAndPoly = navmesh.GetTileAndPolyByRef(point.GetRandomRef()).result;
Tuple<DtMeshTile, DtPoly> tileAndPoly = navmesh.GetTileAndPolyByRef(point.GetRandomRef()).result;
float[] bmin = new float[2];
float[] bmax = new float[2];
for (int j = 0; j < tileAndPoly.Item2.vertCount; j++)
@ -91,7 +91,7 @@ public class RandomPointTest : AbstractDetourTest
public void TestRandomWithinCircle()
{
FRand f = new FRand(1);
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
FindRandomPointResult point = query.FindRandomPoint(filter, f).result;
float radius = 5f;
for (int i = 0; i < 1000; i++)
@ -109,7 +109,7 @@ public class RandomPointTest : AbstractDetourTest
public void TestPerformance()
{
FRand f = new FRand(1);
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
FindRandomPointResult point = query.FindRandomPoint(filter, f).result;
float radius = 5f;
// jvm warmup

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour.Test;
public class RecastTestMeshBuilder
{
private readonly MeshData meshData;
private readonly DtMeshData meshData;
private const float m_cellSize = 0.3f;
private const float m_cellHeight = 0.2f;
private const float m_agentHeight = 2.0f;
@ -65,7 +65,7 @@ public class RecastTestMeshBuilder
}
RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
option.verts = m_pmesh.verts;
option.vertCount = m_pmesh.nverts;
option.polys = m_pmesh.polys;
@ -108,7 +108,7 @@ public class RecastTestMeshBuilder
meshData = NavMeshBuilder.CreateNavMeshData(option);
}
public MeshData GetMeshData()
public DtMeshData GetMeshData()
{
return meshData;
}

View File

@ -23,7 +23,7 @@ namespace DotRecast.Detour.Test;
public class TestDetourBuilder : DetourBuilder
{
public MeshData Build(IInputGeomProvider geom, RecastBuilderConfig rcConfig, float agentHeight, float agentRadius,
public DtMeshData Build(IInputGeomProvider geom, RecastBuilderConfig rcConfig, float agentHeight, float agentRadius,
float agentMaxClimb, int x, int y, bool applyRecastDemoFlags)
{
RecastBuilder rcBuilder = new RecastBuilder();
@ -59,15 +59,15 @@ public class TestDetourBuilder : DetourBuilder
}
RcPolyMeshDetail dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = GetNavMeshCreateParams(rcConfig.cfg, pmesh, dmesh, agentHeight, agentRadius,
DtNavMeshCreateParams option = GetNavMeshCreateParams(rcConfig.cfg, pmesh, dmesh, agentHeight, agentRadius,
agentMaxClimb);
return Build(option, x, y);
}
public NavMeshDataCreateParams GetNavMeshCreateParams(RcConfig rcConfig, RcPolyMesh pmesh, RcPolyMeshDetail dmesh,
public DtNavMeshCreateParams GetNavMeshCreateParams(RcConfig rcConfig, RcPolyMesh pmesh, RcPolyMeshDetail dmesh,
float agentHeight, float agentRadius, float agentMaxClimb)
{
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
option.verts = pmesh.verts;
option.vertCount = pmesh.nverts;
option.polys = pmesh.polys;

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour.Test;
public class TestTiledNavMeshBuilder
{
private readonly NavMesh navMesh;
private readonly DtNavMesh navMesh;
private const float m_cellSize = 0.3f;
private const float m_cellHeight = 0.2f;
private const float m_agentHeight = 2.0f;
@ -58,13 +58,13 @@ public class TestTiledNavMeshBuilder
float m_detailSampleMaxError, int m_tileSize)
{
// Create empty nav mesh
NavMeshParams navMeshParams = new NavMeshParams();
DtNavMeshParams navMeshParams = new DtNavMeshParams();
navMeshParams.orig = m_geom.GetMeshBoundsMin();
navMeshParams.tileWidth = m_tileSize * m_cellSize;
navMeshParams.tileHeight = m_tileSize * m_cellSize;
navMeshParams.maxTiles = 128;
navMeshParams.maxPolys = 32768;
navMesh = new NavMesh(navMeshParams, 6);
navMesh = new DtNavMesh(navMeshParams, 6);
// Build all tiles
RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize),
@ -89,7 +89,7 @@ public class TestTiledNavMeshBuilder
pmesh.flags[i] = 1;
}
NavMeshDataCreateParams option = new NavMeshDataCreateParams();
DtNavMeshCreateParams option = new DtNavMeshCreateParams();
option.verts = pmesh.verts;
option.vertCount = pmesh.nverts;
option.polys = pmesh.polys;
@ -117,7 +117,7 @@ public class TestTiledNavMeshBuilder
}
}
public NavMesh GetNavMesh()
public DtNavMesh GetNavMesh()
{
return navMesh;
}

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour.Test;
[Parallelizable]
public class TiledFindPathTest
{
private static readonly Status[] STATUSES = { Status.SUCCSESS };
private static readonly DtStatus[] STATUSES = { DtStatus.SUCCSESS };
private static readonly long[][] RESULTS =
{
@ -46,17 +46,17 @@ public class TiledFindPathTest
protected static readonly RcVec3f[] START_POS = { RcVec3f.Of(39.447338f, 9.998177f, -0.784811f) };
protected static readonly RcVec3f[] END_POS = { RcVec3f.Of(19.292645f, 11.611748f, -57.750366f) };
protected NavMeshQuery query;
protected NavMesh navmesh;
protected DtNavMeshQuery query;
protected DtNavMesh navmesh;
[SetUp]
public void SetUp()
{
navmesh = CreateNavMesh();
query = new NavMeshQuery(navmesh);
query = new DtNavMeshQuery(navmesh);
}
protected NavMesh CreateNavMesh()
protected DtNavMesh CreateNavMesh()
{
return new TestTiledNavMeshBuilder().GetNavMesh();
}
@ -64,7 +64,7 @@ public class TiledFindPathTest
[Test]
public void TestFindPath()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < START_REFS.Length; i++)
{
long startRef = START_REFS[i];

View File

@ -41,7 +41,7 @@ public class AbstractTileCacheTest
protected class TestTileCacheMeshProcess : ITileCacheMeshProcess
{
public void Process(NavMeshDataCreateParams option)
public void Process(DtNavMeshCreateParams option)
{
for (int i = 0; i < option.polyCount; ++i)
{
@ -65,13 +65,13 @@ public class AbstractTileCacheTest
option.maxSimplificationError = m_edgeMaxError;
option.maxTiles = tw * th * EXPECTED_LAYERS_PER_TILE;
option.maxObstacles = 128;
NavMeshParams navMeshParams = new NavMeshParams();
DtNavMeshParams navMeshParams = new DtNavMeshParams();
navMeshParams.orig = geom.GetMeshBoundsMin();
navMeshParams.tileWidth = m_tileSize * m_cellSize;
navMeshParams.tileHeight = m_tileSize * m_cellSize;
navMeshParams.maxTiles = 256;
navMeshParams.maxPolys = 16384;
NavMesh navMesh = new NavMesh(navMeshParams, 6);
DtNavMesh navMesh = new DtNavMesh(navMeshParams, 6);
TileCache tc = new TileCache(option, new TileCacheStorageParams(order, cCompatibility), navMesh,
TileCacheCompressorFactory.Get(cCompatibility), new TestTileCacheMeshProcess());
return tc;

View File

@ -53,9 +53,9 @@ public class TileCacheReaderTest
Assert.That(tc.GetTileCount(), Is.EqualTo(168));
// Tile0: Tris: 1, Verts: 4 Detail Meshed: 1 Detail Verts: 0 Detail Tris: 2
// Verts: -2.269517, 28.710686, 28.710686
MeshTile tile = tc.GetNavMesh().GetTile(0);
MeshData data = tile.data;
MeshHeader header = data.header;
DtMeshTile tile = tc.GetNavMesh().GetTile(0);
DtMeshData data = tile.data;
DtMeshHeader header = data.header;
Assert.That(header.vertCount, Is.EqualTo(4));
Assert.That(header.polyCount, Is.EqualTo(1));
Assert.That(header.detailMeshCount, Is.EqualTo(1));
@ -151,9 +151,9 @@ public class TileCacheReaderTest
Assert.That(tc.GetTileCount(), Is.EqualTo(168));
// Tile0: Tris: 8, Verts: 18 Detail Meshed: 8 Detail Verts: 0 Detail Tris: 14
// Verts: 14.997294, 15.484785, 15.484785
MeshTile tile = tc.GetNavMesh().GetTile(0);
MeshData data = tile.data;
MeshHeader header = data.header;
DtMeshTile tile = tc.GetNavMesh().GetTile(0);
DtMeshData data = tile.data;
DtMeshHeader header = data.header;
Assert.That(header.vertCount, Is.EqualTo(18));
Assert.That(header.polyCount, Is.EqualTo(8));
Assert.That(header.detailMeshCount, Is.EqualTo(8));

View File

@ -82,9 +82,9 @@ public class TileCacheReaderWriterTest : AbstractTileCacheTest
Assert.That(tc.GetParams().maxObstacles, Is.EqualTo(128));
Assert.That(tc.GetTileCount(), Is.EqualTo(168));
// Tile0: Tris: 8, Verts: 18 Detail Meshed: 8 Detail Verts: 0 Detail Tris: 14
MeshTile tile = tc.GetNavMesh().GetTile(0);
MeshData data = tile.data;
MeshHeader header = data.header;
DtMeshTile tile = tc.GetNavMesh().GetTile(0);
DtMeshData data = tile.data;
DtMeshHeader header = data.header;
Assert.That(header.vertCount, Is.EqualTo(18));
Assert.That(header.polyCount, Is.EqualTo(8));
Assert.That(header.detailMeshCount, Is.EqualTo(8));

View File

@ -43,8 +43,8 @@ public class TempObstaclesTest : AbstractTileCacheTest
tc.BuildNavMeshTile(refs);
}
List<MeshTile> tiles = tc.GetNavMesh().GetTilesAt(1, 4);
MeshTile tile = tiles[0];
List<DtMeshTile> tiles = tc.GetNavMesh().GetTilesAt(1, 4);
DtMeshTile tile = tiles[0];
Assert.That(tile.data.header.vertCount, Is.EqualTo(16));
Assert.That(tile.data.header.polyCount, Is.EqualTo(6));
long o = tc.AddObstacle(RcVec3f.Of(-1.815208f, 9.998184f, -20.307983f), 1f, 2f);
@ -77,8 +77,8 @@ public class TempObstaclesTest : AbstractTileCacheTest
tc.BuildNavMeshTile(refs);
}
List<MeshTile> tiles = tc.GetNavMesh().GetTilesAt(1, 4);
MeshTile tile = tiles[0];
List<DtMeshTile> tiles = tc.GetNavMesh().GetTilesAt(1, 4);
DtMeshTile tile = tiles[0];
Assert.That(tile.data.header.vertCount, Is.EqualTo(16));
Assert.That(tile.data.header.polyCount, Is.EqualTo(6));
long o = tc.AddBoxObstacle(

View File

@ -32,8 +32,8 @@ public class TileCacheFindPathTest : AbstractTileCacheTest
{
private readonly RcVec3f start = RcVec3f.Of(39.44734f, 9.998177f, -0.784811f);
private readonly RcVec3f end = RcVec3f.Of(19.292645f, 11.611748f, -57.750366f);
private readonly NavMesh navmesh;
private readonly NavMeshQuery query;
private readonly DtNavMesh navmesh;
private readonly DtNavMeshQuery query;
public TileCacheFindPathTest()
{
@ -41,13 +41,13 @@ public class TileCacheFindPathTest : AbstractTileCacheTest
using var @is = new BinaryReader(msis);
TileCache tcC = new TileCacheReader().Read(@is, 6, new TestTileCacheMeshProcess());
navmesh = tcC.GetNavMesh();
query = new NavMeshQuery(navmesh);
query = new DtNavMeshQuery(navmesh);
}
[Test]
public void TestFindPath()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
RcVec3f extents = RcVec3f.Of(2f, 4f, 2f);
Result<FindNearestPolyResult> findPolyStart = query.FindNearestPoly(start, extents, filter);
Result<FindNearestPolyResult> findPolyEnd = query.FindNearestPoly(end, extents, filter);

View File

@ -34,7 +34,7 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
protected readonly long[] endRefs = { 281474986147841L };
protected readonly RcVec3f[] startPoss = { RcVec3f.Of(39.447338f, 9.998177f, -0.784811f) };
protected readonly RcVec3f[] endPoss = { RcVec3f.Of(19.292645f, 11.611748f, -57.750366f) };
private readonly Status[] statuses = { Status.SUCCSESS };
private readonly DtStatus[] statuses = { DtStatus.SUCCSESS };
private readonly long[][] results =
{
@ -49,8 +49,8 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
}
};
protected NavMesh navmesh;
protected NavMeshQuery query;
protected DtNavMesh navmesh;
protected DtNavMeshQuery query;
[SetUp]
public void SetUp()
@ -77,13 +77,13 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
}
navmesh = tc.GetNavMesh();
query = new NavMeshQuery(navmesh);
query = new DtNavMeshQuery(navmesh);
}
[Test]
public void TestFindPathWithDefaultHeuristic()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];
@ -103,7 +103,7 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
[Test]
public void TestFindPathWithNoHeuristic()
{
IQueryFilter filter = new DefaultQueryFilter();
IDtQueryFilter filter = new DtQueryDefaultFilter();
for (int i = 0; i < startRefs.Length; i++)
{
long startRef = startRefs[i];

View File

@ -93,9 +93,9 @@ public class TileCacheTest : AbstractTileCacheTest
Assert.That(tc.GetTileCount(), Is.EqualTo(168));
// Tile0: Tris: 8, Verts: 18 Detail Meshed: 8 Detail Verts: 0 Detail Tris: 14
MeshTile tile = tc.GetNavMesh().GetTile(0);
MeshData data = tile.data;
MeshHeader header = data.header;
DtMeshTile tile = tc.GetNavMesh().GetTile(0);
DtMeshData data = tile.data;
DtMeshHeader header = data.header;
Assert.That(header.vertCount, Is.EqualTo(18));
Assert.That(header.polyCount, Is.EqualTo(8));
Assert.That(header.detailMeshCount, Is.EqualTo(8));
@ -227,9 +227,9 @@ public class TileCacheTest : AbstractTileCacheTest
Assert.That(tc.GetParams().maxObstacles, Is.EqualTo(128));
Assert.That(tc.GetTileCount(), Is.EqualTo(168));
// Tile0: Tris: 8, Verts: 18 Detail Meshed: 8 Detail Verts: 0 Detail Tris: 14
MeshTile tile = tc.GetNavMesh().GetTile(0);
MeshData data = tile.data;
MeshHeader header = data.header;
DtMeshTile tile = tc.GetNavMesh().GetTile(0);
DtMeshData data = tile.data;
DtMeshHeader header = data.header;
Assert.That(header.vertCount, Is.EqualTo(18));
Assert.That(header.polyCount, Is.EqualTo(8));
Assert.That(header.detailMeshCount, Is.EqualTo(8));