FIRE-30873: Burninate BD posing components

master
Angeldark Raymaker 2024-09-30 21:25:10 +01:00
parent a512c01157
commit 471fc38b7f
7 changed files with 0 additions and 416 deletions

View File

@ -169,16 +169,6 @@ public:
S32 mJointNum;
// <FS> [FIRE-30873]: Poser
LLQuaternion mNextRotation;
LLQuaternion mTargetRotation;
LLQuaternion mLastRotation;
LLVector3 mNextPosition;
LLVector3 mTargetPosition;
LLVector3 mLastPosition;
bool mHasPosition;
// </FS>
// child joints
typedef std::vector<LLJoint*> joints_t;
joints_t mChildren;
@ -294,29 +284,6 @@ public:
const LLVector3& getScale();
void setScale( const LLVector3& scale, bool apply_attachment_overrides = false );
// <FS> [FIRE-30873]: Poser
void setTargetPosition(const LLVector3 &pos) { mTargetPosition = pos; }
LLVector3 getTargetPosition() const { return mTargetPosition; }
void setTargetRotation(const LLQuaternion &rot) { mTargetRotation = rot; }
LLQuaternion getTargetRotation() const { return mTargetRotation; }
void setLastPosition(const LLVector3 &pos) { mLastPosition = pos; }
LLVector3 getLastPosition() const { return mLastPosition; }
void setLastRotation(const LLQuaternion &rot) { mLastRotation = rot; }
LLQuaternion getLastRotation() const { return mLastRotation; }
void setCanReposition(const bool can_reposition) { mHasPosition = can_reposition; }
bool canReposition() const { return mHasPosition; }
void setNextPosition(const LLVector3 &pos) { mNextPosition = pos; }
LLVector3 getNextPosition() const { return mNextPosition; }
void setNextRotation(const LLQuaternion &rot) { mNextRotation = rot; }
LLQuaternion getNextRotation() const { return mNextRotation; }
// </FS>
// get/set world matrix
const LLMatrix4 &getWorldMatrix();
void setWorldMatrix( const LLMatrix4& mat );

View File

