X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=collision.c;h=7ed1291eaf18c06a3ecce7840bd6c11529c0716c;hb=aa2be95cac4543cdd49fae01e9dc412f7e95b801;hp=2511205e123bfbc9d1ae143d3ac5c6e52f43ca0c;hpb=d19ee69546ce77acd4a3c1f4a11f9ad79a111e80;p=xonotic%2Fdarkplaces.git diff --git a/collision.c b/collision.c index 2511205e..7ed1291e 100644 --- a/collision.c +++ b/collision.c @@ -33,8 +33,6 @@ static int RecursiveHullCheck (RecursiveHullCheckTraceInfo_t *t, int num, double int ret; mplane_t *plane; double t1, t2; - //double frac; - //double mid[3]; // variables that need to be stored on the stack when recursing dclipnode_t *node; @@ -170,6 +168,7 @@ loc0: // used if start and end are the same static void RecursiveHullCheckPoint (RecursiveHullCheckTraceInfo_t *t, int num) { + // If you can read this, you understand BSP trees while (num >= 0) num = t->hull->clipnodes[num].children[((t->hull->planes[t->hull->clipnodes[num].planenum].type < 3) ? (t->start[t->hull->planes[t->hull->clipnodes[num].planenum].type]) : (DotProduct(t->hull->planes[t->hull->clipnodes[num].planenum].normal, t->start))) < t->hull->planes[t->hull->clipnodes[num].planenum].dist]; @@ -377,10 +376,11 @@ void Collision_ClipTrace (trace_t *trace, const void *cent, const model_t *cmode VectorCopy(endd, rhc.end); VectorCopy(rhc.end, rhc.trace->endpos); VectorSubtract(rhc.end, rhc.start, rhc.dist); - if (DotProduct(rhc.dist, rhc.dist) > 0.00001) + if (rhc.dist[0] || rhc.dist[1] || rhc.dist[2]) RecursiveHullCheck (&rhc, rhc.hull->firstclipnode, 0, 1, rhc.start, rhc.end); else RecursiveHullCheckPoint (&rhc, rhc.hull->firstclipnode); + if (rhc.trace->fraction < 0 || rhc.trace->fraction > 1) Con_Printf("fraction out of bounds %f %s:%d\n", rhc.trace->fraction, __LINE__, __FILE__); // if we hit, unrotate endpos and normal, and store the entity we hit if (rhc.trace->fraction != 1) @@ -419,10 +419,11 @@ void Collision_ClipTrace (trace_t *trace, const void *cent, const model_t *cmode VectorSubtract(end, offset, rhc.end); VectorCopy(rhc.end, rhc.trace->endpos); VectorSubtract(rhc.end, rhc.start, rhc.dist); - if (DotProduct(rhc.dist, rhc.dist) > 0.00001) + if (rhc.dist[0] || rhc.dist[1] || rhc.dist[2]) RecursiveHullCheck (&rhc, rhc.hull->firstclipnode, 0, 1, rhc.start, rhc.end); else RecursiveHullCheckPoint (&rhc, rhc.hull->firstclipnode); + if (rhc.trace->fraction < 0 || rhc.trace->fraction > 1) Con_Printf("fraction out of bounds %f %s:%d\n", rhc.trace->fraction, __LINE__, __FILE__); // if we hit, store the entity we hit if (rhc.trace->fraction != 1) @@ -435,3 +436,4 @@ void Collision_ClipTrace (trace_t *trace, const void *cent, const model_t *cmode rhc.trace->ent = (void *) cent; } } +