This project has moved and is read-only. For the latest updates, please go here.

Pixel Accuracy Collisions

Topics: Developer Forum
Nov 6, 2010 at 6:56 PM

Hi all,

I've been trying to come to grips to the transformation between screen space and world space in Farseer 3.0. I'm not sure if I got it completely, but things seem to work fine when I move them about manually.

The strange thing I'm realizing is that as soon as I turn on physics, collisions don't seem to be pixel-accurate. I'm trying to simulate the classic box on floor example. When the box is at rest on the floor there seems to be a couple of pixels separating both contact surfaces. If I turn off collisions, the box and the floor align with pixel accuracy. It's not a question of texture mismatch, since I've created them manually with a corresponding width and height.

Any clues as to what this might be?

Best regards,


Nov 6, 2010 at 7:14 PM

I would try making the fixture slightly smaller than the texture if you want the textures to appear to be touching.

Nov 7, 2010 at 12:53 AM

FPE 3 does not know about pixels - it uses meters. The conversion is pretty easy, take a look at the Box2D FAQ for an example. There are several posts on the forum with examples on how to convert between the spaces.

Nov 7, 2010 at 1:37 AM

Also, I think Box2D leaves a slight gap between objects because of the radius for continued physics. Usually this is not that noticeable, but depending on your sizes and unit conversions it may be more obvious.

Nov 7, 2010 at 1:54 AM

Yes, there is a skin thickness of 1 cm used in CCD. It should not be noticeable unless you zoom in very near the shapes.

Nov 8, 2010 at 2:13 PM

I believe this 'skin' was what I saw. I was zooming in really close to make sure that the conversions from world space to screen space were accurate, and that's how I noticed it.

Thanks. For me it's not a problem as long as I know what to expect :)