@ -90,7 +90,6 @@ set(viewer_SOURCE_FILES
ao.cpp
aoengine.cpp
aoset.cpp
bdposingmotion.cpp
chatbar_as_cmdline.cpp
daeexport.cpp
dialogstack.cpp

View File

@ -1,229 +0,0 @@
/**
*
* Copyright (C) 2018, NiranV Dean
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
#include "linden_common.h"
#include "llviewerprecompiledheaders.h"
#include "bdposingmotion.h"
#include "llcharacter.h"
#include "llviewercontrol.h"
BDPosingMotion::BDPosingMotion(const LLUUID &id) :
LLMotion(id),
mCharacter(NULL),
mTargetJoint(NULL)
{
mName = "custom_pose";
//BD - Use slight spherical linear interpolation by default.
mInterpolationTime = 0.25f;
mInterpolationType = 2;
for (auto& entry : mJointState)
entry = new LLJointState;
}
BDPosingMotion::~BDPosingMotion() {}
LLMotion::LLMotionInitStatus BDPosingMotion::onInitialize(LLCharacter *character)
{
// save character for future use
mCharacter = character;
for (S32 i = 0; (mTargetJoint = mCharacter->getCharacterJoint(i)); ++i) // this seems poorly constrained
{
mJointState[i]->setJoint(mTargetJoint);
mJointState[i]->setUsage(LLJointState::POS | LLJointState::ROT /* | LLJointState::SCALE*/);
addJointState(mJointState[i]);
}
return STATUS_SUCCESS;
}
bool BDPosingMotion::onActivate()
{
for (auto joint_state : mJointState)
{
LLJoint* joint = joint_state->getJoint();
if (!joint)
continue;
joint->setTargetRotation(joint->getRotation());
joint->setTargetPosition(joint->getPosition());
}
return true;
}
bool BDPosingMotion::onUpdate(F32 time, U8* joint_mask)
{
LLQuaternion target_quat;
LLQuaternion joint_quat;
LLQuaternion last_quat;
LLQuaternion next_quat;
LLVector3 joint_pos;
LLVector3 last_pos;
LLVector3 target_pos;
LLVector3 next_pos;
F32 perc = 0.0f;
for (auto joint_state : mJointState)
{
LLJoint* joint = joint_state->getJoint();
if (!joint)
continue;
target_quat = joint->getTargetRotation();
joint_quat = joint->getRotation();
last_quat = joint->getLastRotation();
//BD - Merge these two together?
perc = llclamp(mInterpolationTimer.getElapsedTimeF32() / mInterpolationTime, 0.0f, 1.0f);
//BD - All bones support positions now.
joint_pos = joint->getPosition();
target_pos = joint->getTargetPosition();
last_pos = joint->getLastPosition();
if (target_pos != joint_pos)
{
if (mInterpolationType == 2)
{
//BD - Do spherical linear interpolation.
// We emulate the spherical linear interpolation here because
// slerp() does not support LLVector3. mInterpolationTime is always
// in a range between 0.00 and 1.00 which makes it perfect to use
// as percentage directly.
// We use the current joint position rather than the original like
// in linear interpolation to take a fraction of the fraction, this
// re-creates spherical linear interpolation's behavior.
joint_pos = lerp(joint_pos, target_pos, mInterpolationTime);
}
else if (mInterpolationType == 3)
{
next_pos = joint->getNextPosition();
//BD - Do curve interpolation.
// This is a special kind of interpolation where we interpolate towards
// a "middle" pose to a given degree while on our way to the actual final
// pose.
joint_pos = lerp(joint_pos, next_pos, perc);
joint_pos = lerp(joint_pos, target_pos, 0.5f - abs(0.5f - perc));
}
else
{
if (perc >= 1.0f)
{
//BD - Can be used to do no interpolation too.
joint_pos = target_pos;
last_pos = joint_pos;
}
else
{
//BD - Do linear interpolation.
joint_pos = lerp(last_pos, target_pos, perc);
}
}
joint_state->setPosition(joint_pos);
}
if (target_quat != joint_quat)
{
if (mInterpolationType == 2)
{
//BD - Do spherical linear interpolation.
joint_quat = slerp(mInterpolationTime, joint_quat, target_quat);
}
else if (mInterpolationType == 3)
{
next_pos = joint->getNextPosition();
//BD - Do curve interpolation.
// This is a special kind of interpolation where we interpolate towards
// a "middle" pose to a given degree while on our way to the actual final
// pose.
joint_quat = lerp(perc, joint_quat, next_quat);
joint_quat = lerp(0.5f - abs(0.5f - perc), joint_quat, target_quat);
}
else
{
if (perc >= 1.0f)
{
//BD - Can be used to do no interpolation too.
joint_quat = target_quat;
last_quat = joint_quat;
}
else
{
//BD - Do linear interpolation.
joint_quat = lerp(perc, last_quat, target_quat);
}
}
joint_state->setRotation(joint_quat);
}
}
if (perc >= 1.0f && mInterpolationTimer.getStarted()
&& (last_quat == joint_quat
&& (last_pos == joint_pos)))
{
mInterpolationTimer.stop();
}
return true;
}
void BDPosingMotion::onDeactivate() {}
void BDPosingMotion::addJointToState(LLJoint *joint) { setJointState(joint, LLJointState::POS | LLJointState::ROT); }
void BDPosingMotion::removeJointFromState(LLJoint *joint) { setJointState(joint, 0); }
void BDPosingMotion::setJointState(LLJoint *joint, U32 state)
{
if (!joint)
return;
LLPose* pose = this->getPose();
if (!pose)
return;
LLPointer<LLJointState> jointState = pose->findJointState(joint);
if (jointState.isNull())
return;
pose->removeJointState(jointState);
S32 jointNumber = joint->getJointNum();
if (jointNumber < 0 || jointNumber >= _numberOfBonesApropoOfNothing)
return;
mJointState[jointNumber]->setUsage(state);
addJointState(mJointState[jointNumber]);
}
bool BDPosingMotion::currentlyPosingJoint(LLJoint* joint)
{
if (!joint)
return false;
LLJointState* jointState = mPose.findJointState(joint);
if (!jointState)
return false;
S32 jointNumber = joint->getJointNum();
if (jointNumber < 0 || jointNumber >= _numberOfBonesApropoOfNothing)
return false;
U32 state = mJointState[jointNumber]->getUsage();
return (state & LLJointState::POS) && (state & LLJointState::ROT);
}

View File

