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
+1 -6
View File
@@ -379,7 +379,7 @@ public:
b2BodyUserData& GetUserData();
/// Set the user data. Use this to store your application specific data.
void SetUserData(b2BodyUserData& data);
void SetUserData(void* data);
/// Get the parent world of this body.
b2World* GetWorld();
@@ -736,11 +736,6 @@ inline b2BodyUserData& b2Body::GetUserData()
return m_userData;
}
inline void b2Body::SetUserData(b2BodyUserData& userData)
{
m_userData = userData;
}
inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
{
if (m_type != b2_dynamicBody)
-8
View File
@@ -158,9 +158,6 @@ public:
/// store your application specific data.
b2FixtureUserData& GetUserData();
/// Set the user data. Use this to store your application specific data.
void SetUserData(b2FixtureUserData& userData);
/// Test a point for containment in this fixture.
/// @param p a point in world coordinates.
bool TestPoint(const b2Vec2& p) const;
@@ -283,11 +280,6 @@ inline b2FixtureUserData& b2Fixture::GetUserData()
return m_userData;
}
inline void b2Fixture::SetUserData(b2FixtureUserData& userData)
{
m_userData = userData;
}
inline b2Body* b2Fixture::GetBody()
{
return m_body;
-8
View File
@@ -139,9 +139,6 @@ public:
/// Get the user data pointer.
b2JointUserData& GetUserData();
/// Set the user data pointer.
void SetUserData(b2JointUserData& userData);
/// Short-cut function to determine if either body is enabled.
bool IsEnabled() const;
@@ -223,11 +220,6 @@ inline b2JointUserData& b2Joint::GetUserData()
return m_userData;
}
inline void b2Joint::SetUserData(b2JointUserData& userData)
{
m_userData = userData;
}
inline bool b2Joint::GetCollideConnected() const
{
return m_collideConnected;
-15
View File
@@ -123,23 +123,8 @@ inline void b2Log(const char* string, ...)
#endif // B2_USER_SETTINGS
void loveAssert(bool test, const char* teststr);
#define b2Assert(A) loveAssert((A), #A)
namespace love {
namespace physics {
namespace box2d {
struct bodyudata;
struct fixtureudata;
struct jointudata;
}
}
}
#define b2BodyUserData love::physics::box2d::bodyudata*
#define b2FixtureUserData love::physics::box2d::fixtureudata*
#define b2JointUserData love::physics::box2d::jointudata*
#include "b2_common.h"
#endif
+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)