mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
add arm ik class for cleanup of inverse kinematics
This commit is contained in:
parent
3b5d8db650
commit
bd9405aef8
3 changed files with 77 additions and 1 deletions
40
libraries/animation/src/AnimArmIK.cpp
Normal file
40
libraries/animation/src/AnimArmIK.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// AnimArmIK.cpp
|
||||
//
|
||||
// Created by Angus Antley on 1/9/19.
|
||||
// Copyright (c) 2019 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "AnimArmIK.h"
|
||||
|
||||
#include <DebugDraw.h>
|
||||
|
||||
#include "AnimationLogging.h"
|
||||
#include "AnimUtil.h"
|
||||
|
||||
AnimArmIK::AnimArmIK(const QString& id, float alpha, bool enabled, float interpDuration,
|
||||
const QString& baseJointName, const QString& midJointName,
|
||||
const QString& tipJointName, const glm::vec3& midHingeAxis,
|
||||
const QString& alphaVar, const QString& enabledVar,
|
||||
const QString& endEffectorRotationVarVar, const QString& endEffectorPositionVarVar) :
|
||||
AnimTwoBoneIK(id, alpha, enabled, interpDuration, baseJointName, midJointName, tipJointName, midHingeAxis, alphaVar, enabledVar, endEffectorRotationVarVar, endEffectorPositionVarVar) {
|
||||
|
||||
}
|
||||
|
||||
AnimArmIK::~AnimArmIK() {
|
||||
|
||||
}
|
||||
|
||||
const AnimPoseVec& AnimArmIK::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) {
|
||||
qCDebug(animation) << "evaluating the arm IK";
|
||||
|
||||
assert(_children.size() == 1);
|
||||
if (_children.size() != 1) {
|
||||
return _poses;
|
||||
} else {
|
||||
return _poses;
|
||||
}
|
||||
}
|
34
libraries/animation/src/AnimArmIK.h
Normal file
34
libraries/animation/src/AnimArmIK.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// AnimArmIK.h
|
||||
//
|
||||
// Created by Angus Antley on 1/9/19.
|
||||
// Copyright (c) 2019 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_AnimArmIK_h
|
||||
#define hifi_AnimArmIK_h
|
||||
|
||||
//#include "AnimNode.h"
|
||||
#include "AnimTwoBoneIK.h"
|
||||
//#include "AnimChain.h"
|
||||
|
||||
// Simple two bone IK chain
|
||||
class AnimArmIK : public AnimTwoBoneIK {
|
||||
public:
|
||||
AnimArmIK(const QString& id, float alpha, bool enabled, float interpDuration,
|
||||
const QString& baseJointName, const QString& midJointName,
|
||||
const QString& tipJointName, const glm::vec3& midHingeAxis,
|
||||
const QString& alphaVar, const QString& enabledVar,
|
||||
const QString& endEffectorRotationVarVar, const QString& endEffectorPositionVarVar);
|
||||
virtual ~AnimArmIK();
|
||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) override;
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_AnimArmIK_h
|
||||
|
|
@ -237,6 +237,7 @@ void AnimInverseKinematics::solve(const AnimContext& context, const std::vector<
|
|||
|
||||
// solve all targets
|
||||
for (size_t i = 0; i < targets.size(); i++) {
|
||||
qCDebug(animation) << "target id: " << targets[i].getIndex() << " and type " << (int)targets[i].getType();
|
||||
switch (targets[i].getType()) {
|
||||
case IKTarget::Type::Unknown:
|
||||
break;
|
||||
|
@ -859,6 +860,7 @@ void AnimInverseKinematics::solveTargetWithSpline(const AnimContext& context, co
|
|||
//virtual
|
||||
const AnimPoseVec& AnimInverseKinematics::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) {
|
||||
// don't call this function, call overlay() instead
|
||||
qCDebug(animation) << "called evaluate for inverse kinematics";
|
||||
assert(false);
|
||||
return _relativePoses;
|
||||
}
|
||||
|
@ -869,7 +871,7 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
|
|||
// disable IK on android
|
||||
return underPoses;
|
||||
#endif
|
||||
|
||||
qCDebug(animation) << "called overlay for inverse kinematics";
|
||||
// allows solutionSource to be overridden by an animVar
|
||||
auto solutionSource = animVars.lookup(_solutionSourceVar, (int)_solutionSource);
|
||||
|
||||
|
|
Loading…
Reference in a new issue