From 4419bb870986c6900fc096338622d27b999cd771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Sun, 11 Feb 2024 01:23:28 +0100 Subject: more misc: BOOL (int) to real bool --- indra/llcharacter/llkeyframemotion.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcharacter/llkeyframemotion.h') diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index 96746f57c9..59a1d39a62 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -86,9 +86,9 @@ public: //------------------------------------------------------------------------- // motions must specify whether or not they loop - virtual BOOL getLoop() { - if (mJointMotionList) return mJointMotionList->mLoop; - else return FALSE; + virtual bool getLoop() { + if (mJointMotionList) return mJointMotionList->mLoop; + else return false; } // motions must report their total duration -- cgit v1.2.3 From 9e854b697a06abed2a0917fb6120445f176764f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Fri, 16 Feb 2024 19:29:51 +0100 Subject: misc: BOOL to bool --- indra/llcharacter/llkeyframemotion.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indra/llcharacter/llkeyframemotion.h') diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index 59a1d39a62..56c4364fd8 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -135,14 +135,14 @@ public: virtual LLMotionInitStatus onInitialize(LLCharacter *character); // called when a motion is activated - // must return TRUE to indicate success, or else + // must return true to indicate success, or else // it will be deactivated - virtual BOOL onActivate(); + 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); + // 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(); @@ -155,14 +155,14 @@ public: public: U32 getFileSize(); - BOOL serialize(LLDataPacker& dp) const; - BOOL deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints = true); - BOOL isLoaded() { return mJointMotionList != NULL; } + bool serialize(LLDataPacker& dp) const; + bool deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints = true); + bool isLoaded() { return mJointMotionList != NULL; } bool dumpToFile(const std::string& name); // setters for modifying a keyframe animation - void setLoop(BOOL loop); + void setLoop(bool loop); F32 getLoopIn() { return (mJointMotionList) ? mJointMotionList->mLoopInPoint : 0.f; @@ -211,7 +211,7 @@ protected: mEaseInStopTime(0.f), mEaseOutStartTime(0.f), mEaseOutStopTime(0.f), - mUseTargetOffset(FALSE), + mUseTargetOffset(false), mConstraintType(CONSTRAINT_TYPE_POINT), mConstraintTargetType(CONSTRAINT_TARGET_TYPE_BODY), mSourceConstraintVolume(0), @@ -231,7 +231,7 @@ protected: F32 mEaseInStopTime; F32 mEaseOutStartTime; F32 mEaseOutStopTime; - BOOL mUseTargetOffset; + bool mUseTargetOffset; EConstraintType mConstraintType; EConstraintTargetType mConstraintTargetType; }; @@ -251,7 +251,7 @@ protected: LLVector3 mPositions[MAX_CHAIN_LENGTH]; F32 mJointLengths[MAX_CHAIN_LENGTH]; F32 mJointLengthFractions[MAX_CHAIN_LENGTH]; - BOOL mActive; + bool mActive; LLVector3d mGroundPos; LLVector3 mGroundNorm; LLJoint* mSourceVolume; @@ -271,7 +271,7 @@ protected: void applyConstraint(JointConstraint* constraintp, F32 time, U8* joint_mask); - BOOL setupPose(); + bool setupPose(); public: enum AssetStatus { ASSET_LOADED, ASSET_FETCHED, ASSET_NEEDS_FETCH, ASSET_FETCH_FAILED, ASSET_UNDEFINED }; -- cgit v1.2.3 From 321f283032688f0feddc696654e86f62af07121a Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 19 Feb 2024 15:01:44 +0100 Subject: Replace remaining BOOL with bool llinventory and llmessage --- indra/llcharacter/llkeyframemotion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcharacter/llkeyframemotion.h') diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index 56c4364fd8..4acebeba27 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -398,7 +398,7 @@ public: public: std::vector mJointMotionArray; F32 mDuration; - BOOL mLoop; + bool mLoop; F32 mLoopInPoint; F32 mLoopOutPoint; F32 mEaseInDuration; -- cgit v1.2.3 From 7d87e41bbd5d4761b1eb17e49b7a00b948d84213 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 25 Apr 2024 23:25:57 +0200 Subject: secondlife/viewer#1331 The animation with null id is attempted to fetch --- indra/llcharacter/llkeyframemotion.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llcharacter/llkeyframemotion.h') diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index 4acebeba27..be9f35d3e4 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -412,7 +412,9 @@ public: // mEmoteName is a facial motion, but it's necessary to appear here so that it's cached. // TODO: LLKeyframeDataCache::getKeyframeData should probably return a class containing // JointMotionList and mEmoteName, see LLKeyframeMotion::onInitialize. - std::string mEmoteName; + std::string mEmoteName; + LLUUID mEmoteID; + public: JointMotionList(); ~JointMotionList(); -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/llcharacter/llkeyframemotion.h | 928 +++++++++++++++++------------------ 1 file changed, 464 insertions(+), 464 deletions(-) (limited to 'indra/llcharacter/llkeyframemotion.h') diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index a2c3eacbe1..edf2308050 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -1,464 +1,464 @@ -/** - * @file llkeyframemotion.h - * @brief Implementation of LLKeframeMotion class. - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLKEYFRAMEMOTION_H -#define LL_LLKEYFRAMEMOTION_H - -//----------------------------------------------------------------------------- -// Header files -//----------------------------------------------------------------------------- - -#include - -#include "llassetstorage.h" -#include "llbboxlocal.h" -#include "llhandmotion.h" -#include "lljointstate.h" -#include "llmotion.h" -#include "llquaternion.h" -#include "v3dmath.h" -#include "v3math.h" -#include "llbvhconsts.h" - -class LLKeyframeDataCache; -class LLDataPacker; - -#define MIN_REQUIRED_PIXEL_AREA_KEYFRAME (40.f) -#define MAX_CHAIN_LENGTH (4) - -const S32 KEYFRAME_MOTION_VERSION = 1; -const S32 KEYFRAME_MOTION_SUBVERSION = 0; - -//----------------------------------------------------------------------------- -// class LLKeyframeMotion -//----------------------------------------------------------------------------- -class LLKeyframeMotion : - public LLMotion -{ - friend class LLKeyframeDataCache; -public: - // Constructor - LLKeyframeMotion(const LLUUID &id); - - // Destructor - virtual ~LLKeyframeMotion(); - -private: - // private helper functions to wrap some asserts - LLPointer& getJointState(U32 index); - LLJoint* getJoint(U32 index ); - -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); - -public: - //------------------------------------------------------------------------- - // animation callbacks to be implemented by subclasses - //------------------------------------------------------------------------- - - // motions must specify whether or not they loop - virtual bool getLoop() { - if (mJointMotionList) return mJointMotionList->mLoop; - else return false; - } - - // motions must report their total duration - virtual F32 getDuration() { - if (mJointMotionList) return mJointMotionList->mDuration; - else return 0.f; - } - - // motions must report their "ease in" duration - virtual F32 getEaseInDuration() { - if (mJointMotionList) return mJointMotionList->mEaseInDuration; - else return 0.f; - } - - // motions must report their "ease out" duration. - virtual F32 getEaseOutDuration() { - if (mJointMotionList) return mJointMotionList->mEaseOutDuration; - else return 0.f; - } - - // motions must report their priority - virtual LLJoint::JointPriority getPriority() { - if (mJointMotionList) return mJointMotionList->mBasePriority; - else return LLJoint::LOW_PRIORITY; - } - - virtual S32 getNumJointMotions() - { - if (mJointMotionList) - { - return mJointMotionList->getNumJointMotions(); - } - return 0; - } - - 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_KEYFRAME; } - - // 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(); - - virtual void setStopTime(F32 time); - - static void onLoadComplete(const LLUUID& asset_uuid, - LLAssetType::EType type, - void* user_data, S32 status, LLExtStat ext_status); - -public: - U32 getFileSize(); - bool serialize(LLDataPacker& dp) const; - bool deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints = true); - bool isLoaded() { return mJointMotionList != NULL; } - bool dumpToFile(const std::string& name); - - - // setters for modifying a keyframe animation - void setLoop(bool loop); - - F32 getLoopIn() { - return (mJointMotionList) ? mJointMotionList->mLoopInPoint : 0.f; - } - - F32 getLoopOut() { - return (mJointMotionList) ? mJointMotionList->mLoopOutPoint : 0.f; - } - - void setLoopIn(F32 in_point); - - void setLoopOut(F32 out_point); - - void setHandPose(LLHandMotion::eHandPose pose) { - if (mJointMotionList) mJointMotionList->mHandPose = pose; - } - - LLHandMotion::eHandPose getHandPose() { - return (mJointMotionList) ? mJointMotionList->mHandPose : LLHandMotion::HAND_POSE_RELAXED; - } - - void setPriority(S32 priority); - - void setEmote(const LLUUID& emote_id); - - void setEaseIn(F32 ease_in); - - void setEaseOut(F32 ease_in); - - F32 getLastUpdateTime() { return mLastLoopedTime; } - - const LLBBoxLocal& getPelvisBBox(); - - static void flushKeyframeCache(); - -protected: - //------------------------------------------------------------------------- - // JointConstraintSharedData - //------------------------------------------------------------------------- - class JointConstraintSharedData - { - public: - JointConstraintSharedData() : - mChainLength(0), - mEaseInStartTime(0.f), - mEaseInStopTime(0.f), - mEaseOutStartTime(0.f), - mEaseOutStopTime(0.f), - mUseTargetOffset(false), - mConstraintType(CONSTRAINT_TYPE_POINT), - mConstraintTargetType(CONSTRAINT_TARGET_TYPE_BODY), - mSourceConstraintVolume(0), - mTargetConstraintVolume(0), - mJointStateIndices(NULL) - { }; - ~JointConstraintSharedData() { delete [] mJointStateIndices; } - - S32 mSourceConstraintVolume; - LLVector3 mSourceConstraintOffset; - S32 mTargetConstraintVolume; - LLVector3 mTargetConstraintOffset; - LLVector3 mTargetConstraintDir; - S32 mChainLength; - S32* mJointStateIndices; - F32 mEaseInStartTime; - F32 mEaseInStopTime; - F32 mEaseOutStartTime; - F32 mEaseOutStopTime; - bool mUseTargetOffset; - EConstraintType mConstraintType; - EConstraintTargetType mConstraintTargetType; - }; - - //----------------------------------------------------------------------------- - // JointConstraint() - //----------------------------------------------------------------------------- - class JointConstraint - { - public: - JointConstraint(JointConstraintSharedData* shared_data); - ~JointConstraint(); - - JointConstraintSharedData* mSharedData; - F32 mWeight; - F32 mTotalLength; - LLVector3 mPositions[MAX_CHAIN_LENGTH]; - F32 mJointLengths[MAX_CHAIN_LENGTH]; - F32 mJointLengthFractions[MAX_CHAIN_LENGTH]; - bool mActive; - LLVector3d mGroundPos; - LLVector3 mGroundNorm; - LLJoint* mSourceVolume; - LLJoint* mTargetVolume; - F32 mFixupDistanceRMS; - }; - - void applyKeyframes(F32 time); - - void applyConstraints(F32 time, U8* joint_mask); - - void activateConstraint(JointConstraint* constraintp); - - void initializeConstraint(JointConstraint* constraint); - - void deactivateConstraint(JointConstraint *constraintp); - - void applyConstraint(JointConstraint* constraintp, F32 time, U8* joint_mask); - - bool setupPose(); - -public: - enum AssetStatus { ASSET_LOADED, ASSET_FETCHED, ASSET_NEEDS_FETCH, ASSET_FETCH_FAILED, ASSET_UNDEFINED }; - - enum InterpolationType { IT_STEP, IT_LINEAR, IT_SPLINE }; - - //------------------------------------------------------------------------- - // ScaleKey - //------------------------------------------------------------------------- - class ScaleKey - { - public: - ScaleKey() { mTime = 0.0f; } - ScaleKey(F32 time, const LLVector3 &scale) { mTime = time; mScale = scale; } - - F32 mTime; - LLVector3 mScale; - }; - - //------------------------------------------------------------------------- - // RotationKey - //------------------------------------------------------------------------- - class RotationKey - { - public: - RotationKey() { mTime = 0.0f; } - RotationKey(F32 time, const LLQuaternion &rotation) { mTime = time; mRotation = rotation; } - - F32 mTime; - LLQuaternion mRotation; - }; - - //------------------------------------------------------------------------- - // PositionKey - //------------------------------------------------------------------------- - class PositionKey - { - public: - PositionKey() { mTime = 0.0f; } - PositionKey(F32 time, const LLVector3 &position) { mTime = time; mPosition = position; } - - F32 mTime; - LLVector3 mPosition; - }; - - //------------------------------------------------------------------------- - // ScaleCurve - //------------------------------------------------------------------------- - class ScaleCurve - { - public: - ScaleCurve(); - ~ScaleCurve(); - LLVector3 getValue(F32 time, F32 duration); - LLVector3 interp(F32 u, ScaleKey& before, ScaleKey& after); - - InterpolationType mInterpolationType; - S32 mNumKeys; - typedef std::map key_map_t; - key_map_t mKeys; - ScaleKey mLoopInKey; - ScaleKey mLoopOutKey; - }; - - //------------------------------------------------------------------------- - // RotationCurve - //------------------------------------------------------------------------- - class RotationCurve - { - public: - RotationCurve(); - ~RotationCurve(); - LLQuaternion getValue(F32 time, F32 duration); - LLQuaternion interp(F32 u, RotationKey& before, RotationKey& after); - - InterpolationType mInterpolationType; - S32 mNumKeys; - typedef std::map key_map_t; - key_map_t mKeys; - RotationKey mLoopInKey; - RotationKey mLoopOutKey; - }; - - //------------------------------------------------------------------------- - // PositionCurve - //------------------------------------------------------------------------- - class PositionCurve - { - public: - PositionCurve(); - ~PositionCurve(); - LLVector3 getValue(F32 time, F32 duration); - LLVector3 interp(F32 u, PositionKey& before, PositionKey& after); - - InterpolationType mInterpolationType; - S32 mNumKeys; - typedef std::map key_map_t; - key_map_t mKeys; - PositionKey mLoopInKey; - PositionKey mLoopOutKey; - }; - - //------------------------------------------------------------------------- - // JointMotion - //------------------------------------------------------------------------- - class JointMotion - { - public: - PositionCurve mPositionCurve; - RotationCurve mRotationCurve; - ScaleCurve mScaleCurve; - std::string mJointName; - U32 mUsage; - LLJoint::JointPriority mPriority; - - void update(LLJointState* joint_state, F32 time, F32 duration); - }; - - //------------------------------------------------------------------------- - // JointMotionList - //------------------------------------------------------------------------- - class JointMotionList - { - public: - std::vector mJointMotionArray; - F32 mDuration; - bool mLoop; - F32 mLoopInPoint; - F32 mLoopOutPoint; - F32 mEaseInDuration; - F32 mEaseOutDuration; - LLJoint::JointPriority mBasePriority; - LLHandMotion::eHandPose mHandPose; - LLJoint::JointPriority mMaxPriority; - typedef std::list constraint_list_t; - constraint_list_t mConstraints; - LLBBoxLocal mPelvisBBox; - // mEmoteName is a facial motion, but it's necessary to appear here so that it's cached. - // TODO: LLKeyframeDataCache::getKeyframeData should probably return a class containing - // JointMotionList and mEmoteName, see LLKeyframeMotion::onInitialize. - std::string mEmoteName; - LLUUID mEmoteID; - - public: - JointMotionList(); - ~JointMotionList(); - U32 dumpDiagInfo(); - JointMotion* getJointMotion(U32 index) const { llassert(index < mJointMotionArray.size()); return mJointMotionArray[index]; } - U32 getNumJointMotions() const { return mJointMotionArray.size(); } - }; - -protected: - JointMotionList* mJointMotionList; - std::vector > mJointStates; - LLJoint* mPelvisp; - LLCharacter* mCharacter; - typedef std::list constraint_list_t; - constraint_list_t mConstraints; - U32 mLastSkeletonSerialNum; - F32 mLastUpdateTime; - F32 mLastLoopedTime; - AssetStatus mAssetStatus; - -public: - void setCharacter(LLCharacter* character) { mCharacter = character; } -}; - -class LLKeyframeDataCache -{ -public: - // *FIX: implement this as an actual singleton member of LLKeyframeMotion - LLKeyframeDataCache(){}; - ~LLKeyframeDataCache(); - - typedef std::map keyframe_data_map_t; - static keyframe_data_map_t sKeyframeDataMap; - - static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*); - static LLKeyframeMotion::JointMotionList* getKeyframeData(const LLUUID& id); - - static void removeKeyframeData(const LLUUID& id); - - //print out diagnostic info - static void dumpDiagInfo(); - static void clear(); -}; - -#endif // LL_LLKEYFRAMEMOTION_H - - +/** + * @file llkeyframemotion.h + * @brief Implementation of LLKeframeMotion class. + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLKEYFRAMEMOTION_H +#define LL_LLKEYFRAMEMOTION_H + +//----------------------------------------------------------------------------- +// Header files +//----------------------------------------------------------------------------- + +#include + +#include "llassetstorage.h" +#include "llbboxlocal.h" +#include "llhandmotion.h" +#include "lljointstate.h" +#include "llmotion.h" +#include "llquaternion.h" +#include "v3dmath.h" +#include "v3math.h" +#include "llbvhconsts.h" + +class LLKeyframeDataCache; +class LLDataPacker; + +#define MIN_REQUIRED_PIXEL_AREA_KEYFRAME (40.f) +#define MAX_CHAIN_LENGTH (4) + +const S32 KEYFRAME_MOTION_VERSION = 1; +const S32 KEYFRAME_MOTION_SUBVERSION = 0; + +//----------------------------------------------------------------------------- +// class LLKeyframeMotion +//----------------------------------------------------------------------------- +class LLKeyframeMotion : + public LLMotion +{ + friend class LLKeyframeDataCache; +public: + // Constructor + LLKeyframeMotion(const LLUUID &id); + + // Destructor + virtual ~LLKeyframeMotion(); + +private: + // private helper functions to wrap some asserts + LLPointer& getJointState(U32 index); + LLJoint* getJoint(U32 index ); + +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); + +public: + //------------------------------------------------------------------------- + // animation callbacks to be implemented by subclasses + //------------------------------------------------------------------------- + + // motions must specify whether or not they loop + virtual bool getLoop() { + if (mJointMotionList) return mJointMotionList->mLoop; + else return false; + } + + // motions must report their total duration + virtual F32 getDuration() { + if (mJointMotionList) return mJointMotionList->mDuration; + else return 0.f; + } + + // motions must report their "ease in" duration + virtual F32 getEaseInDuration() { + if (mJointMotionList) return mJointMotionList->mEaseInDuration; + else return 0.f; + } + + // motions must report their "ease out" duration. + virtual F32 getEaseOutDuration() { + if (mJointMotionList) return mJointMotionList->mEaseOutDuration; + else return 0.f; + } + + // motions must report their priority + virtual LLJoint::JointPriority getPriority() { + if (mJointMotionList) return mJointMotionList->mBasePriority; + else return LLJoint::LOW_PRIORITY; + } + + virtual S32 getNumJointMotions() + { + if (mJointMotionList) + { + return mJointMotionList->getNumJointMotions(); + } + return 0; + } + + 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_KEYFRAME; } + + // 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(); + + virtual void setStopTime(F32 time); + + static void onLoadComplete(const LLUUID& asset_uuid, + LLAssetType::EType type, + void* user_data, S32 status, LLExtStat ext_status); + +public: + U32 getFileSize(); + bool serialize(LLDataPacker& dp) const; + bool deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints = true); + bool isLoaded() { return mJointMotionList != NULL; } + bool dumpToFile(const std::string& name); + + + // setters for modifying a keyframe animation + void setLoop(bool loop); + + F32 getLoopIn() { + return (mJointMotionList) ? mJointMotionList->mLoopInPoint : 0.f; + } + + F32 getLoopOut() { + return (mJointMotionList) ? mJointMotionList->mLoopOutPoint : 0.f; + } + + void setLoopIn(F32 in_point); + + void setLoopOut(F32 out_point); + + void setHandPose(LLHandMotion::eHandPose pose) { + if (mJointMotionList) mJointMotionList->mHandPose = pose; + } + + LLHandMotion::eHandPose getHandPose() { + return (mJointMotionList) ? mJointMotionList->mHandPose : LLHandMotion::HAND_POSE_RELAXED; + } + + void setPriority(S32 priority); + + void setEmote(const LLUUID& emote_id); + + void setEaseIn(F32 ease_in); + + void setEaseOut(F32 ease_in); + + F32 getLastUpdateTime() { return mLastLoopedTime; } + + const LLBBoxLocal& getPelvisBBox(); + + static void flushKeyframeCache(); + +protected: + //------------------------------------------------------------------------- + // JointConstraintSharedData + //------------------------------------------------------------------------- + class JointConstraintSharedData + { + public: + JointConstraintSharedData() : + mChainLength(0), + mEaseInStartTime(0.f), + mEaseInStopTime(0.f), + mEaseOutStartTime(0.f), + mEaseOutStopTime(0.f), + mUseTargetOffset(false), + mConstraintType(CONSTRAINT_TYPE_POINT), + mConstraintTargetType(CONSTRAINT_TARGET_TYPE_BODY), + mSourceConstraintVolume(0), + mTargetConstraintVolume(0), + mJointStateIndices(NULL) + { }; + ~JointConstraintSharedData() { delete [] mJointStateIndices; } + + S32 mSourceConstraintVolume; + LLVector3 mSourceConstraintOffset; + S32 mTargetConstraintVolume; + LLVector3 mTargetConstraintOffset; + LLVector3 mTargetConstraintDir; + S32 mChainLength; + S32* mJointStateIndices; + F32 mEaseInStartTime; + F32 mEaseInStopTime; + F32 mEaseOutStartTime; + F32 mEaseOutStopTime; + bool mUseTargetOffset; + EConstraintType mConstraintType; + EConstraintTargetType mConstraintTargetType; + }; + + //----------------------------------------------------------------------------- + // JointConstraint() + //----------------------------------------------------------------------------- + class JointConstraint + { + public: + JointConstraint(JointConstraintSharedData* shared_data); + ~JointConstraint(); + + JointConstraintSharedData* mSharedData; + F32 mWeight; + F32 mTotalLength; + LLVector3 mPositions[MAX_CHAIN_LENGTH]; + F32 mJointLengths[MAX_CHAIN_LENGTH]; + F32 mJointLengthFractions[MAX_CHAIN_LENGTH]; + bool mActive; + LLVector3d mGroundPos; + LLVector3 mGroundNorm; + LLJoint* mSourceVolume; + LLJoint* mTargetVolume; + F32 mFixupDistanceRMS; + }; + + void applyKeyframes(F32 time); + + void applyConstraints(F32 time, U8* joint_mask); + + void activateConstraint(JointConstraint* constraintp); + + void initializeConstraint(JointConstraint* constraint); + + void deactivateConstraint(JointConstraint *constraintp); + + void applyConstraint(JointConstraint* constraintp, F32 time, U8* joint_mask); + + bool setupPose(); + +public: + enum AssetStatus { ASSET_LOADED, ASSET_FETCHED, ASSET_NEEDS_FETCH, ASSET_FETCH_FAILED, ASSET_UNDEFINED }; + + enum InterpolationType { IT_STEP, IT_LINEAR, IT_SPLINE }; + + //------------------------------------------------------------------------- + // ScaleKey + //------------------------------------------------------------------------- + class ScaleKey + { + public: + ScaleKey() { mTime = 0.0f; } + ScaleKey(F32 time, const LLVector3 &scale) { mTime = time; mScale = scale; } + + F32 mTime; + LLVector3 mScale; + }; + + //------------------------------------------------------------------------- + // RotationKey + //------------------------------------------------------------------------- + class RotationKey + { + public: + RotationKey() { mTime = 0.0f; } + RotationKey(F32 time, const LLQuaternion &rotation) { mTime = time; mRotation = rotation; } + + F32 mTime; + LLQuaternion mRotation; + }; + + //------------------------------------------------------------------------- + // PositionKey + //------------------------------------------------------------------------- + class PositionKey + { + public: + PositionKey() { mTime = 0.0f; } + PositionKey(F32 time, const LLVector3 &position) { mTime = time; mPosition = position; } + + F32 mTime; + LLVector3 mPosition; + }; + + //------------------------------------------------------------------------- + // ScaleCurve + //------------------------------------------------------------------------- + class ScaleCurve + { + public: + ScaleCurve(); + ~ScaleCurve(); + LLVector3 getValue(F32 time, F32 duration); + LLVector3 interp(F32 u, ScaleKey& before, ScaleKey& after); + + InterpolationType mInterpolationType; + S32 mNumKeys; + typedef std::map key_map_t; + key_map_t mKeys; + ScaleKey mLoopInKey; + ScaleKey mLoopOutKey; + }; + + //------------------------------------------------------------------------- + // RotationCurve + //------------------------------------------------------------------------- + class RotationCurve + { + public: + RotationCurve(); + ~RotationCurve(); + LLQuaternion getValue(F32 time, F32 duration); + LLQuaternion interp(F32 u, RotationKey& before, RotationKey& after); + + InterpolationType mInterpolationType; + S32 mNumKeys; + typedef std::map key_map_t; + key_map_t mKeys; + RotationKey mLoopInKey; + RotationKey mLoopOutKey; + }; + + //------------------------------------------------------------------------- + // PositionCurve + //------------------------------------------------------------------------- + class PositionCurve + { + public: + PositionCurve(); + ~PositionCurve(); + LLVector3 getValue(F32 time, F32 duration); + LLVector3 interp(F32 u, PositionKey& before, PositionKey& after); + + InterpolationType mInterpolationType; + S32 mNumKeys; + typedef std::map key_map_t; + key_map_t mKeys; + PositionKey mLoopInKey; + PositionKey mLoopOutKey; + }; + + //------------------------------------------------------------------------- + // JointMotion + //------------------------------------------------------------------------- + class JointMotion + { + public: + PositionCurve mPositionCurve; + RotationCurve mRotationCurve; + ScaleCurve mScaleCurve; + std::string mJointName; + U32 mUsage; + LLJoint::JointPriority mPriority; + + void update(LLJointState* joint_state, F32 time, F32 duration); + }; + + //------------------------------------------------------------------------- + // JointMotionList + //------------------------------------------------------------------------- + class JointMotionList + { + public: + std::vector mJointMotionArray; + F32 mDuration; + bool mLoop; + F32 mLoopInPoint; + F32 mLoopOutPoint; + F32 mEaseInDuration; + F32 mEaseOutDuration; + LLJoint::JointPriority mBasePriority; + LLHandMotion::eHandPose mHandPose; + LLJoint::JointPriority mMaxPriority; + typedef std::list constraint_list_t; + constraint_list_t mConstraints; + LLBBoxLocal mPelvisBBox; + // mEmoteName is a facial motion, but it's necessary to appear here so that it's cached. + // TODO: LLKeyframeDataCache::getKeyframeData should probably return a class containing + // JointMotionList and mEmoteName, see LLKeyframeMotion::onInitialize. + std::string mEmoteName; + LLUUID mEmoteID; + + public: + JointMotionList(); + ~JointMotionList(); + U32 dumpDiagInfo(); + JointMotion* getJointMotion(U32 index) const { llassert(index < mJointMotionArray.size()); return mJointMotionArray[index]; } + U32 getNumJointMotions() const { return mJointMotionArray.size(); } + }; + +protected: + JointMotionList* mJointMotionList; + std::vector > mJointStates; + LLJoint* mPelvisp; + LLCharacter* mCharacter; + typedef std::list constraint_list_t; + constraint_list_t mConstraints; + U32 mLastSkeletonSerialNum; + F32 mLastUpdateTime; + F32 mLastLoopedTime; + AssetStatus mAssetStatus; + +public: + void setCharacter(LLCharacter* character) { mCharacter = character; } +}; + +class LLKeyframeDataCache +{ +public: + // *FIX: implement this as an actual singleton member of LLKeyframeMotion + LLKeyframeDataCache(){}; + ~LLKeyframeDataCache(); + + typedef std::map keyframe_data_map_t; + static keyframe_data_map_t sKeyframeDataMap; + + static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*); + static LLKeyframeMotion::JointMotionList* getKeyframeData(const LLUUID& id); + + static void removeKeyframeData(const LLUUID& id); + + //print out diagnostic info + static void dumpDiagInfo(); + static void clear(); +}; + +#endif // LL_LLKEYFRAMEMOTION_H + + -- cgit v1.2.3 From b42f9d836b4c0f7fbd4bdae1734021e2a09fdbe8 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 1 Jun 2024 15:49:26 +0200 Subject: Re-enable a lot of compiler warnings for MSVC and address the C4267 "possible loss of precision" warnings --- indra/llcharacter/llkeyframemotion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcharacter/llkeyframemotion.h') diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index edf2308050..d5b27c8102 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -420,7 +420,7 @@ public: ~JointMotionList(); U32 dumpDiagInfo(); JointMotion* getJointMotion(U32 index) const { llassert(index < mJointMotionArray.size()); return mJointMotionArray[index]; } - U32 getNumJointMotions() const { return mJointMotionArray.size(); } + U32 getNumJointMotions() const { return static_cast(mJointMotionArray.size()); } }; protected: -- cgit v1.2.3