FIRE-30873: Refactor recapture

so joints usage stays in llmotion derivative; and recap position/scales too
meow-7.2.2
Angeldark Raymaker 2024-10-11 21:40:20 +01:00
parent f75ba4c24a
commit 5c703892e6
4 changed files with 65 additions and 25 deletions

View File

@ -576,8 +576,8 @@ void FSFloaterPoser::onClickRecaptureSelectedBones()
LLVector3 newRotation = _poserAnimator.getJointRotation(avatar, *item, getJointTranslation(item->jointName()),
getJointNegation(item->jointName()), true);
LLVector3 newPosition = _poserAnimator.getJointPosition(avatar, *item);
LLVector3 newScale = _poserAnimator.getJointScale(avatar, *item);
LLVector3 newPosition = _poserAnimator.getJointPosition(avatar, *item, true);
LLVector3 newScale = _poserAnimator.getJointScale(avatar, *item, true);
_poserAnimator.setPosingAvatarJoint(avatar, *item, true);

View File

@ -341,7 +341,7 @@ void FSPoserAnimator::redoLastJointScale(LLVOAvatar* avatar, FSPoserJoint joint,
oppositeJointPose->redoLastScaleSet();
}
LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar *avatar, FSPoserJoint joint)
LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture)
{
LLVector3 pos;
if (!isAvatarSafeToUse(avatar))
@ -355,7 +355,10 @@ LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar *avatar, FSPoserJoint joi
if (!jointPose)
return pos;
pos = jointPose->getTargetPosition();
if (forRecapture)
pos = jointPose->getCurrentPosition();
else
pos = jointPose->getTargetPosition();
return pos;
}
@ -415,27 +418,19 @@ LLVector3 FSPoserAnimator::getJointRotation(LLVOAvatar *avatar, FSPoserJoint joi
if (!isAvatarSafeToUse(avatar))
return vec3;
FSPosingMotion* posingMotion = getPosingMotion(avatar);
if (!posingMotion)
return vec3;
FSPosingMotion::FSJointPose* jointPose = posingMotion->getJointPoseByJointName(joint.jointName());
if (!jointPose)
return vec3;
LLQuaternion rot;
if (forRecapture)
{
LLJoint* avJoint = avatar->getJoint(JointKey::construct(joint.jointName()));
if (!avJoint)
return vec3;
rot = avJoint->getRotation();
}
rot = jointPose->getCurrentRotation();
else
{
FSPosingMotion* posingMotion = getPosingMotion(avatar);
if (!posingMotion)
return vec3;
FSPosingMotion::FSJointPose* jointPose = posingMotion->getJointPoseByJointName(joint.jointName());
if (!jointPose)
return vec3;
rot = jointPose->getTargetRotation();
}
return translateRotationFromQuaternion(translation, negation, rot);
}
@ -650,7 +645,7 @@ LLVector3 FSPoserAnimator::translateRotationFromQuaternion(E_BoneAxisTranslation
return vec3;
}
LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar *avatar, FSPoserJoint joint)
LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture)
{
LLVector3 scale;
if (!isAvatarSafeToUse(avatar))
@ -664,7 +659,10 @@ LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar *avatar, FSPoserJoint joint)
if (!jointPose)
return scale;
scale = jointPose->getTargetScale();
if (forRecapture)
scale = jointPose->getCurrentScale();
else
scale = jointPose->getTargetScale();
return scale;
}

View File

@ -334,7 +334,7 @@ public:
/// <param name="avatar">The avatar whose joint is being queried.</param>
/// <param name="joint">The joint to determine the position for.</param>
/// <returns>The position of the requested joint, if determinable, otherwise a default vector.</returns>
LLVector3 getJointPosition(LLVOAvatar *avatar, FSPoserJoint joint);
LLVector3 getJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture = false);
/// <summary>
/// Sets the position of a joint for the supplied avatar.
@ -374,7 +374,7 @@ public:
/// <param name="avatar">The avatar whose joint is being queried.</param>
/// <param name="joint">The joint to determine the scale for.</param>
/// <returns>The scale of the requested joint, if determinable, otherwise a default vector.</returns>
LLVector3 getJointScale(LLVOAvatar *avatar, FSPoserJoint joint);
LLVector3 getJointScale(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture = false);
/// <summary>
/// Sets the scale of a joint for the supplied avatar.

View File

@ -173,6 +173,20 @@ public:
/// </summary>
LLVector3 getTargetPosition() const { return _targetPosition; }
/// <summary>
/// Gets the position the animator wishes the joint to be in.
/// </summary>
LLVector3 getCurrentPosition()
{
LLVector3 vec3;
LLJoint* joint = _jointState->getJoint();
if (!joint)
return vec3;
vec3 = joint->getPosition();
return vec3;
}
/// <summary>
/// Sets the position the animator wishes the joint to be in.
/// </summary>
@ -196,6 +210,20 @@ public:
/// </summary>
LLQuaternion getTargetRotation() const { return _targetRotation; }
/// <summary>
/// Gets the rotation of the joint.
/// </summary>
LLQuaternion getCurrentRotation()
{
LLQuaternion quat;
LLJoint* joint = _jointState->getJoint();
if (!joint)
return quat;
quat = joint->getRotation();
return quat;
}
/// <summary>
/// Sets the rotation the animator wishes the joint to be in.
/// </summary>
@ -214,6 +242,20 @@ public:
/// </summary>
LLVector3 getTargetScale() const { return _targetScale; }
/// <summary>
/// Gets the scale the joint has.
/// </summary>
LLVector3 getCurrentScale()
{
LLVector3 vec3;
LLJoint* joint = _jointState->getJoint();
if (!joint)
return vec3;
vec3 = joint->getScale();
return vec3;
}
/// <summary>
/// Gets the scale the joint had when the animation was initialized.
/// </summary>