mirror of https://github.com/bjornbytes/lovr.git
World:isCollisionEnabledBetween takes nils;
They act like wildcards, just like nil tags do otherwise.
This commit is contained in:
parent
b1deeda0ce
commit
0d6c9a1def
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue