From 98a2c7bfeec6eda7cffbe5c84083ef3a736e306d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 01:10:39 +0100 Subject: modulate collision sounds intensity with relative collision speed --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 74 ++++++++++++---------- 1 file changed, 42 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 4522f9e..724ecb6 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -33,14 +33,24 @@ using OpenSim.Framework; namespace OpenSim.Region.Framework.Scenes { + public struct CollisionForSoundInfo + { + public uint colliderID; + public Vector3 position; + public float relativeVel; + } + public static class CollisionSounds { + + + // defines for cases // only know one UUID for now (woodflesh) private const int MaxMaterials = 7; // part part - private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -48,29 +58,29 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -107,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part,List Colliders) { // temporary mute sounds - return; +// return; if(Colliders.Count == 0 || part == null) return; @@ -178,28 +188,15 @@ namespace OpenSim.Region.Framework.Scenes } } } -/* avatars get notification let them trigger the sound - else if (!doneownsound) - { - ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id); - if (av != null && (!av.IsChildAgent)) - { - index = thisMatScaled + 4; // flesh - soundID = m_PartPart[index]; - part.SendCollisionSound(soundID, 1.0); - doneownsound = true; - } - } - */ } } - public static void AvatarCollisionSound(ScenePresence av, List Colliders) + public static void AvatarCollisionSound(ScenePresence av, List collidersinfolist) { // temporary mute sounds - return; +// return; - if (Colliders.Count == 0 || av == null) + if (collidersinfolist.Count == 0 || av == null) return; UUID soundID; @@ -211,30 +208,43 @@ namespace OpenSim.Region.Framework.Scenes int index; // bool doneownsound = false; - Vector3 position = av.AbsolutePosition; + CollisionForSoundInfo colInfo; + uint id; + float volume; - foreach (uint Id in Colliders) + for(int i = 0; i< collidersinfolist.Count; i++) { - if (Id == 0) + colInfo = collidersinfolist[i]; + + volume = Math.Abs(colInfo.relativeVel); + if(volume < 0.2f) + continue; + + id = colInfo.colliderID; + + if (id == 0) // no terrain collision sounds for now { continue; } - SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id); + SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); if (otherPart != null) { if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) continue; if (otherPart.CollisionSound != UUID.Zero) - otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); + otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); else { + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) otherMaterial = 3; index = thisMatScaled + otherMaterial; soundID = m_PartPart[index]; - otherPart.SendCollisionSound(soundID, 1.0, position); + otherPart.SendCollisionSound(soundID, volume, colInfo.position); } } /* -- cgit v1.1 From 9ecdef2686de9045f1fddd8b64bcf73c04e1e0ab Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 02:04:10 +0100 Subject: modulate collision sound intensity with collision relative velocity for parts also --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 90 ++++++++++++++-------- 1 file changed, 60 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 724ecb6..1f43843 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -114,12 +114,9 @@ namespace OpenSim.Region.Framework.Scenes snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber }; - public static void PartCollisionSound(SceneObjectPart part,List Colliders) + public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { - // temporary mute sounds -// return; - - if(Colliders.Count == 0 || part == null) + if (collidersinfolist.Count == 0 || part == null) return; if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) @@ -128,19 +125,20 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentGroup == null) return; - if (part.CollisionSound == part.invalidCollisionSoundUUID) + UUID soundID = part.CollisionSound; + if (soundID == part.invalidCollisionSoundUUID) return; - UUID soundID; + float volume = 0.0f; int otherMaterial; + bool HaveSound = false; - Vector3 position = part.AbsolutePosition; - - if (part.CollisionSound != UUID.Zero) + if (soundID != UUID.Zero) { - if (part.CollisionSoundVolume > 0.0f) - part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position); - return; + volume = part.CollisionSoundVolume; + if (volume == 0.0f) + return; + HaveSound = true; } int thisMaterial = (int) part.Material; @@ -152,41 +150,73 @@ namespace OpenSim.Region.Framework.Scenes bool doneownsound = false; - foreach (uint Id in Colliders) + CollisionForSoundInfo colInfo; + uint id; + + for(int i = 0; i< collidersinfolist.Count; i++) { - if (Id == 0) + colInfo = collidersinfolist[i]; + + if (!HaveSound) + { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + } + + id = colInfo.colliderID; + if (id == 0) { if (!doneownsound) { - soundID = m_TerrainPart[thisMaterial]; - part.SendCollisionSound(soundID, 1.0, position); + if (!HaveSound) + { + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; + soundID = m_TerrainPart[thisMaterial]; + } + part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } continue; } - SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); + SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); if (otherPart != null) { if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) continue; - if (otherPart.CollisionSound != UUID.Zero) - otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); - else + + if (!HaveSound) { - otherMaterial = (int)otherPart.Material; - if (otherMaterial >= MaxMaterials) - otherMaterial = 3; - index = thisMatScaled + otherMaterial; - soundID = m_PartPart[index]; - if (doneownsound) - otherPart.SendCollisionSound(soundID, 1.0, position); + if (otherPart.CollisionSound != UUID.Zero) + { + soundID = otherPart.CollisionSound; + volume = otherPart.CollisionSoundVolume; + if (volume == 0.0f) + continue; + } else { - part.SendCollisionSound(soundID, 1.0, position); - doneownsound = true; + volume *= volume * .0625f; // 4m/s == full volume + if (volume > 1.0f) + volume = 1.0f; + otherMaterial = (int)otherPart.Material; + if (otherMaterial >= MaxMaterials) + otherMaterial = 3; + index = thisMatScaled + otherMaterial; + soundID = m_PartPart[index]; } } + + if (doneownsound) + otherPart.SendCollisionSound(soundID, volume, colInfo.position); + else + { + part.SendCollisionSound(soundID, volume, colInfo.position); + doneownsound = true; + } } } } -- cgit v1.1 From a2c64d9795b82e02d8f75976da9cbb9749f69627 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 12:25:31 +0100 Subject: temp work: sounds simetric acording to materials, still 'window close' test sound. Included in coment full assimetric ( since seems we have files for it now ) case with some uuids --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 128 ++++++++++++++++----- 1 file changed, 98 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 1f43843..c593b63 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -42,34 +42,94 @@ namespace OpenSim.Region.Framework.Scenes public static class CollisionSounds { - - - - // defines for cases - // only know one UUID for now (woodflesh) - private const int MaxMaterials = 7; // part part +/* + private static UUID snd_StoneStone = new UUID("be7295c0-a158-11e1-b3dd-0800200c9a66"); + private static UUID snd_StoneMetal = new UUID("be7295c0-a158-11e1-b3dd-0800201c9a66"); + private static UUID snd_StoneGlass = new UUID("be7295c0-a158-11e1-b3dd-0800202c9a66"); + private static UUID snd_StoneWood = new UUID("be7295c0-a158-11e1-b3dd-0800203c9a66"); + private static UUID snd_StoneFlesh = new UUID("be7295c0-a158-11e1-b3dd-0800204c9a66"); + private static UUID snd_StonePlastic = new UUID("be7295c0-a158-11e1-b3dd-0800205c9a66"); + private static UUID snd_StoneRubber = new UUID("be7295c0-a158-11e1-b3dd-0800206c9a66"); + + private static UUID snd_MetalStone = new UUID("be7295c0-a158-11e1-b3dd-0801200c9a66"); + private static UUID snd_MetalMetal = new UUID("be7295c0-a158-11e1-b3dd-0801201c9a66"); + private static UUID snd_MetalGlass = new UUID("be7295c0-a158-11e1-b3dd-0801202c9a66"); + private static UUID snd_MetalWood = new UUID("be7295c0-a158-11e1-b3dd-0801203c9a66"); + private static UUID snd_MetalFlesh = new UUID("be7295c0-a158-11e1-b3dd-0801204c9a66"); + private static UUID snd_MetalPlastic = new UUID("be7295c0-a158-11e1-b3dd-0801205c9a66"); + private static UUID snd_MetalRubber = new UUID("be7295c0-a158-11e1-b3dd-0801206c9a66"); + + private static UUID snd_GlassStone = new UUID("be7295c0-a158-11e1-b3dd-0802200c9a66"); + private static UUID snd_GlassMetal = new UUID("be7295c0-a158-11e1-b3dd-0802201c9a66"); + private static UUID snd_GlassGlass = new UUID("be7295c0-a158-11e1-b3dd-0802202c9a66"); + private static UUID snd_GlassWood = new UUID("be7295c0-a158-11e1-b3dd-0802203c9a66"); + private static UUID snd_GlassFlesh = new UUID("be7295c0-a158-11e1-b3dd-0802204c9a66"); + private static UUID snd_GlassPlastic = new UUID("be7295c0-a158-11e1-b3dd-0802205c9a66"); + private static UUID snd_GlassRubber = new UUID("be7295c0-a158-11e1-b3dd-0802206c9a66"); + + private static UUID snd_WoodStone = new UUID("be7295c0-a158-11e1-b3dd-0803200c9a66"); + private static UUID snd_WoodMetal = new UUID("be7295c0-a158-11e1-b3dd-0803201c9a66"); + private static UUID snd_WoodGlass = new UUID("be7295c0-a158-11e1-b3dd-0803202c9a66"); + private static UUID snd_WoodWood = new UUID("be7295c0-a158-11e1-b3dd-0803203c9a66"); + private static UUID snd_WoodFlesh = new UUID("be7295c0-a158-11e1-b3dd-0803204c9a66"); + private static UUID snd_WoodPlastic = new UUID("be7295c0-a158-11e1-b3dd-0803205c9a66"); + private static UUID snd_WoodRubber = new UUID("be7295c0-a158-11e1-b3dd-0803206c9a66"); + + private static UUID snd_FleshStone = new UUID("be7295c0-a158-11e1-b3dd-0804200c9a66"); + private static UUID snd_FleshMetal = new UUID("be7295c0-a158-11e1-b3dd-0804201c9a66"); + private static UUID snd_FleshGlass = new UUID("be7295c0-a158-11e1-b3dd-0804202c9a66"); + private static UUID snd_FleshWood = new UUID("be7295c0-a158-11e1-b3dd-0804203c9a66"); + private static UUID snd_FleshFlesh = new UUID("be7295c0-a158-11e1-b3dd-0804204c9a66"); + private static UUID snd_FleshPlastic = new UUID("be7295c0-a158-11e1-b3dd-0804205c9a66"); + private static UUID snd_FleshRubber = new UUID("be7295c0-a158-11e1-b3dd-0804206c9a66"); + + private static UUID snd_PlasticStone = new UUID("be7295c0-a158-11e1-b3dd-0805200c9a66"); + private static UUID snd_PlasticMetal = new UUID("be7295c0-a158-11e1-b3dd-0805201c9a66"); + private static UUID snd_PlasticGlass = new UUID("be7295c0-a158-11e1-b3dd-0805202c9a66"); + private static UUID snd_PlasticWood = new UUID("be7295c0-a158-11e1-b3dd-0805203c9a66"); + private static UUID snd_PlasticFlesh = new UUID("be7295c0-a158-11e1-b3dd-0805204c9a66"); + private static UUID snd_PlasticPlastic = new UUID("be7295c0-a158-11e1-b3dd-0805205c9a66"); + private static UUID snd_PlasticRubber = new UUID("be7295c0-a158-11e1-b3dd-0805206c9a66"); + + private static UUID snd_RubberStone = new UUID("be7295c0-a158-11e1-b3dd-0806200c9a66"); + private static UUID snd_RubberMetal = new UUID("be7295c0-a158-11e1-b3dd-0806201c9a66"); + private static UUID snd_RubberGlass = new UUID("be7295c0-a158-11e1-b3dd-0806202c9a66"); + private static UUID snd_RubberWood = new UUID("be7295c0-a158-11e1-b3dd-0806203c9a66"); + private static UUID snd_RubberFlesh = new UUID("be7295c0-a158-11e1-b3dd-0806204c9a66"); + private static UUID snd_RubberPlastic = new UUID("be7295c0-a158-11e1-b3dd-0806205c9a66"); + private static UUID snd_RubberRubber = new UUID("be7295c0-a158-11e1-b3dd-0806206c9a66"); + + // terrain part + private static UUID snd_TerrainStone = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainMetal = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainGlass = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainWood = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainFlesh = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainPlastic = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); + private static UUID snd_TerrainRubber = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); +*/ private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -77,11 +137,11 @@ namespace OpenSim.Region.Framework.Scenes private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); - private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); @@ -103,7 +163,19 @@ namespace OpenSim.Region.Framework.Scenes snd_TerrainPlastic, snd_TerrainRubber }; - +/* + //full assimetric sounds + public static UUID[] m_PartPart = { + snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, + snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, + snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, + snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, + snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, + snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber, + snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber + }; +*/ + // simetric sounds public static UUID[] m_PartPart = { snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, @@ -113,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber }; - + public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { if (collidersinfolist.Count == 0 || part == null) @@ -223,9 +295,6 @@ namespace OpenSim.Region.Framework.Scenes public static void AvatarCollisionSound(ScenePresence av, List collidersinfolist) { - // temporary mute sounds -// return; - if (collidersinfolist.Count == 0 || av == null) return; @@ -291,6 +360,5 @@ namespace OpenSim.Region.Framework.Scenes */ } } - } } \ No newline at end of file -- cgit v1.1 From 2c498baf58005be487b4e457455a9896a96b90d3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 13:53:49 +0100 Subject: a bit faster collision sound type verification plus a few fixes/changes --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 73 ++++++++++++---------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs') diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index c593b63..476eccd 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -197,30 +197,29 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentGroup == null) return; - UUID soundID = part.CollisionSound; - if (soundID == part.invalidCollisionSoundUUID) + if (part.CollisionSoundType < 0) return; float volume = 0.0f; - int otherMaterial; bool HaveSound = false; - if (soundID != UUID.Zero) + UUID soundID = part.CollisionSound; + + if (part.CollisionSoundType > 0) { + // soundID = part.CollisionSound; volume = part.CollisionSoundVolume; if (volume == 0.0f) return; HaveSound = true; } - int thisMaterial = (int) part.Material; + bool doneownsound = false; + + int thisMaterial = (int)part.Material; if (thisMaterial >= MaxMaterials) thisMaterial = 3; - int thisMatScaled = thisMaterial * MaxMaterials; - int index; - - bool doneownsound = false; CollisionForSoundInfo colInfo; uint id; @@ -229,23 +228,21 @@ namespace OpenSim.Region.Framework.Scenes { colInfo = collidersinfolist[i]; - if (!HaveSound) - { - volume = Math.Abs(colInfo.relativeVel); - if (volume < 0.2f) - continue; - } - id = colInfo.colliderID; - if (id == 0) + if (id == 0) // terrain collision { if (!doneownsound) { if (!HaveSound) { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) volume = 1.0f; + soundID = m_TerrainPart[thisMaterial]; } part.SendCollisionSound(soundID, volume, colInfo.position); @@ -257,12 +254,12 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); if (otherPart != null) { - if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) + if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) continue; if (!HaveSound) { - if (otherPart.CollisionSound != UUID.Zero) + if (otherPart.CollisionSoundType > 0) { soundID = otherPart.CollisionSound; volume = otherPart.CollisionSoundVolume; @@ -271,14 +268,19 @@ namespace OpenSim.Region.Framework.Scenes } else { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) volume = 1.0f; - otherMaterial = (int)otherPart.Material; + + int otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) otherMaterial = 3; - index = thisMatScaled + otherMaterial; - soundID = m_PartPart[index]; + + soundID = m_PartPart[thisMatScaled + otherMaterial]; } } @@ -301,11 +303,11 @@ namespace OpenSim.Region.Framework.Scenes UUID soundID; int otherMaterial; - int thisMaterial = 3; + int thisMaterial = 4; // flesh int thisMatScaled = thisMaterial * MaxMaterials; - int index; -// bool doneownsound = false; + + // bool doneownsound = false; CollisionForSoundInfo colInfo; uint id; @@ -315,36 +317,41 @@ namespace OpenSim.Region.Framework.Scenes { colInfo = collidersinfolist[i]; - volume = Math.Abs(colInfo.relativeVel); - if(volume < 0.2f) - continue; - id = colInfo.colliderID; if (id == 0) // no terrain collision sounds for now { continue; +// volume = Math.Abs(colInfo.relativeVel); +// if (volume < 0.2f) +// continue; + } SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); if (otherPart != null) { - if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) + if (otherPart.CollisionSoundType < 0) continue; - if (otherPart.CollisionSound != UUID.Zero) + if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); else { + volume = Math.Abs(colInfo.relativeVel); + if (volume < 0.2f) + continue; + volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) volume = 1.0f; otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) otherMaterial = 3; - index = thisMatScaled + otherMaterial; - soundID = m_PartPart[index]; + + soundID = m_PartPart[thisMatScaled + otherMaterial]; otherPart.SendCollisionSound(soundID, volume, colInfo.position); } + continue; } /* else if (!doneownsound) -- cgit v1.1