P
P
Pavel Matveev2021-12-02 23:47:51
Box2D
Pavel Matveev, 2021-12-02 23:47:51

Is it possible to get coordinates of shapes attached to b2Body via b2Fixture in Box2D?

I've been digging through the documentation for the Box2D code and haven't found any way to get the coordinates of a shape attached via b2Fixture... I.e. at all.
What do I mean:

b2PolygonShape box_shape;
box_shape.SetAsBox(10 / 2, 10 / 2);

b2FixtureDef fixture_def;
fixture_def.shape = &box;

b2BodyDef body_def;
body_def.type = b2_dynamicBody;

b2Body* body = world.CreateBody(&body_def);
b2Fixture* first_fixture = body->CreateFixture(&fixture_def);

box_shape.SetAsBox(10 / 2, 10 / 2, b2Vec2(10, 10), 0);
b2Fixture* second_fixture = body->CreateFixture(&fixture_def);

How to get the coordinates of a shape attached via second_fixture ?
Maybe I didn't search well? Or is there some crutch?

I am sure that there is some way, because the Box2D test environment somehow draws all the figures - including the attached ones - which means that it takes the coordinates from somewhere.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question