Bodies penetrate each other

Topics: User Forum
Mar 2, 2011 at 9:14 AM


I'm using Farseer 3.1 to build a WPF application.

I'm  still in an early stage of developing, but already i have a problem that i don't understand:

When i drop a simple square straight on the floor (gravity = 9.8) - it stops at the floor as expected,

But when the square touches the floor not straight (rotated) - it goes in to the floor.

I uploaded a video (few seconds, 1MB) of the problem:

Can someone please help me understand why this is happening?

Some more information:

I used the "texture to polygon" technique (from the documentation) to create all the elements in the program.

I tried giving the floor big mass (1000) and small mass for the squares (10).



Mar 2, 2011 at 10:31 AM

Are you converting your units to MKS ?

I also suggest you implement the DebugView so that you can exactly see how your fixtures are aligned.

Mar 2, 2011 at 11:38 AM


1. Yes, I'm using ConvertUnits (50px = 1 meter).

2. I added a DebugView implementation (like in "Farseer Physics Engine 3.1 SimpleSamples Silverlight") and i can see all the data:

Bodies: 3 (floor, straight square, rotated square)

Fixtures: 3 (one for each body)

Contacts: I can see that for a moment the engine is recognizing the contact between the problematic square (the rotated one) and the floor, but then it goes into the floor and (and the contact count is decreased by 1).

What did you mean by "see how your fixtures are aligned" ? How does DebugView can help me do that?



Mar 2, 2011 at 11:58 AM
alonkad wrote:

What did you mean by "see how your fixtures are aligned" ? How does DebugView can help me do that?

It's because there could be a discrepancy between where you are drawing the textures and where the physics bodies actually are.  By using the DebugView, you can take the drawing of textures out of the equation and make sure that the position and rotation of your bodies are in fact where you think they are and not somewhere else.

Once that is cleared up, you can draw the textures and see if they are drawn correctly according to their respective physics body's position.

Mar 4, 2011 at 2:17 PM


I used the DebugView to show the center of mass of the objects - and i saw that they didn't penetrate the floor.

With your advice - I tried to figure out what caused the discrepancy.

The problem was that the body referenced to one point of the object the texture (image) an other point.

I used the next line of code the fix the issue:

objectImage.Image.RenderTransformOrigin = new Point(0, 0);


Thanks again!