From e238288549ed2debad377e3ed828d13bf6320a7e Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Fri, 11 Mar 2011 17:28:39 +0000 Subject: [PATCH] getNeibours() was accessing wrong agent list. --- DetourCrowd/Include/DetourCrowd.h | 3 ++- DetourCrowd/Source/DetourCrowd.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DetourCrowd/Include/DetourCrowd.h b/DetourCrowd/Include/DetourCrowd.h index 03d9c46..9daefd5 100644 --- a/DetourCrowd/Include/DetourCrowd.h +++ b/DetourCrowd/Include/DetourCrowd.h @@ -165,7 +165,8 @@ class dtCrowd dtNavMeshQuery* m_navquery; int getNeighbours(const float* pos, const float height, const float range, - const dtCrowdAgent* skip, dtCrowdNeighbour* result, const int maxResult); + const dtCrowdAgent* skip, dtCrowdNeighbour* result, const int maxResult, + dtCrowdAgent** agents, const int nagents); void updateTopologyOptimization(dtCrowdAgent** agents, const int nagents, const float dt); void updateMoveRequest(const float dt); diff --git a/DetourCrowd/Source/DetourCrowd.cpp b/DetourCrowd/Source/DetourCrowd.cpp index db1cccf..6ffea9c 100644 --- a/DetourCrowd/Source/DetourCrowd.cpp +++ b/DetourCrowd/Source/DetourCrowd.cpp @@ -489,7 +489,8 @@ int dtCrowd::getActiveAgents(dtCrowdAgent** agents, const int maxAgents) int dtCrowd::getNeighbours(const float* pos, const float height, const float range, - const dtCrowdAgent* skip, dtCrowdNeighbour* result, const int maxResult) + const dtCrowdAgent* skip, dtCrowdNeighbour* result, const int maxResult, + dtCrowdAgent** agents, const int nagents) { int n = 0; @@ -501,7 +502,7 @@ int dtCrowd::getNeighbours(const float* pos, const float height, const float ran for (int i = 0; i < nids; ++i) { - dtCrowdAgent* ag = &m_agents[ids[i]]; + const dtCrowdAgent* ag = agents[ids[i]]; if (ag == skip) continue; @@ -800,7 +801,7 @@ void dtCrowd::update(const float dt, dtCrowdAgentDebugInfo* debug) } // Query neighbour agents ag->nneis = getNeighbours(ag->npos, ag->params.height, ag->params.collisionQueryRange, - ag, ag->neis, DT_CROWDAGENT_MAX_NEIGHBOURS); + ag, ag->neis, DT_CROWDAGENT_MAX_NEIGHBOURS, agents, nagents); } // Find next corner to steer to.