bool BotFindRouteExt( int botClientNum, const botRouteTarget_t *target, bool allowPartial ) { rVec start; Bot_t *bot = &agents[ botClientNum ]; GetEntPosition( botClientNum, start ); bool result = FindRoute( bot, start, *target, allowPartial ); return static_cast<bool>( result ); }
DXMRoute* DXMNodeDagAdapter::AddRoute(MDagPath& path) { if( g_DebugExtreme ) { MString name= MFnDependencyNode(GetNode()->GetSite()).name(); MString pathName= path.fullPathName(); DXCC_DPFA_REPORT( "(This: %s) (Path: %s)", name.asChar(), pathName.asChar() ); } if(FindRoute(path)) return NULL; DXCC_ASSERT( path.node() == GetNode()->GetSite() ); DXMRoute* route= CreateRoute(); Routes.SetAt(route, route); route->Initialize(this, path); return route; }
void BotUpdateCorridor( int botClientNum, const botRouteTarget_t *target, botNavCmd_t *cmd ) { rVec spos; rVec epos; Bot_t *bot = &agents[ botClientNum ]; botRouteTargetInternal rtarget; if ( !cmd || !target ) { return; } GetEntPosition( botClientNum, spos ); rtarget = *target; epos = rtarget.pos; UpdatePathCorridor( bot, spos, rtarget ); if ( !bot->offMesh ) { if ( bot->needReplan ) { if ( FindRoute( bot, spos, rtarget, false ) ) { bot->needReplan = false; } } cmd->havePath = !bot->needReplan; if ( overOffMeshConnectionStart( bot, spos ) ) { dtPolyRef refs[ 2 ]; rVec start; rVec end; int corner = bot->numCorners - 1; dtPolyRef con = bot->cornerPolys[ corner ]; if ( bot->corridor.moveOverOffmeshConnection( con, refs, start, end, bot->nav->query ) ) { bot->offMesh = true; bot->offMeshPoly = con; bot->offMeshEnd = end; bot->offMeshStart = start; } } dtPolyRef firstPoly = bot->corridor.getFirstPoly(); dtPolyRef lastPoly = bot->corridor.getLastPoly(); if ( !PointInPoly( bot, firstPoly, spos ) ) { bot->needReplan = true; } if ( rtarget.type == BOT_TARGET_DYNAMIC ) { if ( !PointInPolyExtents( bot, lastPoly, epos, rtarget.polyExtents ) ) { bot->needReplan = true; } } rVec rdir; BotCalcSteerDir( bot, rdir ); VectorCopy( rdir, cmd->dir ); recast2quake( cmd->dir ); cmd->directPathToGoal = bot->numCorners <= 1; VectorCopy( bot->corridor.getPos(), cmd->pos ); recast2quake( cmd->pos ); // if there are no corners, we have reached the goal // FIXME: this must be done because of a weird bug where the target is not reachable even if // the path was checked for a partial path beforehand if ( bot->numCorners == 0 ) { VectorCopy( cmd->pos, cmd->tpos ); } else { VectorCopy( bot->corridor.getTarget(), cmd->tpos ); float height; if ( dtStatusSucceed( bot->nav->query->getPolyHeight( bot->corridor.getLastPoly(), cmd->tpos, &height ) ) ) { cmd->tpos[ 1 ] = height; } recast2quake( cmd->tpos ); } } if ( bot->offMesh ) { qVec pos, proj; qVec start = bot->offMeshStart; qVec end = bot->offMeshEnd; qVec dir; qVec pVec; GetEntPosition( botClientNum, pos ); start[ 2 ] = pos[ 2 ]; end[ 2 ] = pos[ 2 ]; ProjectPointOntoVectorBounded( pos, start, end, proj ); VectorCopy( proj, cmd->pos ); cmd->directPathToGoal = false; VectorSubtract( end, pos, cmd->dir ); VectorNormalize( cmd->dir ); VectorCopy( bot->corridor.getTarget(), cmd->tpos ); float height; if ( dtStatusSucceed( bot->nav->query->getPolyHeight( bot->corridor.getLastPoly(), cmd->tpos, &height ) ) ) { cmd->tpos[ 1 ] = height; } recast2quake( cmd->tpos ); cmd->havePath = true; if ( withinRadiusOfOffMeshConnection( bot, spos, bot->offMeshEnd, bot->offMeshPoly ) ) { bot->offMesh = false; } } }
void DXMNodeDagAdapter::RemoveRoute(MDagPath& path, bool deleteIt) { DXMRoute* route= FindRoute(path); if(route) RemoveRoute(route, deleteIt); }