mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
simplify logic of RotationAccumulator::add()
This commit is contained in:
parent
6ed0a57d9f
commit
a85afb5280
2 changed files with 8 additions and 8 deletions
|
@ -12,14 +12,12 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
void RotationAccumulator::add(glm::quat rotation) {
|
||||
if (_numRotations == 0) {
|
||||
_rotationSum = rotation;
|
||||
} else {
|
||||
if (glm::dot(_rotationSum, rotation) < 0.0f) {
|
||||
rotation = -rotation;
|
||||
}
|
||||
_rotationSum += 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;
|
||||
++_numRotations;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
class RotationAccumulator {
|
||||
public:
|
||||
RotationAccumulator() : _rotationSum(0.0f, 0.0f, 0.0f, 0.0f), _numRotations(0) { }
|
||||
|
||||
int size() const { return _numRotations; }
|
||||
|
||||
void add(glm::quat rotation);
|
||||
|
@ -24,7 +26,7 @@ public:
|
|||
|
||||
private:
|
||||
glm::quat _rotationSum;
|
||||
int _numRotations = 0;
|
||||
int _numRotations;
|
||||
};
|
||||
|
||||
#endif // hifi_RotationAccumulator_h
|
||||
|
|
Loading…
Reference in a new issue