lljointstate.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /**
  2. * @file lljointstate.h
  3. * @brief Implementation of LLJointState class.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLJOINTSTATE_H
  33. #define LL_LLJOINTSTATE_H
  34. #include "llerror.h"
  35. #include "lljoint.h"
  36. #include "llpreprocessor.h"
  37. #include "llrefcount.h"
  38. class LLJointState : public LLRefCount
  39. {
  40. public:
  41. enum BlendPhase
  42. {
  43. INACTIVE,
  44. EASE_IN,
  45. ACTIVE,
  46. EASE_OUT
  47. };
  48. // Constructors
  49. LLJointState()
  50. : mUsage(0),
  51. mJoint(NULL),
  52. mWeight(0.f),
  53. mPriority(LLJoint::USE_MOTION_PRIORITY)
  54. {
  55. }
  56. LLJointState(LLJoint* joint)
  57. : mUsage(0),
  58. mJoint(joint),
  59. mWeight(0.f),
  60. mPriority(LLJoint::USE_MOTION_PRIORITY)
  61. {
  62. }
  63. // joint that this state is applied to
  64. LL_INLINE LLJoint* getJoint() { return mJoint; }
  65. LL_INLINE const LLJoint* getJoint() const { return mJoint; }
  66. LL_INLINE bool setJoint(LLJoint* joint) { mJoint = joint; return mJoint != NULL; }
  67. // Transform type (bitwise flags can be combined). Note that these are set
  68. // automatically when various member setPos/setRot/setScale functions are
  69. // called.
  70. enum Usage
  71. {
  72. POS = 1,
  73. ROT = 2,
  74. SCALE = 4,
  75. };
  76. LL_INLINE U32 getUsage() const { return mUsage; }
  77. LL_INLINE void setUsage(U32 usage) { mUsage = usage; }
  78. LL_INLINE F32 getWeight() const { return mWeight; }
  79. LL_INLINE void setWeight(F32 weight) { mWeight = weight; }
  80. // get/set position
  81. LL_INLINE const LLVector3& getPosition() const { return mPosition; }
  82. LL_INLINE void setPosition(const LLVector3& pos) { llassert(mUsage & POS); mPosition = pos; }
  83. // get/set rotation
  84. LL_INLINE const LLQuaternion& getRotation() const { return mRotation; }
  85. LL_INLINE void setRotation(const LLQuaternion& rot) { llassert(mUsage & ROT); mRotation = rot; }
  86. // get/set scale
  87. LL_INLINE const LLVector3& getScale() const { return mScale; }
  88. LL_INLINE void setScale(const LLVector3& scale) { llassert(mUsage & SCALE); mScale = scale; }
  89. // get/set priority
  90. LL_INLINE LLJoint::JointPriority getPriority() const { return mPriority; }
  91. LL_INLINE void setPriority(LLJoint::JointPriority p) { mPriority = p; }
  92. protected:
  93. ~LLJointState() override = default;
  94. protected:
  95. // Note: the first member variable is 32 bits in order to align on 64 bits
  96. // for the next variables, counting the 32 bits counter from LLRefCount. HB
  97. // Indicates which members are used
  98. U32 mUsage;
  99. // Associated joint
  100. LLJoint* mJoint;
  101. // Transformation members
  102. LLQuaternion mRotation; // Joint rotation relative to parent
  103. LLVector3 mPosition; // Position relative to parent joint
  104. LLVector3 mScale; // Scale relative to rotated frame
  105. // Indicates weighted effect of this joint
  106. F32 mWeight;
  107. // How important this joint state is relative to others
  108. LLJoint::JointPriority mPriority;
  109. };
  110. #endif // LL_LLJOINTSTATE_H