llwearabledata.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**
  2. * @file llwearabledata.h
  3. * @brief LLWearableData class header file
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewergpl$
  6. *
  7. * Copyright (c) 2010, 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_WEARABLEDATA_H
  33. #define LL_WEARABLEDATA_H
  34. #include "llavatarappearancedefines.h"
  35. #include "llerror.h"
  36. #include "llwearable.h"
  37. class LLAvatarAppearance;
  38. class LLWearableData
  39. {
  40. protected:
  41. LOG_CLASS(LLWearableData);
  42. public:
  43. LLWearableData();
  44. virtual ~LLWearableData() = default;
  45. LL_INLINE void setAvatarAppearance(LLAvatarAppearance* appearance)
  46. {
  47. mAvatarAppearance = appearance;
  48. }
  49. LLWearable* getWearable(LLWearableType::EType type, U32 index);
  50. const LLWearable* getWearable(LLWearableType::EType type, U32 index) const;
  51. LLWearable* getTopWearable(LLWearableType::EType type);
  52. const LLWearable* getTopWearable(LLWearableType::EType type) const;
  53. LLWearable* getBottomWearable(LLWearableType::EType type);
  54. const LLWearable* getBottomWearable(LLWearableType::EType type) const;
  55. U32 getWearableCount(LLWearableType::EType type) const;
  56. U32 getWearableCount(U32 tex_idx) const;
  57. bool getWearableIndex(const LLWearable* wearable, U32& index) const;
  58. U32 getClothingLayerCount() const;
  59. bool canAddWearable(LLWearableType::EType type) const;
  60. bool isOnTop(LLWearable* wearable) const;
  61. LLUUID computeBakedTextureHash(LLAvatarAppearanceDefines::EBakedTextureIndex idx,
  62. bool generate_valid_hash = true);
  63. protected:
  64. //MK
  65. LL_INLINE void setCanWearFunc(bool (*func)(LLWearableType::EType))
  66. {
  67. mCanWearFunc = func;
  68. }
  69. LL_INLINE void setCanUnwearFunc(bool (*func)(LLWearableType::EType))
  70. {
  71. mCanUnwearFunc = func;
  72. }
  73. //mk
  74. // Low-level data structure setter - public access is via setWearableItem, etc.
  75. // These two methods return false when they fail (e.g. because of RLV
  76. // restrictions)
  77. bool setWearable(LLWearableType::EType type, U32 index,
  78. LLWearable* wearable);
  79. bool pushWearable(LLWearableType::EType type, LLWearable* wearable,
  80. bool trigger_updated = true);
  81. virtual void wearableUpdated(LLWearable* wearable, bool removed);
  82. void eraseWearable(LLWearable* wearable);
  83. void eraseWearable(LLWearableType::EType type, U32 index);
  84. void clearWearableType(LLWearableType::EType type);
  85. bool swapWearables(LLWearableType::EType type, U32 index_a, U32 index_b);
  86. virtual void invalidateBakedTextureHash(LLMD5& hash) const {}
  87. private:
  88. void pullCrossWearableValues(LLWearableType::EType type);
  89. public:
  90. static constexpr U32 MAX_CLOTHING_LAYERS = 60;
  91. protected:
  92. LLAvatarAppearance* mAvatarAppearance;
  93. // All wearables of a certain type (e.g. all shirts):
  94. typedef std::vector<LLWearable*> wearableentry_vec_t;
  95. // Wearable "categories" arranged by wearable type:
  96. typedef std::map<LLWearableType::EType,
  97. wearableentry_vec_t> wearableentry_map_t;
  98. wearableentry_map_t mWearableDatas;
  99. private:
  100. bool (*mCanWearFunc)(LLWearableType::EType type);
  101. bool (*mCanUnwearFunc)(LLWearableType::EType type);
  102. };
  103. #endif // LL_WEARABLEDATA_H