Potential bug with setLocalScaling() and broadphase update.

Post Reply
rknoesel
Posts: 17
Joined: Wed Feb 25, 2009 2:18 am

Potential bug with setLocalScaling() and broadphase update.

Post by rknoesel » Wed Feb 25, 2009 2:44 am

I am experiencing a case where using setLocalScaling() on a btBvhTriangleMeshShape after a rigid body has been created and added to the world does not seem to update the extents used by my broadphase (btAxisSweep3).

My test case is a static btBvhTriangleMeshShape which is a 100x100 meter donut placed at the origin. If, by using debug telemetry while running the application, I set a local scaling of (1,2,1), all the triangles that are within the original 100x100 meter aabb collide as expected. However, no collisions outside this original aabb are detected.

My current workaround to this issue is to call btDynamicsWorld::removeRigidBody() and btDynamicsWorld::addRigidBody() immediately after calling setLocalScaling(), after which everything works fine.

Is setLocalScaling() not supposed to be used after a btRigidBody has already been added to the btDynamicsWorld?

This is using v2.73 on the PC.

User avatar
Erwin Coumans
Site Admin
Posts: 4182
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Potential bug with setLocalScaling() and broadphase update.

Post by Erwin Coumans » Wed Feb 25, 2009 11:10 pm

rknoesel wrote: Is setLocalScaling() not supposed to be used after a btRigidBody has already been added to the btDynamicsWorld?
Yes, btCollisionObject::setLocalScaling should not be called while the object is inside the btDynamicsWorld. Static (non-moving) objects don't update their AABB for performance reasons.

Bullet 2.74 will have a btCollisionWorld::updateSingleAabb(btCollisionObject*), that you can call instead of removing/adding the object back.
Thanks for the feedback,
Erwin

rknoesel
Posts: 17
Joined: Wed Feb 25, 2009 2:18 am

Re: Potential bug with setLocalScaling() and broadphase update.

Post by rknoesel » Sun Mar 01, 2009 7:38 am

Thanks for the prompt reply and clarification!

That's great news regarding v2.74...

gjaegy
Posts: 170
Joined: Fri Apr 18, 2008 2:20 pm

Re: Potential bug with setLocalScaling() and broadphase update.

Post by gjaegy » Sun Mar 01, 2009 11:14 am

just a small question regarding this setLocalScaling() function:

I am using a kind of shape manager, this let me share some shapes between some objects which use the same collision mesh. This let me save some memory and avoid to load them multiple time. However, I came across an issue as some objects using the same collision mesh use different scaling. As the scaling seems to be stored into the shape class I had to load the collision mesh multiple time when different scale factor are used.

I thought it would have been a good idea to move the scale factor into the rigid body creation phase, as this would let me share the shapes even for objects using different scaling factors.

Not sure this is possible however, but would be useful from a user point of view (actually, from my point of view ;)

Cheers,
Greg

User avatar
Erwin Coumans
Site Admin
Posts: 4182
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Potential bug with setLocalScaling() and broadphase update.

Post by Erwin Coumans » Sun Mar 01, 2009 4:01 pm

As the scaling seems to be stored into the shape class I had to load the collision mesh multiple time when different scale factor are used.
For most collision shapes there is a way to re-use a scaled version without any copying. What kind of collision shape are you using?

Did you know that you can use the btScaledBvhTriangleMeshShape to re-use a scaled instance of a btBvhTriangleMeshShape, without copying any mesh data?
Thanks,
Erwin

gjaegy
Posts: 170
Joined: Fri Apr 18, 2008 2:20 pm

Re: Potential bug with setLocalScaling() and broadphase update.

Post by gjaegy » Tue Mar 03, 2009 7:48 am

i am using triangle shape for my level and convex hull decomp for the dynamic objects ( which are the ones i need to reuse)

rknoesel
Posts: 17
Joined: Wed Feb 25, 2009 2:18 am

Re: Potential bug with setLocalScaling() and broadphase update.

Post by rknoesel » Wed Mar 04, 2009 6:34 am

Bullet 2.74 will have a btCollisionWorld::updateSingleAabb(btCollisionObject*), that you can call instead of removing/adding the object back.
I just upgraded our engine to v2.74, and this new feature works like a charm. Thanks!

Post Reply