trigger collision sounds on active agent position for better spatial effect without using the detailed collision position. (current error will be half max physical prim size). Moved some checks from sop to collisionSound code

avinationmerge
UbitUmarov 2012-05-17 12:17:29 +01:00
parent e4231e95a9
commit 6af78836a5
2 changed files with 22 additions and 23 deletions

View File

@ -130,7 +130,7 @@ namespace OpenSim.Region.Framework.Scenes
if(Colliders.Count == 0 || part == null)
return;
if ((part.Flags & PrimFlags.Physics) == 0) // let only active prims trigger sounds
if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0)
return;
if (part.ParentGroup == null)
@ -142,6 +142,15 @@ namespace OpenSim.Region.Framework.Scenes
UUID soundID;
int otherMaterial;
Vector3 position = part.AbsolutePosition;
if (part.CollisionSound != UUID.Zero)
{
if (part.CollisionSoundVolume > 0.0f)
part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position);
return;
}
int thisMaterial = (int) part.Material;
if (thisMaterial >= MaxMaterials)
thisMaterial = 3;
@ -158,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!doneownsound)
{
soundID = m_TerrainPart[thisMaterial];
part.SendCollisionSound(soundID, 1.0);
part.SendCollisionSound(soundID, 1.0, position);
doneownsound = true;
}
continue;
@ -170,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes
if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive)
continue;
if (otherPart.CollisionSound != UUID.Zero)
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume);
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position);
else
{
otherMaterial = (int)otherPart.Material;
@ -179,10 +188,10 @@ namespace OpenSim.Region.Framework.Scenes
index = thisMatScaled + otherMaterial;
soundID = m_PartPart[index];
if (doneownsound)
otherPart.SendCollisionSound(soundID, 1.0);
otherPart.SendCollisionSound(soundID, 1.0, position);
else
{
part.SendCollisionSound(soundID, 1.0);
part.SendCollisionSound(soundID, 1.0, position);
doneownsound = true;
}
}
@ -217,6 +226,8 @@ namespace OpenSim.Region.Framework.Scenes
int index;
// bool doneownsound = false;
Vector3 position = av.AbsolutePosition;
foreach (uint Id in Colliders)
{
if (Id == 0)
@ -230,7 +241,7 @@ namespace OpenSim.Region.Framework.Scenes
if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID)
continue;
if (otherPart.CollisionSound != UUID.Zero)
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume);
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position);
else
{
otherMaterial = (int)otherPart.Material;
@ -238,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes
otherMaterial = 3;
index = thisMatScaled + otherMaterial;
soundID = m_PartPart[index];
otherPart.SendCollisionSound(soundID, 1.0);
otherPart.SendCollisionSound(soundID, 1.0, position);
}
}
/*

View File

@ -2632,7 +2632,6 @@ namespace OpenSim.Region.Framework.Scenes
else
{
// calculate things that started colliding this time
// and build up list of colliders this time
foreach (uint localid in collissionswith.Keys)
@ -2657,22 +2656,13 @@ namespace OpenSim.Region.Framework.Scenes
foreach (uint localID in endedColliders)
m_lastColliders.Remove(localID);
}
// play the sound.
bool IsNotVolumeDtc = !VolumeDetectActive;
if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID)
{
if (CollisionSound != UUID.Zero)
{
if (CollisionSoundVolume > 0.0f)
SendCollisionSound(CollisionSound, CollisionSoundVolume);
}
else
{
CollisionSounds.PartCollisionSound(this, startedColliders);
}
}
CollisionSounds.PartCollisionSound(this, startedColliders);
SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart);
if (IsNotVolumeDtc)
@ -3206,12 +3196,11 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void SendCollisionSound(UUID soundID, double volume)
public void SendCollisionSound(UUID soundID, double volume, Vector3 position)
{
if (soundID == UUID.Zero)
return;
ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>();
if (soundModule == null)
return;
@ -3230,10 +3219,9 @@ namespace OpenSim.Region.Framework.Scenes
UUID ownerID = OwnerID;
UUID objectID = ParentGroup.RootPart.UUID;
UUID parentID = ParentGroup.UUID;
Vector3 position = AbsolutePosition; // region local
ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle;
soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0);
soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 );
}