mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Update userdata stuff to how new box2d wants it
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user