love.physics: simplify Body and Shape API.

#1130

- Shapes are now directly attached to Bodies when they're created (similar to love 0.7 and older).
- Fixtures are removed.
- All methods that were in Fixtures now exist in Shapes.
- All APIs that used or returned a Fixture now do the same with a Shape.

- Add new love.physics.new*Shape variants that take a Body as the first parameter.
- Deprecate the new*Shape APIs that don't take a Body.
- Deprecate love.physics.newFixture (the deprecated function now returns a Shape).
- Replace Body:getFixture and Body:getFixtures with Body:getShape and Body:getShapes (Body:getFixtures is deprecated).
- Replace World:queryFixturesInArea and World:getFixturesInArea with World:queryShapesInArea and World:getShapesInArea (queryFixturesInArea is deprecated).
- Replace Contact:getFixtures with Contact:getShapes (Contact:getFixtures is deprecated).
- Replace all love.physics callback Fixture parameters with Shape parameters.
- Deprecate ChainShape:getChildEdge.
This commit is contained in:
Sasha Szpakowski
2023-10-07 15:17:24 -03:00
parent 2702004bb2
commit ac9ae82524
35 changed files with 1137 additions and 1236 deletions
+4 -7
View File
@@ -39,7 +39,6 @@ namespace box2d
// Forward declarations.
class World;
class Shape;
class Fixture;
/**
* A Body is an entity which has position and orientation
@@ -57,7 +56,6 @@ public:
friend class CircleShape;
friend class PolygonShape;
friend class Shape;
friend class Fixture;
// Public because joints et al ask for b2body
b2Body *body;
@@ -391,15 +389,14 @@ public:
World *getWorld() const;
/**
* Gets the first Fixture attached to this Body.
* Gets the first Shape attached to this Body.
**/
Fixture *getFixture() const;
Shape *getShape() const;
/**
* Get an array of all the Fixtures attached to this Body.
* @return An array of Fixtures.
* Get an array of all the Shapes attached to this Body.
**/
int getFixtures(lua_State *L) const;
int getShapes(lua_State *L) const;
/**
* Get an array of all Joints attached to this Body.