当前位置: 首页>>代码示例>>C++>>正文


C++ QuadTreeNode类代码示例

本文整理汇总了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);
	}
开发者ID:hahahahaman,项目名称:ltbl,代码行数:34,代码来源:QuadTreeNode.cpp

示例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);
	}
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:28,代码来源:quadtreenode.cpp

示例3: update_object

    void QuadTree::update_object(GameObject *object)
    {
        QuadTreeNode *node = m_object_node_map[object->getID()];
        node->remove_object(object);

        add_object(object);
    }
开发者ID:Maduiini,项目名称:derelictfactory,代码行数:7,代码来源:QuadTree.cpp

示例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));
        }
    }
开发者ID:0xmono,项目名称:openmw,代码行数:26,代码来源:world.cpp

示例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);
	}
开发者ID:TehPwns,项目名称:LTBL,代码行数:29,代码来源:QuadTreeNode.cpp

示例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();
 }
开发者ID:0xmono,项目名称:openmw,代码行数:10,代码来源:world.cpp

示例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;
    
}
开发者ID:dolaneast,项目名称:Trajectory-Index,代码行数:11,代码来源:quad_tree.cpp

示例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++;
	}
}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:13,代码来源:quad_tree.cpp

示例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;
  }
}
开发者ID:killerwife,项目名称:ACMadness,代码行数:13,代码来源:main.cpp

示例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;
	}
}
开发者ID:TricycleCavalry,项目名称:CodeWars,代码行数:13,代码来源:QuadTreeNode.cpp

示例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));
}
开发者ID:schardong,项目名称:HashTree,代码行数:14,代码来源:quadtreenode.cpp

示例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();
}
开发者ID:allanmc,项目名称:Spring-brAIn,代码行数:18,代码来源:QuadTreeNode.cpp

示例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;
	}
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:19,代码来源:quadtreenode.cpp

示例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();
    }
}
开发者ID:matrixworld,项目名称:openmw,代码行数:41,代码来源:quadtreenode.cpp

示例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;
	}
开发者ID:TehPwns,项目名称:LTBL,代码行数:21,代码来源:QuadTreeNode.cpp


注:本文中的QuadTreeNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。