mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 02:23:57 +02:00
hack to reduce hand influence of hips in HMD mode
This commit is contained in:
parent
2cd6d7c8a5
commit
917bfbf64e
4 changed files with 13 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -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};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue