本文整理汇总了C++中QuadTreeNode::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ QuadTreeNode::Add方法的具体用法?C++ QuadTreeNode::Add怎么用?C++ QuadTreeNode::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuadTreeNode
的用法示例。
在下文中一共展示了QuadTreeNode::Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void QuadTreeNode::Update(QuadTreeOccupant* pOc)
{
// Remove, may be re-added to this node later
m_pOccupants.erase(pOc);
// Propogate upwards, looking for a node that has room (the current one may still have room)
QuadTreeNode* pNode = this;
while(pNode != NULL)
{
pNode->m_numOccupantsBelow--;
// If has room for 1 more, found a spot
if(pNode->m_region.Contains(pOc->m_aabb))
break;
pNode = pNode->m_pParent;
}
// If no node that could contain the occupant was found, add to outside root set
if(pNode == NULL)
{
m_pQuadTree->m_outsideRoot.insert(pOc);
pOc->m_pQuadTreeNode = NULL;
}
else // Add to the selected node
pNode->Add(pOc);
}
示例2: AddToChildren
bool QuadTreeNode::AddToChildren(QuadTreeOccupant* pOc)
{
assert(m_hasChildren);
Point2i position;
GetPossibleOccupantPosition(pOc, position);
QuadTreeNode* pChild = GetChild(position);
// See if the occupant fits in the child at the selected position
if(pChild->m_region.Contains(pOc->m_aabb))
{
// Fits, so can add to the child and finish
pChild->Add(pOc);
return true;
}
return false;
}
示例3: TreeUpdate
void QuadTreeOccupant::TreeUpdate()
{
if(m_pQuadTree == NULL)
return;
if(m_pQuadTreeNode == NULL)
{
// If fits in the root now, add it
QuadTreeNode* pRootNode = m_pQuadTree->m_pRootNode.get();
if(pRootNode->m_region.Contains(m_aabb))
{
// Remove from outside root and add to tree
m_pQuadTree->m_outsideRoot.erase(this);
pRootNode->Add(this);
}
}
else
m_pQuadTreeNode->Update(this);
}