diff options
Diffstat (limited to 'src/physics.c')
-rw-r--r-- | src/physics.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/physics.c b/src/physics.c index 7867fd1..af1e9a6 100644 --- a/src/physics.c +++ b/src/physics.c @@ -133,22 +133,22 @@ static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *ot int found = 0; - switch ( other->model->primitives[a]->type ) { + switch ( other->model->coll_primitives[a]->type ) { case PRIMITIVE_QUADS : { /* Faces are quads */ int f; - - for ( f=0; f<other->model->primitives[a]->num_vertices/4; f++ ) { + + for ( f=0; f<other->model->coll_primitives[a]->num_vertices/4; f++ ) { double face[3*4]; int q; double ttc; - const double nx = other->model->primitives[a]->normals[3*(4*f)+0]; - const double ny = other->model->primitives[a]->normals[3*(4*f)+1]; - const double nz = other->model->primitives[a]->normals[3*(4*f)+2]; + const double nx = other->model->coll_primitives[a]->normals[3*(4*f)+0]; + const double ny = other->model->coll_primitives[a]->normals[3*(4*f)+1]; + const double nz = other->model->coll_primitives[a]->normals[3*(4*f)+2]; /* Skip if moving from the back to the front of this quad */ if ( nx*obj->vx + ny*obj->vy + nz*obj->vz > 0.0 ) continue; @@ -157,9 +157,9 @@ static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *ot const double ox = other->x; const double oy = other->y; const double oz = other->z; - face[3*q + 0] = ox + other->model->primitives[a]->vertices[3*((4*f)+q) + 0]; - face[3*q + 1] = oy + other->model->primitives[a]->vertices[3*((4*f)+q) + 1]; - face[3*q + 2] = oz + other->model->primitives[a]->vertices[3*((4*f)+q) + 2]; + face[3*q + 0] = ox + other->model->coll_primitives[a]->vertices[3*((4*f)+q) +0]; + face[3*q + 1] = oy + other->model->coll_primitives[a]->vertices[3*((4*f)+q) +1]; + face[3*q + 2] = oz + other->model->coll_primitives[a]->vertices[3*((4*f)+q) +2]; face[3*q + 0] += 10.0*(room->rx - game->cur_room_x); face[3*q + 1] += 10.0*(room->ry - game->cur_room_y); face[3*q + 2] += 10.0*(room->rz - game->cur_room_z); @@ -201,6 +201,10 @@ static int physics_check_collide(ModelInstance *obj, ModelInstance *other, doubl int i; int found = 0; + if ( strcmp("pipe", other->model->name) == 0 ) { + // printf("pipe prim 0 has %i vertices\n", other->model->primitives[0]->num_vertices); + // printf("pipe cprim 0 has %i vertices\n", other->model->coll_primitives[0]->num_vertices); + } /* Check all the vertices in the moving object... */ for ( i=0; i<obj->model->num_coll_primitives; i++ ) { int j; @@ -214,7 +218,7 @@ static int physics_check_collide(ModelInstance *obj, ModelInstance *other, doubl const double sz = obj->model->coll_primitives[i]->vertices[3*j+2]; /* ...against all primitives in the static object */ - for ( a=0; a<other->model->num_primitives; a++ ) { + for ( a=0; a<other->model->num_coll_primitives; a++ ) { if ( physics_check_collide_all_faces(obj, other, dt, a, sx, sy, sz, coll, room, game) ) { found = 1; @@ -467,6 +471,5 @@ void physics_step(Game *game, int dt) { game->time_physics = us + sec*1e6; - } |