mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
love.physics: move internal box2d->love object map to World instances, and clean up some physics object code. Resolves issue #1465.
This commit is contained in:
@@ -22,8 +22,6 @@
|
||||
#include "World.h"
|
||||
#include "Physics.h"
|
||||
|
||||
#include "common/Memoizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace physics
|
||||
@@ -33,10 +31,11 @@ namespace box2d
|
||||
|
||||
love::Type Contact::type("Contact", &Object::type);
|
||||
|
||||
Contact::Contact(b2Contact *contact)
|
||||
Contact::Contact(World *world, b2Contact *contact)
|
||||
: contact(contact)
|
||||
, world(world)
|
||||
{
|
||||
Memoizer::add(contact, this);
|
||||
world->registerObject(contact, this);
|
||||
}
|
||||
|
||||
Contact::~Contact()
|
||||
@@ -48,14 +47,14 @@ void Contact::invalidate()
|
||||
{
|
||||
if (contact != NULL)
|
||||
{
|
||||
Memoizer::remove(contact);
|
||||
world->unregisterObject(contact);
|
||||
contact = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool Contact::isValid()
|
||||
{
|
||||
return contact != NULL ? true : false;
|
||||
return contact != NULL;
|
||||
}
|
||||
|
||||
int Contact::getPositions(lua_State *L)
|
||||
@@ -146,8 +145,8 @@ void Contact::getChildren(int &childA, int &childB)
|
||||
|
||||
void Contact::getFixtures(Fixture *&fixtureA, Fixture *&fixtureB)
|
||||
{
|
||||
fixtureA = (Fixture *) Memoizer::find(contact->GetFixtureA());
|
||||
fixtureB = (Fixture *) Memoizer::find(contact->GetFixtureB());
|
||||
fixtureA = (Fixture *) world->findObject(contact->GetFixtureA());
|
||||
fixtureB = (Fixture *) world->findObject(contact->GetFixtureB());
|
||||
|
||||
if (!fixtureA || !fixtureB)
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
|
||||
Reference in New Issue
Block a user