本文整理汇总了C++中NodesList::find方法的典型用法代码示例。如果您正苦于以下问题:C++ NodesList::find方法的具体用法?C++ NodesList::find怎么用?C++ NodesList::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodesList
的用法示例。
在下文中一共展示了NodesList::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: followPath
bool CCPathFinderNetwork::followPath(CCCollideable *objectToPath,
Path &path, const int currentDirection,
const float currentDistance,
NodesList<const PathNode, 50> &previousNodes,
const PathNode *fromNode, const PathNode *toNode)
{
// Node found
if( fromNode == toNode )
{
path.endDirection = currentDirection;
path.distance = currentDistance;
return true;
}
const int nextDirection = currentDirection+1;
if( nextDirection >= 50 )
{
// Give up
return false;
}
pathFromNode = fromNode;
const CCList<PathNode::PathConnection> &connections = fromNode->connections;
int *values = new int[connections.length];
for( int i=0; i<connections.length; ++i )
{
values[i] = i;
}
qsort( values, connections.length, sizeof( int ), compare );
for( int i=0; i<connections.length; ++i )
{
const PathNode::PathConnection *nextConnection = connections.list[values[i]];
const PathNode *targetNode = nextConnection->node;
// Previously followed?
if( previousNodes.find( targetNode ) != -1 )
{
continue;
}
CCCollideable *collidedWith = CCOctreeMovementCollisionCheck( objectToPath, fromNode->point, targetNode->point );
if( collidedWith != NULL )
{
continue;
}
const float pathDistance = currentDistance + nextConnection->distance;
if( previousNodes.add( targetNode ) == false )
{
delete[] values;
return false;
}
if( followPath( objectToPath, path, nextDirection, pathDistance, previousNodes, targetNode, toNode ) )
{
path.directions[currentDirection] = values[i];
delete[] values;
return true;
}
}
delete[] values;
return false;
}