Control BoundingBoxes on Entity-Level.

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
lithander
Greenskin
Posts: 125
Joined: Fri Nov 09, 2007 4:46 pm
Location: Bremen, Germany
Contact:

Control BoundingBoxes on Entity-Level.

Post by lithander » Wed Nov 26, 2008 12:51 pm

On a Mesh level a BoundingBox can be customized and set using _setBounds(). On an Entity level getBoundingBox() returns it's Meshes bounding box unaffected by the current AnimationState. Thus the meshes bounding box needs to be big enough to encompass the mesh in _all_ possible animation states.

In our use-case this results in way too large bounding boxes preventing effective culling for rendering and hit test purposes. The caused performance hit is a lot bigger then what it would cost to maintaining a BoundingBox per entity that takes the current animationState into account. As far as I can see ogre seems to be missing an interface for the programmer to control the results of Entity::getBoundinBox, though.

I'd suggest to extend the MovableObject::Listener interface to return a custom boundingBox just like you can use it to return a custom LightList allready. Or a _setBounds() method on an movableObject/entity level.

Or is there another way to do it that I'm not seeing?
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Wed Nov 26, 2008 1:41 pm

Get the geometry data from the mesh each frame and make/update your own boundingbox.
You can optimise by checking if the mesh animates, so that the boundingbox is only updated if something has changed since the last update.
That works splendidly. :wink:
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
lithander
Greenskin
Posts: 125
Joined: Fri Nov 09, 2007 4:46 pm
Location: Bremen, Germany
Contact:

Post by lithander » Wed Nov 26, 2008 2:25 pm

jacmoe wrote:Get the geometry data from the mesh each frame and make/update your own boundingbox.
Yeah, calculating a fitting bounding box is easy enough. But how can I make Ogre use my bounding box instead of it's own?
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Wed Nov 26, 2008 2:45 pm

You can probably override this:

Code: Select all

virtual const AxisAlignedBox& Ogre::MovableObject::getWorldBoundingBox(bool derive = false);
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 3

Post by syedhs » Wed Nov 26, 2008 7:40 pm

Well Jacmoe then a new class need to be created which is a little overkill for this purpose. And I am not sure about how function like SceneManager::createEntity (and others) are going to be affected.
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: Control BoundingBoxes on Entity-Level.

Post by Red5_StandingBy » Wed Dec 24, 2008 12:40 pm

Hi,

Here is how we have overcome this issue.

When we export the skeletal animation of our character, we keep the translational change of the root bone at zero and write those values to a separate animation curve file.
(only translation, rotation of the root bone should by untouched)
We then run the skeletal animation and translational path animation in sync. So the character animates in place and is at the same time translated to the correct point in world space. The bounding box does not need to be updated since the animation of the character now includes only body motion of arms, legs etc., which are insignificant and do not invalidate the original bounding box of the model.
0 x

User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1669
Joined: Mon Jan 21, 2008 10:26 pm

Re: Control BoundingBoxes on Entity-Level.

Post by madmarx » Wed Dec 24, 2008 1:04 pm

Same here than Red5_StandingBy's solution.
0 x
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0

User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm

Re: Control BoundingBoxes on Entity-Level.

Post by koirat » Mon Sep 14, 2009 8:38 pm

My model is ok when running or walking, the problem is when i play death animation and then i have got a Fallen Pose. Since now character is aligned paralelle to the ground it's bounding box should be different.(it's not and my model is blinking when going out off FOV) I's there an easy way to update it's BB ? Ogre is doing it somehow at start can i just somehow repeat the process for current model state.
0 x
This is a block of text that can be added to posts you make. There is a 255 character limit.

User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1669
Joined: Mon Jan 21, 2008 10:26 pm

Re: Control BoundingBoxes on Entity-Level.

Post by madmarx » Mon Sep 14, 2009 9:28 pm

I don't know :
>>Ogre is doing it somehow at start
Not exactly, a boundingbox is stored within the mesh during the conversion to binary mesh. This bounding box is aggregated within the one of the parent node, using its actual rotation/scale/position.

I think you could try to alter the bounding box using : Ogre::Mesh::_setBounds ( const AxisAlignedBox & bounds, bool pad = true )
I have never done it myself though.
0 x
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0

robtherich
Halfling
Posts: 87
Joined: Sun Mar 05, 2006 10:56 pm
Location: Brooklyn, NY

Re: Control BoundingBoxes on Entity-Level.

Post by robtherich » Tue Sep 15, 2009 12:56 am

madmarx wrote:I think you could try to alter the bounding box using : Ogre::Mesh::_setBounds ( const AxisAlignedBox & bounds, bool pad = true )
I have never done it myself though.
This works.
0 x

User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm

Re: Control BoundingBoxes on Entity-Level.

Post by koirat » Tue Sep 15, 2009 8:48 am

Thanks guys.
I will try it.
0 x
This is a block of text that can be added to posts you make. There is a 255 character limit.

User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
Contact:

Re: Control BoundingBoxes on Entity-Level.

Post by Praetor » Tue Sep 15, 2009 8:52 pm

If you come up with an elegant solution then patches are welcome. The separate animations for translations and everything else seems less elegant but quite workable.
0 x
Game Development, Engine Development, Porting
http://www.darkwindmedia.com

User avatar
oddrose
Orc
Posts: 470
Joined: Thu Feb 15, 2007 2:08 pm
Location: Gothenburg, Sweden
Contact:

Re: Control BoundingBoxes on Entity-Level.

Post by oddrose » Sat Sep 19, 2009 10:10 pm

Not sure if it counts as elegant, but I'm implementing what has been on the roadmap for a while i.e. dynamic bounds for meshes. The implementation I'm doing is updating the bounds when the animation is updated and checks that the bounds are outside the bones+a padding "factor" that's defined in the mesh-file. Since I'm not involved in any exporter work I'll have to collaborate with someone on this I guess. The padding is going to be calculated as a maximum value of the distance from bones to the vertices attached to them. (In the 3d app).

Here's the implementation in more detail:
http://www.ogre3d.org/forums/viewtopic.php?f=4&t=52560

I think I'll manage to submit a patch in 1 to 2 weeks. (Busy with school=) )
0 x

Post Reply