@ -1,131 +0,0 @@
/**
*
* Copyright (C) 2018, NiranV Dean
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
#ifndef LL_BDPOSINGMOTION_H
#define LL_BDPOSINGMOTION_H
//-----------------------------------------------------------------------------
// Header files
//-----------------------------------------------------------------------------
#include "llmotion.h"
#include "lljointsolverrp3.h"
#include "v3dmath.h"
#define MIN_REQUIRED_PIXEL_AREA_POSING 500.f
//-----------------------------------------------------------------------------
// class BDPosingMotion
//-----------------------------------------------------------------------------
class BDPosingMotion :
public LLMotion
{
public:
/// <summary>
/// Unsure why it is special. Perhaps its a low-priority animation? Perhaps it just needs to be unique?
/// </summary>
const LLUUID ANIM_BD_POSING_MOTION = LLUUID("fd29b117-9429-09c4-10cb-933d0b2ab653");
BDPosingMotion(const LLUUID &id);
virtual ~BDPosingMotion();
public:
//-------------------------------------------------------------------------
// functions to support MotionController and MotionRegistry
//-------------------------------------------------------------------------
// static constructor
// all subclasses must implement such a function and register it
static LLMotion *create(const LLUUID &id) { return new BDPosingMotion(id); }
public:
virtual bool getLoop() { return TRUE; }
virtual F32 getDuration() { return 0.0; }
virtual F32 getEaseInDuration() { return 0.0f; }
virtual F32 getEaseOutDuration() { return 0.5f; }
// motions must report their priority
virtual LLJoint::JointPriority getPriority() { return LLJoint::ADDITIVE_PRIORITY; }
virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
// called to determine when a motion should be activated/deactivated based on avatar pixel coverage
virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_POSING; }
// run-time (post constructor) initialization,
// called after parameters have been set
// must return true to indicate success and be available for activation
virtual LLMotionInitStatus onInitialize(LLCharacter *character);
// called when a motion is activated
// must return TRUE to indicate success, or else
// it will be deactivated
virtual bool onActivate();
// called per time step
// must return TRUE while it is active, and
// must return FALSE when the motion is completed.
virtual bool onUpdate(F32 time, U8 *joint_mask);
// called when a motion is deactivated
virtual void onDeactivate();
/// <summary>
/// Adds the supplied joint to the current animation-state.
/// </summary>
/// <param name="joint">The joint to animate.</param>
void addJointToState(LLJoint *joint);
/// <summary>
/// Removes the supplied joint to the current animation-state.
/// </summary>
/// <param name="joint">The joint to stop animating.</param>
void removeJointFromState(LLJoint *joint);
/// <summary>
/// Queries whether the supplied joint is being animated.
/// </summary>
/// <param name="joint">The joint to query.</param>
bool currentlyPosingJoint(LLJoint *joint);
/// <summary>
/// Removes the current joint state, and adds a new one.
/// </summary>
void setJointState(LLJoint* joint, U32 state);
private:
static const S32 _numberOfBonesApropoOfNothing = 134;
// BD - functions to set/get our interpolation type
// 0 = None,
// 1 = Linear Interpolatioon,
// 2 = Spherical Linear Interpolation,
// 3 = Curve
S32 mInterpolationType;
F32 mInterpolationTime;
LLFrameTimer mInterpolationTimer;
LLCharacter *mCharacter;
LLPointer<LLJointState> mJointState[_numberOfBonesApropoOfNothing];
LLJoint *mTargetJoint;
};
#endif // LL_LLKEYFRAMEMOTION_H

View File

@ -33,8 +33,6 @@
#include "llvoavatarself.h"
#include <llanimationstates.h>
#include "bdposingmotion.h" // BD - Use Black Dragon posing piece
/// <summary>
/// This has turned into a shim-class rather than the business of posing. *shrug*
/// </summary>
@ -46,7 +44,6 @@ bool FSPoserAnimator::isPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint
if (!isAvatarSafeToUse(avatar))
return false;
BDPosingMotion *motion = (BDPosingMotion *) avatar->findMotion(ANIM_BD_POSING_MOTION);
if (!motion || motion->isStopped())
return false;
@ -66,7 +63,6 @@ void FSPoserAnimator::setPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint join
if (arePosing && shouldPose || !arePosing && !shouldPose) // could !XOR, but this is readable
return;
BDPosingMotion *motion = (BDPosingMotion *) avatar->findMotion(ANIM_BD_POSING_MOTION);
if (!motion || motion->isStopped())
return;
@ -85,7 +81,6 @@ void FSPoserAnimator::resetAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint)
if (!isAvatarSafeToUse(avatar))
return;
BDPosingMotion *motion = (BDPosingMotion *) avatar->findMotion(ANIM_BD_POSING_MOTION);
if (!motion || motion->isStopped())
return;
@ -390,14 +385,12 @@ bool FSPoserAnimator::tryPosingAvatar(LLVOAvatar *avatar)
if (!isAvatarSafeToUse(avatar))
return false;
BDPosingMotion *motion = (BDPosingMotion *) avatar->findMotion(ANIM_BD_POSING_MOTION);
if (!motion || motion->isStopped())
{
if (avatar->isSelf())
gAgent.stopFidget();
avatar->startDefaultMotions();
avatar->startMotion(ANIM_BD_POSING_MOTION);
// TODO: scrape motion state prior to edit, facilitating reset
@ -412,7 +405,6 @@ void FSPoserAnimator::stopPosingAvatar(LLVOAvatar *avatar)
if (!avatar || avatar->isDead())
return;
avatar->stopMotion(ANIM_BD_POSING_MOTION);
}
bool FSPoserAnimator::isPosingAvatar(LLVOAvatar* avatar)
@ -420,7 +412,6 @@ bool FSPoserAnimator::isPosingAvatar(LLVOAvatar* avatar)
if (!isAvatarSafeToUse(avatar))
return false;
BDPosingMotion *motion = (BDPosingMotion *) avatar->findMotion(ANIM_BD_POSING_MOTION);
if (!motion)
return false;

View File

@ -176,8 +176,6 @@ const LLUUID ANIM_AGENT_TARGET = LLUUID("0e4896cb-fba4-926c-f355-8720189d5b55");
const LLUUID ANIM_AGENT_WALK_ADJUST = LLUUID("829bc85b-02fc-ec41-be2e-74cc6dd7215d"); //"walk_adjust"
const LLUUID ANIM_AGENT_PHYSICS_MOTION = LLUUID("7360e029-3cb8-ebc4-863e-212df440d987"); //"physics_motion"
const LLUUID ANIM_BD_POSING_MOTION = LLUUID("fd29b117-9429-09c4-10cb-933d0b2ab653"); // <FS> [FIRE-30873]: Poser: "custom_motion"
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
@ -1256,7 +1254,6 @@ void LLVOAvatar::initClass()
gAnimLibrary.animStateSetString(ANIM_AGENT_PELVIS_FIX,"pelvis_fix");
gAnimLibrary.animStateSetString(ANIM_AGENT_TARGET,"target");
gAnimLibrary.animStateSetString(ANIM_AGENT_WALK_ADJUST,"walk_adjust");
gAnimLibrary.animStateSetString(ANIM_BD_POSING_MOTION, "custom_pose"); // <FS> [FIRE-30873]: Poser
// Where should this be set initially?
LLJoint::setDebugJointNames(gSavedSettings.getString("DebugAvatarJoints"));
@ -1379,8 +1376,6 @@ void LLVOAvatar::initInstance()
registerMotion( ANIM_AGENT_SIT_FEMALE, LLKeyframeMotion::create );
registerMotion( ANIM_AGENT_TARGET, LLTargetingMotion::create );
registerMotion( ANIM_AGENT_WALK_ADJUST, LLWalkAdjustMotion::create );
registerMotion(ANIM_BD_POSING_MOTION, BDPosingMotion::create); // <FS/> [FIRE-30873]: Poser
}
LLAvatarAppearance::initInstance();
@ -2294,12 +2289,6 @@ void LLVOAvatar::resetSkeleton(bool reset_animations)
return;
}
// <FS> [FIRE-30873]: Poser: BD - We need to clear posing here otherwise we'll crash.
LLMotion *pose_motion = findMotion(ANIM_BD_POSING_MOTION);
if (pose_motion)
removeMotion(ANIM_BD_POSING_MOTION);
// </FS>
// Save mPelvis state
//LLVector3 pelvis_pos = getJoint("mPelvis")->getPosition();
//LLQuaternion pelvis_rot = getJoint("mPelvis")->getRotation();

View File

@ -67,8 +67,6 @@ extern const LLUUID ANIM_AGENT_PELVIS_FIX;
extern const LLUUID ANIM_AGENT_TARGET;
extern const LLUUID ANIM_AGENT_WALK_ADJUST;
extern const LLUUID ANIM_BD_POSING_MOTION; // <FS> [FIRE-30873]: Poser
class LLViewerWearable;
class LLVoiceVisualizer;
class LLHUDNameTag;