mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:04:44 +02:00
Get the base position/orientation directly from the avatar to prevent
jerkiness when flying with the Hydra. Also, restore arm lengths when the Hydra becomes inactive.
This commit is contained in:
parent
81ab68a529
commit
804ce83fa6
4 changed files with 23 additions and 20 deletions
|
@ -262,15 +262,6 @@ void Hand::simulate(float deltaTime, bool isMine) {
|
|||
|
||||
if (isMine) {
|
||||
_buckyBalls.simulate(deltaTime);
|
||||
}
|
||||
|
||||
const glm::vec3 leapHandsOffsetFromFace(0.0, -0.2, -0.3); // place the hand in front of the face where we can see it
|
||||
|
||||
Head& head = _owningAvatar->getHead();
|
||||
_baseOrientation = _owningAvatar->getOrientation();
|
||||
_basePosition = head.calculateAverageEyePosition() + _baseOrientation * leapHandsOffsetFromFace * head.getScale();
|
||||
|
||||
if (isMine) {
|
||||
updateCollisions();
|
||||
}
|
||||
|
||||
|
@ -465,7 +456,7 @@ void Hand::calculateGeometry() {
|
|||
const float standardBallRadius = FINGERTIP_COLLISION_RADIUS;
|
||||
_leapFingerTipBalls.resize(_leapFingerTipBalls.size() + 1);
|
||||
HandBall& ball = _leapFingerTipBalls.back();
|
||||
ball.rotation = _baseOrientation;
|
||||
ball.rotation = getBaseOrientation();
|
||||
ball.position = finger.getTipPosition();
|
||||
ball.radius = standardBallRadius;
|
||||
ball.touchForce = 0.0;
|
||||
|
@ -487,7 +478,7 @@ void Hand::calculateGeometry() {
|
|||
const float standardBallRadius = 0.005f;
|
||||
_leapFingerRootBalls.resize(_leapFingerRootBalls.size() + 1);
|
||||
HandBall& ball = _leapFingerRootBalls.back();
|
||||
ball.rotation = _baseOrientation;
|
||||
ball.rotation = getBaseOrientation();
|
||||
ball.position = finger.getRootPosition();
|
||||
ball.radius = standardBallRadius;
|
||||
ball.touchForce = 0.0;
|
||||
|
|
|
@ -798,7 +798,10 @@ bool Model::restoreJointPosition(int jointIndex, float percent) {
|
|||
const QVector<int>& freeLineage = geometry.joints.at(jointIndex).freeLineage;
|
||||
|
||||
foreach (int index, freeLineage) {
|
||||
_jointStates[index].rotation = safeMix(_jointStates[index].rotation, geometry.joints.at(index).rotation, percent);
|
||||
JointState& state = _jointStates[index];
|
||||
const FBXJoint& joint = geometry.joints.at(index);
|
||||
state.rotation = safeMix(state.rotation, joint.rotation, percent);
|
||||
state.translation = glm::mix(state.translation, joint.translation, percent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
const int fingerVectorRadix = 4;
|
||||
|
||||
HandData::HandData(AvatarData* owningAvatar) :
|
||||
_basePosition(0.0f, 0.0f, 0.0f),
|
||||
_baseOrientation(0.0f, 0.0f, 0.0f, 1.0f),
|
||||
_owningAvatarData(owningAvatar)
|
||||
{
|
||||
// Start with two palms
|
||||
|
@ -26,11 +24,11 @@ HandData::HandData(AvatarData* owningAvatar) :
|
|||
}
|
||||
|
||||
glm::vec3 HandData::worldPositionToLeapPosition(const glm::vec3& worldPosition) const {
|
||||
return glm::inverse(_baseOrientation) * (worldPosition - _basePosition) / LEAP_UNIT_SCALE;
|
||||
return glm::inverse(getBaseOrientation()) * (worldPosition - getBasePosition()) / LEAP_UNIT_SCALE;
|
||||
}
|
||||
|
||||
glm::vec3 HandData::worldVectorToLeapVector(const glm::vec3& worldVector) const {
|
||||
return glm::inverse(_baseOrientation) * worldVector / LEAP_UNIT_SCALE;
|
||||
return glm::inverse(getBaseOrientation()) * worldVector / LEAP_UNIT_SCALE;
|
||||
}
|
||||
|
||||
PalmData& HandData::addNewPalm() {
|
||||
|
@ -254,6 +252,15 @@ bool HandData::findSpherePenetration(const glm::vec3& penetratorCenter, float pe
|
|||
return false;
|
||||
}
|
||||
|
||||
glm::quat HandData::getBaseOrientation() const {
|
||||
return _owningAvatarData->getOrientation();
|
||||
}
|
||||
|
||||
glm::vec3 HandData::getBasePosition() const {
|
||||
const glm::vec3 LEAP_HANDS_OFFSET_FROM_TORSO(0.0, 0.3, -0.3);
|
||||
return _owningAvatarData->getPosition() + getBaseOrientation() * LEAP_HANDS_OFFSET_FROM_TORSO *
|
||||
_owningAvatarData->getTargetScale();
|
||||
}
|
||||
|
||||
void FingerData::setTrailLength(unsigned int length) {
|
||||
_tipTrailPositions.resize(length);
|
||||
|
|
|
@ -50,10 +50,10 @@ public:
|
|||
|
||||
// position conversion
|
||||
glm::vec3 leapPositionToWorldPosition(const glm::vec3& leapPosition) {
|
||||
return _basePosition + _baseOrientation * (leapPosition * LEAP_UNIT_SCALE);
|
||||
return getBasePosition() + getBaseOrientation() * (leapPosition * LEAP_UNIT_SCALE);
|
||||
}
|
||||
glm::vec3 leapDirectionToWorldDirection(const glm::vec3& leapDirection) {
|
||||
return _baseOrientation * leapDirection;
|
||||
return getBaseOrientation() * leapDirection;
|
||||
}
|
||||
glm::vec3 worldPositionToLeapPosition(const glm::vec3& worldPosition) const;
|
||||
glm::vec3 worldVectorToLeapVector(const glm::vec3& worldVector) const;
|
||||
|
@ -86,10 +86,12 @@ public:
|
|||
|
||||
friend class AvatarData;
|
||||
protected:
|
||||
glm::vec3 _basePosition; // Hands are placed relative to this
|
||||
glm::quat _baseOrientation; // Hands are placed relative to this
|
||||
AvatarData* _owningAvatarData;
|
||||
std::vector<PalmData> _palms;
|
||||
|
||||
glm::quat getBaseOrientation() const;
|
||||
glm::vec3 getBasePosition() const;
|
||||
|
||||
private:
|
||||
// privatize copy ctor and assignment operator so copies of this object cannot be made
|
||||
HandData(const HandData&);
|
||||
|
|
Loading…
Reference in a new issue