Simulate the insertion of an object into a set of shapes

Typically: "How do I... ", "How can I... " questions
Post Reply
marcofe
Posts: 16
Joined: 27 Apr 2015, 14:25

Simulate the insertion of an object into a set of shapes

Post by marcofe »

Hi,

I would like to dynamically simulate the insertion of a shape into a multi-layer object. In particular, I'm trying to simulate a "rupture" event of the collision, e.g., due to a sufficiently high resulting contact force. As a result of such rupture, what I would like to achieve is the inserted shape keeping moving along the original motion direction, with the physics engine not accounting the collision with that layer anymore.

From this topic, I see that I can get access to the contact points for an arbitrary pair of shapes, assumed that the physics engine is enabled, shapes are respondable and at least one of them is dynamically enabled.

While I successfully achieved this, I'm still wondering how the rupture event (meant as vanishing of the collision) can be simulated. The simplest idea would be to remove the respondable colliding layer from the simulated scene, thus avoiding the physics engine to process that contact. However, I wonder if there is a smarter way like, .e.g, changing the respondable masks of the shapes online during the simulation.

Would this be possible? If not, are there any smarter actions I can apply, that do no take into account the total removal of the object?

Thanks in advance

coppelia
Site Admin
Posts: 10364
Joined: 14 Dec 2012, 00:25

Re: Simulate the insertion of an object into a set of shapes

Post by coppelia »

Hello,

I am not sure I completely visualize what you are trying to achieve with rupture and multi-layered objects, but why not use a contact callback function? That's actually the only way you can change the collidable properties between objects, while simulation is running. This method is however quite slow, since the callback is called very often.

Another option would be to play the difference between local and global respondable mask: imagine you have the local respondable masks fully set, and the global respondable masks fully cleared.
If you start your simulation by having all objects supposed to mutually respond to collision inside of the same scene hierarchy (i.e. parented with each other, i.e. in the same hierarchy tree), they will all react mutually to collision. If you then make one of them orphan (with sim.setObjectParent), then that object won't respond to collision anymore with the other objects that are still in the same tree. This method however works nicely for lose objects, but can't always be applied depending on your constraints between them (e.g. joints, force sensors, etc.)

Cheers

Post Reply