本文整理汇总了C++中PathNode::UpdateVariables方法的典型用法代码示例。如果您正苦于以下问题:C++ PathNode::UpdateVariables方法的具体用法?C++ PathNode::UpdateVariables怎么用?C++ PathNode::UpdateVariables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathNode
的用法示例。
在下文中一共展示了PathNode::UpdateVariables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindPathStep
//-----------------------------------------------------------------------------------
bool Path::FindPathStep()
{
if (m_openList.empty() && m_hasBegun)
{
return false;
}
PathNode* activeNode = FindLowestFNodeOnOpenListAndRemoveIt();
m_closedList.push_back(activeNode);
if (activeNode->position == m_currentGoal)
{
RecursivelyBuildPathToStartFromNode(activeNode);
m_hasBegun = false;
m_openList.clear();
m_closedList.clear();
m_currentGoal = -Vector2Int::ONE;
return true;
}
std::vector<PathNode*> validPositions;
FindValidAdjacentPositions(validPositions, activeNode, m_currentGoal);
for (PathNode* positionNode : validPositions)
{
MapPosition position = positionNode->position;
if (IsPositionOnClosedList(positionNode->position))
continue;
float localG = positionNode->g; //The computed local G.
float parentG = activeNode->g; //The parent's actual G, which includes the entire cost to get here.
float h = positionNode->h; //The computed H for the proposed posiion
PathNode* existingNode = FindOpenNodeWithPosInOpenList(position);
if (existingNode)
{
if (localG + parentG < existingNode->g)
{
existingNode->UpdateVariables(activeNode, localG + parentG, h);
}
continue;
}
PathNode* newNode = new PathNode(position, activeNode, localG + parentG, h);
m_openList.push_back(newNode);
}
return false;
}