diff --git a/src/api/l_physics_world.c b/src/api/l_physics_world.c index 53113367..58469ac4 100644 --- a/src/api/l_physics_world.c +++ b/src/api/l_physics_world.c @@ -392,8 +392,8 @@ static int l_lovrWorldEnableCollisionBetween(lua_State* L) { static int l_lovrWorldIsCollisionEnabledBetween(lua_State* L) { World* world = luax_checktype(L, 1, World); - const char* tag1 = luaL_checkstring(L, 2); - const char* tag2 = luaL_checkstring(L, 3); + const char* tag1 = lua_tostring(L, 2); + const char* tag2 = lua_tostring(L, 3); lua_pushboolean(L, lovrWorldIsCollisionEnabledBetween(world, tag1, tag2)); return 1; } diff --git a/src/modules/physics/physics.c b/src/modules/physics/physics.c index 9ab986ad..efc39206 100644 --- a/src/modules/physics/physics.c +++ b/src/modules/physics/physics.c @@ -401,35 +401,38 @@ const char* lovrWorldGetTagName(World* world, uint32_t tag) { return (tag == NO_TAG) ? NULL : world->tags[tag]; } -int lovrWorldDisableCollisionBetween(World* world, const char* tag1, const char* tag2) { +void lovrWorldDisableCollisionBetween(World* world, const char* tag1, const char* tag2) { uint32_t i = findTag(world, tag1); uint32_t j = findTag(world, tag2); + if (i == NO_TAG || j == NO_TAG) { - return NO_TAG; + return; } world->masks[i] &= ~(1 << j); world->masks[j] &= ~(1 << i); - return 0; + return; } -int lovrWorldEnableCollisionBetween(World* world, const char* tag1, const char* tag2) { +void lovrWorldEnableCollisionBetween(World* world, const char* tag1, const char* tag2) { uint32_t i = findTag(world, tag1); uint32_t j = findTag(world, tag2); + if (i == NO_TAG || j == NO_TAG) { - return NO_TAG; + return; } world->masks[i] |= (1 << j); world->masks[j] |= (1 << i); - return 0; + return; } -int lovrWorldIsCollisionEnabledBetween(World* world, const char* tag1, const char* tag2) { +bool lovrWorldIsCollisionEnabledBetween(World* world, const char* tag1, const char* tag2) { uint32_t i = findTag(world, tag1); uint32_t j = findTag(world, tag2); + if (i == NO_TAG || j == NO_TAG) { - return NO_TAG; + return true; } return (world->masks[i] & (1 << j)) && (world->masks[j] & (1 << i)); diff --git a/src/modules/physics/physics.h b/src/modules/physics/physics.h index 91954821..2a52176f 100644 --- a/src/modules/physics/physics.h +++ b/src/modules/physics/physics.h @@ -67,9 +67,9 @@ void lovrWorldSetAngularDamping(World* world, float damping, float threshold); bool lovrWorldIsSleepingAllowed(World* world); void lovrWorldSetSleepingAllowed(World* world, bool allowed); const char* lovrWorldGetTagName(World* world, uint32_t tag); -int lovrWorldDisableCollisionBetween(World* world, const char* tag1, const char* tag2); -int lovrWorldEnableCollisionBetween(World* world, const char* tag1, const char* tag2); -int lovrWorldIsCollisionEnabledBetween(World* world, const char* tag1, const char* tag); +void lovrWorldDisableCollisionBetween(World* world, const char* tag1, const char* tag2); +void lovrWorldEnableCollisionBetween(World* world, const char* tag1, const char* tag2); +bool lovrWorldIsCollisionEnabledBetween(World* world, const char* tag1, const char* tag); // Collider