Porting 1.9 to 2.0: AAbb

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
User avatar
ghiboz
Goblin
Posts: 205
Joined: Wed Apr 25, 2007 9:47 pm
Location: Centallo (I)
Contact:

Porting 1.9 to 2.0: AAbb

Post by ghiboz » Wed Nov 26, 2014 8:21 pm

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
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1202
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 76

Re: Porting 1.9 to 2.0: AAbb

Post by al2950 » Wed Nov 26, 2014 9:37 pm

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!!
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4116
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 243
Contact:

Re: Porting 1.9 to 2.0: AAbb

Post by dark_sylinc » Wed Nov 26, 2014 11:32 pm

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).
0 x

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

Re: Porting 1.9 to 2.0: AAbb

Post by ghiboz » Thu Nov 27, 2014 8:32 am

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 :)
0 x

Post Reply