Precision problems - Physics

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
AlexsSteel
Prole
Posts: 17
Joined: Sat Dec 27, 2014 2:11 am

Precision problems - Physics

Post 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?
Attachments
test.love
Code
(1.68 KiB) Downloaded 91 times
Last edited by AlexsSteel on Sat Feb 14, 2015 12:16 am, edited 1 time in total.
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Precision problems - Physics

Post 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.
User avatar
AlexsSteel
Prole
Posts: 17
Joined: Sat Dec 27, 2014 2:11 am

Re: Precision problems - Physics

Post by AlexsSteel »

Thanks, it worked.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Precision problems - Physics

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests