Exemplo n.º 1
0
	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;
	}
Exemplo n.º 2
0
	bool QuadTreeNode::addToChildren(QuadTreeOccupant* pOc)
	{
		assert(m_hasChildren);

		sf::Vector2i 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;
	}