mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
use dynamic constraints for IK
This commit is contained in:
parent
71a81331d1
commit
48efbba335
3 changed files with 16 additions and 1 deletions
|
@ -396,6 +396,17 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
|
||||||
}
|
}
|
||||||
_relativePoses[i].trans = underPoses[i].trans;
|
_relativePoses[i].trans = underPoses[i].trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_relativePoses.empty()) {
|
||||||
|
// Sometimes the underpose itself can violate the constraints. Rather than
|
||||||
|
// clamp the animation we dynamically expand each constraint to accomodate it.
|
||||||
|
std::map<int, RotationConstraint*>::iterator constraintItr = _constraints.begin();
|
||||||
|
while (constraintItr != _constraints.end()) {
|
||||||
|
int index = constraintItr->first;
|
||||||
|
constraintItr->second->dynamicallyAdjustLimits(_relativePoses[index].rot);
|
||||||
|
++constraintItr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_relativePoses.empty()) {
|
if (!_relativePoses.empty()) {
|
||||||
|
|
|
@ -31,6 +31,10 @@ public:
|
||||||
/// \return true if this constraint is part of lower spine
|
/// \return true if this constraint is part of lower spine
|
||||||
virtual bool isLowerSpine() const { return false; }
|
virtual bool isLowerSpine() const { return false; }
|
||||||
|
|
||||||
|
/// \param rotation rotation to allow
|
||||||
|
/// \brief clear previous adjustment and adjust constraint limits to allow rotation
|
||||||
|
virtual void dynamicallyAdjustLimits(const glm::quat& rotation) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
glm::quat _referenceRotation = glm::quat();
|
glm::quat _referenceRotation = glm::quat();
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
|
|
||||||
/// \param rotation rotation to allow
|
/// \param rotation rotation to allow
|
||||||
/// \brief clear previous adjustment and adjust constraint limits to allow rotation
|
/// \brief clear previous adjustment and adjust constraint limits to allow rotation
|
||||||
void dynamicallyAdjustLimits(const glm::quat& rotation);
|
virtual void dynamicallyAdjustLimits(const glm::quat& rotation) override;
|
||||||
|
|
||||||
// for testing purposes
|
// for testing purposes
|
||||||
const std::vector<float>& getMinDots() { return _swingLimitFunction.getMinDots(); }
|
const std::vector<float>& getMinDots() { return _swingLimitFunction.getMinDots(); }
|
||||||
|
|
Loading…
Reference in a new issue