From 4cb2249cda69af25bd8121e33a8043776ddeebc6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 18 Sep 2015 10:16:19 -0700 Subject: [PATCH] premature optimization: remove another branch --- libraries/animation/src/RotationAccumulator.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libraries/animation/src/RotationAccumulator.cpp b/libraries/animation/src/RotationAccumulator.cpp index b3ec790d20..e3de402ef8 100644 --- a/libraries/animation/src/RotationAccumulator.cpp +++ b/libraries/animation/src/RotationAccumulator.cpp @@ -12,12 +12,8 @@ #include void RotationAccumulator::add(glm::quat rotation) { - // make sure both quaternions are on the same hyper-hemisphere before we add them - if (glm::dot(_rotationSum, rotation) < 0.0f) { - rotation = -rotation; - } - // sum the rotation linearly (lerp) - _rotationSum += rotation; + // make sure both quaternions are on the same hyper-hemisphere before we add them linearly (lerp) + _rotationSum += copysignf(1.0f, glm::dot(_rotationSum, rotation)) * rotation; ++_numRotations; }