Closed GoogleCodeExporter closed 9 years ago
If you change the collision shape or scale, you need to manually remove the
cached contact points.
The easiest way is to first remove the object from the world, change the
collision shape, and re-insert the object in the world.
There is also another API to manually clear the contacts for specific objects,
but the CPU cost is not much different from the remove/insert method.
Original comment by erwin.coumans
on 18 Oct 2011 at 3:34
Isn't removing/adding a bit slow? Especially if I have several objects in the
game that I rescale each frame? It looks like the complexity for that could be
O(n*m) with n being the total number of objects and m being the objects that I
remove/add.
(oh by the way a tiny optimization for that: consider doing the linear search
in remove rigid body starting at the end. I would think it more likely that an
object that is to be removed has just been added. I'm thinking of all the many
games that spawn enemies and then when you kill them they have to be removed
again)
Also the reason why I thought that updateSingleAabb should work here was this
forum post:
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=3262
In there you say that updateSingleAabb is specifically for this. Shouldn't that
function also do the removing of the cached contact points?
Original comment by malteska...@gmail.com
on 18 Oct 2011 at 5:07
>>Shouldn't that function also do the removing of the cached contact points?
Unfortunately it doesn't. Either you remove/change/re-insert or remove the
contact points in another way.
Removal/re-insertion into the array of objects is not the main performance
bottleneck. Updating the broadphase data structures and allocation of other
structures (contact caches/manifolds etc) is. If you are using a
btDbvtBroadphase it should be O(log(n)).
world->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(object->g
etBroadphaseHandle(),world->getDispatcher());
Original comment by erwin.coumans
on 18 Oct 2011 at 8:16
Alright, works for me.
In that case I would think that it would be convenient to provide a function
that calls updateSingleAabb and then calls that line. Otherwise other people
would run into the same problem and be confused. And neither the remove/add
approach, nor this one is documented anywhere as far as I can tell.
Providing a function that is called updateForNewSize(btRigidBody &) or
something would make it clear for people that they have to call that function
when scaling an object that has already been added to the world.
But anyways: My problem is solved, so I guess you can close this ticket if you
want.
Original comment by malteska...@gmail.com
on 18 Oct 2011 at 11:39
Right, it should be documented.
Thanks for the feedback!
Original comment by erwin.coumans
on 20 Oct 2011 at 5:51
See https://github.com/bulletphysics/bullet3/issues/134
Original comment by erwin.coumans
on 30 Mar 2014 at 7:40
Original issue reported on code.google.com by
malteska...@gmail.com
on 17 Oct 2011 at 6:56Attachments: