本文整理汇总了C++中PathNode::combineNode方法的典型用法代码示例。如果您正苦于以下问题:C++ PathNode::combineNode方法的具体用法?C++ PathNode::combineNode怎么用?C++ PathNode::combineNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathNode
的用法示例。
在下文中一共展示了PathNode::combineNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tempChildNode
std::vector<PathNode*> Pathfinding::FindPath(PathNode* start, PathNode* goal)
{
std::vector<PathNode*> retPath;
PathNode* currentNode = new PathNode(*start);
currentNode->combineNode(currentNode, start);
while (!ArrivedAtEnd(currentNode, goal))
{
PathNode tempChildNode(*currentNode);
//Get adjacent walkable tiles
//Move the child node one node to the right to get the node to the right of currentNode
tempChildNode.xPos++;
AddChild(tempChildNode, currentNode, goal, Direction::DIRECTION::EAST);
//Move the child node to the left to get the node to the left of currentNode
tempChildNode.xPos -= 2;
AddChild(tempChildNode, currentNode, goal, Direction::DIRECTION::WEST);
//Move the child node up one row to get the node above currentNode
tempChildNode.xPos++;
tempChildNode.zPos++;
AddChild(tempChildNode, currentNode, goal, Direction::DIRECTION::NORTH);
//Finally, move the child node to the bottom, to get the node one below currentNode
tempChildNode.zPos -= 2;
AddChild(tempChildNode, currentNode, goal, Direction::DIRECTION::SOUTH);
mClosedSet.insert(currentNode);
mOpenList.sort(PathNode::FCostSort());
if (mOpenList.size() > 0)
{
currentNode = mOpenList.back();
mOpenList.remove(currentNode);
}
else
{
break;
}
}
//Populate and create the path vector
while (currentNode->parent != NULL && currentNode != start)
{
retPath.push_back(currentNode);
currentNode = currentNode->getParent();
}
std::reverse(retPath.begin(), retPath.end());
mOpenList.clear();
mClosedSet.clear();
return retPath;
}