aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llhudeffecttrail.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llhudeffecttrail.cpp')
-rw-r--r--linden/indra/newview/llhudeffecttrail.cpp290
1 files changed, 290 insertions, 0 deletions
diff --git a/linden/indra/newview/llhudeffecttrail.cpp b/linden/indra/newview/llhudeffecttrail.cpp
new file mode 100644
index 0000000..ac7f22f
--- /dev/null
+++ b/linden/indra/newview/llhudeffecttrail.cpp
@@ -0,0 +1,290 @@
1/**
2 * @file llhudeffecttrail.cpp
3 * @brief LLHUDEffectSpiral class implementation
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llhudeffecttrail.h"
31
32#include "llviewercontrol.h"
33#include "llimagegl.h"
34#include "message.h"
35
36#include "llagent.h"
37#include "llbox.h"
38#include "lldrawable.h"
39#include "llhudrender.h"
40#include "llviewerimagelist.h"
41#include "llviewerobjectlist.h"
42#include "llviewerpartsim.h"
43#include "llviewerpartsource.h"
44#include "llvoavatar.h"
45#include "llworld.h"
46
47
48const F32 PARTICLE_SPACING = 0.01f;
49const F32 MAX_SIZE = 0.025f;
50const F32 START_POS_MAG = 1.f;
51const F32 END_POS_MAG = 1.2f;
52
53
54LLHUDEffectSpiral::LLHUDEffectSpiral(const U8 type) : LLHUDEffect(type), mbInit(FALSE)
55{
56 mKillTime = 10.f;
57 mVMag = 1.f;
58 mVOffset = 0.f;
59 mInitialRadius = 1.f;
60 mFinalRadius = 1.f;
61 mSpinRate = 10.f;
62 mFlickerRate = 50.f;
63 mScaleBase = 0.1f;
64 mScaleVar = 0.f;
65
66 mFadeInterp.setStartTime(0.f);
67 mFadeInterp.setEndTime(mKillTime);
68 mFadeInterp.setStartVal(1.f);
69 mFadeInterp.setEndVal(1.f);
70}
71
72LLHUDEffectSpiral::~LLHUDEffectSpiral()
73{
74}
75
76void LLHUDEffectSpiral::markDead()
77{
78 if (mPartSourcep)
79 {
80 mPartSourcep->setDead();
81 mPartSourcep = NULL;
82 }
83 LLHUDObject::markDead();
84}
85
86void LLHUDEffectSpiral::packData(LLMessageSystem *mesgsys)
87{
88 if (!mSourceObject)
89 {
90 //llwarns << "Missing object in trail pack!" << llendl;
91 }
92 LLHUDEffect::packData(mesgsys);
93
94 U8 packed_data[56];
95 memset(packed_data, 0, 56);
96
97 if (mSourceObject)
98 {
99 htonmemcpy(packed_data, mSourceObject->mID.mData, MVT_LLUUID, 16);
100 }
101 if (mTargetObject)
102 {
103 htonmemcpy(packed_data + 16, mTargetObject->mID.mData, MVT_LLUUID, 16);
104 }
105 if (!mPositionGlobal.isExactlyZero())
106 {
107 htonmemcpy(packed_data + 32, mPositionGlobal.mdV, MVT_LLVector3d, 24);
108 }
109 mesgsys->addBinaryDataFast(_PREHASH_TypeData, packed_data, 56);
110}
111
112void LLHUDEffectSpiral::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
113{
114 U8 packed_data[56];
115
116 LLHUDEffect::unpackData(mesgsys, blocknum);
117 LLUUID object_id, target_object_id;
118 S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
119 if (size != 56)
120 {
121 llwarns << "Spiral effect with bad size " << size << llendl;
122 return;
123 }
124 mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, 56, blocknum);
125
126 htonmemcpy(object_id.mData, packed_data, MVT_LLUUID, 16);
127 htonmemcpy(target_object_id.mData, packed_data + 16, MVT_LLUUID, 16);
128 htonmemcpy(mPositionGlobal.mdV, packed_data + 32, MVT_LLVector3d, 24);
129
130 LLViewerObject *objp = NULL;
131
132 if (object_id.isNull())
133 {
134 setSourceObject(NULL);
135 }
136 else
137 {
138 LLViewerObject *objp = gObjectList.findObject(object_id);
139 if (objp)
140 {
141 setSourceObject(objp);
142 }
143 else
144 {
145 // We don't have this object, kill this effect
146 markDead();
147 return;
148 }
149 }
150
151 if (target_object_id.isNull())
152 {
153 setTargetObject(NULL);
154 }
155 else
156 {
157 objp = gObjectList.findObject(target_object_id);
158 if (objp)
159 {
160 setTargetObject(objp);
161 }
162 else
163 {
164 // We don't have this object, kill this effect
165 markDead();
166 return;
167 }
168 }
169
170 triggerLocal();
171}
172
173void LLHUDEffectSpiral::triggerLocal()
174{
175 mKillTime = mTimer.getElapsedTimeF32() + mDuration;
176
177 BOOL show_beam = gSavedSettings.getBOOL("ShowSelectionBeam");
178
179 LLColor4 color;
180 color.setVec(mColor);
181
182 if (!mPartSourcep)
183 {
184 if (!mTargetObject.isNull() && !mSourceObject.isNull())
185 {
186 if (show_beam)
187 {
188 LLViewerPartSourceBeam *psb = new LLViewerPartSourceBeam;
189 psb->setColor(color);
190 psb->setSourceObject(mSourceObject);
191 psb->setTargetObject(mTargetObject);
192 psb->setOwnerUUID(gAgent.getID());
193 gWorldPointer->mPartSim.addPartSource(psb);
194 mPartSourcep = psb;
195 }
196 }
197 else
198 {
199 if (!mSourceObject.isNull() && !mPositionGlobal.isExactlyZero())
200 {
201 if (show_beam)
202 {
203 LLViewerPartSourceBeam *psb = new LLViewerPartSourceBeam;
204 psb->setSourceObject(mSourceObject);
205 psb->setTargetObject(NULL);
206 psb->setColor(color);
207 psb->mLKGTargetPosGlobal = mPositionGlobal;
208 psb->setOwnerUUID(gAgent.getID());
209 gWorldPointer->mPartSim.addPartSource(psb);
210 mPartSourcep = psb;
211 }
212 }
213 else
214 {
215 LLVector3 pos;
216 if (mSourceObject)
217 {
218 pos = mSourceObject->getPositionAgent();
219 }
220 else
221 {
222 pos = gAgent.getPosAgentFromGlobal(mPositionGlobal);
223 }
224 LLViewerPartSourceSpiral *pss = new LLViewerPartSourceSpiral(pos);
225 if (!mSourceObject.isNull())
226 {
227 pss->setSourceObject(mSourceObject);
228 }
229 pss->setColor(color);
230 pss->setOwnerUUID(gAgent.getID());
231 gWorldPointer->mPartSim.addPartSource(pss);
232 mPartSourcep = pss;
233 }
234 }
235 }
236 else
237 {
238 LLViewerPartSource *ps = mPartSourcep;
239 if (mPartSourcep->getType() == LLViewerPartSource::LL_PART_SOURCE_BEAM)
240 {
241 LLViewerPartSourceBeam *psb = (LLViewerPartSourceBeam *)ps;
242 psb->setSourceObject(mSourceObject);
243 psb->setTargetObject(mTargetObject);
244 psb->setColor(color);
245 if (mTargetObject.isNull())
246 {
247 psb->mLKGTargetPosGlobal = mPositionGlobal;
248 }
249 }
250 else
251 {
252 LLViewerPartSourceSpiral *pss = (LLViewerPartSourceSpiral *)ps;
253 pss->setSourceObject(mSourceObject);
254 }
255 }
256
257 mbInit = TRUE;
258}
259
260void LLHUDEffectSpiral::setTargetObject(LLViewerObject *objp)
261{
262 if (objp == mTargetObject)
263 {
264 return;
265 }
266
267 mTargetObject = objp;
268}
269
270void LLHUDEffectSpiral::render()
271{
272 if (!mSourceObject.isNull() && mSourceObject->isDead())
273 {
274 markDead();
275 return;
276 }
277
278 if(!mTargetObject.isNull() && mTargetObject->isDead())
279 {
280 markDead();
281 return;
282 }
283
284 F32 time = mTimer.getElapsedTimeF32();
285 if (mKillTime < time)
286 {
287 markDead();
288 return;
289 }
290}