From b735015f6eca40f4447301b86b8f57274feb00f7 Mon Sep 17 00:00:00 2001 From: Josip Miskovic Date: Thu, 12 Nov 2020 17:18:40 +0100 Subject: [PATCH] Check if shape can be positioned and oriented Shape without attached collider cannot be positioned or oriented. Trying to do so results in ODE crash. Better to throw a more descriptive error. --- src/api/l_physics_shapes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/l_physics_shapes.c b/src/api/l_physics_shapes.c index 880e9369..9f3630cc 100644 --- a/src/api/l_physics_shapes.c +++ b/src/api/l_physics_shapes.c @@ -115,6 +115,7 @@ static int l_lovrShapeGetPosition(lua_State* L) { static int l_lovrShapeSetPosition(lua_State* L) { Shape* shape = luax_checkshape(L, 1); + lovrAssert(lovrShapeGetCollider(shape) != NULL, "Shape must be attached to collider"); float position[4]; luax_readvec3(L, 2, position, NULL); lovrShapeSetPosition(shape, position[0], position[1], position[2]); @@ -135,6 +136,7 @@ static int l_lovrShapeGetOrientation(lua_State* L) { static int l_lovrShapeSetOrientation(lua_State* L) { Shape* shape = luax_checkshape(L, 1); + lovrAssert(lovrShapeGetCollider(shape) != NULL, "Shape must be attached to collider"); float orientation[4]; luax_readquat(L, 2, orientation, NULL); lovrShapeSetOrientation(shape, orientation);