SFML/Box2D : collision between line and a box

Hi everybody !

I'm learning how to use Box2D, and I wanted to try a simple physic render with a box falling to a line but it just doesn't work... The box keep falling through the line and I can't understand why...

Here is my code :

http://pastebin.com/Nb858uqv

If someone could give me a clue?

Thanks in advance
The first thing I would suggest is to use Box2D's debug draw so that you can see exactly what it's doing.

Remember the SetAsBox function takes 'half-height' and 'half-width' values, and the body position will be the center of the box... it looks like you are drawing the box with the body position at the bottom left corner.
I have cleaned a bit the code and make some changes but it still doesn't work, I really don't know where I'm wrong...

I convert Pixels to Meters when I set the position of my bodies, I convert Meters to Pixels when I set the position of my sfml object (draw) in the main loop...
And I take care put the good values as parameters for SetAsBox. But something is wrong...

First, when I set up my sfml object in converting meters to pixels, the box doesn't appear on the screen.
If i set up the position of the draw without converting, it draws, fall down and weirdly after some sec go a bit to the left... and the worst... it still fall down through the line...

I will look for Box2D's debug draw function, when I really don't know where is my mistake here :s

http://pastebin.com/XSx4p8X9
When you use SetAsEdge, the positions are relative to the body, not a world position. So the physics positions of the line shape in your code will be (100,1100) to (800,750) because the lineBody's position is (50,550) and the lineShape's ends' relative positions are (50,550) and (750,200). Subtracting the line ends' positions by the lineBody's position when you use SetAsEdge should fix it.

Original thread: https://box2d.org/forum/viewtopic.php?t=8439