Delete/Remove dynamic object while colliding

AngelGM
Posts: 12
Joined: Mon Oct 28, 2013 2:40 pm

Delete/Remove dynamic object while colliding

Post by AngelGM »

Hi all,

In my world I have several btMultiBody that are formed by two btCapsuleShapes (with a constraint and a motor). When the time comes, I want to delete it and create another one with different setup. The problem is that when I create a new one in the position of the old one, it always "gets" inside other shapes that are surrounding the original one (all of them colliding between each other). At the end, the bodies become crazy and finally disappear giving an error of the type: "Overflow in AABB, object removed from simulation".

Either 1) I am not removing the MultiBody correctly from the world and probably missing something, or 2) the creation of MultiBodies in such an environment (lots of bodies colliding) is not correctly done. Or maybe both! :)

If any ideas, please tell me. Any help very very welcome.

Cheers,
A.

PD. Bullet 2.82 in Linux Debian.
nikomaster
Posts: 13
Joined: Fri May 16, 2014 9:55 am

Re: Delete/Remove dynamic object while colliding

Post by nikomaster »

Hi,

My suggestion would be storing the information of the object you are about to remove such as position, motion direction (velocity) and all of its properties on temporal variables then remove it and put it back again but in a position just before having contact. You can get that information by adding the gContactAddedCallback. You can find where to implement it on internaledgedemo on the SDK demo folder. Just check on the penetration depth and use it to translate the object to a position where contact has not happened yet. Something like this

Code: Select all

//inside function callback
btVector3 trans=cp.m_distance1 * cp.m_normalWorldOnB;
btTransform transform=collisionobject.getWorldTransform();
transform.setOrigin(transform.getOrigin + trans);//keep this for the new object

Moreover, if the new object is bigger or smaller, make adjustments using the bounding box as reference.
AngelGM
Posts: 12
Joined: Mon Oct 28, 2013 2:40 pm

Re: Delete/Remove dynamic object while colliding

Post by AngelGM »

Hi all,

Thanks for the reply. Unfortunately, I still cannot make it work.

What do I want?
Grow a bacterial community.

Where do I start?
I am starting from the "FeatherstoneMultiBodyDemo" found in the demo folder.

How do I do it?
I start with a btMultiBody of two btCapsuleShape (prismatic joint and motor to simulate growth). During run time I monitor the lenght and when the two capsules are apart I delete them from the world. Previously I copy the information (location and that) to create a starting btMultiBody in the exact position of each capsule.

Problem
After a few btMultiBody are created (I start with one), the simulation cracks with a "Overflow in AABB". I have tried to code it in several ways but always the same result.

Any ideas why this overflow is happening? At the creation of new bodies maybe? It is relevant to notice that all the bodies are always colliding among each other in the world.

Many thanks,
A