p2.js icon indicating copy to clipboard operation
p2.js copied to clipboard

Overlapping after fall (video)

Open ghost opened this issue 7 years ago • 3 comments

I can provide code too if it will be necessary

How to decrease overlapping after fall down on static body? It looks very strange..

Circle body falls down and when it reachs ground (static box body) then it falls down a little.. more over static body, next step, it goes up to line of ground. Very visible.

VIDEO: https://webmshare.com/b8Wxy

this.world = new p2.World({ gravity:[0, 9.5] });
this.world.solver.iterations = 10; //more or less, not fixing problem
this.world.solver.tolerance = 0; //same here
World.prototype.update = function() { // called 60 times per sec
  this.world.step( 1/60 );
}

ghost avatar Jan 11 '17 22:01 ghost

High speed objects need CCD. Otherwise the object will be pushed into other objects and overlap.

jtenner avatar Jan 12 '17 21:01 jtenner

but with CCD it still happens only a little less often.

Does CCD is created only for very small bodies aka bullets?

Does algorithm that works for any size of body exists?

ghost avatar Jul 07 '17 18:07 ghost

CCD can be enabled manually on bodies. Size does not matter. Not sure if it will help here.

I wrote a parameter tweaking guide for Cannon.js that should work for p2 as well. It should help minimizing the overlap. Read it here https://github.com/schteppe/cannon.js/wiki/Parameter-tweaking

schteppe avatar Jul 08 '17 10:07 schteppe