mirror of https://github.com/bjornbytes/lovr.git
rm World:getContacts;
This commit is contained in:
parent
c896541356
commit
e4895a7f1e
|
@ -198,35 +198,6 @@ static int l_lovrWorldUpdate(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrWorldGetContacts(lua_State* L) {
|
||||
World* world = luax_checktype(L, 1, World);
|
||||
Shape* a = luax_checkshape(L, 2);
|
||||
Shape* b = luax_checkshape(L, 3);
|
||||
uint32_t count;
|
||||
Contact contacts[MAX_CONTACTS];
|
||||
lovrWorldGetContacts(world, a, b, contacts, &count);
|
||||
lua_createtable(L, count, 0);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
lua_createtable(L, 7, 0);
|
||||
lua_pushnumber(L, contacts[i].x);
|
||||
lua_rawseti(L, -2, 1);
|
||||
lua_pushnumber(L, contacts[i].y);
|
||||
lua_rawseti(L, -2, 2);
|
||||
lua_pushnumber(L, contacts[i].z);
|
||||
lua_rawseti(L, -2, 3);
|
||||
lua_pushnumber(L, contacts[i].nx);
|
||||
lua_rawseti(L, -2, 4);
|
||||
lua_pushnumber(L, contacts[i].ny);
|
||||
lua_rawseti(L, -2, 5);
|
||||
lua_pushnumber(L, contacts[i].nz);
|
||||
lua_rawseti(L, -2, 6);
|
||||
lua_pushnumber(L, contacts[i].depth);
|
||||
lua_rawseti(L, -2, 7);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrWorldRaycast(lua_State* L) {
|
||||
World* world = luax_checktype(L, 1, World);
|
||||
float start[3], end[3];
|
||||
|
@ -413,7 +384,6 @@ const luaL_Reg lovrWorld[] = {
|
|||
{ "getColliders", l_lovrWorldGetColliders },
|
||||
{ "getJoints", l_lovrWorldGetJoints },
|
||||
{ "update", l_lovrWorldUpdate },
|
||||
{ "getContacts", l_lovrWorldGetContacts },
|
||||
{ "raycast", l_lovrWorldRaycast },
|
||||
{ "queryBox", l_lovrWorldQueryBox },
|
||||
{ "querySphere", l_lovrWorldQuerySphere },
|
||||
|
|
|
@ -35,12 +35,6 @@ void lovrPhysicsDestroy(void);
|
|||
|
||||
// World
|
||||
|
||||
typedef struct {
|
||||
float x, y, z;
|
||||
float nx, ny, nz;
|
||||
float depth;
|
||||
} Contact;
|
||||
|
||||
typedef struct {
|
||||
uint32_t maxColliders;
|
||||
uint32_t maxColliderPairs;
|
||||
|
@ -58,7 +52,6 @@ uint32_t lovrWorldGetJointCount(World* world);
|
|||
Collider* lovrWorldGetColliders(World* world, Collider* collider);
|
||||
Joint* lovrWorldGetJoints(World* world, Joint* joint);
|
||||
void lovrWorldUpdate(World* world, float dt);
|
||||
void lovrWorldGetContacts(World* world, Shape* a, Shape* b, Contact contacts[MAX_CONTACTS], uint32_t* count);
|
||||
void lovrWorldRaycast(World* world, float start[3], float end[3], RaycastCallback callback, void* userdata);
|
||||
bool lovrWorldQueryBox(World* world, float position[3], float size[3], QueryCallback callback, void* userdata);
|
||||
bool lovrWorldQuerySphere(World* world, float position[3], float radius, QueryCallback callback, void* userdata);
|
||||
|
|
|
@ -181,10 +181,6 @@ void lovrWorldUpdate(World* world, float dt) {
|
|||
JPH_PhysicsSystem_Step(world->system, dt, world->collisionSteps);
|
||||
}
|
||||
|
||||
void lovrWorldGetContacts(World* world, Shape* a, Shape* b, Contact contacts[MAX_CONTACTS], uint32_t* count) {
|
||||
//
|
||||
}
|
||||
|
||||
void lovrWorldRaycast(World* world, float start[3], float end[3], RaycastCallback callback, void* userdata) {
|
||||
const JPH_NarrowPhaseQuery* query = JPC_PhysicsSystem_GetNarrowPhaseQueryNoLock(world->system);
|
||||
const JPH_RVec3 origin = { start[0], start[1], start[2] };
|
||||
|
|
|
@ -276,22 +276,6 @@ void lovrWorldSetStepCount(World* world, int iterations) {
|
|||
dWorldSetQuickStepNumIterations(world->id, iterations);
|
||||
}
|
||||
|
||||
void lovrWorldGetContacts(World* world, Shape* a, Shape* b, Contact contacts[MAX_CONTACTS], uint32_t* count) {
|
||||
dContactGeom info[MAX_CONTACTS];
|
||||
int c = *count = dCollide(a->id, b->id, MAX_CONTACTS, info, sizeof(info[0]));
|
||||
for (int i = 0; i < c; i++) {
|
||||
contacts[i] = (Contact) {
|
||||
.x = info[i].pos[0],
|
||||
.y = info[i].pos[1],
|
||||
.z = info[i].pos[2],
|
||||
.nx = info[i].normal[0],
|
||||
.ny = info[i].normal[1],
|
||||
.nz = info[i].normal[2],
|
||||
.depth = info[i].depth
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void lovrWorldRaycast(World* world, float start[3], float end[3], RaycastCallback callback, void* userdata) {
|
||||
RaycastData data = { .callback = callback, .userdata = userdata, .shouldStop = false };
|
||||
float dx = start[0] - end[0];
|
||||
|
|
Loading…
Reference in New Issue