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


C++ QuadTreeNode::Add方法代码示例

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

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

示例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);
	}
开发者ID:adt-git,项目名称:TDSDL,代码行数:21,代码来源:QuadTreeOccupant.cpp


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