From ba50beab911f486a4fa0995890837b15a31f22fc Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 17 Nov 2014 18:30:21 -0800 Subject: [PATCH] Normal fix. --- libraries/metavoxels/src/Spanner.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/metavoxels/src/Spanner.cpp b/libraries/metavoxels/src/Spanner.cpp index bd0e2143cf..35b0754727 100644 --- a/libraries/metavoxels/src/Spanner.cpp +++ b/libraries/metavoxels/src/Spanner.cpp @@ -2002,6 +2002,9 @@ bool Heightfield::intersects(const glm::vec3& start, const glm::vec3& end, float } } + glm::vec3 normalScale(1.0f / (inverseScale.y * inverseScale.z), 1.0f / (inverseScale.x * inverseScale.z), + 1.0f / (inverseScale.x * inverseScale.y)); + bool withinBounds = true; float accumulatedDistance = boundsDistance; while (withinBounds && accumulatedDistance <= 1.0f) { @@ -2081,7 +2084,7 @@ bool Heightfield::intersects(const glm::vec3& start, const glm::vec3& end, float if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && intersection.z >= intersection.x) { distance = accumulatedDistance + planeDistance; - normal = glm::normalize(getRotation() * (lowerNormal / inverseScale)); + normal = glm::normalize(getRotation() * (lowerNormal * normalScale)); return true; } } @@ -2095,7 +2098,7 @@ bool Heightfield::intersects(const glm::vec3& start, const glm::vec3& end, float if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && intersection.x >= intersection.z) { distance = accumulatedDistance + planeDistance; - normal = glm::normalize(getRotation() * (upperNormal / inverseScale)); + normal = glm::normalize(getRotation() * (upperNormal * normalScale)); return true; } }