* refactor: Replace part of SceneObjectPart with the identical sound playing code in the SoundModule

0.6.2-post-fixes
Justin Clarke Casey 2008-12-23 17:54:13 +00:00
parent c1320112a9
commit cce1b096db
5 changed files with 35 additions and 29 deletions

View File

@ -406,9 +406,9 @@ namespace OpenSim.Framework
public delegate void AcceptCallingCard(IClientAPI remoteClient, UUID transactionID, UUID folderID);
public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID);
public delegate void SoundTrigger(UUID soundId,UUID ownerid,UUID objid, UUID parentid,float Gain, Vector3 Position,UInt64 Handle);
public delegate void SoundTrigger(
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 TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client);
@ -723,8 +723,6 @@ namespace OpenSim.Framework
event TeleportLureRequest OnTeleportLureRequest;
event NetworkStats OnNetworkStatsUpdate;
// void ActivateGesture(UUID assetId, UUID gestureId);
/// <summary>
/// Tell this client what items it should be wearing now
/// </summary>

View File

@ -4597,6 +4597,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
}
break;
case PacketType.AgentSit:
if (OnAgentSit != null)
{
@ -4609,13 +4610,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
break;
case PacketType.SoundTrigger:
// TODO: handle this packet
// SM 200811
SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
handlerSoundTrigger = OnSoundTrigger;
if (handlerSoundTrigger != null)
//UUID ownerID, UUID objectID, UUID parentID
{
handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID,
soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID,
@ -4623,9 +4622,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
soundTriggerPacket.SoundData.Handle);
}
else
m_log.Error("Null pointer for Soundtrigger");
break;
case PacketType.AvatarPickerRequest:
AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
@ -4639,6 +4637,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Utils.BytesToString(querydata.Name));
}
break;
case PacketType.AgentDataUpdateRequest:
AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;

View File

@ -33,7 +33,9 @@ namespace OpenSim.Region.Environment
{
public interface ISoundModule
{
void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags);
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);
}
}

View File

@ -61,20 +61,37 @@ namespace OpenSim.Region.Environment.World.Sound
client.OnSoundTrigger += TriggerSound;
}
public virtual void TriggerSound(
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, float gain, Vector3 position, UInt64 handle)
public virtual void PlayAttachedSound(
UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags)
{
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.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(
soundId, ownerID, objectID, parentID, handle, position, (float)gain);
}
}
}
}
}

View File

@ -37,6 +37,7 @@ using log4net;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Physics.Manager;
@ -2362,24 +2363,13 @@ if (m_shape != null) {
if (soundID == UUID.Zero)
return;
List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
foreach (ScenePresence p in avatarts)
ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>();
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)
{
p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume);
}
soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle);
else
{
p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags);
}
soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags);
}
}