Collision callback that affects collision response

Post Reply
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Collision callback that affects collision response

Post by sparkprime »

I would like to set up a simulation as follows:

A streetlamp is a static rigid body (mass==0) comprised of a compound of boxes and cylinders.

A car is a compound of convex hulls.

A car collides with a street lamp at ~40 mph.

I would like the streetlamp to vanish and be replaced with a dynamic fractured streetlamp that has an initial velocity consistent with the collsion. By iterating through manifolds and contact points this much is easy. I just remove the static rigid body and replace it with a set of 'pieces' and use the impulse to help set their initial velocities.

However the car has already responded to the initial collision by having an enormous impulse applied to it in the opposite of its velocity. This causes its motion to completely halt. I would like it to continue through the the streetlamp with only a small degradation in velocity, or none at all. This is similar to how many games operate, e.g. GTA IV.

I tried to do this while iterating through the contact points, by applying an impulse (the one from each contact point) to the car in the direction of its penetration into the streetlamp (using the contact normal). However the car still reacts strongly to the collision (perhaps less strongly than before). I've tried both the position A and position B, using the normal and negative normal, with varying results. Is this the correct way to proceed?
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Collision callback that affects collision response

Post by sparkprime »

Noone knows how to do this in Bullet then?
snake5
Posts: 13
Joined: Tue Mar 01, 2011 4:04 pm

Re: Collision callback that affects collision response

Post by snake5 »

Make a breakable joint (idk if bullet already has a joint like this) and connect a dynamic lamp to any static body. You can also connect the parts together with a joint like that. If you just want everything to fly around and leave the speed of the car the same, you can just make the bodies sleep initially.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Collision callback that affects collision response

Post by sparkprime »

I can't have them sleep initially because they need to behave as a static object when objects collide with low impulses.

Setting it up as a joint will not help here -- the impulse applied to the car will still be too large because it will have been chosen before the joint broke.
snake5
Posts: 13
Joined: Tue Mar 01, 2011 4:04 pm

Re: Collision callback that affects collision response

Post by snake5 »

Setting it up as a joint will not help here -- the impulse applied to the car will still be too large because it will have been chosen before the joint broke.
I doubt that... I haven't seen anything like that happen for dynamic bodies connected with joints. Have you actually tried it?
proof
Posts: 18
Joined: Tue Mar 01, 2011 11:00 pm

Re: Collision callback that affects collision response

Post by proof »

It seems Erwin added a fracture demo 3 days ago to svn which you should definitely check out: http://code.google.com/p/bullet/source/detail?r=2311
Post Reply