mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Added Body:setUserData and Body:getUserData (resolves issue #853_
This commit is contained in:
@@ -41,6 +41,16 @@ class World;
|
||||
class Shape;
|
||||
class Fixture;
|
||||
|
||||
/**
|
||||
* This struct is stored in a void pointer in the Box2D Body class. For now, all
|
||||
* we need is a Lua reference to arbitrary data, but we might need more later.
|
||||
**/
|
||||
struct bodyudata
|
||||
{
|
||||
// Reference to arbitrary data.
|
||||
Reference *ref;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Body is an entity which has position and orientation
|
||||
* in world space. A Body does have collision geometry
|
||||
@@ -388,6 +398,18 @@ public:
|
||||
**/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* This function stores an in-C reference to
|
||||
* arbitrary Lua data in the Box2D Body object.
|
||||
**/
|
||||
int setUserData(lua_State *L);
|
||||
|
||||
/**
|
||||
* Gets the data set with setData. If no
|
||||
* data is set, nil is returned.
|
||||
**/
|
||||
int getUserData(lua_State *L);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -408,7 +430,10 @@ private:
|
||||
// This ensures that a World only can be destroyed
|
||||
// once all bodies have been destroyed too.
|
||||
World *world;
|
||||
};
|
||||
|
||||
bodyudata *udata;
|
||||
|
||||
}; // Body
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
|
||||
Reference in New Issue
Block a user