diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/collision/Collision.cpp | 21 | ||||
-rw-r--r-- | src/core/World.cpp | 8 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp index 396e3b85..9d656581 100644 --- a/src/collision/Collision.cpp +++ b/src/collision/Collision.cpp @@ -477,8 +477,16 @@ CCollision::TestLineTriangle(const CColLine &line, const CompressedVector *verts if(plane.CalcPoint(line.p0) * plane.CalcPoint(line.p1) > 0.0f) return false; + float p0dist = DotProduct(line.p1 - line.p0, normal); + +#ifdef FIX_BUGS + // line lines in the plane, assume no collision + if (p0dist == 0.0f) + return false; +#endif + // intersection parameter on line - t = -plane.CalcPoint(line.p0) / DotProduct(line.p1 - line.p0, normal); + t = -plane.CalcPoint(line.p0) / p0dist; // find point of intersection CVector p = line.p0 + (line.p1-line.p0)*t; @@ -1286,8 +1294,17 @@ CCollision::ProcessLineTriangle(const CColLine &line, if(plane.CalcPoint(line.p0) * plane.CalcPoint(line.p1) > 0.0f) return false; + float p0dist = DotProduct(line.p1 - line.p0, normal); + +#ifdef FIX_BUGS + // line lines in the plane, assume no collision + if (p0dist == 0.0f) + return false; +#endif + // intersection parameter on line - t = -plane.CalcPoint(line.p0) / DotProduct(line.p1 - line.p0, normal); + t = -plane.CalcPoint(line.p0) / p0dist; + // early out if we're beyond the mindist if(t >= mindist) return false; diff --git a/src/core/World.cpp b/src/core/World.cpp index 6ecc294a..62162dcd 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -431,10 +431,10 @@ CWorld::ProcessVerticalLineSector(CSector §or, const CColLine &line, CColPoi } bool -CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, +CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &mindist, CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly) { - float mindist = dist; + float dist = mindist; CPtrNode *node; CEntity *e; CColModel *colmodel; @@ -451,8 +451,8 @@ CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CCol } } - if(mindist < dist) { - dist = mindist; + if(dist < mindist) { + mindist = dist; return true; } else return false; |