5
\$\begingroup\$

In Box2dWeb, when we create a body we attach a fixture to the body object. We make the shape, friction, restitution and so on by tinkering with the fixture object.

So from this can we conclude that the fixture is what we really need to tinker with to get the body we want, and the body object we create just an abstract entity? Abstract in the sense that by itself, it is invisible in the canvas after we draw and animate the canvas? The body is just the abstract, formless object that becomes physical once we attach the fixture. Is this right to conclude?

\$\endgroup\$
4
\$\begingroup\$

Yep, sounds right.

A body abstractly represents a physical entity. A fixture defines its shape, physical properties and which other fixtures it collides with. Technical details in the Box2D manual, Chapter 7: Fixtures.

Some reasons they are separate:

  • This separates concerns by allowing the same fixtures to be used for all types of bodies (dynamic, static, kinematic).
  • It allows you to create a compound body that has multiple fixtures. Fixtures in the same body are stationary relative to each other. (This is superior to a weld joint, which can flex slightly due to Box2D being an iterative solver.)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.