llpolyskeletaldistortion.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /**
  2. * @file llpolyskeletaldistortion.h
  3. * @brief Implementation of LLPolyMesh 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_LLPOLYSKELETALDISTORTION_H
  33. #define LL_LLPOLYSKELETALDISTORTION_H
  34. #include "linden_common.h"
  35. #include "lljoint.h"
  36. #include "llpreprocessor.h"
  37. #include "llquaternion.h"
  38. #include "llstl.h"
  39. #include "llviewervisualparam.h"
  40. #include "llvector2.h"
  41. #include "llvector3.h"
  42. class LLAvatarAppearance;
  43. //-----------------------------------------------------------------------------
  44. // LLPolySkeletalDeformationInfo
  45. // Shared information for LLPolySkeletalDeformations
  46. //-----------------------------------------------------------------------------
  47. struct LLPolySkeletalBoneInfo
  48. {
  49. LLPolySkeletalBoneInfo(const std::string& name, const LLVector3& scale,
  50. const LLVector3& pos, bool haspos)
  51. : mJointKey(LLJoint::getKey(name)),
  52. mScaleDeformation(scale),
  53. mPositionDeformation(pos),
  54. mHasPositionDeformation(haspos)
  55. {
  56. }
  57. LLVector3 mScaleDeformation;
  58. LLVector3 mPositionDeformation;
  59. U32 mJointKey;
  60. bool mHasPositionDeformation;
  61. };
  62. class LLPolySkeletalDistortionInfo : public LLViewerVisualParamInfo
  63. {
  64. friend class LLPolySkeletalDistortion;
  65. protected:
  66. LOG_CLASS(LLPolySkeletalDistortionInfo);
  67. public:
  68. LLPolySkeletalDistortionInfo() = default;
  69. LL_INLINE LLPolySkeletalDistortionInfo* asPolySkeletalDistortionInfo() override
  70. {
  71. return this;
  72. }
  73. bool parseXml(LLXmlTreeNode* node) override;
  74. protected:
  75. typedef std::vector<LLPolySkeletalBoneInfo> bone_info_list_t;
  76. bone_info_list_t mBoneInfoList;
  77. };
  78. //-----------------------------------------------------------------------------
  79. // LLPolySkeletalDeformation
  80. // A set of joint scale data for deforming the avatar mesh
  81. //-----------------------------------------------------------------------------
  82. class alignas(16) LLPolySkeletalDistortion : public LLViewerVisualParam
  83. {
  84. protected:
  85. LOG_CLASS(LLPolySkeletalDistortion);
  86. LLPolySkeletalDistortion(const LLPolySkeletalDistortion& other);
  87. public:
  88. LLPolySkeletalDistortion(LLAvatarAppearance* avatarp);
  89. LL_INLINE LLPolySkeletalDistortion* asPolySkeletalDistortion() override
  90. {
  91. return this;
  92. }
  93. // Special: these functions are overridden by child classes
  94. LL_INLINE LLPolySkeletalDistortionInfo* getInfo() const
  95. {
  96. return (LLPolySkeletalDistortionInfo*)mInfo;
  97. }
  98. // This sets mInfo and calls initialization functions
  99. bool setInfo(LLPolySkeletalDistortionInfo* info);
  100. LLViewerVisualParam* cloneParam(LLWearable* wearable) const override;
  101. // LLVisualParam Virtual function
  102. void apply(ESex sex) override;
  103. #if 0 // Unused methods
  104. // LLViewerVisualParam Virtual functions
  105. LL_INLINE F32 getTotalDistortion() override { return 0.1f; }
  106. LL_INLINE const LLVector4a& getAvgDistortion() override { return mDefaultVec; }
  107. LL_INLINE F32 getMaxDistortion() override { return 0.1f; }
  108. LL_INLINE LLVector4a getVertexDistortion(S32, LLPolyMesh*) override
  109. {
  110. return LLVector4a(0.001f, 0.001f, 0.001f);
  111. }
  112. LL_INLINE const LLVector4a* getFirstDistortion(U32* index,
  113. LLPolyMesh** pmesh) override
  114. {
  115. index = 0;
  116. pmesh = NULL;
  117. return &mDefaultVec;
  118. }
  119. LL_INLINE const LLVector4a* getNextDistortion(U32* index,
  120. LLPolyMesh** pmesh) override
  121. {
  122. index = 0;
  123. pmesh = NULL;
  124. return NULL;
  125. }
  126. #endif
  127. protected:
  128. LLVector4a mDefaultVec;
  129. // Backlink only; do not make this an LLPointer:
  130. LLAvatarAppearance* mAvatar;
  131. typedef std::map<LLJoint*, LLVector3> joint_vec_map_t;
  132. joint_vec_map_t mJointScales;
  133. joint_vec_map_t mJointOffsets;
  134. };
  135. #endif // LL_LLPOLYSKELETALDISTORTION_H