mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:13:29 +02:00
remove more std::max/min favor of glm utilities
This commit is contained in:
parent
23c92662ee
commit
8e82e48f76
1 changed files with 5 additions and 5 deletions
|
@ -25,7 +25,7 @@ SwingTwistConstraint::SwingLimitFunction::SwingLimitFunction() {
|
||||||
|
|
||||||
void SwingTwistConstraint::SwingLimitFunction::setCone(float maxAngle) {
|
void SwingTwistConstraint::SwingLimitFunction::setCone(float maxAngle) {
|
||||||
_minDots.clear();
|
_minDots.clear();
|
||||||
float minDot = std::max(MIN_MINDOT, std::min(cosf(maxAngle), MAX_MINDOT));
|
float minDot = glm::clamp(maxAngle, MIN_MINDOT, MAX_MINDOT);
|
||||||
_minDots.push_back(minDot);
|
_minDots.push_back(minDot);
|
||||||
// push the first value to the back to establish cyclic boundary conditions
|
// push the first value to the back to establish cyclic boundary conditions
|
||||||
_minDots.push_back(minDot);
|
_minDots.push_back(minDot);
|
||||||
|
@ -36,7 +36,7 @@ void SwingTwistConstraint::SwingLimitFunction::setMinDots(const std::vector<floa
|
||||||
_minDots.clear();
|
_minDots.clear();
|
||||||
_minDots.reserve(numDots);
|
_minDots.reserve(numDots);
|
||||||
for (int i = 0; i < numDots; ++i) {
|
for (int i = 0; i < numDots; ++i) {
|
||||||
_minDots.push_back(std::max(MIN_MINDOT, std::min(minDots[i], MAX_MINDOT)));
|
_minDots.push_back(glm::clamp(minDots[i], MIN_MINDOT, MAX_MINDOT));
|
||||||
}
|
}
|
||||||
// push the first value to the back to establish cyclic boundary conditions
|
// push the first value to the back to establish cyclic boundary conditions
|
||||||
_minDots.push_back(_minDots[0]);
|
_minDots.push_back(_minDots[0]);
|
||||||
|
@ -71,8 +71,8 @@ void SwingTwistConstraint::setSwingLimits(std::vector<float> minDots) {
|
||||||
|
|
||||||
void SwingTwistConstraint::setTwistLimits(float minTwist, float maxTwist) {
|
void SwingTwistConstraint::setTwistLimits(float minTwist, float maxTwist) {
|
||||||
// NOTE: min/maxTwist angles should be in the range [-PI, PI]
|
// NOTE: min/maxTwist angles should be in the range [-PI, PI]
|
||||||
_minTwist = std::min(minTwist, maxTwist);
|
_minTwist = glm::min(minTwist, maxTwist);
|
||||||
_maxTwist = std::max(minTwist, maxTwist);
|
_maxTwist = glm::max(minTwist, maxTwist);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SwingTwistConstraint::apply(glm::quat& rotation) const {
|
bool SwingTwistConstraint::apply(glm::quat& rotation) const {
|
||||||
|
@ -92,7 +92,7 @@ bool SwingTwistConstraint::apply(glm::quat& rotation) const {
|
||||||
twistAngle *= copysignf(1.0f, glm::dot(glm::cross(xAxis, twistedX), yAxis));
|
twistAngle *= copysignf(1.0f, glm::dot(glm::cross(xAxis, twistedX), yAxis));
|
||||||
|
|
||||||
// clamp twistAngle
|
// clamp twistAngle
|
||||||
float clampedTwistAngle = std::max(_minTwist, std::min(twistAngle, _maxTwist));
|
float clampedTwistAngle = glm::clamp(twistAngle, _minTwist, _maxTwist);
|
||||||
bool twistWasClamped = (twistAngle != clampedTwistAngle);
|
bool twistWasClamped = (twistAngle != clampedTwistAngle);
|
||||||
|
|
||||||
// clamp the swing
|
// clamp the swing
|
||||||
|
|
Loading…
Reference in a new issue