Fix bug in SoundModule.TriggerSound() where every sound update to an avatar would base its gain calculation on the previous avatar's gain, instead of the original input gain.

This was making sound attenuate oddly when there were NPCs in the region, though it could also happen with ordinary avatars.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-07-31 22:52:17 +01:00
parent 12fbfb6125
commit ec063b9088
1 changed files with 6 additions and 3 deletions

View File

@ -119,17 +119,20 @@ namespace OpenSim.Region.CoreModules.World.Sound
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
if (dis > 100.0) // Max audio distance if (dis > 100.0) // Max audio distance
return; return;
float thisSpGain;
// Scale by distance // Scale by distance
if (radius == 0) if (radius == 0)
gain = (float)((double)gain * ((100.0 - dis) / 100.0)); thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
else else
gain = (float)((double)gain * ((radius - dis) / radius)); thisSpGain = (float)((double)gain * ((radius - dis) / radius));
sp.ControllingClient.SendTriggeredSound( sp.ControllingClient.SendTriggeredSound(
soundId, ownerID, objectID, parentID, handle, position, (float)gain); soundId, ownerID, objectID, parentID, handle, position, thisSpGain);
}); });
} }
} }