aboutsummaryrefslogtreecommitdiff
path: root/src/physics.c
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-06-11 23:10:00 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-06-11 23:10:00 +0000
commit0453db5eb3133b2e378587d26860b9ec8beadab5 (patch)
treeab27e2eb3010613b9d51403dcddfec966a665e8d /src/physics.c
parent429c794b4fce1e1b389f5e3fe7f790ee5db9b2be (diff)
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
Diffstat (limited to 'src/physics.c')
-rw-r--r--src/physics.c12
1 files changed, 8 insertions, 4 deletions
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];