10 #ifndef hifi_SwingTwistConstraint_h
11 #define hifi_SwingTwistConstraint_h
15 #include "RotationConstraint.h"
19 class SwingTwistConstraint :
public RotationConstraint {
26 SwingTwistConstraint();
36 void setSwingLimits(std::vector<float> minDots);
42 void setSwingLimits(
const std::vector<glm::vec3>& swungDirections);
47 void setTwistLimits(
float minTwist,
float maxTwist);
51 virtual bool apply(glm::quat& rotation)
const override;
53 void setLowerSpine(
bool lowerSpine) { _lowerSpine = lowerSpine; }
54 virtual bool isLowerSpine()
const override {
return _lowerSpine; }
58 virtual void dynamicallyAdjustLimits(
const glm::quat& rotation)
override;
61 const std::vector<float>& getMinDots()
const {
return _swingLimitFunction.getMinDots(); }
68 class SwingLimitFunction {
73 void setMinDots(
const std::vector<float>& minDots);
78 void dynamicallyAdjustMinDots(
float theta,
float minDot);
81 float getMinDot(
float theta)
const;
84 const std::vector<float>& getMinDots()
const {
return _minDots; }
88 std::vector<float> _minDots;
98 const SwingLimitFunction& getSwingLimitFunction()
const {
return _swingLimitFunction; }
100 void clearHistory()
override;
102 virtual glm::quat computeCenterRotation()
const override;
104 float getMinTwist()
const {
return _minTwist; }
105 float getMaxTwist()
const {
return _maxTwist; }
108 float handleTwistBoundaryConditions(
float twistAngle)
const;
111 SwingLimitFunction _swingLimitFunction;
120 mutable int _lastTwistBoundary;
121 bool _lowerSpine {
false };
122 bool _twistAdjusted {
false };