From deb87e78907fae00301c9c3428da2f41e1f588b3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 01:01:46 +0100 Subject: [PATCH 1/2] fix character IsPhysical --- OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index bfff3d40af..b36b93372e 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -239,7 +239,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override bool IsPhysical { - get { return false; } + get { return m_isPhysical; } set { return; } } From 98a2c7bfeec6eda7cffbe5c84083ef3a736e306d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 01:10:39 +0100 Subject: [PATCH 2/2] modulate collision sounds intensity with relative collision speed --- .../Framework/Scenes/CollisionSounds.cs | 74 +++++----- .../Region/Framework/Scenes/ScenePresence.cs | 129 +++++++++++------- 2 files changed, 121 insertions(+), 82 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 4522f9eab9..724ecb6fb8 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); } } /* diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebddf21032..06dec8f9e4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4112,71 +4112,100 @@ namespace OpenSim.Region.Framework.Scenes List thisHitColliders = new List(); List endedColliders = new List(); List startedColliders = new List(); + List soundinfolist = new List(); + CollisionForSoundInfo soundinfo; + ContactPoint curcontact; - foreach (uint localid in coldata.Keys) + if (coldata.Count == 0) { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); - } - - // calculate things that ended colliding - foreach (uint localID in m_lastColliders) - { - if (!thisHitColliders.Contains(localID)) + if (m_lastColliders.Count == 0) + return; // nothing to do + + foreach (uint localID in m_lastColliders) { endedColliders.Add(localID); } - } - //add the items that started colliding this time to the last colliders list. - foreach (uint localID in startedColliders) - { - m_lastColliders.Add(localID); - } - // remove things that ended colliding from the last colliders list - foreach (uint localID in endedColliders) - { - m_lastColliders.Remove(localID); + m_lastColliders.Clear(); } - // do event notification - if (startedColliders.Count > 0) + else { - CollisionSounds.AvatarCollisionSound(this, startedColliders); - - ColliderArgs StartCollidingMessage = new ColliderArgs(); - List colliding = new List(); - foreach (uint localId in startedColliders) + foreach (uint id in coldata.Keys) { - if (localId == 0) - continue; - - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj.OwnerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj.GroupID; - colliding.Add(detobj); + startedColliders.Add(id); + curcontact = coldata[id]; + if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + { + soundinfo = new CollisionForSoundInfo(); + soundinfo.colliderID = id; + soundinfo.position = curcontact.Position; + soundinfo.relativeVel = curcontact.RelativeSpeed; + soundinfolist.Add(soundinfo); + } } + //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); } - if (colliding.Count > 0) + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) { - StartCollidingMessage.Colliders = colliding; + if (!thisHitColliders.Contains(localID)) + { + endedColliders.Add(localID); + } + } + //add the items that started colliding this time to the last colliders list. + foreach (uint localID in startedColliders) + { + m_lastColliders.Add(localID); + } + // remove things that ended colliding from the last colliders list + foreach (uint localID in endedColliders) + { + m_lastColliders.Remove(localID); + } - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + if (soundinfolist.Count > 0) + CollisionSounds.AvatarCollisionSound(this, soundinfolist); + + // do event notification + if (startedColliders.Count > 0) + { + + ColliderArgs StartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + continue; + + SceneObjectPart obj = Scene.GetSceneObjectPart(localId); + string data = ""; + if (obj != null) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj.OwnerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj.GroupID; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + StartCollidingMessage.Colliders = colliding; + + foreach (SceneObjectGroup att in GetAttachments()) + Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + } } }