lldriverparam.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /**
  2. * @file lldriverparam.h
  3. * @brief A visual parameter that drives (controls) other visual parameters.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-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_LLDRIVERPARAM_H
  33. #define LL_LLDRIVERPARAM_H
  34. #include <deque>
  35. #include "llmemory.h"
  36. #include "llviewervisualparam.h"
  37. #include "llwearabletype.h"
  38. class LLAvatarAppearance;
  39. class LLDriverParam;
  40. class LLWearable;
  41. struct LLDrivenEntryInfo
  42. {
  43. LLDrivenEntryInfo(S32 id, F32 min1, F32 max1, F32 max2, F32 min2)
  44. : mDrivenID(id),
  45. mMin1(min1),
  46. mMax1(max1),
  47. mMax2(max2),
  48. mMin2(min2)
  49. {
  50. }
  51. S32 mDrivenID;
  52. F32 mMin1;
  53. F32 mMax1;
  54. F32 mMax2;
  55. F32 mMin2;
  56. };
  57. struct LLDrivenEntry
  58. {
  59. LLDrivenEntry(LLViewerVisualParam* param, LLDrivenEntryInfo* info)
  60. : mParam(param),
  61. mInfo(info)
  62. {
  63. }
  64. LLViewerVisualParam* mParam;
  65. LLDrivenEntryInfo* mInfo;
  66. };
  67. class LLDriverParamInfo final : public LLViewerVisualParamInfo
  68. {
  69. friend class LLDriverParam;
  70. protected:
  71. LOG_CLASS(LLDriverParamInfo);
  72. public:
  73. LLDriverParamInfo();
  74. bool parseXml(LLXmlTreeNode* node) override;
  75. protected:
  76. typedef std::deque<LLDrivenEntryInfo> entry_info_list_t;
  77. entry_info_list_t mDrivenInfoList;
  78. LLDriverParam* mDriverParam; // backpointer
  79. };
  80. class alignas(16) LLDriverParam final : public LLViewerVisualParam
  81. {
  82. public:
  83. // No default constructor. Force construction with LLAvatarAppearance.
  84. LLDriverParam() = delete;
  85. LLDriverParam(LLAvatarAppearance* appearance, LLWearable* wearable = NULL);
  86. LL_INLINE LLDriverParam* asDriverParam() override { return this; }
  87. // Special: These functions are overridden by child classes
  88. LL_INLINE LLDriverParamInfo* getInfo() const { return (LLDriverParamInfo*)mInfo; }
  89. // This sets mInfo and calls initialization functions
  90. bool setInfo(LLDriverParamInfo* info);
  91. LL_INLINE LLAvatarAppearance* getAvatarAppearance() { return mAvatarAppearance; }
  92. LL_INLINE const LLAvatarAppearance* getAvatarAppearance() const
  93. {
  94. return mAvatarAppearance;
  95. }
  96. void updateCrossDrivenParams(LLWearableType::EType driven_type);
  97. LLViewerVisualParam* cloneParam(LLWearable* wearable) const override;
  98. // LLVisualParam Virtual functions
  99. // Apply is called separately for each driven param:
  100. LL_INLINE void apply(ESex sex) override {}
  101. void setWeight(F32 weight, bool upload_bake) override;
  102. void setAnimationTarget(F32 target_value, bool upload_bake) override;
  103. void stopAnimating(bool upload_bake) override;
  104. bool linkDrivenParams(visual_param_mapper mapper,
  105. bool only_cross_params) override;
  106. void resetDrivenParams() override;
  107. // LLViewerVisualParam Virtual functions
  108. #if 0 // Unused methods
  109. F32 getTotalDistortion() override;
  110. const LLVector4a& getAvgDistortion() override;
  111. F32 getMaxDistortion() override;
  112. LLVector4a getVertexDistortion(S32 index, LLPolyMesh* poly_mesh) override;
  113. const LLVector4a* getFirstDistortion(U32* idx, LLPolyMesh** mesh) override;
  114. const LLVector4a* getNextDistortion(U32* idx, LLPolyMesh** pmesh) override;
  115. #endif
  116. S32 getDrivenParamsCount() const;
  117. const LLViewerVisualParam* getDrivenParam(S32 index) const;
  118. typedef std::vector<LLDrivenEntry> entry_list_t;
  119. LL_INLINE entry_list_t& getDrivenList() { return mDriven; }
  120. LL_INLINE void setDrivenList(entry_list_t& list) { mDriven = list; }
  121. protected:
  122. LLDriverParam(const LLDriverParam& other);
  123. F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight);
  124. void setDrivenWeight(LLDrivenEntry* driven, F32 driven_weight,
  125. bool upload_bake);
  126. protected:
  127. LLVector4a mDefaultVec; // Temp holder
  128. entry_list_t mDriven;
  129. LLViewerVisualParam* mCurrentDistortionParam;
  130. LLWearable* mWearablep;
  131. // Backlink only; don't make this an LLPointer.
  132. LLAvatarAppearance* mAvatarAppearance;
  133. };
  134. #endif // LL_LLDRIVERPARAM_H