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