Porting 1.9 to 2.0: AAbb

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2

Porting 1.9 to 2.0: AAbb

Post by ghiboz »

hi all!
i'm trying to porting my code from ogre 1.9 to ogre 2.0 and my first attempt is blocked by the old _getWorldAABB() function from the scenenode.
in 2.0 how I check the aabb of the node?
thanks again
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Porting 1.9 to 2.0: AAbb

Post by al2950 »

Ogre 2.0 works fairly differently to Ogre 1.x in the way it deals with the scene graph and sorts/finds renderble objects, as a result SceneNodes are more light weight than they used to be. SceneNodes now are only really only used for transform and hierarchical data, and MovableObject contain the 'visible info' data, and so MovableObject has the calls getWorldAabb or getWorldAabbUpdate. Of course this means if you have a scene node with multiple MovableObjects attached you will have to do some maths to combine the Aabb of all the attached objects.

There are some very good reasons why this has been done but if you are still unhappy let me know!!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5477
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1359

Re: Porting 1.9 to 2.0: AAbb

Post by dark_sylinc »

Nodes no longer have the AABB information as al2950 said.

This information is now contained in MovableObject (Entity, Billboards, Particles, etc).

You can iterate through the SceneNode's attached objects and grow an aabb with MovableObject::getWorldAabb (returns a cached version, will assert if called at the wrong time*; i.e. the cache is out of date) or MovableObject::getWorldAabbUpdated (will never assert, but is slower as it always recalculates the cache)

*wrong time means being done after the parent scene node has been modified and before SceneManager::updateAllBounds happens (which happens inside SceneManager::updateSceneGraph; in turn called by Root::renderOneFrame)

This shouldn't be an issue since most use cases have 1:1 relationship between Nodes and MovableObject (i.e. most of the times people would have 1 SceneNode for each MovableObject).
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
x 2

Re: Porting 1.9 to 2.0: AAbb

Post by ghiboz »

thanks to all!

Code: Select all

		Ogre::Aabb nodeAAbb;
		for (int i = 0; i < TheNode->numAttachedObjects(); ++i)
		{
			nodeAAbb.merge(TheNode->getAttachedObject(i)->getWorldAabb());
		}
		Ogre::Vector3 min = nodeAAbb.getMinimum();
		Ogre::Vector3 max = nodeAAbb.getMaximum();
I continue to update my code :)