1

I'm creating a body with many vertices to collide with another bodies in the scene. This is done with b2ChainShape, but I first tried creating a single edge of that chain (v2v is the coordinates conversion method):

b2Vec2 v1 = [U v2v:CGPointMake(0, 150)];
b2Vec2 v2 = [U v2v:CGPointMake(50, 150)];

b2EdgeShape shape;
shape.Set(v1, v2);

This works as expected: other bodies collide with this edge. Strangely, when using the same vertices for the chain shape, there's no collision:

b2Vec2 vertices[2];
vertices[0] = [U v2v:CGPointMake(0, 150)];
vertices[1] = [U v2v:CGPointMake(50, 150)];

b2ChainShape shape;
shape.CreateChain(vertices, 2);

Any idea why? Do chains use some different coordinate system?

Sergey Mikhanov
  • 8,880
  • 9
  • 44
  • 54
  • That's weird. Internally a chain shape just manages a bunch of edge shapes so there should be no difference here. Is there nothing else somewhere in your code that could be relevant? – iforce2d May 28 '12 at 08:00

1 Answers1

0

Please read following paragraph that I take from Box2d manual. http://www.box2d.org/manual.pdf

Edge shapes are line segments. These are provided to assist in making a free-form static environment for your game. A major limitation of edge shapes is that they can collide with circles and polygons but not with themselves. The collision algorithms used by Box2D require that at least one of two colliding shapes have volume. Edge shapes have no volume, so edge-edge collision is not possible.

Julien Vernay
  • 295
  • 3
  • 13