Skip to content

Commit

Permalink
Fix for issue 197.
Browse files Browse the repository at this point in the history
git-svn-id: http://recastnavigation.googlecode.com/svn/trunk@338 678f7576-1c49-11de-8b5c-13accb87f508
  • Loading branch information
memononen committed Apr 1, 2012
1 parent 79a000c commit 20d6546
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RecastDemo/Include/CrowdTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct CrowdToolParams
class CrowdToolState : public SampleToolState
{
Sample* m_sample;
dtNavMesh* m_nav;
dtCrowd* m_crowd;

float m_targetPos[3];
dtPolyRef m_targetRef;
Expand Down
10 changes: 8 additions & 2 deletions RecastDemo/Source/CrowdTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ static void getAgentBounds(const dtCrowdAgent* ag, float* bmin, float* bmax)

CrowdToolState::CrowdToolState() :
m_sample(0),
m_nav(0),
m_crowd(0),
m_targetRef(0),
m_run(true)
{
Expand Down Expand Up @@ -142,8 +144,12 @@ void CrowdToolState::init(class Sample* sample)

dtNavMesh* nav = m_sample->getNavMesh();
dtCrowd* crowd = m_sample->getCrowd();
if (nav && crowd && crowd->getAgentCount() == 0)

if (nav && crowd && (m_nav != nav || m_crowd != crowd))
{
m_nav = nav;
m_crowd = crowd;

crowd->init(MAX_AGENTS, m_sample->getAgentRadius(), nav);

// Make polygons with 'disabled' flag invalid.
Expand All @@ -163,7 +169,7 @@ void CrowdToolState::init(class Sample* sample)

// Medium (22)
params.velBias = 0.5f;
params.adaptiveDivs = 5;
params.adaptiveDivs = 5;
params.adaptiveRings = 2;
params.adaptiveDepth = 2;
crowd->setObstacleAvoidanceParams(1, &params);
Expand Down

0 comments on commit 20d6546

Please sign in to comment.