schteppe / p2.js

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

Can shapes have 0 width/radius etc? #219

Closed AndrewRayCode closed 8 years ago

AndrewRayCode commented 8 years ago

Related to #218 where I want to create an "empty" object - can shapes have no width? Because if so, the truthiness test on this line is a bug that would be better as something like 'width' in options or typeof otpions.width === 'number'

schteppe commented 8 years ago

If you only want a place to connect a constraint, you can create a body without shapes. This is totally fine. This is how the mouse joint works in the demos.

Regarding the zero size... I don't think zero sized boxes or circles should be allowed. Contacts will behave weirdly, tunneling will occur, and CCD will not work properly. And inertia calculations will be super weird as well. How about throwing an error when trying to set zero?

(If you really want zero size, there's Line and Particle shapes)

AndrewRayCode commented 8 years ago

thanks!

schteppe commented 8 years ago

https://github.com/schteppe/p2.js/commit/96fb1576739f7011ad3b5163da88f0e3c5225429