diff options
author | UbitUmarov | 2014-07-27 08:18:27 +0100 |
---|---|---|
committer | UbitUmarov | 2014-07-27 08:18:27 +0100 |
commit | c3b5a6c2abaa5f508344f75d338fc7ff1be08538 (patch) | |
tree | bb52b457c7ae64c705418b69c5f257b5cbe10521 /OpenSim/Region/CoreModules | |
parent | remove forgotten lines (diff) | |
download | opensim-SC_OLD-c3b5a6c2abaa5f508344f75d338fc7ff1be08538.zip opensim-SC_OLD-c3b5a6c2abaa5f508344f75d338fc7ff1be08538.tar.gz opensim-SC_OLD-c3b5a6c2abaa5f508344f75d338fc7ff1be08538.tar.bz2 opensim-SC_OLD-c3b5a6c2abaa5f508344f75d338fc7ff1be08538.tar.xz |
change how sounds work. May be bad.. needs testing
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 149 |
1 files changed, 55 insertions, 94 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index d093224..34253d5 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | |||
@@ -48,6 +48,18 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
48 | 48 | ||
49 | private Scene m_scene; | 49 | private Scene m_scene; |
50 | 50 | ||
51 | public enum SoundFlags: byte | ||
52 | { | ||
53 | NONE = 0, | ||
54 | LOOP = 1 << 0, | ||
55 | SYNC_MASTER = 1<<1, | ||
56 | SYNC_SLAVE = 1<<2, | ||
57 | SYNC_PENDING = 1<<3, | ||
58 | QUEUE = 1<<4, | ||
59 | STOP = 1<<5, | ||
60 | SYNC_MASK = SYNC_MASTER | SYNC_SLAVE | SYNC_PENDING | ||
61 | } | ||
62 | |||
51 | public bool Enabled { get; private set; } | 63 | public bool Enabled { get; private set; } |
52 | 64 | ||
53 | public float MaxDistance { get; private set; } | 65 | public float MaxDistance { get; private set; } |
@@ -124,26 +136,19 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
124 | if (radius == 0) | 136 | if (radius == 0) |
125 | radius = MaxDistance; | 137 | radius = MaxDistance; |
126 | 138 | ||
139 | if (part.SoundQueueing) | ||
140 | flags |= (byte)SoundFlags.QUEUE; | ||
141 | |||
127 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 142 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
128 | { | 143 | { |
129 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | ||
130 | if (dis > MaxDistance) // Max audio distance | ||
131 | return; | ||
132 | |||
133 | if (grp.IsAttachment) | 144 | if (grp.IsAttachment) |
134 | { | 145 | { |
135 | if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID) | 146 | if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID) |
136 | return; | 147 | return; |
137 | |||
138 | if (sp.ControllingClient.AgentId == grp.OwnerID) | ||
139 | dis = 0; | ||
140 | } | 148 | } |
141 | 149 | // no radius ? | |
142 | // Scale by distance | ||
143 | double thisSpGain = gain * ((radius - dis) / radius); | ||
144 | |||
145 | sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, | 150 | sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, |
146 | ownerID, (float)thisSpGain, flags); | 151 | ownerID, (float)gain, flags); |
147 | }); | 152 | }); |
148 | } | 153 | } |
149 | 154 | ||
@@ -161,9 +166,9 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
161 | { | 166 | { |
162 | SceneObjectGroup grp = part.ParentGroup; | 167 | SceneObjectGroup grp = part.ParentGroup; |
163 | 168 | ||
164 | if (grp.IsAttachment && grp.AttachmentPoint > 30) | 169 | if (grp.IsAttachment && grp.HasPrivateAttachmentPoint) |
165 | { | 170 | { |
166 | objectID = ownerID; | 171 | // objectID = ownerID; |
167 | parentID = ownerID; | 172 | parentID = ownerID; |
168 | } | 173 | } |
169 | } | 174 | } |
@@ -174,16 +179,12 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
174 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 179 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
175 | { | 180 | { |
176 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | 181 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); |
177 | 182 | if (dis > radius) // Max audio distance | |
178 | if (dis > MaxDistance) // Max audio distance | ||
179 | return; | 183 | return; |
180 | 184 | ||
181 | // Scale by distance | ||
182 | double thisSpGain = gain * ((radius - dis) / radius); | ||
183 | |||
184 | sp.ControllingClient.SendTriggeredSound(soundId, ownerID, | 185 | sp.ControllingClient.SendTriggeredSound(soundId, ownerID, |
185 | objectID, parentID, handle, position, | 186 | objectID, parentID, handle, position, |
186 | (float)thisSpGain); | 187 | (float)gain); |
187 | }); | 188 | }); |
188 | } | 189 | } |
189 | 190 | ||
@@ -199,39 +200,12 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
199 | private static void StopSound(SceneObjectPart m_host) | 200 | private static void StopSound(SceneObjectPart m_host) |
200 | { | 201 | { |
201 | m_host.AdjustSoundGain(0); | 202 | m_host.AdjustSoundGain(0); |
202 | // Xantor 20080528: Clear prim data of sound instead | 203 | m_host.Sound = UUID.Zero; |
203 | if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) | 204 | m_host.SoundFlags = (byte)SoundFlags.STOP; |
204 | { | 205 | m_host.SoundRadius = 0; |
205 | if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) | 206 | m_host.SoundGain = 0; |
206 | { | 207 | m_host.ScheduleFullUpdate(); |
207 | foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) | 208 | m_host.SendFullUpdateToAllClients(); |
208 | { | ||
209 | part.Sound = UUID.Zero; | ||
210 | part.SoundFlags = 1 << 5; | ||
211 | part.SoundRadius = 0; | ||
212 | part.ScheduleFullUpdate(); | ||
213 | part.SendFullUpdateToAllClients(); | ||
214 | } | ||
215 | m_host.ParentGroup.LoopSoundMasterPrim = null; | ||
216 | m_host.ParentGroup.LoopSoundSlavePrims.Clear(); | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | m_host.Sound = UUID.Zero; | ||
221 | m_host.SoundFlags = 1 << 5; | ||
222 | m_host.SoundRadius = 0; | ||
223 | m_host.ScheduleFullUpdate(); | ||
224 | m_host.SendFullUpdateToAllClients(); | ||
225 | } | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | m_host.Sound = UUID.Zero; | ||
230 | m_host.SoundFlags = 1 << 5; | ||
231 | m_host.SoundRadius = 0; | ||
232 | m_host.ScheduleFullUpdate(); | ||
233 | m_host.SendFullUpdateToAllClients(); | ||
234 | } | ||
235 | } | 209 | } |
236 | 210 | ||
237 | public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) | 211 | public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) |
@@ -248,7 +222,7 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
248 | 222 | ||
249 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 223 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
250 | { | 224 | { |
251 | if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance)) | 225 | if (Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) < radius) |
252 | sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); | 226 | sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); |
253 | }); | 227 | }); |
254 | } | 228 | } |
@@ -262,21 +236,31 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
262 | // 20080530 Updated to remove code duplication | 236 | // 20080530 Updated to remove code duplication |
263 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | 237 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work |
264 | public void LoopSound(UUID objectID, UUID soundID, | 238 | public void LoopSound(UUID objectID, UUID soundID, |
265 | double volume, double radius, bool isMaster) | 239 | double volume, double radius, bool isMaster, bool isSlave) |
266 | { | 240 | { |
267 | SceneObjectPart m_host; | 241 | SceneObjectPart m_host; |
268 | if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) | 242 | if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) |
269 | return; | 243 | return; |
270 | 244 | ||
271 | if (isMaster) | 245 | // if (isMaster) |
272 | m_host.ParentGroup.LoopSoundMasterPrim = m_host; | 246 | // m_host.ParentGroup.LoopSoundMasterPrim = m_host; |
273 | 247 | ||
274 | if (m_host.Sound != UUID.Zero) | 248 | // sl does not stop previus sound, volume changes don't work (wiki) |
275 | StopSound(m_host); | 249 | // if (m_host.Sound != UUID.Zero) |
250 | // StopSound(m_host); | ||
251 | |||
252 | byte iflags = 1; // looping | ||
253 | if (isMaster) | ||
254 | iflags |= (byte)SoundFlags.SYNC_MASTER; | ||
255 | // TODO check viewer seems to accept both | ||
256 | if (isSlave) | ||
257 | iflags |= (byte)SoundFlags.SYNC_SLAVE; | ||
258 | if (m_host.SoundQueueing) | ||
259 | iflags |= (byte)SoundFlags.QUEUE; | ||
276 | 260 | ||
277 | m_host.Sound = soundID; | 261 | m_host.Sound = soundID; |
278 | m_host.SoundGain = volume; | 262 | m_host.SoundGain = volume; |
279 | m_host.SoundFlags = 1; // looping | 263 | m_host.SoundFlags = iflags; |
280 | m_host.SoundRadius = radius; | 264 | m_host.SoundRadius = radius; |
281 | 265 | ||
282 | m_host.ScheduleFullUpdate(); | 266 | m_host.ScheduleFullUpdate(); |
@@ -301,42 +285,19 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
301 | Vector3 position = part.AbsolutePosition; // region local | 285 | Vector3 position = part.AbsolutePosition; // region local |
302 | ulong regionHandle = m_scene.RegionInfo.RegionHandle; | 286 | ulong regionHandle = m_scene.RegionInfo.RegionHandle; |
303 | 287 | ||
304 | if (useMaster) | 288 | if(triggered) |
305 | { | 289 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); |
306 | if (isMaster) | ||
307 | { | ||
308 | if (triggered) | ||
309 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); | ||
310 | else | ||
311 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); | ||
312 | part.ParentGroup.PlaySoundMasterPrim = part; | ||
313 | if (triggered) | ||
314 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); | ||
315 | else | ||
316 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); | ||
317 | foreach (SceneObjectPart prim in part.ParentGroup.PlaySoundSlavePrims) | ||
318 | { | ||
319 | position = prim.AbsolutePosition; // region local | ||
320 | if (triggered) | ||
321 | TriggerSound(soundID, part.OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius); | ||
322 | else | ||
323 | PlayAttachedSound(soundID, part.OwnerID, prim.UUID, volume, position, flags, radius); | ||
324 | } | ||
325 | part.ParentGroup.PlaySoundSlavePrims.Clear(); | ||
326 | part.ParentGroup.PlaySoundMasterPrim = null; | ||
327 | } | ||
328 | else | ||
329 | { | ||
330 | part.ParentGroup.PlaySoundSlavePrims.Add(part); | ||
331 | } | ||
332 | } | ||
333 | else | 290 | else |
334 | { | 291 | { |
335 | if (triggered) | 292 | byte bflags = 0; |
336 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); | 293 | |
337 | else | 294 | if (isMaster) |
338 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); | 295 | bflags |= (byte)SoundFlags.SYNC_MASTER; |
339 | } | 296 | // TODO check viewer seems to accept both |
297 | if (useMaster) | ||
298 | bflags |= (byte)SoundFlags.SYNC_SLAVE; | ||
299 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, bflags, radius); | ||
300 | } | ||
340 | } | 301 | } |
341 | 302 | ||
342 | public void TriggerSoundLimited(UUID objectID, UUID sound, | 303 | public void TriggerSoundLimited(UUID objectID, UUID sound, |