From e1dfd7d28889ce5c6d18e0424aef56a1f0f333ba Mon Sep 17 00:00:00 2001 From: Angus Antley Date: Sat, 16 Feb 2019 23:40:16 -0800 Subject: [PATCH] cleanup white space --- libraries/animation/src/AnimNodeLoader.cpp | 1 - .../src/AnimPoleVectorConstraint.cpp | 5 +- libraries/animation/src/AnimSplineIK.cpp | 1 - libraries/animation/src/AnimSplineIK.h | 2 +- libraries/animation/src/Rig.cpp | 51 ++++++++----------- libraries/animation/src/Rig.h | 8 +-- 6 files changed, 25 insertions(+), 43 deletions(-) diff --git a/libraries/animation/src/AnimNodeLoader.cpp b/libraries/animation/src/AnimNodeLoader.cpp index 3518fe14e5..b637d131f8 100644 --- a/libraries/animation/src/AnimNodeLoader.cpp +++ b/libraries/animation/src/AnimNodeLoader.cpp @@ -42,7 +42,6 @@ static AnimNode::Pointer loadManipulatorNode(const QJsonObject& jsonObj, const Q static AnimNode::Pointer loadInverseKinematicsNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl); static AnimNode::Pointer loadDefaultPoseNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl); static AnimNode::Pointer loadTwoBoneIKNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl); -static AnimNode::Pointer loadArmIKNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl); static AnimNode::Pointer loadSplineIKNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl); static AnimNode::Pointer loadPoleVectorConstraintNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl); diff --git a/libraries/animation/src/AnimPoleVectorConstraint.cpp b/libraries/animation/src/AnimPoleVectorConstraint.cpp index 7b60d6984b..f017fe2348 100644 --- a/libraries/animation/src/AnimPoleVectorConstraint.cpp +++ b/libraries/animation/src/AnimPoleVectorConstraint.cpp @@ -13,7 +13,6 @@ #include "AnimUtil.h" #include "GLMHelpers.h" -#define USE_Q_OS_ANDROID const float FRAMES_PER_SECOND = 30.0f; const float INTERP_DURATION = 6.0f; @@ -122,8 +121,6 @@ const AnimPoseVec& AnimPoleVectorConstraint::evaluate(const AnimVariantMap& anim float sideDot = glm::dot(poleVector, sideVector); float theta = copysignf(1.0f, sideDot) * acosf(dot); - - glm::quat deltaRot = glm::angleAxis(theta, unitAxis); // transform result back into parent relative frame. @@ -133,7 +130,7 @@ const AnimPoseVec& AnimPoleVectorConstraint::evaluate(const AnimVariantMap& anim glm::quat relTipRot = glm::inverse(midPose.rot()) * glm::inverse(deltaRot) * tipPose.rot(); ikChain.setRelativePoseAtJointIndex(_tipJointIndex, AnimPose(relTipRot, underPoses[_tipJointIndex].trans())); } - + // start off by initializing output poses with the underPoses _poses = underPoses; diff --git a/libraries/animation/src/AnimSplineIK.cpp b/libraries/animation/src/AnimSplineIK.cpp index 72dcbfc5e7..30e0a42e65 100644 --- a/libraries/animation/src/AnimSplineIK.cpp +++ b/libraries/animation/src/AnimSplineIK.cpp @@ -14,7 +14,6 @@ #include #include "AnimUtil.h" -static const float JOINT_CHAIN_INTERP_TIME = 0.5f; static const float FRAMES_PER_SECOND = 30.0f; AnimSplineIK::AnimSplineIK(const QString& id, float alpha, bool enabled, float interpDuration, diff --git a/libraries/animation/src/AnimSplineIK.h b/libraries/animation/src/AnimSplineIK.h index bca0f7fe77..a4d8da37ca 100644 --- a/libraries/animation/src/AnimSplineIK.h +++ b/libraries/animation/src/AnimSplineIK.h @@ -57,8 +57,8 @@ protected: bool _enabled; float _interpDuration; QString _baseJointName; - QString _tipJointName; QString _midJointName; + QString _tipJointName; QString _basePositionVar; QString _baseRotationVar; QString _midPositionVar; diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index bd990470e2..ee8daef668 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -1462,7 +1462,7 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab glm::vec3 poleVector; #if defined(Q_OS_ANDROID) || defined(USE_Q_OS_ANDROID) bool isLeft = true; - bool usePoleVector = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleVector); + bool usePoleVector = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleVector); #else bool usePoleVector = calculateElbowPoleVector(handJointIndex, elbowJointIndex, armJointIndex, oppositeArmJointIndex, poleVector); #endif @@ -1727,9 +1727,9 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s float zFactor; if (armToHand[1] > 0.0f) { - zFactor = weights[2] * glm::max(zStart - (armToHand[2] / defaultArmLength), 0.0f) * fabs(armToHand[1] / defaultArmLength); + zFactor = weights[2] * glm::max(zStart - (armToHand[2] / defaultArmLength), 0.0f) * fabsf(armToHand[1] / defaultArmLength); } else { - zFactor = zWeightBottom * glm::max(zStart - (armToHand[2] / defaultArmLength), 0.0f) * fabs(armToHand[1] / defaultArmLength); + zFactor = zWeightBottom * glm::max(zStart - (armToHand[2] / defaultArmLength), 0.0f) * fabsf(armToHand[1] / defaultArmLength); } float xFactor; @@ -1766,8 +1766,8 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s // now we calculate the contribution of the hand rotation relative to the arm - // we are adding in the delta rotation so that we have the hand correction relative to the - // latest theta for hand position + // we are adding in the delta rotation so that we have the hand correction relative to the + // latest theta for hand position glm::quat relativeHandRotation = (newAbsMid.inverse() * handPose).rot(); //glm::quat relativeHandRotation = (elbowPose.inverse() * handPose).rot(); if (relativeHandRotation.w < 0.0f) { @@ -1852,7 +1852,6 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s //qCDebug(animation) << "flex ave: " << (_flexThetaRunningAverageRight / PI) * 180.0f << " twist ave: " << (_twistThetaRunningAverageRight / PI) * 180.0f << " ulnar deviation ave: " << (_ulnarRadialThetaRunningAverageRight / PI) * 180.0f; } - const float POWER = 2.0f; const float FLEX_BOUNDARY = PI / 6.0f; const float EXTEND_BOUNDARY = -PI / 4.0f; float flexCorrection = 0.0f; @@ -1862,7 +1861,7 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s } else if (_flexThetaRunningAverageLeft < EXTEND_BOUNDARY) { flexCorrection = ((_flexThetaRunningAverageLeft - EXTEND_BOUNDARY) / PI) * 180.0f; } - if (fabs(flexCorrection) > 30.0f) { + if (fabsf(flexCorrection) > 30.0f) { flexCorrection = glm::sign(flexCorrection) * 30.0f; } theta += flexCorrection; @@ -1872,7 +1871,7 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s } else if (_flexThetaRunningAverageRight < EXTEND_BOUNDARY) { flexCorrection = ((_flexThetaRunningAverageRight - EXTEND_BOUNDARY) / PI) * 180.0f; } - if (fabs(flexCorrection) > 30.0f) { + if (fabsf(flexCorrection) > 30.0f) { flexCorrection = glm::sign(flexCorrection) * 30.0f; } theta -= flexCorrection; @@ -1888,23 +1887,23 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s } else if (_ulnarRadialThetaRunningAverageLeft < ULNAR_BOUNDARY_MINUS) { ulnarDiff = _ulnarRadialThetaRunningAverageLeft - ULNAR_BOUNDARY_MINUS; } - if (fabs(ulnarDiff) > 0.0f) { - float twistCoefficient = (fabs(_twistThetaRunningAverageLeft) / (PI / 20.0f)); + if (fabsf(ulnarDiff) > 0.0f) { + float twistCoefficient = (fabsf(_twistThetaRunningAverageLeft) / (PI / 20.0f)); if (twistCoefficient > 1.0f) { twistCoefficient = 1.0f; } if (left) { if (trueTwistTheta < 0.0f) { - ulnarCorrection -= glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection -= glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } else { - ulnarCorrection += glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection += glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } } else { // right hand if (trueTwistTheta > 0.0f) { - ulnarCorrection -= glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection -= glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } else { - ulnarCorrection += glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection += glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } } if (fabsf(ulnarCorrection) > 20.0f) { @@ -1918,23 +1917,23 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s } else if (_ulnarRadialThetaRunningAverageRight < ULNAR_BOUNDARY_MINUS) { ulnarDiff = _ulnarRadialThetaRunningAverageRight - ULNAR_BOUNDARY_MINUS; } - if (fabs(ulnarDiff) > 0.0f) { - float twistCoefficient = (fabs(_twistThetaRunningAverageRight) / (PI / 20.0f)); + if (fabsf(ulnarDiff) > 0.0f) { + float twistCoefficient = (fabsf(_twistThetaRunningAverageRight) / (PI / 20.0f)); if (twistCoefficient > 1.0f) { twistCoefficient = 1.0f; } if (left) { if (trueTwistTheta < 0.0f) { - ulnarCorrection -= glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection -= glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } else { - ulnarCorrection += glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection += glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } } else { // right hand if (trueTwistTheta > 0.0f) { - ulnarCorrection -= glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection -= glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } else { - ulnarCorrection += glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient; + ulnarCorrection += glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient; } } if (fabsf(ulnarCorrection) > 20.0f) { @@ -1998,15 +1997,12 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s float yValue = -1.0f * cos(thetaRadians); float zValue = 0.0f; glm::vec3 thetaVector(xValue, yValue, zValue); - //glm::vec3 thetaVector(1.0f, 0.0f, 0.0f); - glm::vec3 xAxis = glm::cross(Vectors::UNIT_Y, armToHand); - glm::vec3 up = glm::cross(armToHand, xAxis); - glm::quat armAxisRotation; - glm::vec3 u, v, w; + glm::vec3 up = Vectors::UNIT_Y; glm::vec3 fwd = armToHand/glm::length(armToHand); + glm::vec3 u, v, w; - generateBasisVectors(fwd, Vectors::UNIT_Y, u, v, w); + generateBasisVectors(fwd, up, u, v, w); AnimPose armAxisPose(glm::mat4(glm::vec4(-w, 0.0f), glm::vec4(v, 0.0f), glm::vec4(u, 0.0f), glm::vec4(glm::vec3(0.0f, 0.0f, 0.0f), 1.0f))); poleVector = armAxisPose * thetaVector; @@ -2092,9 +2088,6 @@ bool Rig::calculateElbowPoleVector(int handIndex, int elbowIndex, int armIndex, } poleVector = glm::normalize(attenuationVector + fullPoleVector + correctionVector); - if (handIndex == _animSkeleton->nameToJointIndex("LeftHand")) { - qCDebug(animation) << "the pole vector is " << poleVector; - } return true; } diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index 693aa732fa..94f18d789a 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -415,12 +415,6 @@ protected: glm::vec3 _prevLeftFootPoleVector { Vectors::UNIT_Z }; // sensor space bool _prevLeftFootPoleVectorValid { false }; - glm::vec3 _prevRightHandPoleVector { Vectors::UNIT_Z }; // sensor space - bool _prevRightHandPoleVectorValid { false }; - - glm::vec3 _prevLeftHandPoleVector { Vectors::UNIT_Z }; // sensor space - bool _prevLeftHandPoleVectorValid { false }; - int _rigId; bool _headEnabled { false }; bool _computeNetworkAnimation { false }; @@ -429,7 +423,7 @@ protected: float _twistThetaRunningAverageLeft { 0.0f }; float _flexThetaRunningAverageLeft { 0.0f }; float _ulnarRadialThetaRunningAverageLeft { 0.0f }; - float _twistThetaRunningAverageRight{ 0.0f }; + float _twistThetaRunningAverageRight { 0.0f }; float _flexThetaRunningAverageRight { 0.0f }; float _ulnarRadialThetaRunningAverageRight { 0.0f }; float _lastThetaLeft { 0.0f };