diff --git a/src/api/types/shapes.c b/src/api/types/shapes.c index 5da4a6f1..c609d1ce 100644 --- a/src/api/types/shapes.c +++ b/src/api/types/shapes.c @@ -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; +} diff --git a/src/physics/physics.c b/src/physics/physics.c index 78b1276f..479c2a76 100644 --- a/src/physics/physics.c +++ b/src/physics/physics.c @@ -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); + } } diff --git a/src/physics/physics.h b/src/physics/physics.h index d690c6c3..d6de448f 100644 --- a/src/physics/physics.h +++ b/src/physics/physics.h @@ -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);