Search code examples
c#c++box2dfarseer

Why does Box2D/Farseer EdgeShape have 4 vertices defined?


When you create a Farseer (or Box2D) edge Fixture you write:

FixtureFactory.AttachEdge(start, end, bodyToAttachTheFixtureTo);

Which makes sense - you need start and end point to define an edge.

What bothers me is when you want to read the Fixture. Assuming fixture is the Fixture we read:

  • ((EdgeShape) fixture.Shape).Vertex1
  • ((EdgeShape) fixture.Shape).Vertex2

Should be the only options. But we also get Vertex3 and Vertex4. Why? What do they mean?


Solution

  • Most likely vertices 1 and 4 are 'ghost vertices': http://www.iforce2d.net/b2dtut/ghost-vertices

    If you're looking for the original two vertices you gave when creating the edge, you probably want vertices 2 and 3.