aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llhudobject.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llhudobject.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llhudobject.cpp')
-rw-r--r--linden/indra/newview/llhudobject.cpp296
1 files changed, 296 insertions, 0 deletions
diff --git a/linden/indra/newview/llhudobject.cpp b/linden/indra/newview/llhudobject.cpp
new file mode 100644
index 0000000..eece86f
--- /dev/null
+++ b/linden/indra/newview/llhudobject.cpp
@@ -0,0 +1,296 @@
1/**
2 * @file llhudobject.cpp
3 * @brief LLHUDObject 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// llhudobject.cpp
29// Copyright 2002, Linden Research, Inc.
30
31#include "llviewerprecompiledheaders.h"
32
33#include "llhudobject.h"
34#include "llviewerobject.h"
35
36#include "llhudtext.h"
37#include "llhudicon.h"
38#include "llhudconnector.h"
39#include "llhudeffectbeam.h"
40#include "llhudeffecttrail.h"
41#include "llhudeffectlookat.h"
42
43//Ventrella
44#include "llanimalcontrols.h"
45#include "lllocalanimationobject.h"
46#include "llcape.h"
47// End Ventrella
48
49#include "llagent.h"
50
51// statics
52std::list<LLPointer<LLHUDObject> > LLHUDObject::sHUDObjects;
53
54struct hud_object_further_away
55{
56 bool operator()(const LLPointer<LLHUDObject>& lhs, const LLPointer<LLHUDObject>& rhs) const;
57};
58
59
60bool hud_object_further_away::operator()(const LLPointer<LLHUDObject>& lhs, const LLPointer<LLHUDObject>& rhs) const
61{
62 return (lhs->getDistance() > rhs->getDistance()) ? true : false;
63}
64
65
66LLHUDObject::LLHUDObject(const U8 type) :
67 mPositionGlobal(),
68 mSourceObject(NULL),
69 mTargetObject(NULL)
70{
71 mVisible = TRUE;
72 mType = type;
73 mDead = FALSE;
74 mOnHUDAttachment = FALSE;
75}
76
77LLHUDObject::~LLHUDObject()
78{
79}
80
81void LLHUDObject::markDead()
82{
83 mVisible = FALSE;
84 mDead = TRUE;
85 mSourceObject = NULL;
86 mTargetObject = NULL;
87}
88
89F32 LLHUDObject::getDistance() const
90{
91 return 0.f;
92}
93
94void LLHUDObject::setSourceObject(LLViewerObject* objectp)
95{
96 if (objectp == mSourceObject)
97 {
98 return;
99 }
100
101 mSourceObject = objectp;
102}
103
104void LLHUDObject::setTargetObject(LLViewerObject* objectp)
105{
106 if (objectp == mTargetObject)
107 {
108 return;
109 }
110
111 mTargetObject = objectp;
112}
113
114void LLHUDObject::setPositionGlobal(const LLVector3d &position_global)
115{
116 mPositionGlobal = position_global;
117}
118
119void LLHUDObject::setPositionAgent(const LLVector3 &position_agent)
120{
121 mPositionGlobal = gAgent.getPosGlobalFromAgent(position_agent);
122}
123
124// static
125void LLHUDObject::cleanupHUDObjects()
126{
127 LLHUDIcon::cleanupDeadIcons();
128 hud_object_list_t::iterator object_it;
129 for (object_it = sHUDObjects.begin(); object_it != sHUDObjects.end(); ++object_it)
130 {
131 (*object_it)->markDead();
132 if ((*object_it)->getNumRefs() > 1)
133 {
134 llinfos << "LLHUDObject " << (LLHUDObject *)(*object_it) << " has " << (*object_it)->getNumRefs() << " refs!" << llendl;
135 }
136 }
137 sHUDObjects.clear();
138}
139
140// static
141LLHUDObject *LLHUDObject::addHUDObject(const U8 type)
142{
143 LLHUDObject *hud_objectp = NULL;
144
145 switch (type)
146 {
147 case LL_HUD_TEXT:
148 hud_objectp = new LLHUDText(type);
149 break;
150 case LL_HUD_ICON:
151 hud_objectp = new LLHUDIcon(type);
152 break;
153 case LL_HUD_CONNECTOR:
154 hud_objectp = new LLHUDConnector(type);
155 break;
156 case LL_HUD_EFFECT_BEAM:
157 hud_objectp = new LLHUDEffectSpiral(type);
158 ((LLHUDEffectSpiral *)hud_objectp)->setDuration(0.7f);
159 ((LLHUDEffectSpiral *)hud_objectp)->setVMag(0.f);
160 ((LLHUDEffectSpiral *)hud_objectp)->setVOffset(0.f);
161 ((LLHUDEffectSpiral *)hud_objectp)->setInitialRadius(0.1f);
162 ((LLHUDEffectSpiral *)hud_objectp)->setFinalRadius(0.2f);
163 ((LLHUDEffectSpiral *)hud_objectp)->setSpinRate(10.f);
164 ((LLHUDEffectSpiral *)hud_objectp)->setFlickerRate(0.f);
165 ((LLHUDEffectSpiral *)hud_objectp)->setScaleBase(0.05f);
166 ((LLHUDEffectSpiral *)hud_objectp)->setScaleVar(0.02f);
167 ((LLHUDEffectSpiral *)hud_objectp)->setColor(LLColor4U(255, 255, 255, 255));
168 break;
169 case LL_HUD_EFFECT_GLOW:
170 llerrs << "Glow not implemented!" << llendl;
171 break;
172 case LL_HUD_EFFECT_POINT:
173 hud_objectp = new LLHUDEffectSpiral(type);
174 ((LLHUDEffectSpiral *)hud_objectp)->setDuration(0.5f);
175 ((LLHUDEffectSpiral *)hud_objectp)->setVMag(1.f);
176 ((LLHUDEffectSpiral *)hud_objectp)->setVOffset(0.f);
177 ((LLHUDEffectSpiral *)hud_objectp)->setInitialRadius(0.5f);
178 ((LLHUDEffectSpiral *)hud_objectp)->setFinalRadius(1.f);
179 ((LLHUDEffectSpiral *)hud_objectp)->setSpinRate(10.f);
180 ((LLHUDEffectSpiral *)hud_objectp)->setFlickerRate(0.f);
181 ((LLHUDEffectSpiral *)hud_objectp)->setScaleBase(0.1f);
182 ((LLHUDEffectSpiral *)hud_objectp)->setScaleVar(0.1f);
183 ((LLHUDEffectSpiral *)hud_objectp)->setColor(LLColor4U(255, 255, 255, 255));
184 break;
185 case LL_HUD_EFFECT_SPHERE:
186 hud_objectp = new LLHUDEffectSpiral(type);
187 ((LLHUDEffectSpiral *)hud_objectp)->setDuration(0.5f);
188 ((LLHUDEffectSpiral *)hud_objectp)->setVMag(1.f);
189 ((LLHUDEffectSpiral *)hud_objectp)->setVOffset(0.f);
190 ((LLHUDEffectSpiral *)hud_objectp)->setInitialRadius(0.5f);
191 ((LLHUDEffectSpiral *)hud_objectp)->setFinalRadius(0.5f);
192 ((LLHUDEffectSpiral *)hud_objectp)->setSpinRate(20.f);
193 ((LLHUDEffectSpiral *)hud_objectp)->setFlickerRate(0.f);
194 ((LLHUDEffectSpiral *)hud_objectp)->setScaleBase(0.1f);
195 ((LLHUDEffectSpiral *)hud_objectp)->setScaleVar(0.1f);
196 ((LLHUDEffectSpiral *)hud_objectp)->setColor(LLColor4U(255, 255, 255, 255));
197 break;
198 case LL_HUD_EFFECT_SPIRAL:
199 hud_objectp = new LLHUDEffectSpiral(type);
200 ((LLHUDEffectSpiral *)hud_objectp)->setDuration(2.f);
201 ((LLHUDEffectSpiral *)hud_objectp)->setVMag(-2.f);
202 ((LLHUDEffectSpiral *)hud_objectp)->setVOffset(0.5f);
203 ((LLHUDEffectSpiral *)hud_objectp)->setInitialRadius(1.f);
204 ((LLHUDEffectSpiral *)hud_objectp)->setFinalRadius(0.5f);
205 ((LLHUDEffectSpiral *)hud_objectp)->setSpinRate(10.f);
206 ((LLHUDEffectSpiral *)hud_objectp)->setFlickerRate(20.f);
207 ((LLHUDEffectSpiral *)hud_objectp)->setScaleBase(0.02f);
208 ((LLHUDEffectSpiral *)hud_objectp)->setScaleVar(0.02f);
209 ((LLHUDEffectSpiral *)hud_objectp)->setColor(LLColor4U(255, 255, 255, 255));
210 break;
211 case LL_HUD_EFFECT_EDIT:
212 hud_objectp = new LLHUDEffectSpiral(type);
213 ((LLHUDEffectSpiral *)hud_objectp)->setDuration(2.f);
214 ((LLHUDEffectSpiral *)hud_objectp)->setVMag(2.f);
215 ((LLHUDEffectSpiral *)hud_objectp)->setVOffset(-1.f);
216 ((LLHUDEffectSpiral *)hud_objectp)->setInitialRadius(1.5f);
217 ((LLHUDEffectSpiral *)hud_objectp)->setFinalRadius(1.f);
218 ((LLHUDEffectSpiral *)hud_objectp)->setSpinRate(4.f);
219 ((LLHUDEffectSpiral *)hud_objectp)->setFlickerRate(200.f);
220 ((LLHUDEffectSpiral *)hud_objectp)->setScaleBase(0.1f);
221 ((LLHUDEffectSpiral *)hud_objectp)->setScaleVar(0.1f);
222 ((LLHUDEffectSpiral *)hud_objectp)->setColor(LLColor4U(255, 255, 255, 255));
223 break;
224 case LL_HUD_EFFECT_LOOKAT:
225 hud_objectp = new LLHUDEffectLookAt(type);
226 break;
227 case LL_HUD_EFFECT_POINTAT:
228 hud_objectp = new LLHUDEffectPointAt(type);
229 break;
230 default:
231 llwarns << "Unknown type of hud object:" << (U32) type << llendl;
232 }
233
234 if (hud_objectp)
235 {
236 sHUDObjects.push_back(hud_objectp);
237 }
238 return hud_objectp;
239}
240
241// static
242void LLHUDObject::updateAll()
243{
244 LLFastTimer ftm(LLFastTimer::FTM_HUD_UPDATE);
245 LLHUDText::updateAll();
246 LLHUDIcon::updateAll();
247 sortObjects();
248}
249
250// static
251void LLHUDObject::renderAll()
252{
253 LLHUDObject *hud_objp;
254
255 hud_object_list_t::iterator object_it;
256 for (object_it = sHUDObjects.begin(); object_it != sHUDObjects.end(); )
257 {
258 hud_object_list_t::iterator cur_it = object_it++;
259 hud_objp = (*cur_it);
260 if (hud_objp->getNumRefs() == 1)
261 {
262 sHUDObjects.erase(cur_it);
263 }
264 else if (hud_objp->isVisible())
265 {
266 hud_objp->render();
267 }
268 }
269}
270
271// static
272void LLHUDObject::renderAllForSelect()
273{
274 LLHUDObject *hud_objp;
275
276 hud_object_list_t::iterator object_it;
277 for (object_it = sHUDObjects.begin(); object_it != sHUDObjects.end(); )
278 {
279 hud_object_list_t::iterator cur_it = object_it++;
280 hud_objp = (*cur_it);
281 if (hud_objp->getNumRefs() == 1)
282 {
283 sHUDObjects.erase(cur_it);
284 }
285 else if (hud_objp->isVisible())
286 {
287 hud_objp->renderForSelect();
288 }
289 }
290}
291
292// static
293void LLHUDObject::sortObjects()
294{
295 sHUDObjects.sort(hud_object_further_away());
296}