diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llaudiosourcevo.cpp | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/linden/indra/newview/llaudiosourcevo.cpp b/linden/indra/newview/llaudiosourcevo.cpp new file mode 100644 index 0000000..cbb1c78 --- /dev/null +++ b/linden/indra/newview/llaudiosourcevo.cpp | |||
@@ -0,0 +1,148 @@ | |||
1 | /** | ||
2 | * @file llaudiosourcevo.cpp | ||
3 | * @author Douglas Soo, James Cook | ||
4 | * @brief Audio sources attached to viewer objects | ||
5 | * | ||
6 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #include "llviewerprecompiledheaders.h" | ||
30 | |||
31 | #include "llaudiosourcevo.h" | ||
32 | |||
33 | #include "llagent.h" | ||
34 | #include "llmutelist.h" | ||
35 | #include "llviewerparcelmgr.h" | ||
36 | |||
37 | LLAudioSourceVO::LLAudioSourceVO(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, LLViewerObject *objectp) | ||
38 | : LLAudioSource(sound_id, owner_id, gain), | ||
39 | mObjectp(objectp), | ||
40 | mActualGain(gain) | ||
41 | { | ||
42 | setAmbient(FALSE); | ||
43 | updateGain(); | ||
44 | update(); | ||
45 | } | ||
46 | |||
47 | LLAudioSourceVO::~LLAudioSourceVO() | ||
48 | { | ||
49 | if (mObjectp) | ||
50 | { | ||
51 | mObjectp->clearAttachedSound(); | ||
52 | } | ||
53 | mObjectp = NULL; | ||
54 | } | ||
55 | |||
56 | void LLAudioSourceVO::setGain(const F32 gain) | ||
57 | { | ||
58 | mActualGain = llclamp(gain, 0.f, 1.f); | ||
59 | updateGain(); | ||
60 | } | ||
61 | |||
62 | void LLAudioSourceVO::updateGain() | ||
63 | { | ||
64 | if (!mObjectp) | ||
65 | { | ||
66 | return; | ||
67 | } | ||
68 | |||
69 | BOOL mute = FALSE; | ||
70 | if (gParcelMgr) | ||
71 | { | ||
72 | LLVector3d pos_global = mObjectp->getPositionGlobal(); | ||
73 | if (!gParcelMgr->canHearSound(pos_global)) | ||
74 | { | ||
75 | mute = TRUE; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | if (!mute && gMuteListp) | ||
80 | { | ||
81 | if (gMuteListp->isMuted(mObjectp->getID())) | ||
82 | { | ||
83 | mute = TRUE; | ||
84 | } | ||
85 | else if (gMuteListp->isMuted(mOwnerID)) | ||
86 | { | ||
87 | mute = TRUE; | ||
88 | } | ||
89 | else if (mObjectp->isAttachment()) | ||
90 | { | ||
91 | LLViewerObject* parent = mObjectp; | ||
92 | while (parent | ||
93 | && !parent->isAvatar()) | ||
94 | { | ||
95 | parent = (LLViewerObject*)parent->getParent(); | ||
96 | } | ||
97 | if (parent | ||
98 | && gMuteListp->isMuted(parent->getID())) | ||
99 | { | ||
100 | mute = TRUE; | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | if (!mute) | ||
106 | { | ||
107 | mGain = mActualGain; | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | mGain = 0.f; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | |||
116 | void LLAudioSourceVO::update() | ||
117 | { | ||
118 | if (!mObjectp) | ||
119 | { | ||
120 | return; | ||
121 | } | ||
122 | |||
123 | if (mObjectp->isDead()) | ||
124 | { | ||
125 | mObjectp = NULL; | ||
126 | return; | ||
127 | } | ||
128 | |||
129 | updateGain(); | ||
130 | if (mObjectp->isHUDAttachment()) | ||
131 | { | ||
132 | mPositionGlobal = gAgent.getCameraPositionGlobal(); | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | mPositionGlobal = mObjectp->getPositionGlobal(); | ||
137 | } | ||
138 | if (mObjectp->getSubParent()) | ||
139 | { | ||
140 | mVelocity = mObjectp->getSubParent()->getVelocity(); | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | mVelocity = mObjectp->getVelocity(); | ||
145 | } | ||
146 | |||
147 | LLAudioSource::update(); | ||
148 | } | ||