mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 20:35:17 +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>
|
#include <glm/gtx/quaternion.hpp>
|
||||||
|
|
||||||
void RotationAccumulator::add(glm::quat rotation) {
|
void RotationAccumulator::add(glm::quat rotation) {
|
||||||
if (_numRotations == 0) {
|
// make sure both quaternions are on the same hyper-hemisphere before we add them
|
||||||
_rotationSum = rotation;
|
if (glm::dot(_rotationSum, rotation) < 0.0f) {
|
||||||
} else {
|
rotation = -rotation;
|
||||||
if (glm::dot(_rotationSum, rotation) < 0.0f) {
|
|
||||||
rotation = -rotation;
|
|
||||||
}
|
|
||||||
_rotationSum += rotation;
|
|
||||||
}
|
}
|
||||||
|
// sum the rotation linearly (lerp)
|
||||||
|
_rotationSum += rotation;
|
||||||
++_numRotations;
|
++_numRotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
class RotationAccumulator {
|
class RotationAccumulator {
|
||||||
public:
|
public:
|
||||||
|
RotationAccumulator() : _rotationSum(0.0f, 0.0f, 0.0f, 0.0f), _numRotations(0) { }
|
||||||
|
|
||||||
int size() const { return _numRotations; }
|
int size() const { return _numRotations; }
|
||||||
|
|
||||||
void add(glm::quat rotation);
|
void add(glm::quat rotation);
|
||||||
|
@ -24,7 +26,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
glm::quat _rotationSum;
|
glm::quat _rotationSum;
|
||||||
int _numRotations = 0;
|
int _numRotations;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_RotationAccumulator_h
|
#endif // hifi_RotationAccumulator_h
|
||||||
|
|
Loading…
Reference in a new issue