本文整理汇总了C++中QuadTreeNode类的典型用法代码示例。如果您正苦于以下问题:C++ QuadTreeNode类的具体用法?C++ QuadTreeNode怎么用?C++ QuadTreeNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuadTreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
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;
//auto tempQuadTree = m_pQuadTree;
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)
{
pOc->m_pQuadTreeNode = NULL;
//fucking 5 characters is what i spent my saturday and sunday morning writing, 5 fucking characters
//guess what? no checks for this->m_pQuadTree being null, and no initialization either, so i get a shit ton of segmention fault
//(well 1 but that's a shit ton)
pOc->m_pQuadTree->m_outsideRoot.insert(pOc);
}
else // Add to the selected node
pNode->add(pOc);
}
示例2: update
void QuadTreeNode::update(QuadTreeOccupant* occupant)
{
// Remove, may be re-added to this node later
occupants.erase(occupant);
// Propogate upwards, looking for a node that has room (the current one may still have room)
QuadTreeNode* n = this;
while(n)
{
n->numOccupantsBelow--;
// If has room for 1 more, found a spot
if(n->region.contains(occupant->aabb))
break;
n = n->parent;
}
// If no node that could contain the occupant was found, add to outside root set
if(!n)
{
tree->outsideRoot.insert(occupant);
occupant->node = NULL;
}
else // Add to the selected node
n->add(occupant);
}
示例3: update_object
void QuadTree::update_object(GameObject *object)
{
QuadTreeNode *node = m_object_node_map[object->getID()];
node->remove_object(object);
add_object(object);
}
示例4: LoadResponseData
Ogre::WorkQueue::Response* World::handleRequest(const Ogre::WorkQueue::Request *req, const Ogre::WorkQueue *srcQ)
{
if (req->getType() == REQ_ID_CHUNK)
{
const LoadRequestData data = Ogre::any_cast<LoadRequestData>(req->getData());
QuadTreeNode* node = data.mNode;
LoadResponseData* responseData = new LoadResponseData();
getStorage()->fillVertexBuffers(node->getNativeLodLevel(), node->getSize(), node->getCenter(), getAlign(),
responseData->mPositions, responseData->mNormals, responseData->mColours);
return OGRE_NEW Ogre::WorkQueue::Response(req, true, Ogre::Any(responseData));
}
else // REQ_ID_LAYERS
{
const LayersRequestData data = Ogre::any_cast<LayersRequestData>(req->getData());
LayersResponseData* responseData = new LayersResponseData();
getStorage()->getBlendmaps(data.mNodes, responseData->mLayerCollections, data.mPack);
return OGRE_NEW Ogre::WorkQueue::Response(req, true, Ogre::Any(responseData));
}
}
示例5: while
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);
}
示例6: findNode
Ogre::AxisAlignedBox World::getWorldBoundingBox (const Ogre::Vector2& center)
{
if (center.x > mMaxX
|| center.x < mMinX
|| center.y > mMaxY
|| center.y < mMinY)
return Ogre::AxisAlignedBox::BOX_NULL;
QuadTreeNode* node = findNode(center, mRootNode);
return node->getWorldBoundingBox();
}
示例7: QuadTreeNode
QuadTreeNode* QuadTreeNode::create(double xMin, double yMin, double xMax, double yMax, QuadTree* belongTree, QuadTreeNode* parentNode)
{
QuadTreeNode* quadTreeNode = new QuadTreeNode();
if(quadTreeNode->init(xMin, yMin, xMax, yMax, belongTree, parentNode))
{
return quadTreeNode;
}
delete quadTreeNode;
return NULL;
}
示例8: printQTNode
void printQTNode( const QuadTreeNode<TestElement> & node, const char * prefix )
{
QuadTreeNode<TestElement>::Elements::const_iterator iter =
node.elements().begin();
while (iter != node.elements().end())
{
dprintf( "%s(%d, %d) 0x%08x\n", prefix,
(*iter)->x_, (*iter)->y_, *iter );
iter++;
}
}
示例9: main
int main(){
int N;
cin >> N;
for(int i=0; i<N; ++i){
string streeA, streeB;
cin >> streeA >> streeB;
QuadTreeNode* treeA = build(streeA);
QuadTreeNode* treeB = build(streeB);
QuadTreeNode* treeC = sumar(treeA, treeB);
cout << "There are " << treeC->blackPixels() << " black pixels." << endl;
}
}
示例10: GetTreeDwellers
void QuadTreeNode::GetTreeDwellersAboveAndUnder(GrowingArray<QuadTreeDweller*>& anOutArray, int someTreeDwellerFlags)
{
GetTreeDwellers(anOutArray,someTreeDwellerFlags);
GetTreeDwellersUnder(anOutArray,someTreeDwellerFlags);
QuadTreeNode* treeNodeIterator = myParentNode;
while(treeNodeIterator != NULL)
{
treeNodeIterator->GetTreeDwellers(anOutArray,someTreeDwellerFlags);
treeNodeIterator = treeNodeIterator->myParentNode;
}
}
示例11: return
QuadTreeNode* QuadTreeNode::west_nbr(QuadTreeNode *node)
{
if(node->GetParent() == nullptr) //We arrived at the root.
return nullptr;
if((node->GetNodeType() & 0x1) == 1) //(NORTH/SOUTH)-EAST node
return (node->GetNodeType() == NE ? node->GetParent()->GetChild(NW) : node->GetParent()->GetChild(SW));
QuadTreeNode* tmp = west_nbr(node->GetParent());
if(tmp == nullptr || tmp->IsLeaf())
return tmp;
return (node->GetNodeType() == NW ? tmp->GetChild(NE) : tmp->GetChild(SE));
}
示例12: GetContainingNode
void QuadTreeNode::MoveUnitsToChildren()
{
map<int, struct UnitInformationContainer>::iterator iter;
for ( iter = UnitsContained.begin() ; iter != UnitsContained.end() ; iter++ )
{
int unitID = iter->first;
SAIFloat3 pos = iter->second.pos;
UnitDef* def = iter->second.def;
if ( !IsLeaf )
{
QuadTreeNode* node = GetContainingNode( pos );
node->InsertUnit( unitID, pos, def );
}
}
UnitsContained.clear();
}
示例13: assert
bool QuadTreeNode::addToChildren(QuadTreeOccupant* occupant)
{
assert(hasChildren);
Point2i position;
getPossibleOccupantPosition(occupant, position);
QuadTreeNode* c = getChild(position);
// See if the occupant fits in the child at the selected position
if(c->region.contains(occupant->aabb))
{
// Fits, so can add to the child and finish
c->add(occupant);
return true;
}
return false;
}
示例14: getActualLodLevel
void QuadTreeNode::updateIndexBuffers()
{
if (hasChunk())
{
// Fetch a suitable index buffer (which may be shared)
size_t ourLod = getActualLodLevel();
int flags = 0;
for (int i=0; i<4; ++i)
{
QuadTreeNode* neighbour = getNeighbour((Direction)i);
// If the neighbour isn't currently rendering itself,
// go up until we find one. NOTE: We don't need to go down,
// because in that case neighbour's detail would be higher than
// our detail and the neighbour would handle stitching by itself.
while (neighbour && !neighbour->hasChunk())
neighbour = neighbour->getParent();
size_t lod = 0;
if (neighbour)
lod = neighbour->getActualLodLevel();
if (lod <= ourLod) // We only need to worry about neighbours less detailed than we are -
lod = 0; // neighbours with more detail will do the stitching themselves
// Use 4 bits for each LOD delta
if (lod > 0)
{
assert (lod - ourLod < (1 << 4));
flags |= int(lod - ourLod) << (4*i);
}
}
flags |= 0 /*((int)mAdditionalLod)*/ << (4*4);
mChunk->setIndexBuffer(mTerrain->getBufferCache().getIndexBuffer(flags));
}
else if (hasChildren())
{
for (int i=0; i<4; ++i)
mChildren[i]->updateIndexBuffers();
}
}
示例15: assert
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;
}