diff options
-rw-r--r-- | src/Collision.cpp | 27 | ||||
-rw-r--r-- | src/Collision.h | 3 |
2 files changed, 0 insertions, 30 deletions
diff --git a/src/Collision.cpp b/src/Collision.cpp index 91bfc95..ea69b39 100644 --- a/src/Collision.cpp +++ b/src/Collision.cpp @@ -23,33 +23,6 @@ namespace Zoom { -vmml::vec3f Collision::projectToEdge(const vmml::vec3f& p, const vmml::vec3f& v1, const vmml::vec3f& v2) { - vmml::vec3f pVec = p - v1; - vmml::vec3f edge = v2 - v1; - - float lengthSq = edge.squared_length(); - float edgeProj = vmml::dot(edge, pVec); - - if(edgeProj < 0) return v1; - if(edgeProj > lengthSq) return v2; - - return v1 + (edgeProj/lengthSq)*edge; -} - -vmml::vec3f Collision::projectToNearestEdge(const vmml::vec3f& p, const Triangle &t) { - vmml::vec3f p1 = projectToEdge(p, t.getVertex(0), t.getVertex(1)); - vmml::vec3f p2 = projectToEdge(p, t.getVertex(1), t.getVertex(2)); - vmml::vec3f p3 = projectToEdge(p, t.getVertex(2), t.getVertex(0)); - - if(p.squared_distance(p1) < p.squared_distance(p2) && p.squared_distance(p1) < p.squared_distance(p3)) - return p1; - else if(p.squared_distance(p2) < p.squared_distance(p3)) - return p2; - else - return p3; -} - - bool Collision::test(const Triangle &t, const MathUtil::Ray &ray, float *distance) { vmml::vec3f edge1 = t.getVertex(1) - t.getVertex(0); vmml::vec3f edge2 = t.getVertex(2) - t.getVertex(0); diff --git a/src/Collision.h b/src/Collision.h index df69289..ba987b9 100644 --- a/src/Collision.h +++ b/src/Collision.h @@ -34,9 +34,6 @@ class Collision { static bool testEdge(const vmml::vec3f &v1, const vmml::vec3f &v2, const vmml::vec3f &m, float r, const vmml::vec3f &move, float *distance); static bool testVertex(const vmml::vec3f &v, const vmml::vec3f &m, float r, const vmml::vec3f &move, float *distance); - - static vmml::vec3f projectToEdge(const vmml::vec3f& p, const vmml::vec3f& v1, const vmml::vec3f& v2); - static vmml::vec3f projectToNearestEdge(const vmml::vec3f& p, const Triangle &t); }; } |