Poser: tidy up UI methods

and correct shift/alt behaviour when using trackpad
master
Angeldark Raymaker 2025-04-04 11:07:54 +01:00
parent 1d96298089
commit a187191260
2 changed files with 39 additions and 22 deletions

View File

@ -432,6 +432,12 @@ void FSFloaterPoser::onMouseLeaveSavePoseBtn()
{
if (hasString("icon_save_button"))
mSavePosesBtn->setImageOverlay(getString("icon_save_button"), mSavePosesBtn->getImageOverlayHAlign());
LLVOAvatar* avatar = getUiSelectedAvatar();
if (!avatar)
return;
setSavePosesButtonText(!mPoserAnimator.allBaseRotationsAreZero(avatar));
}
void FSFloaterPoser::createUserPoseDirectoryIfNeeded()
@ -1785,17 +1791,29 @@ void FSFloaterPoser::onTrackballChanged()
trackPadDeltaPos[VY] *= NormalTrackpadRangeInRads * trackPadSensitivity * RAD_TO_DEG;
trackPadDeltaPos[VZ] *= NormalTrackpadRangeInRads * RAD_TO_DEG;
F32 axis1 = (F32)mYawSpnr->getValue().asReal();
F32 axis2 = (F32)mPitchSpnr->getValue().asReal();
F32 axis3 = (F32)mRollSpnr->getValue().asReal();
mYawSpnr->setValue(axis1 + trackPadDeltaPos[VX]);
mPitchSpnr->setValue(axis2 + trackPadDeltaPos[VY]);
mRollSpnr->setValue(axis3 + trackPadDeltaPos[VZ]);
F32 axis1 = clipRange((F32)mYawSpnr->getValue().asReal() + trackPadDeltaPos[VX]);
F32 axis2 = (F32)mPitchSpnr->getValue().asReal() + trackPadDeltaPos[VY];
F32 axis3 = (F32)mRollSpnr->getValue().asReal() + trackPadDeltaPos[VZ];
onYawPitchRollChanged();
mYawSpnr->setValue(axis1);
mPitchSpnr->setValue(axis2);
mRollSpnr->setValue(axis3);
onYawPitchRollChanged(true);
}
void FSFloaterPoser::onYawPitchRollChanged()
F32 FSFloaterPoser::clipRange(F32 value)
{
F32 result = fmodf(value, 3600.f); // to avoid time consuming while loops
while (result > 180.f)
result -= 360.f;
while (result < -180.f)
result += 360.f;
return result;
}
void FSFloaterPoser::onYawPitchRollChanged(bool skipUpdateTrackpad)
{
LLVector3 absoluteRotation, deltaRotation;
absoluteRotation.mV[VX] = (F32)mYawSpnr->getValue().asReal() * DEG_TO_RAD;
@ -1806,8 +1824,10 @@ void FSFloaterPoser::onYawPitchRollChanged()
mLastSliderRotation = absoluteRotation;
setSelectedJointsRotation(absoluteRotation, deltaRotation);
refreshTrackpadCursor();
enableOrDisableRedoAndUndoButton();
if (!skipUpdateTrackpad)
refreshTrackpadCursor();
}
void FSFloaterPoser::onAdjustTrackpadSensitivity()
@ -1817,13 +1837,10 @@ void FSFloaterPoser::onAdjustTrackpadSensitivity()
void FSFloaterPoser::refreshTrackpadCursor()
{
F32 axis1 = (F32)mYawSpnr->getValue().asReal() * DEG_TO_RAD / NormalTrackpadRangeInRads;
F32 axis2 = (F32)mPitchSpnr->getValue().asReal() * DEG_TO_RAD / NormalTrackpadRangeInRads;
F32 axis3 = (F32)mRollSpnr->getValue().asReal() * DEG_TO_RAD / NormalTrackpadRangeInRads;
F32 trackPadSensitivity = llmax(gSavedSettings.getF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY), 0.0001f);
axis1 /= trackPadSensitivity;
axis2 /= trackPadSensitivity;
F32 axis1 = (F32)mYawSpnr->getValue().asReal() * DEG_TO_RAD / NormalTrackpadRangeInRads / trackPadSensitivity;
F32 axis2 = (F32)mPitchSpnr->getValue().asReal() * DEG_TO_RAD / NormalTrackpadRangeInRads / trackPadSensitivity;
F32 axis3 = (F32)mRollSpnr->getValue().asReal() * DEG_TO_RAD / NormalTrackpadRangeInRads;
mAvatarTrackball->setValue(axis1, axis2, axis3);
}

View File

@ -251,7 +251,7 @@ public:
void onSetAvatarToTpose();
void onPoseStartStop();
void onTrackballChanged();
void onYawPitchRollChanged();
void onYawPitchRollChanged(bool skipUpdateTrackpad = false);
void onPositionSet();
void onScaleSet();
void onClickToggleSelectedBoneEnabled();
@ -427,15 +427,15 @@ public:
std::string static vec3ToXYZString(const LLVector3& val);
/// <summary>
/// Unwraps a normalized value from the trackball to a slider value.
/// Performs an angle module of the supplied value to between -180 & 180 (degrees).
/// </summary>
/// <param name="scale">The scale value from the trackball.</param>
/// <returns>A value appropriate for fitting a slider.</returns>
/// <param name="value">The value to modulo.</param>
/// <returns>The modulo value.</returns>
/// <remarks>
/// If the trackpad is in 'infinite scroll' mode, it can produce normalized-values outside the range of the sliders.
/// This method ensures whatever value the trackpad produces, they work with the sliders.
/// If the trackpad is in 'infinite scroll' mode, it can produce normalized-values outside the range of the spinners.
/// This method ensures whatever value the trackpad produces, they work with the spinners.
/// </remarks>
static F32 unWrapScale(F32 scale);
static F32 clipRange(F32 value);
LLToolset* mLastToolset{ nullptr };
LLTool* mJointRotTool{ nullptr };