From 0453db5eb3133b2e378587d26860b9ec8beadab5 Mon Sep 17 00:00:00 2001 From: taw27 Date: Wed, 11 Jun 2008 23:10:00 +0000 Subject: Ignore moving from the back to the front of a quad git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@89 84d2e878-0bd5-11dd-ad15-13eda11d74c5 --- src/physics.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/physics.c b/src/physics.c index 6d3ed49..ce0b9bc 100644 --- a/src/physics.c +++ b/src/physics.c @@ -138,13 +138,10 @@ int physics_will_collide_face(double sx, double sy, double sz, double vx, double } +/* Check for collision with all faces in a primitive */ static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *other, Uint32 dt, int a, double sx, double sy, double sz, double vx, double vy, double vz) { - const double nx = other->model->primitives[a]->normals[0]; - const double ny = other->model->primitives[a]->normals[1]; - const double nz = other->model->primitives[a]->normals[2]; - switch ( other->model->primitives[a]->type ) { case PRIMITIVE_QUADS : { @@ -158,6 +155,13 @@ static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *ot 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]; + + /* Skip if moving from the back to the front of this quad */ + if ( nx*vx + ny*vy + nz*vz > 0.0 ) continue; + for ( q=0; q<4; q++ ) { face[3*q + 0] = other->x + other->model->primitives[a]->vertices[3*((4*f)+q) + 0]; face[3*q + 1] = other->y + other->model->primitives[a]->vertices[3*((4*f)+q) + 1]; -- cgit v1.2.3