diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llhudmanager.cpp | |
parent | README.txt (diff) | |
download | meta-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/llhudmanager.cpp')
-rw-r--r-- | linden/indra/newview/llhudmanager.cpp | 318 |
1 files changed, 318 insertions, 0 deletions
diff --git a/linden/indra/newview/llhudmanager.cpp b/linden/indra/newview/llhudmanager.cpp new file mode 100644 index 0000000..2afdac0 --- /dev/null +++ b/linden/indra/newview/llhudmanager.cpp | |||
@@ -0,0 +1,318 @@ | |||
1 | /** | ||
2 | * @file llhudmanager.cpp | ||
3 | * @brief LLHUDManager 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 "llhudmanager.h" | ||
31 | |||
32 | #include "message.h" | ||
33 | #include "object_flags.h" | ||
34 | |||
35 | #include "llagent.h" | ||
36 | #include "llhudconnector.h" | ||
37 | #include "llhudeffect.h" | ||
38 | #include "pipeline.h" | ||
39 | #include "llviewercontrol.h" | ||
40 | #include "llviewerobjectlist.h" | ||
41 | |||
42 | LLHUDManager *gHUDManager = NULL; | ||
43 | |||
44 | extern BOOL gNoRender; | ||
45 | |||
46 | // These are loaded from saved settings. | ||
47 | LLColor4 LLHUDManager::sParentColor; | ||
48 | LLColor4 LLHUDManager::sChildColor; | ||
49 | |||
50 | LLHUDManager::LLHUDManager() | ||
51 | { | ||
52 | mShowPhysical = FALSE; | ||
53 | |||
54 | LLHUDManager::sParentColor = gColors.getColor("FocusColor"); | ||
55 | // rdw commented out since it's not used. Also removed from colors_base.xml | ||
56 | //LLHUDManager::sChildColor = gColors.getColor("FocusSecondaryColor"); | ||
57 | } | ||
58 | |||
59 | LLHUDManager::~LLHUDManager() | ||
60 | { | ||
61 | mHUDJoints.reset(); | ||
62 | mHUDSelectedJoints.reset(); | ||
63 | mHUDEffects.reset(); | ||
64 | } | ||
65 | |||
66 | |||
67 | void LLHUDManager::toggleShowPhysical(const BOOL show_physical) | ||
68 | { | ||
69 | if (show_physical == mShowPhysical) | ||
70 | { | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | mShowPhysical = show_physical; | ||
75 | if (show_physical) | ||
76 | { | ||
77 | S32 i; | ||
78 | for (i = 0; i < gObjectList.getNumObjects(); i++) | ||
79 | { | ||
80 | LLViewerObject *vobjp = gObjectList.getObject(i); | ||
81 | |||
82 | if (vobjp && vobjp->isJointChild() && vobjp->getParent()) | ||
83 | { | ||
84 | LLHUDConnector *connectorp = (LLHUDConnector *)LLHUDObject::addHUDObject(LLHUDObject::LL_HUD_CONNECTOR); | ||
85 | connectorp->setTargets(vobjp, (LLViewerObject *)vobjp->getParent()); | ||
86 | connectorp->setColors(LLColor4(1.f, 1.f, 1.f, 1.f), sChildColor, sParentColor); | ||
87 | EHavokJointType joint_type = vobjp->getJointType(); | ||
88 | if (HJT_HINGE == joint_type) | ||
89 | { | ||
90 | connectorp->setLabel("Hinge"); | ||
91 | } | ||
92 | else if (HJT_POINT == joint_type) | ||
93 | { | ||
94 | connectorp->setLabel("P2P"); | ||
95 | } | ||
96 | #if 0 | ||
97 | else if (HJT_LPOINT == joint_type) | ||
98 | { | ||
99 | connectorp->setLabel("LP2P"); | ||
100 | } | ||
101 | #endif | ||
102 | #if 0 | ||
103 | else if (HJT_WHEEL == joint_type) | ||
104 | { | ||
105 | connectorp->setLabel("Wheel"); | ||
106 | } | ||
107 | #endif | ||
108 | mHUDJoints.put(connectorp); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | mHUDJoints.reset(); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | void LLHUDManager::showJoints(LLDynamicArray < LLViewerObject* > *object_list) | ||
119 | { | ||
120 | for (S32 i=0; i<object_list->count(); i++) | ||
121 | { | ||
122 | LLViewerObject *vobjp = object_list->get(i); | ||
123 | if (vobjp && vobjp->isJointChild() && vobjp->getParent()) | ||
124 | { | ||
125 | LLHUDConnector *connectorp = (LLHUDConnector *)LLHUDObject::addHUDObject(LLHUDObject::LL_HUD_CONNECTOR); | ||
126 | connectorp->setTargets(vobjp, (LLViewerObject *)vobjp->getParent()); | ||
127 | connectorp->setColors(LLColor4(1.f, 1.f, 1.f, 1.f), sChildColor, sParentColor); | ||
128 | |||
129 | EHavokJointType joint_type = vobjp->getJointType(); | ||
130 | if (HJT_HINGE == joint_type) | ||
131 | { | ||
132 | connectorp->setLabel("Hinge"); | ||
133 | } | ||
134 | else if (HJT_POINT == joint_type) | ||
135 | { | ||
136 | connectorp->setLabel("P2P"); | ||
137 | } | ||
138 | #if 0 | ||
139 | else if (HJT_LPOINT == joint_type) | ||
140 | { | ||
141 | connectorp->setLabel("LP2P"); | ||
142 | } | ||
143 | #endif | ||
144 | #if 0 | ||
145 | else if (HJT_WHEEL == joint_type) | ||
146 | { | ||
147 | connectorp->setLabel("Wheel"); | ||
148 | } | ||
149 | #endif | ||
150 | mHUDSelectedJoints.put(connectorp); | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | void LLHUDManager::clearJoints() | ||
156 | { | ||
157 | mHUDSelectedJoints.reset(); | ||
158 | } | ||
159 | |||
160 | BOOL LLHUDManager::getShowPhysical() const | ||
161 | { | ||
162 | return mShowPhysical; | ||
163 | } | ||
164 | |||
165 | void LLHUDManager::updateEffects() | ||
166 | { | ||
167 | LLFastTimer ftm(LLFastTimer::FTM_HUD_EFFECTS); | ||
168 | S32 i; | ||
169 | for (i = 0; i < mHUDEffects.count(); i++) | ||
170 | { | ||
171 | LLHUDEffect *hep = mHUDEffects[i]; | ||
172 | if (hep->isDead()) | ||
173 | { | ||
174 | continue; | ||
175 | } | ||
176 | hep->update(); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | void LLHUDManager::sendEffects() | ||
181 | { | ||
182 | S32 i; | ||
183 | for (i = 0; i < mHUDEffects.count(); i++) | ||
184 | { | ||
185 | LLHUDEffect *hep = mHUDEffects[i]; | ||
186 | if (hep->isDead()) | ||
187 | { | ||
188 | llwarns << "Trying to send dead effect!" << llendl; | ||
189 | continue; | ||
190 | } | ||
191 | if (hep->mType <= LLHUDObject::LL_HUD_CONNECTOR) | ||
192 | { | ||
193 | llwarns << "Trying to send effect of type " << hep->mType << " which isn't really an effect and shouldn't be in this list!" << llendl; | ||
194 | continue; | ||
195 | } | ||
196 | if (hep->getNeedsSendToSim() && hep->getOriginatedHere()) | ||
197 | { | ||
198 | gMessageSystem->newMessageFast(_PREHASH_ViewerEffect); | ||
199 | gMessageSystem->nextBlockFast(_PREHASH_Effect); | ||
200 | hep->packData(gMessageSystem); | ||
201 | hep->setNeedsSendToSim(FALSE); | ||
202 | gAgent.sendMessage(); | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | |||
207 | void LLHUDManager::cleanupEffects() | ||
208 | { | ||
209 | S32 i = 0; | ||
210 | |||
211 | while (i < mHUDEffects.count()) | ||
212 | { | ||
213 | if (mHUDEffects[i]->isDead()) | ||
214 | { | ||
215 | mHUDEffects.remove(i); | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | i++; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | |||
224 | LLHUDEffect *LLHUDManager::createViewerEffect(const U8 type, BOOL send_to_sim, BOOL originated_here) | ||
225 | { | ||
226 | // Should assert that this is actually an LLHUDEffect | ||
227 | LLHUDEffect *hep = (LLHUDEffect *)LLHUDObject::addHUDObject(type); | ||
228 | if (!hep) | ||
229 | { | ||
230 | return NULL; | ||
231 | } | ||
232 | |||
233 | LLUUID tmp; | ||
234 | tmp.generate(); | ||
235 | hep->setID(tmp); | ||
236 | hep->setNeedsSendToSim(send_to_sim); | ||
237 | hep->setOriginatedHere(originated_here); | ||
238 | |||
239 | mHUDEffects.put(hep); | ||
240 | return hep; | ||
241 | } | ||
242 | |||
243 | |||
244 | //static | ||
245 | void LLHUDManager::processViewerEffect(LLMessageSystem *mesgsys, void **user_data) | ||
246 | { | ||
247 | if (gNoRender) | ||
248 | { | ||
249 | return; | ||
250 | } | ||
251 | |||
252 | if (!gHUDManager) | ||
253 | { | ||
254 | llwarns << "No gHUDManager!" << llendl; | ||
255 | return; | ||
256 | } | ||
257 | |||
258 | LLHUDEffect *effectp = NULL; | ||
259 | LLUUID effect_id; | ||
260 | U8 effect_type = 0; | ||
261 | S32 number_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_Effect); | ||
262 | S32 k; | ||
263 | |||
264 | for (k = 0; k < number_blocks; k++) | ||
265 | { | ||
266 | effectp = NULL; | ||
267 | LLHUDEffect::getIDType(mesgsys, k, effect_id, effect_type); | ||
268 | |||
269 | S32 i; | ||
270 | for (i = 0; i < gHUDManager->mHUDEffects.count(); i++) | ||
271 | { | ||
272 | LLHUDEffect *cur_effectp = gHUDManager->mHUDEffects[i]; | ||
273 | if (!cur_effectp) | ||
274 | { | ||
275 | llwarns << "Null effect in effect manager, skipping" << llendl; | ||
276 | gHUDManager->mHUDEffects.remove(i); | ||
277 | i--; | ||
278 | continue; | ||
279 | } | ||
280 | if (cur_effectp->isDead()) | ||
281 | { | ||
282 | // llwarns << "Dead effect in effect manager, removing" << llendl; | ||
283 | gHUDManager->mHUDEffects.remove(i); | ||
284 | i--; | ||
285 | continue; | ||
286 | } | ||
287 | if (cur_effectp->getID() == effect_id) | ||
288 | { | ||
289 | if (cur_effectp->getType() != effect_type) | ||
290 | { | ||
291 | llwarns << "Viewer effect update doesn't match old type!" << llendl; | ||
292 | } | ||
293 | effectp = cur_effectp; | ||
294 | break; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | if (effect_type) | ||
299 | { | ||
300 | if (!effectp) | ||
301 | { | ||
302 | effectp = gHUDManager->createViewerEffect(effect_type, FALSE, FALSE); | ||
303 | } | ||
304 | |||
305 | if (effectp) | ||
306 | { | ||
307 | effectp->unpackData(mesgsys, k); | ||
308 | } | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | llwarns << "Received viewer effect of type " << effect_type << " which isn't really an effect!" << llendl; | ||
313 | } | ||
314 | } | ||
315 | |||
316 | //llinfos << "Got viewer effect: " << effect_id << llendl; | ||
317 | } | ||
318 | |||