Stange issues with positions of bodies and collisions

Roald Baudoux's icon

Hello,

I am trying to put a ball inside a cube (built from six blocks) to make it bounce.

However I have two issues:

1. When the patcher is first loaded the blocks are correctly placed. However if I reset the jit.phys.body objects some blocks disappear and others are not at the right place.
2. The ball seems to be able to go beyond the faces of the cubes (especially when its speed / force is high). That's the reason I changed the block's thickness to 1. (coming from 0.) but it does not solve the issue.

Max Patch
Copy patch and select New From Clipboard in Max.

I can't figure out how to solve this.

matmat's icon

re,
1. you have to use @resetpos (body reset position), @resetquat (body reset quat) messages on jit.phys.body.
2.may be on "jit.phys.world"object, "fixedtimestep"(fixed time step value (Hz) of physics simulation) message could help you...
https://cycling74.com/forums/jit-phys-world-physics-frame-rate-response-maxsubsteps-and-fixedtimestep
https://cycling74.com/forums/jit-phys-tutorial-video-question

mathieu

Roald Baudoux's icon

All right. Thanks a lot matmat.

Rob Ramirez's icon

you also might be interested in the "setresetstate" message to phys.body.
this will set the resetpos and resetquat attributes to the current position and quat values.

Roald Baudoux's icon

I can't get my ball to bounce on the cube's walls without escaping the cube at some point.

Max Patch
Copy patch and select New From Clipboard in Max.

Are my settings correct or do I ask too much from jit.physics ?

Roald Baudoux's icon

Anyone has an idea ???

matmat's icon

hi,
may be the "restitution" is a cause..The restitution is the proportion of kinetic energy preserved on impact.If it's greater than 1, the energy increase, so....
2. for the "qmetro", you have to write "qmetro @interval 30 hz", otherwise the default interval is 5ms...
I hope it can help you

Rob Ramirez's icon

modifying the position / rotation values of a dynamic rigid body will not yield an accurate physical simulation.
you should use forces / impulses, or constraints to move dynamic rigid bodies.
eg, the phys.picker object is simply a phys.point2point constraint.

Roald Baudoux's icon

Ha haaa. Ok I'll dig that. Thanks Rob.