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
+8 -9
View File
@@ -35,7 +35,6 @@ Contact::Contact(World *world, b2Contact *contact)
: contact(contact)
, world(world)
{
//contact->user
world->registerObject(contact, this);
}
@@ -46,16 +45,16 @@ Contact::~Contact()
void Contact::invalidate()
{
if (contact != NULL)
if (contact != nullptr)
{
world->unregisterObject(contact);
contact = NULL;
contact = nullptr;
}
}
bool Contact::isValid()
{
return contact != NULL;
return contact != nullptr;
}
int Contact::getPositions(lua_State *L)
@@ -144,13 +143,13 @@ void Contact::getChildren(int &childA, int &childB)
childB = contact->GetChildIndexB();
}
void Contact::getFixtures(Fixture *&fixtureA, Fixture *&fixtureB)
void Contact::getShapes(Shape *&shapeA, Shape *&shapeB)
{
fixtureA = (Fixture *) (contact->GetFixtureA()->GetUserData().pointer);
fixtureB = (Fixture *) (contact->GetFixtureB()->GetUserData().pointer);
shapeA = (Shape *) (contact->GetFixtureA()->GetUserData().pointer);
shapeB = (Shape *) (contact->GetFixtureB()->GetUserData().pointer);
if (!fixtureA || !fixtureB)
throw love::Exception("A fixture has escaped Memoizer!");
if (!shapeA || !shapeB)
throw love::Exception("A Shape has escaped Memoizer!");
}
} // box2d