llviewerpartsource.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /**
  2. * @file llviewerpartsource.h
  3. * @brief LLViewerPartSource class header file
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewergpl$
  6. *
  7. * Copyright (c) 2003-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_LLVIEWERPARTSOURCE_H
  33. #define LL_LLVIEWERPARTSOURCE_H
  34. #include "llpartdata.h"
  35. #include "llpointer.h"
  36. #include "llquaternion.h"
  37. #include "llrefcount.h"
  38. #include "llvector3.h"
  39. #include "llmutelist.h"
  40. #include "llviewertexture.h"
  41. #include "llvoavatar.h"
  42. class LLViewerObject;
  43. class LLViewerPart;
  44. // A particle source, subclassed to generate particles with different behaviors
  45. class LLViewerPartSource : public LLRefCount
  46. {
  47. public:
  48. enum
  49. {
  50. LL_PART_SOURCE_NULL,
  51. LL_PART_SOURCE_SCRIPT,
  52. LL_PART_SOURCE_SPIRAL,
  53. LL_PART_SOURCE_BEAM,
  54. LL_PART_SOURCE_CHAT
  55. };
  56. LLViewerPartSource(U32 type);
  57. virtual ~LLViewerPartSource() {}
  58. virtual void update(F32 dt) = 0;
  59. virtual void setDead();
  60. LL_INLINE bool isDead() const { return mIsDead; }
  61. LL_INLINE void setSuspended(bool state) { mIsSuspended = state; }
  62. LL_INLINE bool isSuspended() const { return mIsSuspended; }
  63. LL_INLINE U32 getType() const { return mType; }
  64. LL_INLINE void setOwnerUUID(const LLUUID& owner_id) { mOwnerUUID = owner_id; }
  65. LL_INLINE const LLUUID& getOwnerUUID() const { return mOwnerUUID; }
  66. LL_INLINE U32 getID() const { return mID; }
  67. LL_INLINE const LLUUID& getImageUUID() const;
  68. LL_INLINE void setStart() { mDelay = 0; }
  69. LL_INLINE LLViewerTexture* getImage() const { return mImagep; }
  70. LL_INLINE void incPartUpdates() { ++mPartUpdates; }
  71. void incPartCount();
  72. U64 getAveragePartCount();
  73. static void updatePart(LLViewerPart& part, F32 dt);
  74. public:
  75. LLPointer<LLViewerObject> mSourceObjectp;
  76. // Location of the particle source:
  77. LLVector3 mPosAgent;
  78. // Location of the target position:
  79. LLVector3 mTargetPosAgent;
  80. LLVector3 mLastUpdatePosAgent;
  81. // Distance from the camera.
  82. F32 mDistFromCamera;
  83. U32 mID;
  84. // Last particle emitted (for making particle ribbons)
  85. LLViewerPart* mLastPart;
  86. protected:
  87. LLPointer<LLVOAvatar> mOwnerAvatarp;
  88. LLPointer<LLViewerTexture> mImagep;
  89. LLUUID mOwnerUUID;
  90. // Particle information
  91. U64 mPartCount;
  92. U64 mPartUpdates;
  93. U32 mPartFlags; // Flags for the particle
  94. U32 mDelay; // Delay to start particles
  95. U32 mType;
  96. F32 mLastUpdateTime;
  97. F32 mLastPartTime;
  98. bool mIsDead;
  99. bool mIsSuspended;
  100. };
  101. // LLViewerPartSourceScript
  102. // Particle source that handles the "generic" script-drive particle source
  103. // attached to objects
  104. class LLViewerPartSourceScript final : public LLViewerPartSource,
  105. public LLMuteListObserver
  106. {
  107. protected:
  108. LOG_CLASS(LLViewerPartSourceScript);
  109. public:
  110. LLViewerPartSourceScript(LLViewerObject* source_objp);
  111. ~LLViewerPartSourceScript() override;
  112. void update(F32 dt) override;
  113. void setDead() override;
  114. // LLMuteListObserver interface
  115. void onChange() override;
  116. // Returns a new particle source to attach to an object...
  117. static LLPointer<LLViewerPartSourceScript> unpackPSS(LLViewerObject* source_objp,
  118. LLPointer<LLViewerPartSourceScript> pssp,
  119. S32 block_num);
  120. static LLPointer<LLViewerPartSourceScript> unpackPSS(LLViewerObject* source_objp,
  121. LLPointer<LLViewerPartSourceScript> pssp,
  122. LLDataPacker& dp,
  123. bool legacy);
  124. static LLPointer<LLViewerPartSourceScript> createPSS(LLViewerObject* source_objp,
  125. const LLPartSysData& part_params);
  126. LL_INLINE void setImage(LLViewerTexture* imagep) { mImagep = imagep; }
  127. LL_INLINE void setTargetObject(LLViewerObject* obj) { mTargetObjectp = obj; }
  128. public:
  129. LLPartSysData mPartSysData;
  130. protected:
  131. // Target object for the particle source
  132. LLPointer<LLViewerObject> mTargetObjectp;
  133. // Current rotation for particle source
  134. LLQuaternion mRotation;
  135. };
  136. // Particle source for spiral effect (customize avatar, mostly)
  137. class LLViewerPartSourceSpiral final : public LLViewerPartSource
  138. {
  139. public:
  140. LLViewerPartSourceSpiral(const LLVector3& pos);
  141. void setDead() override;
  142. void update(F32 dt) override;
  143. LL_INLINE void setSourceObject(LLViewerObject* obj) { mSourceObjectp = obj; }
  144. LL_INLINE void setColor(const LLColor4& color) { mColor = color; }
  145. static void updatePart(LLViewerPart& part, F32 dt);
  146. public:
  147. LLColor4 mColor;
  148. protected:
  149. LLVector3d mLKGSourcePosGlobal;
  150. };
  151. // Particle source for tractor (editing) beam
  152. class LLViewerPartSourceBeam final : public LLViewerPartSource
  153. {
  154. public:
  155. LLViewerPartSourceBeam();
  156. void setDead() override;
  157. void update(F32 dt) override;
  158. LL_INLINE void setSourceObject(LLViewerObject* obj) { mSourceObjectp = obj; }
  159. LL_INLINE void setTargetObject(LLViewerObject* obj) { mTargetObjectp = obj; }
  160. LL_INLINE void setColor(const LLColor4& color) { mColor = color; }
  161. static void updatePart(LLViewerPart& part, F32 dt);
  162. protected:
  163. LL_INLINE ~LLViewerPartSourceBeam() {}
  164. public:
  165. LLPointer<LLViewerObject> mTargetObjectp;
  166. LLVector3d mLKGTargetPosGlobal;
  167. LLColor4 mColor;
  168. };
  169. // Particle source for chat effect
  170. class LLViewerPartSourceChat final : public LLViewerPartSource
  171. {
  172. public:
  173. LLViewerPartSourceChat(const LLVector3& pos);
  174. void setDead() override;
  175. void update(F32 dt) override;
  176. LL_INLINE void setSourceObject(LLViewerObject* obj) { mSourceObjectp = obj; }
  177. LL_INLINE void setColor(const LLColor4& color) { mColor = color; }
  178. static void updatePart(LLViewerPart& part, F32 dt);
  179. public:
  180. LLColor4 mColor;
  181. protected:
  182. LLVector3d mLKGSourcePosGlobal;
  183. };
  184. #endif // LL_LLVIEWERPARTSOURCE_H