Page 1 of 1

Precision problems - Physics

Posted: Fri Feb 13, 2015 9:23 pm
by AlexsSteel
Good afternoon,
I've been experimenting a bit with Box2D (love.physics) today, everything is working as I expected, except for one problem, it seems that there's a little vague detail respect to the collision distance between a polygonShape and a chainShape, which becomes more notorious with smaller bodies and figures that collide.

Image

Is it a normal problem of Box2D or is the way I make the drawing?
In case of being the second option, could this generate a problem of detection of collisions or positions?

Re: Precision problems - Physics

Posted: Fri Feb 13, 2015 10:54 pm
by Azhukar
http://www.love2d.org/wiki/love.physics.setMeter

Experiment with meter size to suit your world. If you're going to use tiny coordinates you're going to need a tiny meter.

For example love.physics.setMeter(5) would work for the code you posted.

Re: Precision problems - Physics

Posted: Sat Feb 14, 2015 12:11 am
by AlexsSteel
Thanks, it worked.

Re: Precision problems - Physics

Posted: Sat Feb 14, 2015 8:43 am
by ivan
I've been experimenting a bit with Box2D (love.physics) today, everything is working as I expected, except for one problem, it seems that there's a little vague detail respect to the collision distance between a polygonShape and a chainShape, which becomes more notorious with smaller bodies and figures that collide.
Box2D adds "padding" around polygon edges to improve stability.
Generally it's not visible for large objects, but on the smaller scale it becomes more apparent.
I would recommend drawing objects regardless of their size WITH the padding.
Keep in mind that changing the scale of objects changes the simulation in different ways.
Box2D works with meters not pixels, so an object that is 5x10 meters behaves differently than an object that is 50x100 meters.
This is in part because of "maxTranslation" and other constant that affect the simulation.