mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 01:46:18 +02:00
got rid of the lag in the spline code by setting the flex coeffs to 1.0
This commit is contained in:
parent
bcbd9323c0
commit
f2a7f37950
9 changed files with 20 additions and 41 deletions
|
@ -194,8 +194,8 @@
|
|||
"enabledVar": "splineIKEnabled",
|
||||
"endEffectorRotationVarVar": "splineIKRotationVar",
|
||||
"endEffectorPositionVarVar": "splineIKPositionVar",
|
||||
"primaryFlexCoefficients": "1, 0.5, 0.25, 0.2, 0.1",
|
||||
"secondaryFlexCoefficients": "1.0, 0.5, 0.25"
|
||||
"primaryFlexCoefficients": "1.0, 1.0, 1.0, 1.0, 1.0",
|
||||
"secondaryFlexCoefficients": "1.0, 1.0, 1.0"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
|
|
|
@ -4814,6 +4814,7 @@ void setupCpuMonitorThread() {
|
|||
|
||||
void Application::idle() {
|
||||
PerformanceTimer perfTimer("idle");
|
||||
|
||||
// Update the deadlock watchdog
|
||||
updateHeartbeat();
|
||||
|
||||
|
|
|
@ -82,16 +82,6 @@ public:
|
|||
return foundIndex;
|
||||
}
|
||||
|
||||
const AnimPose& getRelativePoseAtJointIndex(int jointIndex) const {
|
||||
for (int i = 0; i < _top; i++) {
|
||||
if (_chain[i].jointIndex == jointIndex) {
|
||||
return _chain[i].relativePose;
|
||||
}
|
||||
}
|
||||
return AnimPose::identity;
|
||||
}
|
||||
|
||||
|
||||
void buildDirtyAbsolutePoses() {
|
||||
// the relative and absolute pose is the same for the base of the chain.
|
||||
_chain[_top - 1].absolutePose = _chain[_top - 1].relativePose;
|
||||
|
|
|
@ -601,9 +601,9 @@ static AnimNode::Pointer loadSplineIKNode(const QJsonObject& jsonObj, const QStr
|
|||
|
||||
auto node = std::make_shared<AnimSplineIK>(id, alpha, enabled, interpDuration,
|
||||
baseJointName, tipJointName,
|
||||
alphaVar, enabledVar, endEffectorRotationVarVar, endEffectorPositionVarVar,
|
||||
basePositionVar, baseRotationVar,
|
||||
tipPositionVar, tipRotationVar, secondaryTargetJointName, secondaryTargetPositionVar,
|
||||
alphaVar, enabledVar, endEffectorRotationVarVar, endEffectorPositionVarVar,
|
||||
basePositionVar, baseRotationVar,
|
||||
tipPositionVar, tipRotationVar, secondaryTargetJointName, secondaryTargetPositionVar,
|
||||
secondaryTargetRotationVar, primaryFlexCoefficients, secondaryFlexCoefficients);
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ AnimSplineIK::AnimSplineIK(const QString& id, float alpha, bool enabled, float i
|
|||
_secondaryTargetPositionVar(secondaryTargetPositionVar),
|
||||
_secondaryTargetRotationVar(secondaryTargetRotationVar)
|
||||
{
|
||||
|
||||
|
||||
QStringList flexCoefficientsValues = primaryFlexCoefficients.split(',', QString::SkipEmptyParts);
|
||||
for (int i = 0; i < flexCoefficientsValues.size(); i++) {
|
||||
if (i < MAX_NUMBER_FLEX_VARIABLES) {
|
||||
|
@ -134,7 +134,6 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
|||
glm::vec3 hipsTargetTranslation;
|
||||
|
||||
// now we override the hips with the hips target pose.
|
||||
////////////////////////////////////////////////////
|
||||
if (_poses.size() > 0) {
|
||||
AnimPose hipsUnderPose = _skeleton->getAbsolutePose(_hipsIndex, _poses);
|
||||
hipsTargetRotation = animVars.lookupRigToGeometry("hipsRotation", hipsUnderPose.rot());
|
||||
|
@ -147,12 +146,11 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
|||
_poses[_hipsIndex] = hipsParentAbsPose.inverse() * absHipsTargetPose;
|
||||
_poses[_hipsIndex].scale() = glm::vec3(1.0f);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
AnimPoseVec absolutePoses;
|
||||
absolutePoses.resize(_poses.size());
|
||||
computeAbsolutePoses(absolutePoses);
|
||||
|
||||
|
||||
IKTarget target;
|
||||
if (_tipJointIndex != -1) {
|
||||
target.setType((int)IKTarget::Type::Spline);
|
||||
|
@ -165,7 +163,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
|||
target.setPose(rotation, translation);
|
||||
target.setWeight(weight);
|
||||
|
||||
|
||||
|
||||
|
||||
const float* flexCoefficients = new float[5]{ 1.0f, 0.5f, 0.25f, 0.2f, 0.1f };
|
||||
target.setFlexCoefficients(_numPrimaryFlexCoefficients, _primaryFlexCoefficients);
|
||||
|
@ -186,12 +184,10 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
|||
|
||||
AnimPose afterSolveSecondaryTarget = _skeleton->getAbsolutePose(_secondaryTargetIndex, _poses);
|
||||
glm::quat secondaryTargetRotation = animVars.lookupRigToGeometry(_secondaryTargetRotationVar, afterSolveSecondaryTarget.rot());
|
||||
|
||||
updatedSecondaryTarget = AnimPose(secondaryTargetRotation, afterSolveSecondaryTarget.trans());
|
||||
updatedSecondaryTarget = AnimPose(secondaryTargetRotation, afterSolveSecondaryTarget.trans());
|
||||
//updatedSecondaryTarget = AnimPose(afterSolveSecondaryTarget.rot(), afterSolveSecondaryTarget.trans());
|
||||
}
|
||||
|
||||
|
||||
IKTarget secondaryTarget;
|
||||
computeAbsolutePoses(absolutePoses2);
|
||||
if (_secondaryTargetIndex != -1) {
|
||||
|
@ -199,14 +195,13 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
|||
secondaryTarget.setIndex(_secondaryTargetIndex);
|
||||
|
||||
float weight2 = 1.0f;
|
||||
|
||||
secondaryTarget.setPose(updatedSecondaryTarget.rot(), updatedSecondaryTarget.trans());
|
||||
secondaryTarget.setWeight(weight2);
|
||||
|
||||
|
||||
const float* flexCoefficients2 = new float[3]{ 1.0f, 0.5f, 0.25f };
|
||||
secondaryTarget.setFlexCoefficients(_numSecondaryFlexCoefficients, _secondaryFlexCoefficients);
|
||||
}
|
||||
|
||||
|
||||
AnimChain secondaryJointChain;
|
||||
AnimPose beforeSolveChestNeck;
|
||||
if (_poses.size() > 0) {
|
||||
|
@ -223,17 +218,11 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
|||
int tipParent = _skeleton->getParentIndex(_tipJointIndex);
|
||||
int secondaryTargetParent = _skeleton->getParentIndex(_secondaryTargetIndex);
|
||||
if ((secondaryTargetParent != -1) && (tipParent != -1) && (_poses.size() > 0)) {
|
||||
/*
|
||||
AnimPose secondaryTargetPose(target2.getRotation(), target2.getTranslation());
|
||||
AnimPose secondaryTargetRelativePose = _skeleton->getAbsolutePose(secondaryTargetParent, _poses).inverse() * secondaryTargetPose;
|
||||
_poses[_secondaryTargetIndex] = secondaryTargetRelativePose;
|
||||
*/
|
||||
|
||||
AnimPose secondaryTargetPose(secondaryTarget.getRotation(), secondaryTarget.getTranslation());
|
||||
AnimPose neckAbsolute = _skeleton->getAbsolutePose(tipParent, _poses);
|
||||
//AnimPose finalNeckAbsolute = AnimPose(safeLerp(target2.getRotation(), target.getRotation(), 1.0f),neckAbsolute.trans());
|
||||
_poses[tipParent] = secondaryTargetPose.inverse() * beforeSolveChestNeck;
|
||||
|
||||
|
||||
AnimPose tipTarget(target.getRotation(),target.getTranslation());
|
||||
AnimPose tipRelativePose = _skeleton->getAbsolutePose(tipParent,_poses).inverse() * tipTarget;
|
||||
_poses[_tipJointIndex] = tipRelativePose;
|
||||
|
@ -314,7 +303,7 @@ const AnimPoseVec& AnimSplineIK::evaluate(const AnimVariantMap& animVars, const
|
|||
|
||||
}
|
||||
_previousEnableDebugIKTargets = context.getEnableDebugDrawIKTargets();
|
||||
|
||||
|
||||
return _poses;
|
||||
}
|
||||
|
||||
|
@ -458,7 +447,7 @@ void AnimSplineIK::solveTargetWithSpline(const AnimContext& context, const IKTar
|
|||
relPose.trans() = glm::vec3(0.0f);
|
||||
}
|
||||
}
|
||||
// note we are ignoring the constrained info for now.
|
||||
// note we are ignoring the constrained info for now.
|
||||
if (!chainInfoOut.setRelativePoseAtJointIndex(splineJointInfo.jointIndex, relPose)) {
|
||||
qCDebug(animation) << "we didn't find the joint index for the spline!!!!";
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ public:
|
|||
AnimSplineIK(const QString& id, float alpha, bool enabled, float interpDuration,
|
||||
const QString& baseJointName, const QString& tipJointName,
|
||||
const QString& alphaVar, const QString& enabledVar,
|
||||
const QString& endEffectorRotationVarVar, const QString& endEffectorPositionVarVar,
|
||||
const QString& basePositionVar, const QString& baseRotationVar,
|
||||
const QString& endEffectorRotationVarVar, const QString& endEffectorPositionVarVar,
|
||||
const QString& basePositionVar, const QString& baseRotationVar,
|
||||
const QString& tipPositionVar, const QString& tipRotationVar,
|
||||
const QString& secondaryTargetJointName,
|
||||
const QString& secondaryTargetPositionVar,
|
||||
|
|
|
@ -89,7 +89,7 @@ const AnimPoseVec& AnimTwoBoneIK::evaluate(const AnimVariantMap& animVars, const
|
|||
}
|
||||
_enabled = enabled;
|
||||
|
||||
// don't build chains or do IK if we are disabled & not interping.
|
||||
// don't build chains or do IK if we are disbled & not interping.
|
||||
if (_interpType == InterpType::None && !enabled) {
|
||||
_poses = underPoses;
|
||||
return _poses;
|
||||
|
|
|
@ -1468,7 +1468,7 @@ void Rig::updateHands(bool leftHandEnabled, bool rightHandEnabled, bool hipsEnab
|
|||
// need this for two bone ik
|
||||
_animVars.set(LEFT_HAND_IK_POSITION_VAR, MAIN_STATE_MACHINE_LEFT_HAND_POSITION);
|
||||
_animVars.set(LEFT_HAND_IK_ROTATION_VAR, MAIN_STATE_MACHINE_LEFT_HAND_ROTATION);
|
||||
|
||||
|
||||
_animVars.set("leftHandPoleVectorEnabled", false);
|
||||
_animVars.unset("leftHandPosition");
|
||||
_animVars.unset("leftHandRotation");
|
||||
|
|
|
@ -1314,7 +1314,6 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
|||
joint.inverseBindRotation = joint.inverseDefaultRotation;
|
||||
joint.name = fbxModel.name;
|
||||
if (hfmModel.hfmToHifiJointNameMapping.contains(hfmModel.hfmToHifiJointNameMapping.key(joint.name))) {
|
||||
// qCDebug(modelformat) << "joint name " << joint.name << " hifi name " << hfmModel.hfmToHifiJointNameMapping.key(fbxModel.name);
|
||||
joint.name = hfmModel.hfmToHifiJointNameMapping.key(fbxModel.name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue