summaryrefslogtreecommitdiffstats
path: root/src/collision/Collision.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-02-08 11:23:19 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2021-02-08 11:23:19 +0100
commitb464bb7fd43a86264e816e950ccac1d6845b0230 (patch)
tree1070200f94f1f7adf4ae26950011884e1956576d /src/collision/Collision.cpp
parentUse our synonyms for attack anims again (diff)
parentreorganize shaders; use modulate flag; update librw (diff)
downloadre3-b464bb7fd43a86264e816e950ccac1d6845b0230.tar
re3-b464bb7fd43a86264e816e950ccac1d6845b0230.tar.gz
re3-b464bb7fd43a86264e816e950ccac1d6845b0230.tar.bz2
re3-b464bb7fd43a86264e816e950ccac1d6845b0230.tar.lz
re3-b464bb7fd43a86264e816e950ccac1d6845b0230.tar.xz
re3-b464bb7fd43a86264e816e950ccac1d6845b0230.tar.zst
re3-b464bb7fd43a86264e816e950ccac1d6845b0230.zip
Diffstat (limited to 'src/collision/Collision.cpp')
-rw-r--r--src/collision/Collision.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp
index bead5183..50c22e32 100644
--- a/src/collision/Collision.cpp
+++ b/src/collision/Collision.cpp
@@ -307,8 +307,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;
@@ -1127,8 +1135,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;