From 8f2d3b17d3d8e5e3dcec715c4e741785aad7894a Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 28 Sep 2018 09:27:38 -0700 Subject: [PATCH] Fix parabola scaling issues and raypick velocity denormalization due to transform affecting direction scale --- interface/src/raypick/ParabolaPick.cpp | 5 +++-- interface/src/raypick/RayPick.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index b10f82c9bd..e8986f7ce9 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -36,9 +36,10 @@ PickParabola ParabolaPick::getMathematicalPick() const { glm::vec3 position = currentParentTransform.transform(_mathPick.origin); glm::vec3 velocity = _mathPick.velocity; if (_scaleWithParent) { - velocity = currentParentTransform.transform(velocity); - } else { velocity = currentParentTransform.transformDirection(velocity); + } else { + glm::vec3 transformedVelocity = currentParentTransform.transformDirection(velocity); + velocity = glm::normalize(transformedVelocity) * glm::distance(velocity, Vectors::ZERO); } glm::vec3 acceleration = _mathPick.acceleration; if (_rotateAccelerationWithAvatar) { diff --git a/interface/src/raypick/RayPick.cpp b/interface/src/raypick/RayPick.cpp index 227b4e2f32..ad12db4df2 100644 --- a/interface/src/raypick/RayPick.cpp +++ b/interface/src/raypick/RayPick.cpp @@ -22,7 +22,7 @@ PickRay RayPick::getMathematicalPick() const { Transform currentParentTransform = parentTransform->getTransform(); glm::vec3 origin = currentParentTransform.transform(_mathPick.origin); - glm::vec3 direction = currentParentTransform.transformDirection(_mathPick.direction); + glm::vec3 direction = glm::normalize(currentParentTransform.transformDirection(_mathPick.direction)); return PickRay(origin, direction); }