Update userdata stuff to how new box2d wants it

This commit is contained in:
Garrett Brown
2020-10-17 22:30:01 -04:00
parent 77f238767f
commit 1b74b34cce
7 changed files with 7 additions and 43 deletions
+2 -2
View File
@@ -45,7 +45,7 @@ Body::Body(World *world, b2Vec2 p, Body::Type type)
udata->ref = nullptr;
b2BodyDef def;
def.position = Physics::scaleDown(p);
def.userData = udata;
def.userData.pointer = (uintptr_t)udata;
body = world->world->CreateBody(&def);
// Box2D body holds a reference to the love Body.
this->retain();
@@ -529,7 +529,7 @@ int Body::setUserData(lua_State *L)
if (udata == nullptr)
{
udata = new bodyudata();
body->SetUserData(udata);
body->GetUserData().pointer = (uintptr_t)udata;
}
if(!udata->ref)
+2 -2
View File
@@ -45,7 +45,7 @@ Fixture::Fixture(Body *body, Shape *shape, float density)
udata->ref = nullptr;
b2FixtureDef def;
def.shape = shape->shape;
def.userData = udata;
def.userData.pointer = (uintptr_t)udata;
def.density = density;
fixture = body->body->CreateFixture(&def);
this->retain();
@@ -262,7 +262,7 @@ int Fixture::setUserData(lua_State *L)
if (udata == nullptr)
{
udata = new fixtureudata();
fixture->SetUserData(udata);
fixture->GetUserData().pointer = (uintptr_t)udata;
}
if(!udata->ref)
+2 -2
View File
@@ -154,7 +154,7 @@ float Joint::getReactionTorque(float dt)
b2Joint *Joint::createJoint(b2JointDef *def)
{
def->userData = udata;
def->userData.pointer = (uintptr_t)udata;
joint = world->world->CreateJoint(def);
world->registerObject(joint, this);
// Box2D joint has a reference to this love Joint.
@@ -202,7 +202,7 @@ int Joint::setUserData(lua_State *L)
if (udata == nullptr)
{
udata = new jointudata();
joint->SetUserData(udata);
joint->GetUserData().pointer = (uintptr_t)udata;
}
if(!udata->ref)