broadPhase size

broadPhase size

Hi,
I load information data from an .HKX file and had a problem with the broadphase size.
I added the following code to adjust the broadphse size to include all rigid bodies in the loaded file (this is done before the world creation)

// calculate broadphase data
for ( int i = 0; i < m_physicsData->getPhysicsSystems().getSize(); ++i )
{
const hkArray& bodies = m_physicsData->getPhysicsSystems()[i]->getRigidBodies();
for ( int j=0; j < bodies.getSize(); j++ )
{
hkAabb aabb;
bodies[j]->getCollidable()->getShape()->getAabb(bodies[j]->getTransform(),0.1,aabb);
worldCinfo->m_broadPhaseWorldAabb.includePoint(aabb.m_min);
worldCinfo->m_broadPhaseWorldAabb.includePoint(aabb.m_max);
}
}

but still sometimes I encounter rigid bodies that are out of the broadphase the moment I add them. It happen with large rigid bodies (like the terrain). Why are there bodies that get out of their AABB?
I thought about adding some factor to the size of th broadphase but as I don't know why the rigid bodies are larger then the AABB I don't know what will be an appropriate scaling factor? I'll be happy for an exlpanation of what happen here.
Thanks
Yinon

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Yinon,

I just have a few questions about this. What is the size of the terrain's AABB? What is the resultant size of your broadphase after this code is run? Have you tried setting the broadphase to a size that you know is larger than your terrain, or have you tried only exporting your terrain and checking the results of this code fragment?

Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Hi Sean,
Thank you for the quick reply,
The Terrain size is z=3600.1998 y=418.393763 x=3600.1999.
This is by far the largest rigid body in the scene so the size of the world after my code is almost
the same (accept for the y where I started with bigger world) z=3600.1998 y=1000 x=3600.1999.
But when I measured the terrain in Maya it was a little bigger then the AABB I got when loading the .hkx file.
It was about 3600.201. If I added 10% to the size of the world I got no problem and every thing worked OK.
I don't care about resizing the world to do a little bigger but I want to know why there is a difference in the size of the AABB and my measurements in Maya so I'll be sure addition of 10% is enough.
Another way is to tell Havok to do nothing when a rigid body leave the broadphase, but the documentation says it may be very inefficent so I'm not sure if this is a wise solution.

Thanks for your help
Yinon

Hi Yinon,

That's a very small difference in the measurements. It could be caused by a few different factors from rounding error to the way measurements are done in Maya, etc. The broadphase checks are also quantized, so precision will be lost. A 10% increase in the size of the world is like 360 units, so you should be safe.

As for objects outside the broadphase, it is best to keep everything inside. There is a good explanation of what happens when things are outside the broadphase in Havok Physics/Collision Detection/Broadphase Collision Detection. The basic idea is that if something leaves the broadphase, but is still included in collision detection steps, it is more likely to be picked up in the narrowphase check creating many more collision agents than you would want. I hope this helps.

Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today