//----------------------------- GetPath ------------------------------------ // // called by an agent after it has been notified that a search has terminated // successfully. The method extracts the path from m_pCurrentSearch, adds // additional edges appropriate to the search type and returns it as a list of // PathEdges. //----------------------------------------------------------------------------- CActor_PathPlanner::Path CActor_PathPlanner::GetPath() { assert( m_pCurrentSearch && "<CActor_PathPlanner::GetPathAsNodes>: no current search" ); Path path = m_pCurrentSearch->GetPathAsPathEdges(); int closest = GetClosestNodeToPosition( m_pOwner->Pos() ); path.push_front( PathEdge( m_pOwner->Pos(), GetNodePosition( closest ), NavGraphEdge::normal ) ); //if the bot requested a path to a location then an edge leading to the //destination must be added if ( m_pCurrentSearch->GetType() == Graph_SearchTimeSliced < EdgeType >::AStar ) { int idx = m_pOwner->World()->GetCellSpace()->PositionToIndex( m_vDestinationPos ); if ( invalid_node_index != m_pOwner->World()->GetNavGraph().GetNode( idx ).Index() ) { path.push_back( PathEdge( path.back().Destination(), m_vDestinationPos, NavGraphEdge::normal ) ); } } //smooth paths if required if ( script->GetBool( "SmoothPathsQuick" ) ) { SmoothPathEdgesQuick( path ); } if ( script->GetBool( "SmoothPathsPrecise" ) ) { SmoothPathEdgesPrecise( path ); } return path; }
//----------------------------- GetPath ------------------------------------ // // called by an agent after it has been notified that a search has terminated // successfully. The method extracts the path from m_pCurrentSearch, adds // additional edges appropriate to the search type and returns it as a list of // PathEdges. //----------------------------------------------------------------------------- Raven_PathPlanner::Path Raven_PathPlanner::GetPath() { assert (m_pCurrentSearch && "<Raven_PathPlanner::GetPathAsNodes>: no current search"); Path path = m_pCurrentSearch->GetPathAsPathEdges(); int closest = GetClosestNodeToPosition(m_pOwner->Pos()); path.push_front(PathEdge(m_pOwner->Pos(), GetNodePosition(closest), NavGraphEdge::normal)); //if the bot requested a path to a location then an edge leading to the //destination must be added if (m_pCurrentSearch->GetType() == Graph_SearchTimeSliced<EdgeType>::AStar) { path.push_back(PathEdge(path.back().Destination(), m_vDestinationPos, NavGraphEdge::normal)); } //smooth paths if required if (UserOptions->m_bSmoothPathsQuick) { SmoothPathEdgesQuick(path); } if (UserOptions->m_bSmoothPathsPrecise) { SmoothPathEdgesPrecise(path); } return path; }