Hi,
I'm using Bullet 2.78
I'm creating a btDiscreteDynamicsWorld using btSequentialImpulseConstraintSolver and btAxisSweep3.
I also have world->setForceUpdateAllAabbs(true);
The size of the broad phase is min (-10000, -10000, -10000) by max (10000, 10000, 10000)
When I add a RigidBody of fixed/static motion, the body's AABB is bigger than it should be. (I've attached a bmp showing the problem.)
It seems that the AABB is always including the center of the world. Calling world->updateSingleAabb(rb) does not change anything.
Has anybody run into this problem? Is it something that I might be doing wrong ?
thanks in advance,
cg
Bt 2.78 generating bad aabbs for static motion RBs
-
- Posts: 13
- Joined: Wed Jun 22, 2011 3:07 pm
Bt 2.78 generating bad aabbs for static motion RBs
You do not have the required permissions to view the files attached to this post.
Last edited by xris on Thu Dec 29, 2011 9:37 pm, edited 2 times in total.
-
- Posts: 13
- Joined: Wed Jun 22, 2011 3:07 pm
Re: Bt 2.78 generating bad aabbs for static motion RBs
Hello again,
I've verified that this also happens with kinematic RBs.
Dynamic RBs (with mass) are fine.
Also the type of the Collision Shape does not matter. The AABB is always miscalculated.
To be more specific, It seems that the AABB is initially calculated when I create the RB (with an identity transform). But, when ever I move the static or kinematic RB (before or after I added to the world), the newly generated AABB also includes the original AABB.
I've verified that this also happens with kinematic RBs.
Dynamic RBs (with mass) are fine.
Also the type of the Collision Shape does not matter. The AABB is always miscalculated.
To be more specific, It seems that the AABB is initially calculated when I create the RB (with an identity transform). But, when ever I move the static or kinematic RB (before or after I added to the world), the newly generated AABB also includes the original AABB.
-
- Posts: 13
- Joined: Wed Jun 22, 2011 3:07 pm
Re: Bt 2.78 generating bad aabbs for static motion RBs
I found the problem.
When setting the world transform of a RB, I need to also call setInterpolationWorldTransform() if the RB is Static or Kinematic.
If not, the AABB of the RB will be build around the original and new transform.
Should this be the default behavior for Static and (maybe) Kinematic objects? Or perhaps the the AABB generation should ignore the interpolated world transform when the body is static.
cg
When setting the world transform of a RB, I need to also call setInterpolationWorldTransform() if the RB is Static or Kinematic.
If not, the AABB of the RB will be build around the original and new transform.
Should this be the default behavior for Static and (maybe) Kinematic objects? Or perhaps the the AABB generation should ignore the interpolated world transform when the body is static.
cg
-
- Posts: 52
- Joined: Mon Jul 19, 2010 3:11 am
Re: Bt 2.78 generating bad aabbs for static motion RBs
I also noticed this, but isn't it only visual / debug draw issue?
-
- Posts: 13
- Joined: Wed Jun 22, 2011 3:07 pm
Re: Bt 2.78 generating bad aabbs for static motion RBs
No,
The debug draw code has similar logic that recalcs the AABB before it draws it.
But, its even worse(?) in the draw code:
In the btCollisionWorld::updateSingleAabb(), the code at least checks the btCollisionWorld::dispatcherInfo.m_useContinuous to be true in order to use the interpolationWorldTransform of the RB. (dispatcherInfo.m_useContinuous is set to true by default).
In the debug draw code, this check is not done. So the draw code will always use the interpolation world transform of a RB to create and draw the AABB, even if the RB is a static one.
Anyhoot,
My fix for moving all Kinematic and Static RBs is...
1) rb->setWorldTransform(xfm)
2) rb->setInterpolationWorldTransform(xfm)
3) world->updateSingleAabb(rb)
This will fix the AABBs in the world and when debug rendering them.
I'm thinking of modifying the updateSingleAabb() to ignore the interpolation world transform if the body is static (or even kinematic?).
Is there a better way to do this?
Update: updating the interpolation world transform as described above on static RBs in one of my scenes just got me back 4 ms from polling Bullet. Previously, the broadphase was basically useless because of this AABB behavior.
The debug draw code has similar logic that recalcs the AABB before it draws it.
But, its even worse(?) in the draw code:
In the btCollisionWorld::updateSingleAabb(), the code at least checks the btCollisionWorld::dispatcherInfo.m_useContinuous to be true in order to use the interpolationWorldTransform of the RB. (dispatcherInfo.m_useContinuous is set to true by default).
In the debug draw code, this check is not done. So the draw code will always use the interpolation world transform of a RB to create and draw the AABB, even if the RB is a static one.
Anyhoot,
My fix for moving all Kinematic and Static RBs is...
1) rb->setWorldTransform(xfm)
2) rb->setInterpolationWorldTransform(xfm)
3) world->updateSingleAabb(rb)
This will fix the AABBs in the world and when debug rendering them.
I'm thinking of modifying the updateSingleAabb() to ignore the interpolation world transform if the body is static (or even kinematic?).
Is there a better way to do this?
Update: updating the interpolation world transform as described above on static RBs in one of my scenes just got me back 4 ms from polling Bullet. Previously, the broadphase was basically useless because of this AABB behavior.
-
- Posts: 52
- Joined: Mon Jul 19, 2010 3:11 am
Re: Bt 2.78 generating bad aabbs for static motion RBs
good job. Thank you for that code I will use it
It is very useful when manually moving static bodies (what I'm doing sometimes). Firstly I was ignoring this issue, because I was thinking that is only draw problem, now I see it's placed also deeper1) rb->setWorldTransform(xfm)
2) rb->setInterpolationWorldTransform(xfm)
3) world->updateSingleAabb(rb)
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Bt 2.78 generating bad aabbs for static motion RBs
This was a bug indeed, and it should be fixed now in latest trunk http://code.google.com/p/bullet/source/detail?r=2463
Can you check it that this is now fixed?
Thanks for the report.
Erwin
Can you check it that this is now fixed?
Thanks for the report.
Erwin
-
- Posts: 13
- Joined: Wed Jun 22, 2011 3:07 pm
Re: Bt 2.78 generating bad aabbs for static motion RBs
Thanks Erwin!
I wont be able to test the latest trunk until after Jan 2nd. I'm wrapping up a milestone for my project right now (also why I'm still on 2.78).
I'll let you know as soon I've tested it.
Thank you again for the quick response!
cg
I wont be able to test the latest trunk until after Jan 2nd. I'm wrapping up a milestone for my project right now (also why I'm still on 2.78).
I'll let you know as soon I've tested it.
Thank you again for the quick response!
cg
-
- Posts: 13
- Joined: Wed Jun 22, 2011 3:07 pm
Bt 2.78 generating bad aabbs for static motion RBs
Hi Erwin,
The fix does not work because it fails to check if the Collision Object is a GhostBody. So all Ghost Bodies that are moved in the world will fail to build a proper AABB.
cg
The fix does not work because it fails to check if the Collision Object is a GhostBody. So all Ghost Bodies that are moved in the world will fail to build a proper AABB.
cg