本文整理汇总了C++中MapObject::GetAABB方法的典型用法代码示例。如果您正苦于以下问题:C++ MapObject::GetAABB方法的具体用法?C++ MapObject::GetAABB怎么用?C++ MapObject::GetAABB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapObject
的用法示例。
在下文中一共展示了MapObject::GetAABB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Insert
void QuadTreeNode::Insert(const MapObject& object)
{
//check if an object falls completely outside a node
if(!object.GetAABB().intersects(m_bounds)) return;
//if node is already split add object to corresponding child node
//if it fits
if(!m_children.empty())
{
sf::Int16 index = m_GetIndex(object.GetAABB());
if(index != -1)
{
m_children[index]->Insert(object);
return;
}
}
//else add object to this node
m_objects.push_back(const_cast<MapObject*>(&object));
//check number of objects in this node, and split if necessary
//adding any objects that fit to the new child node
if(m_objects.size() > MAX_OBJECTS && m_level < MAX_LEVELS)
{
//split if there are no child nodes
if(m_children.empty()) m_Split();
sf::Uint16 i = 0;
while(i < m_objects.size())
{
sf::Int16 index = m_GetIndex(m_objects[i]->GetAABB());
if(index != -1)
{
m_children[index]->Insert(*m_objects[i]);
m_objects.erase(m_objects.begin() + i);
}
else
{
i++; //we only increment i when not erasing, because erasing moves
//everything up one index inside the vector
}
}
}
}