schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Plane offset from origin gives weird behaviour #259

Closed ttencate closed 7 years ago

ttencate commented 7 years ago

When I have a plane that's not at the origin, we get free energy from nothing! Observe: https://ttencate.github.io/p2.js/demos/plane.html

This happens on the current master branch as well as in release 0.7.1.

As a workaround, the plane can be assigned a tiny nonzero angle.

schteppe commented 7 years ago

Many thanks for submitting a demo, this makes it much easier to debug.

This bug has been resolved already. I ran your demo in a fresh build and it didn't have the bug. Did you rebuild p2.js and p2.min.js? (run npm install and grunt in the repo)

ttencate commented 7 years ago

Yep, that helps :) Thank you!

Under what circumstances does this manifest? I'm asking because I just used the plane for testing; in the real game it will probably be a HeightField, and I would prefer to keep using an official, stable release rather than a random Git head :)

schteppe commented 7 years ago

It's only the specific case when you use a Plane shape at a right angle. It made the bounding box computation fail. This is the fix: https://github.com/schteppe/p2.js/commit/c6b447af740557b6bd004db877f23a9b94edb4cf

The master branch has some nice optimizations in it, you may wanna try it. I'd appreciate if you tested it, so I could get the new release out faster :)

ttencate commented 7 years ago

Thanks, OK, I'll check it out. Literally ;)