mirror of https://github.com/bjornbytes/lovr.git
Shape:destroy;
This commit is contained in:
parent
6ef9c6e475
commit
0fb1bd77d8
|
@ -10,6 +10,12 @@ int luax_pushshape(lua_State* L, Shape* shape) {
|
|||
}
|
||||
}
|
||||
|
||||
int l_lovrShapeDestroy(lua_State* L) {
|
||||
Shape* shape = luax_checktypeof(L, 1, Shape);
|
||||
lovrShapeDestroyData(shape);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l_lovrShapeGetType(lua_State* L) {
|
||||
Shape* shape = luax_checktypeof(L, 1, Shape);
|
||||
luax_pushenum(L, &ShapeTypes, lovrShapeGetType(shape));
|
||||
|
@ -172,6 +178,7 @@ int l_lovrShapeComputeMass(lua_State* L) {
|
|||
}
|
||||
|
||||
const luaL_Reg lovrShape[] = {
|
||||
{ "destroy", l_lovrShapeDestroy },
|
||||
{ "getType", l_lovrShapeGetType },
|
||||
{ "getCollider", l_lovrShapeGetCollider },
|
||||
{ "isEnabled", l_lovrShapeIsEnabled },
|
||||
|
|
|
@ -429,10 +429,17 @@ void lovrColliderGetLinearVelocityFromWorldPoint(Collider* collider, float wx, f
|
|||
|
||||
void lovrShapeDestroy(const Ref* ref) {
|
||||
Shape* shape = containerof(ref, Shape);
|
||||
dGeomDestroy(shape->id);
|
||||
lovrShapeDestroyData(shape);
|
||||
free(shape);
|
||||
}
|
||||
|
||||
void lovrShapeDestroyData(Shape* shape) {
|
||||
if (shape->id) {
|
||||
dGeomDestroy(shape->id);
|
||||
shape->id = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ShapeType lovrShapeGetType(Shape* shape) {
|
||||
return shape->type;
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ void lovrColliderGetLinearVelocityFromLocalPoint(Collider* collider, float x, fl
|
|||
void lovrColliderGetLinearVelocityFromWorldPoint(Collider* collider, float wx, float wy, float wz, float* vx, float* vy, float* vz);
|
||||
|
||||
void lovrShapeDestroy(const Ref* ref);
|
||||
void lovrShapeDestroyData(Shape* shape);
|
||||
ShapeType lovrShapeGetType(Shape* shape);
|
||||
Collider* lovrShapeGetCollider(Shape* shape);
|
||||
int lovrShapeIsEnabled(Shape* shape);
|
||||
|
|
Loading…
Reference in New Issue