Page 1 of 1

Potential bug with setLocalScaling() and broadphase update.

Posted: Wed Feb 25, 2009 2:44 am
by rknoesel
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.

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

Posted: Wed Feb 25, 2009 11:10 pm
by Erwin Coumans
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

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

Posted: Sun Mar 01, 2009 7:38 am
by rknoesel
Thanks for the prompt reply and clarification!

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

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

Posted: Sun Mar 01, 2009 11:14 am
by gjaegy
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

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

Posted: Sun Mar 01, 2009 4:01 pm
by Erwin Coumans
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

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

Posted: Tue Mar 03, 2009 7:48 am
by gjaegy
i am using triangle shape for my level and convex hull decomp for the dynamic objects ( which are the ones i need to reuse)

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

Posted: Wed Mar 04, 2009 6:34 am
by rknoesel
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!