From 98601b3425a3ba8d81f3753e49b0b517a55d88a6 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 7 Apr 2024 13:30:14 -0700 Subject: [PATCH] Collider:setShape accepts nil; Internally it still uses a teeny tiny sphere (it's kinda like the collider's shape is a "point"). --- src/api/l_physics_collider.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/l_physics_collider.c b/src/api/l_physics_collider.c index 7ad574b6..0b653fae 100644 --- a/src/api/l_physics_collider.c +++ b/src/api/l_physics_collider.c @@ -42,13 +42,17 @@ static int l_lovrColliderGetShape(lua_State* L) { Collider* collider = luax_checktype(L, 1, Collider); uint32_t child = lua_gettop(L) == 1 ? ~0u : luax_checku32(L, 2) - 1; Shape* shape = lovrColliderGetShape(collider, child); - luax_pushshape(L, shape); + if (shape) { + luax_pushshape(L, shape); + } else { + lua_pushnil(L); + } return 1; } static int l_lovrColliderSetShape(lua_State* L) { Collider* collider = luax_checktype(L, 1, Collider); - Shape* shape = luax_checkshape(L, 2); + Shape* shape = lua_isnoneornil(L, 2) ? NULL : luax_checkshape(L, 2); lovrColliderSetShape(collider, shape); return 0; }