Shape:isEnabled; Shape:setEnabled;

This commit is contained in:
bjorn 2017-05-16 12:29:18 -06:00
parent bca3335da8
commit e93bfb30ad
3 changed files with 25 additions and 0 deletions

View File

@ -31,3 +31,16 @@ int l_lovrShapeSetBody(lua_State* L) {
return 0;
}
int l_lovrShapeIsEnabled(lua_State* L) {
Shape* shape = luax_checktypeof(L, 1, Shape);
lua_pushboolean(L, lovrShapeIsEnabled(shape));
return 1;
}
int l_lovrShapeSetEnabled(lua_State* L) {
Shape* shape = luax_checktypeof(L, 1, Shape);
int enabled = lua_toboolean(L, 2);
lovrShapeSetEnabled(shape, enabled);
return 0;
}

View File

@ -284,4 +284,14 @@ void lovrShapeSetBody(Shape* shape, Body* body) {
dGeomSetBody(shape->id, body ? body->id : 0);
}
int lovrShapeIsEnabled(Shape* shape) {
return dGeomIsEnabled(shape->id);
}
void lovrShapeSetEnabled(Shape* shape, int enabled) {
if (enabled) {
dGeomEnable(shape->id);
} else {
dGeomDisable(shape->id);
}
}

View File

@ -78,3 +78,5 @@ void lovrShapeDestroy(const Ref* ref);
ShapeType lovrShapeGetType(Shape* shape);
Body* lovrShapeGetBody(Shape* shape);
void lovrShapeSetBody(Shape* shape, Body* body);
int lovrShapeIsEnabled(Shape* shape);
void lovrShapeSetEnabled(Shape* shape, int enabled);