diff options
-rw-r--r-- | src/physics.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/physics.c b/src/physics.c index d163b01..466281d 100644 --- a/src/physics.c +++ b/src/physics.c @@ -88,7 +88,7 @@ int physics_point_is_inside_hull(GLfloat cx, GLfloat cy, GLfloat cz, GLfloat *fv int physics_will_collide_face(GLfloat sx, GLfloat sy, GLfloat sz, GLfloat vx, GLfloat vy, GLfloat vz, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat *fvert, int nfvert, Uint32 dt, - ModelInstance *obj, Uint32 *ttc) { + ModelInstance *obj, GLfloat *ttc) { GLfloat px, py, pz; GLfloat pdotn, sdotn, vdotn; @@ -106,10 +106,7 @@ int physics_will_collide_face(GLfloat sx, GLfloat sy, GLfloat sz, GLfloat vx, GL if ( vdotn == 0.0 ) return 0; /* Collision happens infinitely far in the future */ t = (pdotn - sdotn) / vdotn; - /* If the vertex is exactly on the plane, then moving away from the plane is OK */ - if ( (t == 0.0) && (vdotn > 0.0) ) return 0; - - if ( t < 0.0 ) return 0; /* Collided in the past */ + if ( t <= 0.0 ) return 0; /* Collided in the past */ if ( t > dt ) return 0; /* Not going to collide this step */ /* Boundary test */ @@ -159,7 +156,7 @@ static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *ot GLfloat face[3*4]; int q; - Uint32 ttc; + GLfloat ttc; for ( q=0; q<4; q++ ) { face[3*q + 0] = other->x + other->model->primitives[a]->vertices[3*((4*f)+q) + 0]; @@ -169,7 +166,7 @@ static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *ot if ( physics_will_collide_face(sx, sy, sz, vx, vy, vz, nx, ny, nz, face, 4, dt, other, &ttc) != 0 ) { - printf("collides with %s/%p\n", other->model->name, other); + printf("collides with %s/%p in %5.2f ms\n", other->model->name, other, ttc); if ( (nx == 0.0) && (ny == 0.0) && ( nz == 1.0) ) { obj->x += obj->vx * ttc; |