[SOLVED] Improper Collisions

I have a physical ground and blocks falling on it. I have added the appropriate Collision Shapes and Rigid Body Controls to both the ground and the blocks.

Everything is working well for blocks falling from a small height. But weird things start happening for blocks with a larger momentum. The get stuck in the ground. Or simply pass through it.

I’ve tried tweaking the weights of the RigidBodyControls, tried adding and removing restitution amongst other parameters. But still the glitches happen.

Am i missing something?
Below are the methods where i create the chassis box and the ground.

48%20PM
22%20PM

1 Like

Set the margins for the collision shapes, jme used to have 0 margins by default and this causes unstable physics (fixed in master branch)

1 Like

I’m not entirely sure i can help here, since i’ve got little experience using bullet myself.
But from what i read i think your objects might be moving that fast, they are infront of the ground in the one frame and already behind it in the next frame (by frame i mean physics tick) so there is no real collision happening.
However there is a “workaround”, its called CCD (continuous collision detection or something) that makes sure not only the objects current position is taken into accout for collision checks but instead all the way it travelled since last tick
there is 2 methods, namely “setCcdMotionThreshold” and “setCcdSweptSphereRadius” first of which sets when to activate CCD (say you got a ball with diameter of 1 meter you dont need ccd when it only moves 20 centimeters) and the latter of which sets the radius of the sphere that is used for the collision checks because using the original collision shape for all checks on the way to the new position might be to expensive.
But im not sure about good values for these, the threshold could be around the diameter of your spheres and the swept sphere radius somewhat like the radius of your spheres but i guess you have to play around with it as i got no experience, finding good values for collision shapes other than spheres might be even trickier

1 Like

I’m left with questions…

What is “larger” in this case?

What is the ground?

The ground here is the grass. A spatial with a zero mass rigid Body attached to it. It doesn’t move.

Larger momentum means blocks approaching the ground with larger velocities(i.e. larger heights).

This seems to mitigate the effects upto some level. Thanks!

Yes, that much I knew…

Is it a plane. A box. A bunch of grass blades. JME Terrain? Terrain made in an external program? A monkey’s stomach?

…this things might be significant. For example, a plane is going to be nothing but trouble. Non-solid objects are also going to be problematic.

Oh. Sorry i misunderstood.

I make all models in blender and import them. The grass here is a simple green colored square slab(1 X 0.1 X 1 JME units).

To avoid fast-moving bodies getting stuck in (or passing through) other rigid bodies, you probably need to enable continuous collision detection (CCD):

body.setCcdMotionThreshold(1e-6f);

The parameter is the desired minimum distance per timestep to trigger CCD or 0 to disable CCD. Once you’ve got it working, you can try increasing the parameter for better performance.

1 Like

Have you got it working yet?

1 Like

Sorry for the late response. Yes it is working right now.

I have discovered that small size objects generally have an unstable physics simulation. Adding margins to the collision boxes solved my problem upto some level. In addition scaling up all the objects by a factor of ~2 greatly improved the simulation during the test run.

I am looking to get into game development and using jME to get a working understand of all the working parts involved in making a simple 3d game.

1 Like

How are you defining “small” objects? I see you said 1 x .1 x 1 slabs for the ground (which seems fairly small to me), but how small were the objects when you had issues?

My understanding is that what matters is the difference in size/magnitude. If you have your “small” sized objects interact with other similarly small objects, results should be… “better”.

For passing through (I believe they call it “tunneling”), speed also matters, so if that’ll get “too fast” (whatever that turns out to be) you probably need that CCD config above.

So in my case the actual objects in question were all less than 0.4f. The smaller moving parts went till 0.05f. Currently i am not working with high speeds so there’s no tunneling due to that.

I’ll keep you guys updated.