Merge pull request #6116 from AndrewMeadows/reduced-hips-shift-from-hand-targets

hack to reduce hand influence of hips in HMD mode
This commit is contained in:
Philip Rosedale 2015-10-19 22:31:50 -07:00
commit 282485d412
4 changed files with 13 additions and 6 deletions

View file

@ -255,7 +255,7 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(const std::vector<I
}
// store the rotation change in the accumulator
_accumulators[pivotIndex].add(newRot);
_accumulators[pivotIndex].add(newRot, target.getWeight());
// this joint has been changed so we check to see if it has the lowest index
if (pivotIndex < lowestMovedIndex) {

View file

@ -12,6 +12,8 @@
#include "AnimSkeleton.h"
const float HACK_HMD_TARGET_WEIGHT = 8.0f;
class IKTarget {
public:
enum class Type {
@ -33,10 +35,13 @@ public:
void setIndex(int index) { _index = index; }
void setType(int);
// HACK: give HmdHead targets more "weight" during IK algorithm
float getWeight() const { return _type == Type::HmdHead ? HACK_HMD_TARGET_WEIGHT : 1.0f; }
private:
AnimPose _pose;
int _index = -1;
Type _type = Type::RotationAndPosition;
int _index{-1};
Type _type{Type::RotationAndPosition};
};

View file

@ -11,9 +11,9 @@
#include <glm/gtx/quaternion.hpp>
void RotationAccumulator::add(const glm::quat& rotation) {
void RotationAccumulator::add(const glm::quat& rotation, float weight) {
// make sure both quaternions are on the same hyper-hemisphere before we add them linearly (lerp)
_rotationSum += copysignf(1.0f, glm::dot(_rotationSum, rotation)) * rotation;
_rotationSum += copysignf(weight, glm::dot(_rotationSum, rotation)) * rotation;
++_numRotations;
_isDirty = true;
}

View file

@ -18,7 +18,9 @@ public:
int size() const { return _numRotations; }
void add(const glm::quat& rotation);
/// \param rotation rotation to add
/// \param weight contribution factor of this rotation to total accumulation
void add(const glm::quat& rotation, float weight = 1.0f);
glm::quat getAverage();