FIRE-35794: Fix position & scale load

master
Angeldark Raymaker 2025-09-26 19:59:27 +01:00
parent f0061fcd95
commit 695fb54614
4 changed files with 28 additions and 23 deletions

View File

@ -262,15 +262,12 @@ class FSJointPose
mBaseRotation.set(joint->getRotation());
mBasePosition.set(joint->getPosition());
mBaseScale.set(joint->getScale());
mBasePositionFromAnimation.setZero();
mBaseScaleFromAnimation.setZero();
}
FSJointState() = default;
LLQuaternion getTargetRotation() const { return mRotation * mBaseRotation; }
LLVector3 getTargetPosition() const { return mPosition + mBasePosition + mBasePositionFromAnimation; }
LLVector3 getTargetScale() const { return mScale + mBaseScale + mBaseScaleFromAnimation; }
LLVector3 getTargetPosition() const { return mPosition + mBasePosition; }
LLVector3 getTargetScale() const { return mScale + mBaseScale; }
void reflectRotation()
{
@ -310,8 +307,6 @@ class FSJointPose
mRotation.set(LLQuaternion::DEFAULT);
mPosition.setZero();
mScale.setZero();
mBasePositionFromAnimation.setZero();
mBaseScaleFromAnimation.setZero();
}
void zeroBaseRotation()
@ -348,8 +343,8 @@ class FSJointPose
}
mRotation.set(newPublicRot);
mPosition.set(joint->getPosition() - mBasePosition - mBasePositionFromAnimation);
mScale.set(joint->getScale() - mBaseScale - mBaseScaleFromAnimation);
mPosition.set(joint->getPosition() - mBasePosition);
mScale.set(joint->getScale() - mBaseScale);
return newPublicRot *= ~initalPublicRot;
}
@ -374,7 +369,7 @@ class FSJointPose
LL_WARNS("Posing") << "Loaded pos: " << position << " at priority " << priority << LL_ENDL;
mBasePriority = priority;
mBasePositionFromAnimation.set(position);
mBasePosition.set(position);
}
void resetBaseScale(LLVector3 scale, LLJoint::JointPriority priority)
@ -387,7 +382,7 @@ class FSJointPose
LL_WARNS("Posing") << "Loaded pos: " << scale << " at priority " << priority << LL_ENDL;
mBasePriority = priority;
mBaseScaleFromAnimation.set(scale);
mBaseScale.set(scale);
}
void setPriority(LLJoint::JointPriority priority) { mBasePriority = priority; }
@ -399,8 +394,6 @@ class FSJointPose
mBaseRotation.set(state->mBaseRotation);
mBasePosition.set(state->mBasePosition);
mBaseScale.set(state->mBaseScale);
mBasePositionFromAnimation.set(state->mBasePositionFromAnimation);
mBaseScaleFromAnimation.set(state->mBaseScaleFromAnimation);
mRotation.set(state->mRotation);
mPosition.set(state->mPosition);
@ -443,9 +436,7 @@ class FSJointPose
LLQuaternion mStartingRotation;
LLQuaternion mBaseRotation;
LLVector3 mBasePosition;
LLVector3 mBasePositionFromAnimation;
LLVector3 mBaseScale;
LLVector3 mBaseScaleFromAnimation;
LLJoint::JointPriority mBasePriority = LLJoint::LOW_PRIORITY;
};

View File

@ -934,7 +934,11 @@ void FSPoserAnimator::loadJointPosition(LLVOAvatar* avatar, const FSPoserJoint*
if (loadPositionAsDelta)
jointPose->setPublicPosition(position);
else
jointPose->setPublicPosition(position);
{
jointPose->setJointPriority(LLJoint::LOW_PRIORITY);
jointPose->setBasePosition(position, LLJoint::LOW_PRIORITY);
jointPose->setPublicPosition(LLVector3::zero);
}
}
void FSPoserAnimator::loadJointScale(LLVOAvatar* avatar, const FSPoserJoint* joint, bool loadScaleAsDelta, LLVector3 scale)
@ -953,7 +957,11 @@ void FSPoserAnimator::loadJointScale(LLVOAvatar* avatar, const FSPoserJoint* joi
if (loadScaleAsDelta)
jointPose->setPublicScale(scale);
else
jointPose->setPublicScale(scale);
{
jointPose->setJointPriority(LLJoint::LOW_PRIORITY);
jointPose->setBaseScale(scale, LLJoint::LOW_PRIORITY);
jointPose->setPublicScale(LLVector3::zero);
}
}
bool FSPoserAnimator::loadPosingState(LLVOAvatar* avatar, LLSD pose)
@ -968,7 +976,6 @@ bool FSPoserAnimator::loadPosingState(LLVOAvatar* avatar, LLSD pose)
if (!posingMotion)
return false;
// TODO: do I need to zero all bases first to reset latent rotations?
bool loadSuccess = mPosingState.applyMotionStatesToPosingMotion(avatar, posingMotion);
if (loadSuccess)
applyJointMirrorToBaseRotations(posingMotion);

View File

@ -138,7 +138,8 @@ void FSPoseState::restoreMotionStates(LLVOAvatar* avatar, LLSD pose)
continue;
fsMotionState newState;
newState.avatarId = avatar->getID();
newState.avatarId = avatar->getID();
newState.avatarOwnsPose = true;
if (control_map.has("animationId"))
{

View File

@ -297,11 +297,17 @@ bool FSPosingMotion::loadOtherMotionToBaseOfThisMotion(LLKeyframeMotion* motionT
if (hasRotation)
poserJoint_iter->setBaseRotation(rot, priority);
//if (hasPosition)
// poserJoint_iter->setBasePosition(position, priority);
if (hasPosition)
{
poserJoint_iter->setBasePosition(position, priority);
poserJoint_iter->setPublicPosition(LLVector3::zero);
}
//if (hasScale)
// poserJoint_iter->setBaseScale(scale, priority);
if (hasScale)
{
poserJoint_iter->setBaseScale(scale, priority);
poserJoint_iter->setPublicScale(LLVector3::zero);
}
}
return true;