moving SendSound from SceneObjectPart to ISoundModule
parent
af39af1cc4
commit
5abcecc735
|
@ -278,6 +278,79 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
m_host.SendFullUpdateToAllClients();
|
m_host.SendFullUpdateToAllClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendSound(UUID objectID, string sound, double volume,
|
||||||
|
bool triggered, byte flags, float radius, bool useMaster,
|
||||||
|
bool isMaster)
|
||||||
|
{
|
||||||
|
SceneObjectPart part;
|
||||||
|
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||||
|
return;
|
||||||
|
|
||||||
|
volume = Util.Clip((float)volume, 0, 1);
|
||||||
|
|
||||||
|
UUID parentID = part.ParentGroup.UUID;
|
||||||
|
|
||||||
|
UUID soundID = UUID.Zero;
|
||||||
|
Vector3 position = part.AbsolutePosition; // region local
|
||||||
|
ulong regionHandle = m_scene.RegionInfo.RegionHandle;
|
||||||
|
|
||||||
|
if (!UUID.TryParse(sound, out soundID))
|
||||||
|
{
|
||||||
|
// search sound file from inventory
|
||||||
|
lock (part.TaskInventory)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<UUID, TaskInventoryItem> item in part.TaskInventory)
|
||||||
|
{
|
||||||
|
if (item.Value.Type == (int)AssetType.Sound && item.Value.Name == sound)
|
||||||
|
{
|
||||||
|
soundID = item.Value.ItemID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundID == UUID.Zero)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (useMaster)
|
||||||
|
{
|
||||||
|
if (isMaster)
|
||||||
|
{
|
||||||
|
if (triggered)
|
||||||
|
TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
|
||||||
|
else
|
||||||
|
PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
|
||||||
|
part.ParentGroup.PlaySoundMasterPrim = part;
|
||||||
|
if (triggered)
|
||||||
|
TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
|
||||||
|
else
|
||||||
|
PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
|
||||||
|
foreach (SceneObjectPart prim in part.ParentGroup.PlaySoundSlavePrims)
|
||||||
|
{
|
||||||
|
position = prim.AbsolutePosition; // region local
|
||||||
|
if (triggered)
|
||||||
|
TriggerSound(soundID, part.OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius);
|
||||||
|
else
|
||||||
|
PlayAttachedSound(soundID, part.OwnerID, prim.UUID, volume, position, flags, radius);
|
||||||
|
}
|
||||||
|
part.ParentGroup.PlaySoundSlavePrims.Clear();
|
||||||
|
part.ParentGroup.PlaySoundMasterPrim = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
part.ParentGroup.PlaySoundSlavePrims.Add(part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (triggered)
|
||||||
|
TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
|
||||||
|
else
|
||||||
|
PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,5 +96,20 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="isMaster">Set object to sync master if true</param>
|
/// <param name="isMaster">Set object to sync master if true</param>
|
||||||
void LoopSound(UUID objectID, UUID soundID, double gain,
|
void LoopSound(UUID objectID, UUID soundID, double gain,
|
||||||
double radius, bool isMaster);
|
double radius, bool isMaster);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Trigger or play an attached sound in this part's inventory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objectID"></param>
|
||||||
|
/// <param name="sound"></param>
|
||||||
|
/// <param name="volume"></param>
|
||||||
|
/// <param name="triggered"></param>
|
||||||
|
/// <param name="flags"></param>
|
||||||
|
/// <param name="radius"></param>
|
||||||
|
/// <param name="useMaster"></param>
|
||||||
|
/// <param name="isMaster"></param>
|
||||||
|
void SendSound(UUID objectID, string sound, double volume,
|
||||||
|
bool triggered, byte flags, float radius, bool useMaster,
|
||||||
|
bool isMaster);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2239,7 +2239,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// play the sound.
|
// play the sound.
|
||||||
if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f)
|
if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f)
|
||||||
SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false);
|
{
|
||||||
|
ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>();
|
||||||
|
if (soundModule != null)
|
||||||
|
{
|
||||||
|
soundModule.SendSound(UUID, CollisionSound.ToString(),
|
||||||
|
CollisionSoundVolume, true, (byte)0, 0, false,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart);
|
SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart);
|
||||||
SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding);
|
SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding);
|
||||||
|
@ -2644,84 +2652,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Trigger or play an attached sound in this part's inventory.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sound"></param>
|
|
||||||
/// <param name="volume"></param>
|
|
||||||
/// <param name="triggered"></param>
|
|
||||||
/// <param name="flags"></param>
|
|
||||||
public void SendSound(string sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster)
|
|
||||||
{
|
|
||||||
ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>();
|
|
||||||
if(soundModule == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
volume = Util.Clip((float)volume, 0, 1);
|
|
||||||
|
|
||||||
UUID parentID = ParentGroup.UUID;
|
|
||||||
|
|
||||||
UUID soundID = UUID.Zero;
|
|
||||||
Vector3 position = AbsolutePosition; // region local
|
|
||||||
ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle;
|
|
||||||
|
|
||||||
if (!UUID.TryParse(sound, out soundID))
|
|
||||||
{
|
|
||||||
// search sound file from inventory
|
|
||||||
lock (TaskInventory)
|
|
||||||
{
|
|
||||||
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
|
|
||||||
{
|
|
||||||
if (item.Value.Type == (int)AssetType.Sound && item.Value.Name == sound)
|
|
||||||
{
|
|
||||||
soundID = item.Value.ItemID;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (soundID == UUID.Zero)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (useMaster)
|
|
||||||
{
|
|
||||||
if (isMaster)
|
|
||||||
{
|
|
||||||
if (triggered)
|
|
||||||
soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
|
||||||
soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius);
|
|
||||||
ParentGroup.PlaySoundMasterPrim = this;
|
|
||||||
if (triggered)
|
|
||||||
soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
|
||||||
soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius);
|
|
||||||
foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims)
|
|
||||||
{
|
|
||||||
position = prim.AbsolutePosition; // region local
|
|
||||||
if (triggered)
|
|
||||||
soundModule.TriggerSound(soundID, OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
|
||||||
soundModule.PlayAttachedSound(soundID, OwnerID, prim.UUID, volume, position, flags, radius);
|
|
||||||
}
|
|
||||||
ParentGroup.PlaySoundSlavePrims.Clear();
|
|
||||||
ParentGroup.PlaySoundMasterPrim = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ParentGroup.PlaySoundSlavePrims.Add(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (triggered)
|
|
||||||
soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius);
|
|
||||||
else
|
|
||||||
soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a terse update to all clients
|
/// Send a terse update to all clients
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -821,8 +821,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||||
{
|
{
|
||||||
if (!CanEdit())
|
if (!CanEdit())
|
||||||
return;
|
return;
|
||||||
|
ISoundModule module = m_rootScene.RequestModuleInterface<ISoundModule>();
|
||||||
GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false);
|
if (module != null)
|
||||||
|
{
|
||||||
|
module.SendSound(GetSOP().UUID, asset.ToString(), volume, true, 0, 0, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -2367,7 +2367,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
|
||||||
// send the sound, once, to all clients in range
|
// send the sound, once, to all clients in range
|
||||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false);
|
if (m_SoundModule != null)
|
||||||
|
{
|
||||||
|
m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, false, 0, 0, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llLoopSound(string sound, double volume)
|
public void llLoopSound(string sound, double volume)
|
||||||
|
@ -2404,14 +2407,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
|
||||||
// send the sound, once, to all clients in range
|
// send the sound, once, to all clients in range
|
||||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, true, false);
|
if (m_SoundModule != null)
|
||||||
|
{
|
||||||
|
m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, false, 0, 0, true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llTriggerSound(string sound, double volume)
|
public void llTriggerSound(string sound, double volume)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
// send the sound, once, to all clients in range
|
// send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory.
|
||||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false);
|
if (m_SoundModule != null)
|
||||||
|
{
|
||||||
|
m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, true, 0, 0, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llStopSound()
|
public void llStopSound()
|
||||||
|
@ -5824,10 +5833,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
LSL_Vector bottom_south_west)
|
LSL_Vector bottom_south_west)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
if (m_SoundModule != null)
|
||||||
|
{
|
||||||
float radius1 = (float)llVecDist(llGetPos(), top_north_east);
|
float radius1 = (float)llVecDist(llGetPos(), top_north_east);
|
||||||
float radius2 = (float)llVecDist(llGetPos(), bottom_south_west);
|
float radius2 = (float)llVecDist(llGetPos(), bottom_south_west);
|
||||||
float radius = Math.Abs(radius1 - radius2);
|
float radius = Math.Abs(radius1 - radius2);
|
||||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, radius, false, false);
|
m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, true, 0, radius, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llEjectFromLand(string pest)
|
public void llEjectFromLand(string pest)
|
||||||
|
|
Loading…
Reference in New Issue