mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
add proper way for viewers to request mute of collision sounds by setting flag 0x80 on agent update Flags (const U8 AU_FLAGS_MUTECOLLISIONS = 0x80;). Their current method of comparing sound UUIDS is just BROKEN, even at SL.
This commit is contained in:
@@ -215,6 +215,58 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void TriggerCollisionSound(
|
||||
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle)
|
||||
{
|
||||
float radius;
|
||||
SceneObjectPart part;
|
||||
ScenePresence ssp = null;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||
{
|
||||
if (!m_scene.TryGetScenePresence(ownerID, out ssp))
|
||||
return;
|
||||
if (!ssp.ParcelAllowThisAvatarSounds)
|
||||
return;
|
||||
|
||||
radius = MaxDistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneObjectGroup grp = part.ParentGroup;
|
||||
|
||||
if (grp.IsAttachment)
|
||||
{
|
||||
if (!m_scene.TryGetScenePresence(grp.AttachedAvatar, out ssp))
|
||||
return;
|
||||
|
||||
if (!ssp.ParcelAllowThisAvatarSounds)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
radius = (float)part.SoundRadius;
|
||||
if (radius == 0)
|
||||
{
|
||||
radius = MaxDistance;
|
||||
part.SoundRadius = MaxDistance;
|
||||
}
|
||||
}
|
||||
|
||||
radius *= radius;
|
||||
m_scene.ForEachRootScenePresence(delegate (ScenePresence sp)
|
||||
{
|
||||
if(sp.MuteCollisions)
|
||||
return;
|
||||
|
||||
if (Vector3.DistanceSquared(sp.AbsolutePosition, position) > radius) // Max audio distance
|
||||
return;
|
||||
|
||||
sp.ControllingClient.SendTriggeredSound(soundId, ownerID,
|
||||
objectID, parentID, handle, position,
|
||||
(float)gain);
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void StopSound(UUID objectID)
|
||||
{
|
||||
SceneObjectPart m_host;
|
||||
|
||||
@@ -67,6 +67,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
UUID soundId, UUID ownerID, UUID objectID, UUID parentID,
|
||||
double gain, Vector3 position, UInt64 handle);
|
||||
|
||||
void TriggerCollisionSound(
|
||||
UUID soundId, UUID ownerID, UUID objectID, UUID parentID,
|
||||
double gain, Vector3 position, UInt64 handle);
|
||||
/// <summary>
|
||||
/// Stop sounds eminating from an object.
|
||||
/// </summary>
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
int thisMatScaled = thisMaterial * MaxMaterials;
|
||||
|
||||
// bool doneownsound = false;
|
||||
// bool doneownsound = false;
|
||||
|
||||
CollisionForSoundInfo colInfo;
|
||||
uint id;
|
||||
|
||||
@@ -2916,19 +2916,19 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (soundID.IsZero())
|
||||
return;
|
||||
|
||||
int now = Util.EnvironmentTickCount();
|
||||
if (Util.EnvironmentTickCountSubtract(now, LastColSoundSentTime) < 200)
|
||||
return;
|
||||
|
||||
ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>();
|
||||
if (soundModule == null)
|
||||
return;
|
||||
|
||||
if (volume > 1)
|
||||
volume = 1;
|
||||
if (volume < 0)
|
||||
else if (volume < 0)
|
||||
volume = 0;
|
||||
|
||||
int now = Util.EnvironmentTickCount();
|
||||
if(Util.EnvironmentTickCountSubtract(now, LastColSoundSentTime) < 200)
|
||||
return;
|
||||
|
||||
LastColSoundSentTime = now;
|
||||
|
||||
UUID ownerID = OwnerID;
|
||||
@@ -2936,7 +2936,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
UUID parentID = ParentGroup.UUID;
|
||||
ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle;
|
||||
|
||||
soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle);
|
||||
soundModule.TriggerCollisionSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle);
|
||||
}
|
||||
|
||||
public void PhysicsOutOfBounds(Vector3 pos)
|
||||
|
||||
@@ -72,9 +72,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
enum AgentUpdateFlags: byte
|
||||
{
|
||||
None = 0,
|
||||
HideTitle = 1,
|
||||
CliAutoPilot = 2
|
||||
None = 0,
|
||||
HideTitle = 0x01,
|
||||
CliAutoPilot = 0x02,
|
||||
MuteCollisions = 0x80
|
||||
}
|
||||
|
||||
public delegate void SendCoarseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs);
|
||||
@@ -142,7 +143,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
public bool HideTitle = false;
|
||||
public bool HideTitle;
|
||||
public bool MuteCollisions;
|
||||
|
||||
private ScenePresenceStateMachine m_stateMachine;
|
||||
|
||||
@@ -2652,6 +2654,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
SendAvatarDataToAllAgents();
|
||||
}
|
||||
|
||||
MuteCollisions = (agentData.Flags & (byte)AgentUpdateFlags.MuteCollisions) != 0;
|
||||
|
||||
// FIXME: This does not work as intended because the viewer only sends the lbutton down when the button
|
||||
// is first pressed, not whilst it is held down. If this is required in the future then need to look
|
||||
// for an AGENT_CONTROL_LBUTTON_UP event and make sure to handle cases where an initial DOWN is not
|
||||
|
||||
Reference in New Issue
Block a user