Page 1 of 1

Body with 0 mass?

Posted: Wed Nov 30, 2011 6:18 pm
by omnius
When I add a body with 0 mass it seems to not really get created. In fact, it kills the rest of the simulation, not letting me process touch events. I get no error or warning in the console. There are other circumstances that create this "non-fatal fatal error", but this one is the least "workaroundable".

I want to add a shape which processes collisions but doesn't actually impart force (mass 0). If there's a designated way to do this I'm game. Thanks again.

Re: Body with 0 mass?

Posted: Wed Nov 30, 2011 6:44 pm
by omnius
I considered making a shape standalone but these require shapeWithBody:body type construction.

Re: Body with 0 mass?

Posted: Wed Nov 30, 2011 11:00 pm
by omnius
I have found that I can still create the body with zero mass, I just can't actually add it to a space. However, the body can still be used to create a shape, which can be added as normal. The body will be available for later use. Since a body with no mass probably doesn't interact with other objects anyway (in any meaningful sense), this solves the problem for me.

Re: Body with 0 mass?

Posted: Thu Dec 01, 2011 9:33 am
by slembcke
Yeah a body with 0 mass would cause a lot of divide by zero issues and such which tend to be silent errors unless you catch them specifically. I'm adding assertions to throw errors when creating a body with 0 or negative mass/moment.

If you want to work with a physics engine, you have to accept that things simply can't be 0 mass and still be able to be used in a simulation in any meaningful way. The best you can do is to give the object a very small mass.