mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:43:03 +02:00
cleanup white space
This commit is contained in:
parent
0982c37c5e
commit
e1dfd7d288
6 changed files with 25 additions and 43 deletions
|
@ -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 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 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 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 loadSplineIKNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
static AnimNode::Pointer loadPoleVectorConstraintNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
static AnimNode::Pointer loadPoleVectorConstraintNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "AnimUtil.h"
|
#include "AnimUtil.h"
|
||||||
#include "GLMHelpers.h"
|
#include "GLMHelpers.h"
|
||||||
|
|
||||||
#define USE_Q_OS_ANDROID
|
|
||||||
const float FRAMES_PER_SECOND = 30.0f;
|
const float FRAMES_PER_SECOND = 30.0f;
|
||||||
const float INTERP_DURATION = 6.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 sideDot = glm::dot(poleVector, sideVector);
|
||||||
float theta = copysignf(1.0f, sideDot) * acosf(dot);
|
float theta = copysignf(1.0f, sideDot) * acosf(dot);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glm::quat deltaRot = glm::angleAxis(theta, unitAxis);
|
glm::quat deltaRot = glm::angleAxis(theta, unitAxis);
|
||||||
|
|
||||||
// transform result back into parent relative frame.
|
// 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();
|
glm::quat relTipRot = glm::inverse(midPose.rot()) * glm::inverse(deltaRot) * tipPose.rot();
|
||||||
ikChain.setRelativePoseAtJointIndex(_tipJointIndex, AnimPose(relTipRot, underPoses[_tipJointIndex].trans()));
|
ikChain.setRelativePoseAtJointIndex(_tipJointIndex, AnimPose(relTipRot, underPoses[_tipJointIndex].trans()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// start off by initializing output poses with the underPoses
|
// start off by initializing output poses with the underPoses
|
||||||
_poses = underPoses;
|
_poses = underPoses;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <DebugDraw.h>
|
#include <DebugDraw.h>
|
||||||
#include "AnimUtil.h"
|
#include "AnimUtil.h"
|
||||||
|
|
||||||
static const float JOINT_CHAIN_INTERP_TIME = 0.5f;
|
|
||||||
static const float FRAMES_PER_SECOND = 30.0f;
|
static const float FRAMES_PER_SECOND = 30.0f;
|
||||||
|
|
||||||
AnimSplineIK::AnimSplineIK(const QString& id, float alpha, bool enabled, float interpDuration,
|
AnimSplineIK::AnimSplineIK(const QString& id, float alpha, bool enabled, float interpDuration,
|
||||||
|
|
|
@ -57,8 +57,8 @@ protected:
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
float _interpDuration;
|
float _interpDuration;
|
||||||
QString _baseJointName;
|
QString _baseJointName;
|
||||||
QString _tipJointName;
|
|
||||||
QString _midJointName;
|
QString _midJointName;
|
||||||
|
QString _tipJointName;
|
||||||
QString _basePositionVar;
|
QString _basePositionVar;
|
||||||
QString _baseRotationVar;
|
QString _baseRotationVar;
|
||||||
QString _midPositionVar;
|
QString _midPositionVar;
|
||||||
|
|
|
@ -1462,7 +1462,7 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
|
||||||
glm::vec3 poleVector;
|
glm::vec3 poleVector;
|
||||||
#if defined(Q_OS_ANDROID) || defined(USE_Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID) || defined(USE_Q_OS_ANDROID)
|
||||||
bool isLeft = true;
|
bool isLeft = true;
|
||||||
bool usePoleVector = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleVector);
|
bool usePoleVector = calculateElbowPoleVectorOptimized(handJointIndex, elbowJointIndex, armJointIndex, isLeft, poleVector);
|
||||||
#else
|
#else
|
||||||
bool usePoleVector = calculateElbowPoleVector(handJointIndex, elbowJointIndex, armJointIndex, oppositeArmJointIndex, poleVector);
|
bool usePoleVector = calculateElbowPoleVector(handJointIndex, elbowJointIndex, armJointIndex, oppositeArmJointIndex, poleVector);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1727,9 +1727,9 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
|
|
||||||
float zFactor;
|
float zFactor;
|
||||||
if (armToHand[1] > 0.0f) {
|
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 {
|
} 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;
|
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
|
// 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
|
// we are adding in the delta rotation so that we have the hand correction relative to the
|
||||||
// latest theta for hand position
|
// latest theta for hand position
|
||||||
glm::quat relativeHandRotation = (newAbsMid.inverse() * handPose).rot();
|
glm::quat relativeHandRotation = (newAbsMid.inverse() * handPose).rot();
|
||||||
//glm::quat relativeHandRotation = (elbowPose.inverse() * handPose).rot();
|
//glm::quat relativeHandRotation = (elbowPose.inverse() * handPose).rot();
|
||||||
if (relativeHandRotation.w < 0.0f) {
|
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;
|
//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 FLEX_BOUNDARY = PI / 6.0f;
|
||||||
const float EXTEND_BOUNDARY = -PI / 4.0f;
|
const float EXTEND_BOUNDARY = -PI / 4.0f;
|
||||||
float flexCorrection = 0.0f;
|
float flexCorrection = 0.0f;
|
||||||
|
@ -1862,7 +1861,7 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
} else if (_flexThetaRunningAverageLeft < EXTEND_BOUNDARY) {
|
} else if (_flexThetaRunningAverageLeft < EXTEND_BOUNDARY) {
|
||||||
flexCorrection = ((_flexThetaRunningAverageLeft - EXTEND_BOUNDARY) / PI) * 180.0f;
|
flexCorrection = ((_flexThetaRunningAverageLeft - EXTEND_BOUNDARY) / PI) * 180.0f;
|
||||||
}
|
}
|
||||||
if (fabs(flexCorrection) > 30.0f) {
|
if (fabsf(flexCorrection) > 30.0f) {
|
||||||
flexCorrection = glm::sign(flexCorrection) * 30.0f;
|
flexCorrection = glm::sign(flexCorrection) * 30.0f;
|
||||||
}
|
}
|
||||||
theta += flexCorrection;
|
theta += flexCorrection;
|
||||||
|
@ -1872,7 +1871,7 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
} else if (_flexThetaRunningAverageRight < EXTEND_BOUNDARY) {
|
} else if (_flexThetaRunningAverageRight < EXTEND_BOUNDARY) {
|
||||||
flexCorrection = ((_flexThetaRunningAverageRight - EXTEND_BOUNDARY) / PI) * 180.0f;
|
flexCorrection = ((_flexThetaRunningAverageRight - EXTEND_BOUNDARY) / PI) * 180.0f;
|
||||||
}
|
}
|
||||||
if (fabs(flexCorrection) > 30.0f) {
|
if (fabsf(flexCorrection) > 30.0f) {
|
||||||
flexCorrection = glm::sign(flexCorrection) * 30.0f;
|
flexCorrection = glm::sign(flexCorrection) * 30.0f;
|
||||||
}
|
}
|
||||||
theta -= flexCorrection;
|
theta -= flexCorrection;
|
||||||
|
@ -1888,23 +1887,23 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
} else if (_ulnarRadialThetaRunningAverageLeft < ULNAR_BOUNDARY_MINUS) {
|
} else if (_ulnarRadialThetaRunningAverageLeft < ULNAR_BOUNDARY_MINUS) {
|
||||||
ulnarDiff = _ulnarRadialThetaRunningAverageLeft - ULNAR_BOUNDARY_MINUS;
|
ulnarDiff = _ulnarRadialThetaRunningAverageLeft - ULNAR_BOUNDARY_MINUS;
|
||||||
}
|
}
|
||||||
if (fabs(ulnarDiff) > 0.0f) {
|
if (fabsf(ulnarDiff) > 0.0f) {
|
||||||
float twistCoefficient = (fabs(_twistThetaRunningAverageLeft) / (PI / 20.0f));
|
float twistCoefficient = (fabsf(_twistThetaRunningAverageLeft) / (PI / 20.0f));
|
||||||
if (twistCoefficient > 1.0f) {
|
if (twistCoefficient > 1.0f) {
|
||||||
twistCoefficient = 1.0f;
|
twistCoefficient = 1.0f;
|
||||||
}
|
}
|
||||||
if (left) {
|
if (left) {
|
||||||
if (trueTwistTheta < 0.0f) {
|
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 {
|
} else {
|
||||||
ulnarCorrection += glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient;
|
ulnarCorrection += glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// right hand
|
// right hand
|
||||||
if (trueTwistTheta > 0.0f) {
|
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 {
|
} 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) {
|
if (fabsf(ulnarCorrection) > 20.0f) {
|
||||||
|
@ -1918,23 +1917,23 @@ bool Rig::calculateElbowPoleVectorOptimized(int handIndex, int elbowIndex, int s
|
||||||
} else if (_ulnarRadialThetaRunningAverageRight < ULNAR_BOUNDARY_MINUS) {
|
} else if (_ulnarRadialThetaRunningAverageRight < ULNAR_BOUNDARY_MINUS) {
|
||||||
ulnarDiff = _ulnarRadialThetaRunningAverageRight - ULNAR_BOUNDARY_MINUS;
|
ulnarDiff = _ulnarRadialThetaRunningAverageRight - ULNAR_BOUNDARY_MINUS;
|
||||||
}
|
}
|
||||||
if (fabs(ulnarDiff) > 0.0f) {
|
if (fabsf(ulnarDiff) > 0.0f) {
|
||||||
float twistCoefficient = (fabs(_twistThetaRunningAverageRight) / (PI / 20.0f));
|
float twistCoefficient = (fabsf(_twistThetaRunningAverageRight) / (PI / 20.0f));
|
||||||
if (twistCoefficient > 1.0f) {
|
if (twistCoefficient > 1.0f) {
|
||||||
twistCoefficient = 1.0f;
|
twistCoefficient = 1.0f;
|
||||||
}
|
}
|
||||||
if (left) {
|
if (left) {
|
||||||
if (trueTwistTheta < 0.0f) {
|
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 {
|
} else {
|
||||||
ulnarCorrection += glm::sign(ulnarDiff) * (fabs(ulnarDiff) / PI) * 40.0f * twistCoefficient;
|
ulnarCorrection += glm::sign(ulnarDiff) * (fabsf(ulnarDiff) / PI) * 40.0f * twistCoefficient;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// right hand
|
// right hand
|
||||||
if (trueTwistTheta > 0.0f) {
|
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 {
|
} 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) {
|
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 yValue = -1.0f * cos(thetaRadians);
|
||||||
float zValue = 0.0f;
|
float zValue = 0.0f;
|
||||||
glm::vec3 thetaVector(xValue, yValue, zValue);
|
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 = Vectors::UNIT_Y;
|
||||||
glm::vec3 up = glm::cross(armToHand, xAxis);
|
|
||||||
glm::quat armAxisRotation;
|
|
||||||
glm::vec3 u, v, w;
|
|
||||||
glm::vec3 fwd = armToHand/glm::length(armToHand);
|
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)));
|
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;
|
poleVector = armAxisPose * thetaVector;
|
||||||
|
|
||||||
|
@ -2092,9 +2088,6 @@ bool Rig::calculateElbowPoleVector(int handIndex, int elbowIndex, int armIndex,
|
||||||
}
|
}
|
||||||
poleVector = glm::normalize(attenuationVector + fullPoleVector + correctionVector);
|
poleVector = glm::normalize(attenuationVector + fullPoleVector + correctionVector);
|
||||||
|
|
||||||
if (handIndex == _animSkeleton->nameToJointIndex("LeftHand")) {
|
|
||||||
qCDebug(animation) << "the pole vector is " << poleVector;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,12 +415,6 @@ protected:
|
||||||
glm::vec3 _prevLeftFootPoleVector { Vectors::UNIT_Z }; // sensor space
|
glm::vec3 _prevLeftFootPoleVector { Vectors::UNIT_Z }; // sensor space
|
||||||
bool _prevLeftFootPoleVectorValid { false };
|
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;
|
int _rigId;
|
||||||
bool _headEnabled { false };
|
bool _headEnabled { false };
|
||||||
bool _computeNetworkAnimation { false };
|
bool _computeNetworkAnimation { false };
|
||||||
|
@ -429,7 +423,7 @@ protected:
|
||||||
float _twistThetaRunningAverageLeft { 0.0f };
|
float _twistThetaRunningAverageLeft { 0.0f };
|
||||||
float _flexThetaRunningAverageLeft { 0.0f };
|
float _flexThetaRunningAverageLeft { 0.0f };
|
||||||
float _ulnarRadialThetaRunningAverageLeft { 0.0f };
|
float _ulnarRadialThetaRunningAverageLeft { 0.0f };
|
||||||
float _twistThetaRunningAverageRight{ 0.0f };
|
float _twistThetaRunningAverageRight { 0.0f };
|
||||||
float _flexThetaRunningAverageRight { 0.0f };
|
float _flexThetaRunningAverageRight { 0.0f };
|
||||||
float _ulnarRadialThetaRunningAverageRight { 0.0f };
|
float _ulnarRadialThetaRunningAverageRight { 0.0f };
|
||||||
float _lastThetaLeft { 0.0f };
|
float _lastThetaLeft { 0.0f };
|
||||||
|
|
Loading…
Reference in a new issue