FIRE-30873: tidy up for const, add load pose
parent
3fec855fd2
commit
eab80128ab
|
|
@ -385,7 +385,7 @@ void FSFloaterPoser::onPoseMenuAction(const LLSD ¶m)
|
|||
|
||||
std::string poseName = item->getColumn(0)->getValue().asString();
|
||||
|
||||
E_LoadPoseMethods loadType = ROT_POS_AND_SCALES;
|
||||
E_LoadPoseMethods loadType = ROT_POS_AND_SCALES; // the default is to load everything
|
||||
if (boost::iequals(loadStyle, "rotation"))
|
||||
loadType = ROTATIONS;
|
||||
else if (boost::iequals(loadStyle, "position"))
|
||||
|
|
@ -407,8 +407,79 @@ void FSFloaterPoser::onPoseMenuAction(const LLSD ¶m)
|
|||
|
||||
void FSFloaterPoser::loadPoseFromXml(std::string poseFileName, E_LoadPoseMethods loadMethod)
|
||||
{
|
||||
LLVOAvatar *avatar = getUiSelectedAvatar();
|
||||
if (!avatar)
|
||||
return;
|
||||
|
||||
// TODO: add load
|
||||
if (!_poserAnimator.isPosingAvatar(avatar))
|
||||
return;
|
||||
|
||||
std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY);
|
||||
if (!gDirUtilp->fileExists(pathname))
|
||||
return;
|
||||
|
||||
std::string fullPath =
|
||||
gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY, poseFileName + POSE_INTERNAL_FORMAT_FILE_EXT);
|
||||
|
||||
bool loadRotations = loadMethod == ROTATIONS || loadMethod == ROTATIONS_AND_POSITIONS || loadMethod == ROTATIONS_AND_SCALES ||
|
||||
loadMethod == ROT_POS_AND_SCALES;
|
||||
bool loadPositions = loadMethod == POSITIONS || loadMethod == ROTATIONS_AND_POSITIONS || loadMethod == POSITIONS_AND_SCALES ||
|
||||
loadMethod == ROT_POS_AND_SCALES;
|
||||
bool loadScales = loadMethod == SCALES || loadMethod == POSITIONS_AND_SCALES || loadMethod == ROTATIONS_AND_SCALES ||
|
||||
loadMethod == ROT_POS_AND_SCALES;
|
||||
|
||||
try
|
||||
{
|
||||
LLSD pose;
|
||||
llifstream infile;
|
||||
LLVector3 vec3;
|
||||
|
||||
infile.open(fullPath);
|
||||
if (!infile.is_open())
|
||||
return;
|
||||
|
||||
while (!infile.eof())
|
||||
{
|
||||
S32 lineCount = LLSDSerialize::fromXML(pose, infile);
|
||||
if (lineCount == LLSDParser::PARSE_FAILURE)
|
||||
{
|
||||
LL_WARNS("Posing") << "Failed to parse file: " << poseFileName << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
for (LLSD::map_const_iterator itr = pose.beginMap(); itr != pose.endMap(); ++itr)
|
||||
{
|
||||
std::string const &name = itr->first;
|
||||
LLSD const &control_map = itr->second;
|
||||
|
||||
const FSPoserAnimator::FSPoserJoint *poserJoint = _poserAnimator.getPoserJointByName(name);
|
||||
if (!poserJoint)
|
||||
continue;
|
||||
|
||||
if (loadRotations && control_map.has("rotation"))
|
||||
{
|
||||
vec3.setValue(control_map["rotation"]);
|
||||
_poserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE);
|
||||
}
|
||||
|
||||
if (loadPositions && control_map.has("position"))
|
||||
{
|
||||
vec3.setValue(control_map["position"]);
|
||||
_poserAnimator.setJointPosition(avatar, poserJoint, vec3, NONE);
|
||||
}
|
||||
|
||||
if (loadScales && control_map.has("scale"))
|
||||
{
|
||||
vec3.setValue(control_map["scale"]);
|
||||
_poserAnimator.setJointScale(avatar, poserJoint, vec3, NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LL_WARNS("Posing") << "Everything caught fire trying to load the pose: " << poseFileName << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
||||
void FSFloaterPoser::onPoseStartStop()
|
||||
|
|
|
|||
|
|
@ -37,14 +37,13 @@
|
|||
#include "fsposeranimator.h"
|
||||
|
||||
/// <summary>
|
||||
/// Describes how we will cluster the joints/bones/thingos.
|
||||
/// Each joint/bone/thingo should have one of these, <see:"FSPoserAnimator.PoserJoints"/>.
|
||||
/// Describes how to load a pose file.
|
||||
/// </summary>
|
||||
typedef enum E_LoadPoseMethods
|
||||
{
|
||||
ROTATIONS = 0,
|
||||
POSITIONS = 1,
|
||||
SCALES = 2,
|
||||
ROTATIONS = 1,
|
||||
POSITIONS = 2,
|
||||
SCALES = 4,
|
||||
ROTATIONS_AND_POSITIONS = 3,
|
||||
ROTATIONS_AND_SCALES = 4,
|
||||
POSITIONS_AND_SCALES = 5,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,14 @@ bool FSPoserAnimator::isPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint
|
|||
return _currentlyPosingSelf;
|
||||
}
|
||||
|
||||
void FSPoserAnimator::setPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint, bool shouldPose)
|
||||
{
|
||||
if (!avatar || avatar->isDead())
|
||||
return;
|
||||
|
||||
// TODO: Bust a move. Or don't.
|
||||
}
|
||||
|
||||
LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar *avatar, FSPoserJoint joint)
|
||||
{
|
||||
LLVector3 pos;
|
||||
|
|
@ -59,7 +67,7 @@ LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar *avatar, FSPoserJoint joi
|
|||
return pos;
|
||||
}
|
||||
|
||||
void FSPoserAnimator::setJointPosition(LLVOAvatar *avatar, FSPoserJoint *joint, LLVector3 position, E_BoneDeflectionStyles style)
|
||||
void FSPoserAnimator::setJointPosition(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 position, E_BoneDeflectionStyles style)
|
||||
{
|
||||
if (!avatar || avatar->isDead())
|
||||
return;
|
||||
|
|
@ -96,7 +104,7 @@ LLVector3 FSPoserAnimator::getJointRotation(LLVOAvatar *avatar, FSPoserJoint joi
|
|||
return vec3;
|
||||
}
|
||||
|
||||
void FSPoserAnimator::setJointRotation(LLVOAvatar *avatar, FSPoserJoint *joint, LLVector3 rotation, E_BoneDeflectionStyles style)
|
||||
void FSPoserAnimator::setJointRotation(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 rotation, E_BoneDeflectionStyles style)
|
||||
{
|
||||
if (!avatar || avatar->isDead())
|
||||
return;
|
||||
|
|
@ -119,7 +127,7 @@ LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar *avatar, FSPoserJoint joint)
|
|||
return vec3;
|
||||
}
|
||||
|
||||
void FSPoserAnimator::setJointScale(LLVOAvatar *avatar, FSPoserJoint *joint, LLVector3 scale, E_BoneDeflectionStyles style)
|
||||
void FSPoserAnimator::setJointScale(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 scale, E_BoneDeflectionStyles style)
|
||||
{
|
||||
if (!avatar || avatar->isDead())
|
||||
return;
|
||||
|
|
@ -127,6 +135,17 @@ void FSPoserAnimator::setJointScale(LLVOAvatar *avatar, FSPoserJoint *joint, LLV
|
|||
return;
|
||||
}
|
||||
|
||||
const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByName(std::string jointName)
|
||||
{
|
||||
for (size_t index = 0; index != PoserJoints.size(); ++index)
|
||||
{
|
||||
if (boost::iequals(PoserJoints[index].jointName(), jointName))
|
||||
return &PoserJoints[index];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool FSPoserAnimator::tryPosingAvatar(LLVOAvatar *avatar)
|
||||
{
|
||||
if (!avatar || avatar->isDead())
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@
|
|||
/// </summary>
|
||||
typedef enum E_BoneTypes
|
||||
{
|
||||
WHOLEAVATAR = 0, // possibly a single instance of, but this one manipulates everything
|
||||
BODY = 1,
|
||||
FACE = 2,
|
||||
HANDS = 3,
|
||||
MISC = 4
|
||||
WHOLEAVATAR = 0, // possibly a single instance of, but this one manipulates everything
|
||||
BODY = 1,
|
||||
FACE = 2,
|
||||
HANDS = 3,
|
||||
MISC = 4
|
||||
} E_BoneTypes;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -53,9 +53,9 @@ typedef enum E_BoneTypes
|
|||
/// </summary>
|
||||
typedef enum E_BoneDeflectionStyles
|
||||
{
|
||||
NONE = 0, // do nothing additional
|
||||
MIRROR = 1, // change the other joint, like in a mirror, eg: one left one right
|
||||
SYMPATHETIC = 2, // change the other joint, but opposite to a mirrored way, eg: both go right or both go left
|
||||
NONE = 0, // do nothing additional
|
||||
MIRROR = 1, // change the other joint, like in a mirror, eg: one left one right
|
||||
SYMPATHETIC = 2, // change the other joint, but opposite to a mirrored way, eg: both go right or both go left
|
||||
} E_BoneDeflectionStyles;
|
||||
|
||||
class FSPoserAnimator
|
||||
|
|
@ -170,12 +170,11 @@ public:
|
|||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Determines whether the supplied PoserJoint for the supplied avatar is being posed.
|
||||
/// Get a PoserJoint case-insensitive-matching the supplied name.
|
||||
/// </summary>
|
||||
/// <param name="avatar">The avatar having the joint to which we refer.</param>
|
||||
/// <param name="joint">The joint being queried for.</param>
|
||||
/// <returns></returns>
|
||||
bool isPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint);
|
||||
/// <param name="jointName">The name of the joint to match.</param>
|
||||
/// <returns>The matching joint if found, otherwise nullptr</returns>
|
||||
const FSPoserJoint* getPoserJointByName(std::string jointName);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to being posing the supplied avatar.
|
||||
|
|
@ -197,6 +196,25 @@ public:
|
|||
/// <returns>True if this is posing the supplied avatar, otherwise false.</returns>
|
||||
bool isPosingAvatar(LLVOAvatar *avatar);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the supplied PoserJoint for the supplied avatar is being posed.
|
||||
/// </summary>
|
||||
/// <param name="avatar">The avatar having the joint to which we refer.</param>
|
||||
/// <param name="joint">The joint being queried for.</param>
|
||||
/// <returns></returns>
|
||||
bool isPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint);
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the supplied PoserJoint for the supplied avatar shoubd be posed.
|
||||
/// </summary>
|
||||
/// <param name="avatar">The avatar having the joint to which we refer.</param>
|
||||
/// <param name="joint">The joint being queried for.</param>
|
||||
/// <param name="posing">Whether the joint should be posed.</param>
|
||||
/// <remarks>
|
||||
/// If this is not posing the joint, then it is free to be posed by other things.
|
||||
/// </remarks>
|
||||
void setPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint, bool shouldPose);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position of a joint for the supplied avatar.
|
||||
/// </summary>
|
||||
|
|
@ -212,7 +230,7 @@ public:
|
|||
/// <param name="joint">The joint to set.</param>
|
||||
/// <param name="position">The position to set the joint to.</param>
|
||||
/// <param name="style">Any ancilliary action to be taken with the change to be made.</param>
|
||||
void setJointPosition(LLVOAvatar *avatar, FSPoserJoint *joint, LLVector3 position, E_BoneDeflectionStyles style);
|
||||
void setJointPosition(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 position, E_BoneDeflectionStyles style);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rotation of a joint for the supplied avatar.
|
||||
|
|
@ -229,7 +247,7 @@ public:
|
|||
/// <param name="joint">The joint to set.</param>
|
||||
/// <param name="rotation">The rotation to set the joint to.</param>
|
||||
/// <param name="style">Any ancilliary action to be taken with the change to be made.</param>
|
||||
void setJointRotation(LLVOAvatar *avatar, FSPoserJoint *joint, LLVector3 rotation, E_BoneDeflectionStyles style);
|
||||
void setJointRotation(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 rotation, E_BoneDeflectionStyles style);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of a joint for the supplied avatar.
|
||||
|
|
@ -246,7 +264,7 @@ public:
|
|||
/// <param name="joint">The joint to set.</param>
|
||||
/// <param name="scale">The scale to set the joint to.</param>
|
||||
/// <param name="style">Any ancilliary action to be taken with the change to be made.</param>
|
||||
void setJointScale(LLVOAvatar *avatar, FSPoserJoint *joint, LLVector3 scale, E_BoneDeflectionStyles style);
|
||||
void setJointScale(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 scale, E_BoneDeflectionStyles style);
|
||||
|
||||
private:
|
||||
bool _currentlyPosingSelf = false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue