mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 22:37:45 +00:00
Merge pull request #553 from NotAdam/crowd
fix bnpcs not navigating around obstacles
This commit is contained in:
commit
ab1e81ba01
1 changed files with 17 additions and 7 deletions
|
@ -629,14 +629,24 @@ void Sapphire::World::Navi::NaviProvider::setMoveTarget( Entity::Chara& chara,
|
||||||
const dtQueryFilter* filter = m_pCrowd->getFilter( 0 );
|
const dtQueryFilter* filter = m_pCrowd->getFilter( 0 );
|
||||||
const float* halfExtents = m_pCrowd->getQueryExtents();
|
const float* halfExtents = m_pCrowd->getQueryExtents();
|
||||||
|
|
||||||
float vel[ 3 ];
|
|
||||||
float p[ 3 ] = { endPos.x, endPos.y, endPos.z };
|
float p[ 3 ] = { endPos.x, endPos.y, endPos.z };
|
||||||
|
|
||||||
|
dtPolyRef ref;
|
||||||
|
|
||||||
|
auto status = m_naviMeshQuery->findNearestPoly( p, halfExtents, filter, &ref, nullptr );
|
||||||
|
|
||||||
|
if( !dtStatusSucceed( status ) )
|
||||||
|
{
|
||||||
|
Logger::error( "Failed to find nearest poly for Chara#{} for pos X: {} Y: {} Z: {}",
|
||||||
|
chara.getId(), endPos.x, endPos.y, endPos.z );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dtCrowdAgent* ag = m_pCrowd->getAgent( chara.getAgentId() );
|
const dtCrowdAgent* ag = m_pCrowd->getAgent( chara.getAgentId() );
|
||||||
if( ag && ag->active )
|
if( ag && ag->active )
|
||||||
{
|
{
|
||||||
calcVel( vel, ag->npos, p, ag->params.maxSpeed );
|
m_pCrowd->requestMoveTarget( chara.getAgentId(), ref, p );
|
||||||
m_pCrowd->requestMoveVelocity( chara.getAgentId(), vel );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue