parent
a1597896e4
commit
1f834f06bd
|
|
@ -226,7 +226,7 @@ void FSPoserAnimator::resetJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_
|
|||
if (!jointPose)
|
||||
return;
|
||||
|
||||
jointPose->revertJointScale();
|
||||
jointPose->setTargetScale(jointPose->getBeginningScale());
|
||||
|
||||
if (style == NONE)
|
||||
return;
|
||||
|
|
@ -235,7 +235,7 @@ void FSPoserAnimator::resetJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_
|
|||
if (!oppositeJointPose)
|
||||
return;
|
||||
|
||||
oppositeJointPose->revertJointScale();
|
||||
oppositeJointPose->setTargetScale(oppositeJointPose->getBeginningScale());
|
||||
}
|
||||
|
||||
bool FSPoserAnimator::canRedoJointRotation(LLVOAvatar* avatar, FSPoserJoint joint)
|
||||
|
|
@ -664,7 +664,7 @@ LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar *avatar, FSPoserJoint joint)
|
|||
if (!jointPose)
|
||||
return scale;
|
||||
|
||||
scale = jointPose->getJointScale();
|
||||
scale = jointPose->getTargetScale();
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
|
@ -688,7 +688,7 @@ void FSPoserAnimator::setJointScale(LLVOAvatar *avatar, const FSPoserJoint *join
|
|||
if (!jointPose)
|
||||
return;
|
||||
|
||||
jointPose->setJointScale(scale);
|
||||
jointPose->setTargetScale(scale);
|
||||
|
||||
if (style == NONE)
|
||||
return;
|
||||
|
|
@ -697,7 +697,7 @@ void FSPoserAnimator::setJointScale(LLVOAvatar *avatar, const FSPoserJoint *join
|
|||
if (!oppositeJointPose)
|
||||
return;
|
||||
|
||||
oppositeJointPose->setJointScale(scale);
|
||||
oppositeJointPose->setTargetScale(scale);
|
||||
}
|
||||
|
||||
const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByName(std::string jointName)
|
||||
|
|
@ -728,8 +728,6 @@ bool FSPoserAnimator::tryPosingAvatar(LLVOAvatar *avatar)
|
|||
avatar->startDefaultMotions();
|
||||
avatar->startMotion(posingMotion->motionId());
|
||||
|
||||
// TODO: scrape motion state prior to edit, facilitating reset
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ bool FSPosingMotion::onUpdate(F32 time, U8* joint_mask)
|
|||
LLQuaternion currentRotation;
|
||||
LLVector3 currentPosition;
|
||||
LLVector3 targetPosition;
|
||||
LLVector3 currentScale;
|
||||
LLVector3 targetScale;
|
||||
|
||||
for (FSJointPose jointPose : _jointPoses)
|
||||
{
|
||||
|
|
@ -83,8 +85,10 @@ bool FSPosingMotion::onUpdate(F32 time, U8* joint_mask)
|
|||
|
||||
currentRotation = joint->getRotation();
|
||||
currentPosition = joint->getPosition();
|
||||
currentScale = joint->getScale();
|
||||
targetRotation = jointPose.getTargetRotation();
|
||||
targetPosition = jointPose.getTargetPosition();
|
||||
targetScale = jointPose.getTargetScale();
|
||||
|
||||
if (currentPosition != targetPosition)
|
||||
{
|
||||
|
|
@ -97,6 +101,12 @@ bool FSPosingMotion::onUpdate(F32 time, U8* joint_mask)
|
|||
currentRotation = slerp(_interpolationTime, currentRotation, targetRotation);
|
||||
jointPose.getJointState()->setRotation(currentRotation);
|
||||
}
|
||||
|
||||
if (currentScale != targetScale)
|
||||
{
|
||||
currentScale = lerp(currentScale, targetScale, _interpolationTime);
|
||||
jointPose.getJointState()->setScale(currentScale);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -145,15 +145,6 @@ public:
|
|||
_lastSetScales.pop_back();
|
||||
}
|
||||
|
||||
void setScale(LLVector3 scale)
|
||||
{
|
||||
LLJoint* joint = _jointState->getJoint();
|
||||
if (!joint)
|
||||
return;
|
||||
|
||||
joint->setScale(scale);
|
||||
}
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Gets the name of the joint.
|
||||
|
|
@ -218,6 +209,29 @@ public:
|
|||
_targetRotation.set(rot);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale the animator wishes the joint to have.
|
||||
/// </summary>
|
||||
LLVector3 getTargetScale() const { return _targetScale; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale the joint had when the animation was initialized.
|
||||
/// </summary>
|
||||
LLVector3 getBeginningScale() const { return _beginningScale; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the scale the animator wishes the joint to have.
|
||||
/// </summary>
|
||||
void setTargetScale(LLVector3 scale)
|
||||
{
|
||||
auto timeIntervalSinceLastScaleChange = std::chrono::system_clock::now() - _timeLastUpdatedScale;
|
||||
if (timeIntervalSinceLastScaleChange > _undoUpdateInterval)
|
||||
addLastScaleToUndo();
|
||||
|
||||
_timeLastUpdatedScale = std::chrono::system_clock::now();
|
||||
_targetScale.set(scale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Undoes the last position set, if any.
|
||||
/// </summary>
|
||||
|
|
@ -285,6 +299,56 @@ public:
|
|||
_lastSetRotations.pop_front();
|
||||
}
|
||||
|
||||
void undoLastScaleSet()
|
||||
{
|
||||
if (_lastSetScales.empty())
|
||||
return;
|
||||
|
||||
if (_undoneScaleIndex == 0)
|
||||
addLastScaleToUndo();
|
||||
|
||||
_undoneScaleIndex++;
|
||||
_undoneScaleIndex = llclamp(_undoneScaleIndex, 0, _lastSetScales.size() - 1);
|
||||
_targetScale.set(_lastSetScales[_undoneScaleIndex]);
|
||||
}
|
||||
|
||||
void redoLastScaleSet()
|
||||
{
|
||||
if (_lastSetScales.empty())
|
||||
return;
|
||||
|
||||
_undoneScaleIndex--;
|
||||
_undoneScaleIndex = llclamp(_undoneScaleIndex, 0, _lastSetScales.size() - 1);
|
||||
|
||||
_targetScale.set(_lastSetScales[_undoneScaleIndex]);
|
||||
if (_undoneScaleIndex == 0)
|
||||
_lastSetScales.pop_front();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores the joint represented by this to the scale it had when this motion started.
|
||||
/// </summary>
|
||||
void revertJointScale()
|
||||
{
|
||||
LLJoint* joint = _jointState->getJoint();
|
||||
if (!joint)
|
||||
return;
|
||||
|
||||
joint->setScale(_beginningScale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores the joint represented by this to the position it had when this motion started.
|
||||
/// </summary>
|
||||
void revertJointPosition()
|
||||
{
|
||||
LLJoint* joint = _jointState->getJoint();
|
||||
if (!joint)
|
||||
return;
|
||||
|
||||
joint->setPosition(_beginningPosition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collision Volumes do not 'reset' their position/rotation when the animation stops.
|
||||
/// This requires special treatment to revert changes we've made this animation session.
|
||||
|
|
@ -303,70 +367,6 @@ public:
|
|||
joint->setScale(_beginningScale);
|
||||
}
|
||||
|
||||
LLVector3 getJointScale() const { return _targetScale; }
|
||||
void setJointScale(LLVector3 scale)
|
||||
{
|
||||
auto timeIntervalSinceLastScaleChange = std::chrono::system_clock::now() - _timeLastUpdatedScale;
|
||||
if (timeIntervalSinceLastScaleChange > _undoUpdateInterval)
|
||||
addLastScaleToUndo();
|
||||
|
||||
_timeLastUpdatedScale = std::chrono::system_clock::now();
|
||||
|
||||
_targetScale.set(scale);
|
||||
setScale(_targetScale);
|
||||
}
|
||||
|
||||
void undoLastScaleSet()
|
||||
{
|
||||
if (_lastSetScales.empty())
|
||||
return;
|
||||
|
||||
if (_undoneScaleIndex == 0) // at the top of the queue add the current
|
||||
addLastScaleToUndo();
|
||||
|
||||
_undoneScaleIndex++;
|
||||
_undoneScaleIndex = llclamp(_undoneScaleIndex, 0, _lastSetScales.size() - 1);
|
||||
_targetScale.set(_lastSetScales[_undoneScaleIndex]);
|
||||
|
||||
setScale(_targetScale);
|
||||
}
|
||||
|
||||
void redoLastScaleSet()
|
||||
{
|
||||
if (_lastSetScales.empty())
|
||||
return;
|
||||
|
||||
_undoneScaleIndex--;
|
||||
_undoneScaleIndex = llclamp(_undoneScaleIndex, 0, _lastSetScales.size() - 1);
|
||||
|
||||
_targetScale.set(_lastSetScales[_undoneScaleIndex]);
|
||||
if (_undoneScaleIndex == 0)
|
||||
_lastSetScales.pop_front();
|
||||
|
||||
setScale(_targetScale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores the joint represented by this to the scale it had when this motion started.
|
||||
/// </summary>
|
||||
void revertJointScale()
|
||||
{
|
||||
_targetScale.set(_beginningScale);
|
||||
setScale(_beginningScale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores the joint represented by this to the position it had when this motion started.
|
||||
/// </summary>
|
||||
void revertJointPosition()
|
||||
{
|
||||
LLJoint* joint = _jointState->getJoint();
|
||||
if (!joint)
|
||||
return;
|
||||
|
||||
joint->setPosition(_beginningPosition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pointer to the jointstate for the joint this represents.
|
||||
/// </summary>
|
||||
|
|
@ -461,7 +461,7 @@ private:
|
|||
/// <summary>
|
||||
/// The kind of joint state this animation is concerned with changing.
|
||||
/// </summary>
|
||||
static const U32 POSER_JOINT_STATE = LLJointState::POS | LLJointState::ROT /* | LLJointState::SCALE*/;
|
||||
static const U32 POSER_JOINT_STATE = LLJointState::POS | LLJointState::ROT | LLJointState::SCALE;
|
||||
LLAssetID _motionID;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue