* refactor: Replace part of SceneObjectPart with the identical sound playing code in the SoundModule
parent
c1320112a9
commit
cce1b096db
|
@ -407,8 +407,8 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID);
|
public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID);
|
||||||
|
|
||||||
|
public delegate void SoundTrigger(
|
||||||
public delegate void SoundTrigger(UUID soundId,UUID ownerid,UUID objid, UUID parentid,float Gain, Vector3 Position,UInt64 Handle);
|
UUID soundId, UUID ownerid, UUID objid, UUID parentid, double Gain, Vector3 Position, UInt64 Handle);
|
||||||
|
|
||||||
public delegate void StartLure(byte lureType, string message, UUID targetID, IClientAPI client);
|
public delegate void StartLure(byte lureType, string message, UUID targetID, IClientAPI client);
|
||||||
public delegate void TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client);
|
public delegate void TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client);
|
||||||
|
@ -723,8 +723,6 @@ namespace OpenSim.Framework
|
||||||
event TeleportLureRequest OnTeleportLureRequest;
|
event TeleportLureRequest OnTeleportLureRequest;
|
||||||
event NetworkStats OnNetworkStatsUpdate;
|
event NetworkStats OnNetworkStatsUpdate;
|
||||||
|
|
||||||
// void ActivateGesture(UUID assetId, UUID gestureId);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tell this client what items it should be wearing now
|
/// Tell this client what items it should be wearing now
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -4597,6 +4597,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
|
agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PacketType.AgentSit:
|
case PacketType.AgentSit:
|
||||||
if (OnAgentSit != null)
|
if (OnAgentSit != null)
|
||||||
{
|
{
|
||||||
|
@ -4609,13 +4610,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PacketType.SoundTrigger:
|
case PacketType.SoundTrigger:
|
||||||
// TODO: handle this packet
|
|
||||||
// SM 200811
|
|
||||||
SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
|
SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
|
||||||
handlerSoundTrigger = OnSoundTrigger;
|
handlerSoundTrigger = OnSoundTrigger;
|
||||||
if (handlerSoundTrigger != null)
|
if (handlerSoundTrigger != null)
|
||||||
//UUID ownerID, UUID objectID, UUID parentID
|
|
||||||
{
|
{
|
||||||
handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID,
|
handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID,
|
||||||
soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID,
|
soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID,
|
||||||
|
@ -4623,9 +4622,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
soundTriggerPacket.SoundData.Handle);
|
soundTriggerPacket.SoundData.Handle);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_log.Error("Null pointer for Soundtrigger");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PacketType.AvatarPickerRequest:
|
case PacketType.AvatarPickerRequest:
|
||||||
AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
|
AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
|
||||||
AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
|
AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
|
||||||
|
@ -4639,6 +4637,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
Utils.BytesToString(querydata.Name));
|
Utils.BytesToString(querydata.Name));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PacketType.AgentDataUpdateRequest:
|
case PacketType.AgentDataUpdateRequest:
|
||||||
AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
|
AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,9 @@ namespace OpenSim.Region.Environment
|
||||||
{
|
{
|
||||||
public interface ISoundModule
|
public interface ISoundModule
|
||||||
{
|
{
|
||||||
|
void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags);
|
||||||
|
|
||||||
void TriggerSound(
|
void TriggerSound(
|
||||||
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, float gain, Vector3 position, UInt64 handle);
|
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -61,8 +61,8 @@ namespace OpenSim.Region.Environment.World.Sound
|
||||||
client.OnSoundTrigger += TriggerSound;
|
client.OnSoundTrigger += TriggerSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void TriggerSound(
|
public virtual void PlayAttachedSound(
|
||||||
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, float gain, Vector3 position, UInt64 handle)
|
UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags)
|
||||||
{
|
{
|
||||||
foreach (ScenePresence p in m_scene.GetAvatars())
|
foreach (ScenePresence p in m_scene.GetAvatars())
|
||||||
{
|
{
|
||||||
|
@ -72,6 +72,23 @@ namespace OpenSim.Region.Environment.World.Sound
|
||||||
|
|
||||||
// Scale by distance
|
// Scale by distance
|
||||||
gain = (float)((double)gain*((100.0 - dis) / 100.0));
|
gain = (float)((double)gain*((100.0 - dis) / 100.0));
|
||||||
|
|
||||||
|
p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void TriggerSound(
|
||||||
|
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle)
|
||||||
|
{
|
||||||
|
foreach (ScenePresence p in m_scene.GetAvatars())
|
||||||
|
{
|
||||||
|
double dis = Util.GetDistanceTo(p.AbsolutePosition, position);
|
||||||
|
if (dis > 100.0) // Max audio distance
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Scale by distance
|
||||||
|
gain = (float)((double)gain*((100.0 - dis) / 100.0));
|
||||||
|
|
||||||
p.ControllingClient.SendTriggeredSound(
|
p.ControllingClient.SendTriggeredSound(
|
||||||
soundId, ownerID, objectID, parentID, handle, position, (float)gain);
|
soundId, ownerID, objectID, parentID, handle, position, (float)gain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.Packets;
|
using OpenMetaverse.Packets;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||||
using OpenSim.Region.Physics.Manager;
|
using OpenSim.Region.Physics.Manager;
|
||||||
|
|
||||||
|
@ -2362,24 +2363,13 @@ if (m_shape != null) {
|
||||||
if (soundID == UUID.Zero)
|
if (soundID == UUID.Zero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
|
ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>();
|
||||||
foreach (ScenePresence p in avatarts)
|
if (soundModule != null)
|
||||||
{
|
{
|
||||||
double dis=Util.GetDistanceTo(p.AbsolutePosition, position);
|
|
||||||
if (dis > 100.0) // Max audio distance
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Scale by distance
|
|
||||||
volume*=((100.0-dis)/100.0);
|
|
||||||
|
|
||||||
if (triggered)
|
if (triggered)
|
||||||
{
|
soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle);
|
||||||
p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags);
|
||||||
p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue