void PathGraph::findNodesInRange ( Vector const & position_p, float range, PathNodeList & results ) const { float range2 = range * range; int nodeCount = getNodeCount(); for(int i = 0; i < nodeCount; i++) { PathNode const * node = getNode(i); if(node == NULL) continue; if(getEdgeCount(i) == 0) continue; float dist2 = position_p.magnitudeBetweenSquared(node->getPosition_p()); if(dist2 < range2) { results.push_back( const_cast<PathNode*>(node) ); } } }
void Actor::removePathPoints() { uint i, j, l; int start; int end; Point point1, point2; if (_pathNodeList.size() <= 2) return; PathNodeList newPathNodeList; // Add the first node newPathNodeList.push_back(_pathNodeList.front()); // Process all nodes between the first and the last. for (i = 1; i < _pathNodeList.size() - 1; i++) { newPathNodeList.push_back(_pathNodeList[i]); for (j = 5; j > 0; j--) { start = _pathNodeList[i].link - j; end = _pathNodeList[i].link + j; if (start < 0 || end > (int)_pathListIndex) { continue; } point1 = _pathList[start]; point2 = _pathList[end]; if ((point1.x == PATH_NODE_EMPTY) || (point2.x == PATH_NODE_EMPTY)) { continue; } if (scanPathLine(point1, point2)) { for (l = 1; l < newPathNodeList.size(); l++) { if (start <= newPathNodeList[l].link) { newPathNodeList.resize(l + 1); newPathNodeList.back().point = point1; newPathNodeList.back().link = start; newPathNodeList.resize(l + 2); break; } } newPathNodeList.back().point = point2; newPathNodeList.back().link = end; for (int k = start + 1; k < end; k++) { _pathList[k].x = PATH_NODE_EMPTY; } break; } } } // Add the last node newPathNodeList.push_back(_pathNodeList.back()); // Copy newPathNodeList into _pathNodeList, skipping any duplicate points _pathNodeList.clear(); for (i = 0; i < newPathNodeList.size(); i++) { if (((newPathNodeList.size() - 1) == i) || (newPathNodeList[i].point != newPathNodeList[i + 1].point)) { _pathNodeList.push_back(newPathNodeList[i]); } } }