コード例 #1
0
DAVA::AABBox3 SceneSelectionSystem::GetSelectionAABox(DAVA::Entity *entity, const DAVA::Matrix4 &transform) const
{
	DAVA::AABBox3 ret = DAVA::AABBox3(DAVA::Vector3(0, 0, 0), 0);

	if(NULL != entity)
	{
		// we will get selection bbox from collision system 
		DAVA::AABBox3 entityBox = collisionSystem->GetBoundingBox(entity);

		// add childs boxes into entity box
		for (DAVA::int32 i = 0; i < entity->GetChildrenCount(); i++)
		{
			DAVA::Entity *childEntity = entity->GetChild(i);
			DAVA::AABBox3 childBox = GetSelectionAABox(childEntity, childEntity->GetLocalTransform());

			if(entityBox.IsEmpty())
			{
				entityBox = childBox;
			}
			else
			{
				if(!childBox.IsEmpty())
				{
					entityBox.AddAABBox(childBox);
				}
			}
		}

		// we should return box with specified transformation
		if(!entityBox.IsEmpty())
		{
			entityBox.GetTransformedBox(transform, ret);
		}
	}

	return ret;
}
コード例 #2
0
DAVA::AABBox3 SceneSelectionSystem::CalcAABox(DAVA::Entity *entity) const
{
	DAVA::AABBox3 ret;

	if(NULL != entity)
	{
		// we will get selection bbox from collision system
		ret = collisionSystem->GetBoundingBox(entity);

		if(ret.IsEmpty())
		{
			for (DAVA::int32 i = 0; i < entity->GetChildrenCount(); i++)
			{
				ret.AddAABBox(collisionSystem->GetBoundingBox(entity->GetChild(i)));
			}
		}
	}

	return ret;
}