mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Added Joint:setUserData and Joint:getUserData (resolves issue #894.)
This commit is contained in:
@@ -39,6 +39,16 @@ namespace box2d
|
||||
class Body;
|
||||
class World;
|
||||
|
||||
/**
|
||||
* This struct is stored in a void pointer in the Box2D Joint class. For now, all
|
||||
* we need is a Lua reference to arbitrary data, but we might need more later.
|
||||
**/
|
||||
struct jointudata
|
||||
{
|
||||
// Reference to arbitrary data.
|
||||
Reference *ref;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Joint acts as positioning constraints on Bodies.
|
||||
* A Joint can be used to prevent Bodies from going to
|
||||
@@ -95,6 +105,17 @@ public:
|
||||
|
||||
bool getCollideConnected() const;
|
||||
|
||||
/**
|
||||
* This function stores an in-C reference to arbitrary Lua data in the Box2D
|
||||
* Joint object.
|
||||
**/
|
||||
int setUserData(lua_State *L);
|
||||
|
||||
/**
|
||||
* Gets the data set with setUserData. If no data is set, nil is returned.
|
||||
**/
|
||||
int getUserData(lua_State *L);
|
||||
|
||||
/**
|
||||
* Joints require pointers to a Box2D joint objects at
|
||||
* different polymorphic levels, which is why these function
|
||||
@@ -117,6 +138,8 @@ protected:
|
||||
|
||||
World *world;
|
||||
|
||||
jointudata *udata;
|
||||
|
||||
private:
|
||||
|
||||
// A Joint must be destroyed *before* the bodies it acts upon,
|
||||
|
||||
Reference in New Issue
Block a user