From a7ece8c688a44c0d0b05162dbb1e98a1ea4e95ff Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 00:17:37 +0100 Subject: add colliders relative velocity projected in collision direction to collisions report information. --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 2 ++ OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 + OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index b66d7f1..fb90887 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -59,12 +59,14 @@ namespace OpenSim.Region.Physics.Manager public Vector3 Position; public Vector3 SurfaceNormal; public float PenetrationDepth; + public float RelativeSpeed; public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) { Position = position; SurfaceNormal = surfaceNormal; PenetrationDepth = penetrationDepth; + RelativeSpeed = 0f; // for now let this one be set explicity } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index b0711d7..bfff3d4 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -903,6 +903,7 @@ namespace OpenSim.Region.Physics.OdePlugin contact.SurfaceNormal.X = 0f; contact.SurfaceNormal.Y = 0f; contact.SurfaceNormal.Z = -1f; + contact.RelativeSpeed = -vel.Z; AddCollisionEvent(0, contact); vec.Z *= 0.5f; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index ddfdea4..11638d7 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -1064,7 +1064,7 @@ namespace OpenSim.Region.Physics.OdePlugin obj2LocalID = 0; bool p1events = p1.SubscribedEvents(); bool p2events = p2.SubscribedEvents(); - + if (p1.IsVolumeDtc) p2events = false; if (p2.IsVolumeDtc) @@ -1073,6 +1073,15 @@ namespace OpenSim.Region.Physics.OdePlugin if (!(p2events || p1events)) return; + Vector3 vel = Vector3.Zero; + if (p2 != null && p2.IsPhysical) + vel = p2.Velocity; + + if (p1 != null && p1.IsPhysical) + vel -= p1.Velocity; + + contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); + switch ((ActorTypes)p1.PhysicsActorType) { case ActorTypes.Agent: -- cgit v1.1 From deb87e78907fae00301c9c3428da2f41e1f588b3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 01:01:46 +0100 Subject: 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 bfff3d4..b36b933 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; } } -- cgit v1.1 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 ++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 127 +++++++++++++-------- 2 files changed, 120 insertions(+), 81 deletions(-) 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); } } /* diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebddf21..06dec8f 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; + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) + { + 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()); + } - SceneObjectPart obj = Scene.GetSceneObjectPart(localId); - string data = ""; - if (obj != null) + // calculate things that ended colliding + foreach (uint localID in m_lastColliders) + { + if (!thisHitColliders.Contains(localID)) { - 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); + 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); + } - if (colliding.Count > 0) + if (soundinfolist.Count > 0) + CollisionSounds.AvatarCollisionSound(this, soundinfolist); + + // do event notification + if (startedColliders.Count > 0) { - StartCollidingMessage.Colliders = colliding; - foreach (SceneObjectGroup att in GetAttachments()) - Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); + 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); + } } } -- 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 ++++++++++++++-------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 45 +++++++---- 2 files changed, 89 insertions(+), 46 deletions(-) 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; + } } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b5705b7..467b625 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -333,7 +333,7 @@ namespace OpenSim.Region.Framework.Scenes private UUID m_collisionSound; private float m_collisionSoundVolume; - private DateTime LastColSoundSentTime; + private int LastColSoundSentTime; private SOPVehicle m_vehicle = null; @@ -374,7 +374,7 @@ namespace OpenSim.Region.Framework.Scenes // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log m_inventory = new SceneObjectPartInventory(this); - LastColSoundSentTime = DateTime.UtcNow; + LastColSoundSentTime = Util.EnvironmentTickCount(); } /// @@ -2632,13 +2632,29 @@ namespace OpenSim.Region.Framework.Scenes else { + List soundinfolist = new List(); + CollisionForSoundInfo soundinfo; + ContactPoint curcontact; + // calculate things that started colliding this time // and build up list of colliders this time - foreach (uint localid in collissionswith.Keys) + foreach (uint id in collissionswith.Keys) { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - startedColliders.Add(localid); + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) + { + startedColliders.Add(id); + + curcontact = collissionswith[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); + } + } } // calculate things that ended colliding @@ -2655,17 +2671,14 @@ namespace OpenSim.Region.Framework.Scenes // remove things that ended colliding from the last colliders list foreach (uint localID in endedColliders) m_lastColliders.Remove(localID); - } - - // play the sound. - bool IsNotVolumeDtc = !VolumeDetectActive; - - if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) - CollisionSounds.PartCollisionSound(this, startedColliders); + // play sounds. + if (soundinfolist.Count > 0 && !VolumeDetectActive && CollisionSound != invalidCollisionSoundUUID) + CollisionSounds.PartCollisionSound(this, soundinfolist); + } SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); - if (IsNotVolumeDtc) + if (!VolumeDetectActive) SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); @@ -3210,8 +3223,8 @@ namespace OpenSim.Region.Framework.Scenes if (volume < 0) volume = 0; - DateTime now = DateTime.UtcNow; - if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? + int now = Util.EnvironmentTickCount(); + if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) return; LastColSoundSentTime = now; -- 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(-) 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 +++++++++++--------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 80 ++++++++++++++++------ 2 files changed, 100 insertions(+), 53 deletions(-) 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) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 467b625..5fddaed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -329,7 +329,9 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_cameraAtOffset; private bool m_forceMouselook; - // TODO: Collision sound should have default. + + // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound + private sbyte m_collisionSoundType; private UUID m_collisionSound; private float m_collisionSoundVolume; @@ -1342,12 +1344,39 @@ namespace OpenSim.Region.Framework.Scenes public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); + // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound + // runtime thing.. do not persist + [XmlIgnore] + public sbyte CollisionSoundType + { + get + { + return m_collisionSoundType; + } + set + { + m_collisionSoundType = value; + if (value == -1) + m_collisionSound = invalidCollisionSoundUUID; + else if (value == 0) + m_collisionSound = UUID.Zero; + } + } + public UUID CollisionSound { get { return m_collisionSound; } set { m_collisionSound = value; + + if (value == invalidCollisionSoundUUID) + m_collisionSoundType = -1; + else if (value == UUID.Zero) + m_collisionSoundType = 0; + else + m_collisionSoundType = 1; + aggregateScriptEvents(); } } @@ -2633,29 +2662,42 @@ namespace OpenSim.Region.Framework.Scenes else { List soundinfolist = new List(); - CollisionForSoundInfo soundinfo; - ContactPoint curcontact; // calculate things that started colliding this time // and build up list of colliders this time - foreach (uint id in collissionswith.Keys) + if (!VolumeDetectActive && CollisionSoundType >= 0) { - thisHitColliders.Add(id); - if (!m_lastColliders.Contains(id)) - { - startedColliders.Add(id); + CollisionForSoundInfo soundinfo; + ContactPoint curcontact; - curcontact = collissionswith[id]; - if (Math.Abs(curcontact.RelativeSpeed) > 0.2) + foreach (uint id in collissionswith.Keys) + { + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) { - soundinfo = new CollisionForSoundInfo(); - soundinfo.colliderID = id; - soundinfo.position = curcontact.Position; - soundinfo.relativeVel = curcontact.RelativeSpeed; - soundinfolist.Add(soundinfo); + startedColliders.Add(id); + + curcontact = collissionswith[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); + } } } } + else + { + foreach (uint id in collissionswith.Keys) + { + thisHitColliders.Add(id); + if (!m_lastColliders.Contains(id)) + startedColliders.Add(id); + } + } // calculate things that ended colliding foreach (uint localID in m_lastColliders) @@ -2673,7 +2715,7 @@ namespace OpenSim.Region.Framework.Scenes m_lastColliders.Remove(localID); // play sounds. - if (soundinfolist.Count > 0 && !VolumeDetectActive && CollisionSound != invalidCollisionSoundUUID) + if (soundinfolist.Count > 0) CollisionSounds.PartCollisionSound(this, soundinfolist); } @@ -4791,7 +4833,8 @@ namespace OpenSim.Region.Framework.Scenes pa.OnCollisionUpdate -= PhysicsCollision; - bool hassound = ( CollisionSound != invalidCollisionSoundUUID); + bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); + scriptEvents CombinedEvents = AggregateScriptEvents; // merge with root part @@ -4800,10 +4843,7 @@ namespace OpenSim.Region.Framework.Scenes // submit to this part case if (VolumeDetectActive) - { CombinedEvents &= PhyscicsVolumeDtcSubsEvents; - hassound = false; - } else if ((Flags & PrimFlags.Phantom) != 0) CombinedEvents &= PhyscicsPhantonSubsEvents; else -- cgit v1.1 From 10889c86d9d67ca994a090166ad53840ed1dedd0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 16:35:48 +0100 Subject: reduce useless waste of cpu. Make character collision events be done similiar to parts. Let same thread do it all ( like in parts ) ( to change this some structs copies must be added) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +- .../Region/Physics/UbitOdePlugin/ODECharacter.cs | 79 ++++++++------ OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 121 +++++++++++---------- OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 70 ++++++------ 4 files changed, 148 insertions(+), 126 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 06dec8f..be94508 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4098,6 +4098,7 @@ namespace OpenSim.Region.Framework.Scenes private void RaiseCollisionScriptEvents(Dictionary coldata) { + /* lock(m_collisionEventLock) { if (m_collisionEventFlag) @@ -4107,6 +4108,7 @@ namespace OpenSim.Region.Framework.Scenes Util.FireAndForget(delegate(object x) { + */ try { List thisHitColliders = new List(); @@ -4286,7 +4288,7 @@ namespace OpenSim.Region.Framework.Scenes { m_collisionEventFlag = false; } - }); +// }); } private void TeleportFlagsDebug() { diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index b36b933..ca294b8 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -128,9 +128,10 @@ namespace OpenSim.Region.Physics.OdePlugin public d.Mass ShellMass; // public bool collidelock = false; - private bool m_haseventsubscription = false; public int m_eventsubscription = 0; - private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); + private int m_cureventsubscription = 0; + private CollisionEventUpdate CollisionEventsThisFrame = null; + private bool SentEmptyCollisionsEvent; // unique UUID of this character object public UUID m_uuid; @@ -1120,47 +1121,72 @@ namespace OpenSim.Region.Physics.OdePlugin public override void SubscribeEvents(int ms) { - m_requestedUpdateFrequency = ms; m_eventsubscription = ms; - _parent_scene.AddCollisionEventReporting(this); - m_haseventsubscription = true; + m_cureventsubscription = 0; + if (CollisionEventsThisFrame == null) + CollisionEventsThisFrame = new CollisionEventUpdate(); + SentEmptyCollisionsEvent = false; } public override void UnSubscribeEvents() { - m_haseventsubscription = false; - _parent_scene.RemoveCollisionEventReporting(this); - m_requestedUpdateFrequency = 0; + if (CollisionEventsThisFrame != null) + { + CollisionEventsThisFrame.Clear(); + CollisionEventsThisFrame = null; + } m_eventsubscription = 0; } public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { - if (m_haseventsubscription) - { - // m_log.DebugFormat( - // "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact); - - CollisionEventsThisFrame.AddCollider(CollidedWith, contact); - } + if (CollisionEventsThisFrame == null) + CollisionEventsThisFrame = new CollisionEventUpdate(); + CollisionEventsThisFrame.AddCollider(CollidedWith, contact); } public void SendCollisions() { - if (m_haseventsubscription && m_eventsubscription > m_requestedUpdateFrequency) + if (CollisionEventsThisFrame == null) + return; + + if (m_cureventsubscription < m_eventsubscription) + return; + + m_cureventsubscription = 0; + + int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; + + if (!SentEmptyCollisionsEvent || ncolisions > 0) { - if (CollisionEventsThisFrame != null) + base.SendCollisionUpdate(CollisionEventsThisFrame); + + if (ncolisions == 0) { - base.SendCollisionUpdate(CollisionEventsThisFrame); + SentEmptyCollisionsEvent = true; + _parent_scene.RemoveCollisionEventReporting(this); } - CollisionEventsThisFrame = new CollisionEventUpdate(); - m_eventsubscription = 0; - } + else + { + SentEmptyCollisionsEvent = false; + CollisionEventsThisFrame.Clear(); + } + } + } + + internal void AddCollisionFrameTime(int t) + { + // protect it from overflow crashing + if (m_cureventsubscription + t >= int.MaxValue) + m_cureventsubscription = 0; + m_cureventsubscription += t; } public override bool SubscribedEvents() { - return m_haseventsubscription; + if (m_eventsubscription > 0) + return true; + return false; } private void changePhysicsStatus(bool NewStatus) @@ -1466,14 +1492,5 @@ namespace OpenSim.Region.Physics.OdePlugin { _parent_scene.AddChange((PhysicsActor)this, what, arg); } - - - internal void AddCollisionFrameTime(int p) - { - // protect it from overflow crashing - if (m_eventsubscription + p >= int.MaxValue) - m_eventsubscription = 0; - m_eventsubscription += p; - } } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 5db4f17..b2af180 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -477,58 +477,58 @@ namespace OpenSim.Region.Physics.OdePlugin // if(childPrim) we only know about physical linksets return Ptot; - /* - float tmass = _mass; - Ptot *= tmass; +/* + float tmass = _mass; + Ptot *= tmass; - float m; + float m; - foreach (OdePrim prm in childrenPrim) - { - m = prm._mass; - Ptot += prm.CenterOfMass * m; - tmass += m; - } + foreach (OdePrim prm in childrenPrim) + { + m = prm._mass; + Ptot += prm.CenterOfMass * m; + tmass += m; + } - if (tmass == 0) - tmass = 0; - else - tmass = 1.0f / tmass; + if (tmass == 0) + tmass = 0; + else + tmass = 1.0f / tmass; - Ptot *= tmass; - return Ptot; - */ + Ptot *= tmass; + return Ptot; +*/ } else return _position; } } } - /* - public override Vector3 PrimOOBsize - { - get - { - return primOOBsize; - } - } +/* + public override Vector3 PrimOOBsize + { + get + { + return primOOBsize; + } + } - public override Vector3 PrimOOBoffset - { - get - { - return primOOBoffset; - } - } + public override Vector3 PrimOOBoffset + { + get + { + return primOOBoffset; + } + } - public override float PrimOOBRadiusSQ - { - get - { - return primOOBradiusSQ; - } - } - */ + public override float PrimOOBRadiusSQ + { + get + { + return primOOBradiusSQ; + } + } +*/ public override PrimitiveBaseShape Shape { set @@ -582,7 +582,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (value.IsFinite()) { AddChange(changes.Velocity, value); - // _velocity = value; +// _velocity = value; } else @@ -937,12 +937,10 @@ namespace OpenSim.Region.Physics.OdePlugin if (CollisionEventsThisFrame == null) CollisionEventsThisFrame = new CollisionEventUpdate(); SentEmptyCollisionsEvent = false; - _parent_scene.AddCollisionEventReporting(this); } public override void UnSubscribeEvents() { - _parent_scene.RemoveCollisionEventReporting(this); if (CollisionEventsThisFrame != null) { CollisionEventsThisFrame.Clear(); @@ -975,7 +973,10 @@ namespace OpenSim.Region.Physics.OdePlugin base.SendCollisionUpdate(CollisionEventsThisFrame); if (ncolisions == 0) + { SentEmptyCollisionsEvent = true; + _parent_scene.RemoveCollisionEventReporting(this); + } else { SentEmptyCollisionsEvent = false; @@ -1735,8 +1736,8 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetAutoDisableFlag(Body, true); d.BodySetAutoDisableSteps(Body, body_autodisable_frames); - // d.BodySetLinearDampingThreshold(Body, 0.01f); - // d.BodySetAngularDampingThreshold(Body, 0.001f); +// d.BodySetLinearDampingThreshold(Body, 0.01f); +// d.BodySetAngularDampingThreshold(Body, 0.001f); d.BodySetDamping(Body, .002f, .002f); if (m_targetSpace != IntPtr.Zero) @@ -2966,7 +2967,7 @@ namespace OpenSim.Region.Physics.OdePlugin givefakepos--; if (givefakepos < 0) givefakepos = 0; - // changeSelectedStatus(); +// changeSelectedStatus(); resetCollisionAccounting(); } @@ -2981,14 +2982,14 @@ namespace OpenSim.Region.Physics.OdePlugin { _orientation = newOri; } - /* - else if (m_forcePosOrRotation && _orientation != newOri && Body != IntPtr.Zero) - { - FixInertia(_position, newOri); - if (!d.BodyIsEnabled(Body)) - d.BodyEnable(Body); - } - */ +/* + else if (m_forcePosOrRotation && _orientation != newOri && Body != IntPtr.Zero) + { + FixInertia(_position, newOri); + if (!d.BodyIsEnabled(Body)) + d.BodyEnable(Body); + } +*/ } else { @@ -3939,12 +3940,12 @@ namespace OpenSim.Region.Physics.OdePlugin changevelocity((Vector3)arg); break; - // case changes.Acceleration: - // changeacceleration((Vector3)arg); - // break; - // case changes.AngVelocity: - // changeangvelocity((Vector3)arg); - // break; +// case changes.Acceleration: +// changeacceleration((Vector3)arg); +// break; +// case changes.AngVelocity: +// changeangvelocity((Vector3)arg); +// break; case changes.Force: changeForce((Vector3)arg); diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 11638d7..0f341b9 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -247,6 +247,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// A list of actors that should receive collision events. /// private readonly List _collisionEventPrim = new List(); + private readonly List _collisionEventPrimRemove = new List(); private readonly HashSet _badCharacter = new HashSet(); public Dictionary geom_name_map = new Dictionary(); @@ -1073,6 +1074,12 @@ namespace OpenSim.Region.Physics.OdePlugin if (!(p2events || p1events)) return; + if (p1events) + AddCollisionEventReporting(p1); + + if (p2events) + AddCollisionEventReporting(p2); + Vector3 vel = Vector3.Zero; if (p2 != null && p2.IsPhysical) vel = p2.Velocity; @@ -1255,20 +1262,14 @@ namespace OpenSim.Region.Physics.OdePlugin } #endregion - - - /// /// Add actor to the list that should receive collision events in the simulate loop. /// /// public void AddCollisionEventReporting(PhysicsActor obj) { - lock (_collisionEventPrim) - { - if (!_collisionEventPrim.Contains(obj)) - _collisionEventPrim.Add(obj); - } + if (!_collisionEventPrim.Contains(obj)) + _collisionEventPrim.Add(obj); } /// @@ -1277,13 +1278,11 @@ namespace OpenSim.Region.Physics.OdePlugin /// public void RemoveCollisionEventReporting(PhysicsActor obj) { - lock (_collisionEventPrim) - { - if (_collisionEventPrim.Contains(obj)) - _collisionEventPrim.Remove(obj); - } + if (_collisionEventPrim.Contains(obj) && !_collisionEventPrimRemove.Contains(obj)) + _collisionEventPrimRemove.Add(obj); } + #region Add/Remove Entities public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) @@ -1472,6 +1471,7 @@ namespace OpenSim.Region.Physics.OdePlugin { // lock (OdeLock) { + OdePrim p = (OdePrim)prim; p.setPrimForRemoval(); } @@ -1890,33 +1890,35 @@ namespace OpenSim.Region.Physics.OdePlugin collision_optimized(); - lock (_collisionEventPrim) + foreach (PhysicsActor obj in _collisionEventPrim) { - foreach (PhysicsActor obj in _collisionEventPrim) + if (obj == null) + continue; + + switch ((ActorTypes)obj.PhysicsActorType) { - if (obj == null) - continue; + case ActorTypes.Agent: + OdeCharacter cobj = (OdeCharacter)obj; + cobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f)); + cobj.SendCollisions(); + break; - switch ((ActorTypes)obj.PhysicsActorType) - { - case ActorTypes.Agent: - OdeCharacter cobj = (OdeCharacter)obj; - cobj.AddCollisionFrameTime((int)(ODE_STEPSIZE*1000.0f)); - cobj.SendCollisions(); - break; - - case ActorTypes.Prim: - OdePrim pobj = (OdePrim)obj; - if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds)) - { - pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f)); - pobj.SendCollisions(); - } - break; - } + case ActorTypes.Prim: + OdePrim pobj = (OdePrim)obj; + if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds)) + { + pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f)); + pobj.SendCollisions(); + } + break; } } + foreach (PhysicsActor obj in _collisionEventPrimRemove) + _collisionEventPrim.Remove(obj); + + _collisionEventPrimRemove.Clear(); + // do a ode simulation step d.WorldQuickStep(world, ODE_STEPSIZE); d.JointGroupEmpty(contactgroup); -- cgit v1.1 From 2767574d0f17c0bb43c0322505e07d58c60f2f06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 18:10:44 +0100 Subject: fix m_sitAvatarHeight to be half size.z, reduced default to a more resonable value ( 1m); --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index be94508..5a3b518 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2032,7 +2032,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); if (PhysicsActor != null) - m_sitAvatarHeight = PhysicsActor.Size.Z; + m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; bool canSit = false; pos = part.AbsolutePosition + offset; -- cgit v1.1 From 11f582b26da987afe4c9ad76c6ce35b58a8bc6fd Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 May 2012 13:18:15 +0100 Subject: minor changes --- .../Region/Physics/UbitOdePlugin/ODECharacter.cs | 7 ++-- OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 7 ++-- OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 42 ++++++++++------------ 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index ca294b8..1084b0e 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -784,8 +784,6 @@ namespace OpenSim.Region.Physics.OdePlugin // the Amotor still lets avatar rotation to drift during colisions // so force it back to identity - - d.Quaternion qtmp; qtmp.W = 1; @@ -1177,9 +1175,8 @@ namespace OpenSim.Region.Physics.OdePlugin internal void AddCollisionFrameTime(int t) { // protect it from overflow crashing - if (m_cureventsubscription + t >= int.MaxValue) - m_cureventsubscription = 0; - m_cureventsubscription += t; + if (m_cureventsubscription < 50000) + m_cureventsubscription += t; } public override bool SubscribedEvents() diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index b2af180..62fd279 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -987,11 +987,10 @@ namespace OpenSim.Region.Physics.OdePlugin internal void AddCollisionFrameTime(int t) { - // protect it from overflow crashing - if (m_cureventsubscription + t >= int.MaxValue) - m_cureventsubscription = 0; - m_cureventsubscription += t; + if (m_cureventsubscription < 50000) + m_cureventsubscription += t; } + public override bool SubscribedEvents() { if (m_eventsubscription > 0) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 0f341b9..bfcfd21 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -190,6 +190,7 @@ namespace OpenSim.Region.Physics.OdePlugin public float ODE_STEPSIZE = 0.020f; public float HalfOdeStep = 0.01f; + public int odetimestepMS = 20; // rounded private float metersInSpace = 25.6f; private float m_timeDilation = 1.0f; @@ -490,6 +491,7 @@ namespace OpenSim.Region.Physics.OdePlugin } HalfOdeStep = ODE_STEPSIZE * 0.5f; + odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); @@ -1827,7 +1829,6 @@ namespace OpenSim.Region.Physics.OdePlugin { int ttmpstart = Util.EnvironmentTickCount(); int ttmp; - int ttmp2; while(ChangesQueue.Dequeue(out item)) { @@ -1849,11 +1850,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (ttmp > 20) break; } - - ttmp2 = Util.EnvironmentTickCountSubtract(ttmpstart); - if (ttmp2 > 50) - ttmp2 = 0; - } // Move characters @@ -1899,7 +1895,7 @@ namespace OpenSim.Region.Physics.OdePlugin { case ActorTypes.Agent: OdeCharacter cobj = (OdeCharacter)obj; - cobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f)); + cobj.AddCollisionFrameTime((int)(odetimestepMS)); cobj.SendCollisions(); break; @@ -1907,7 +1903,7 @@ namespace OpenSim.Region.Physics.OdePlugin OdePrim pobj = (OdePrim)obj; if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds)) { - pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f)); + pobj.AddCollisionFrameTime((int)(odetimestepMS)); pobj.SendCollisions(); } break; @@ -1924,21 +1920,21 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointGroupEmpty(contactgroup); // update managed ideia of physical data and do updates to core - /* - lock (_characters) - { - foreach (OdeCharacter actor in _characters) - { - if (actor != null) - { - if (actor.bad) - m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); - - actor.UpdatePositionAndVelocity(); - } - } - } - */ + /* + lock (_characters) + { + foreach (OdeCharacter actor in _characters) + { + if (actor != null) + { + if (actor.bad) + m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); + + actor.UpdatePositionAndVelocity(); + } + } + } + */ lock (_activegroups) { -- cgit v1.1 From 32e63fc04fcf08163289c108b278c990208568d5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 20 May 2012 17:30:01 +0100 Subject: missing update script events call --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5fddaed..2852c4b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1604,7 +1604,10 @@ namespace OpenSim.Region.Framework.Scenes } } else if (PhysActor == null) + { ApplyPhysics((uint)Flags, VolumeDetectActive, false); + UpdatePhysicsSubscribedEvents(); + } else { PhysActor.PhysicsShapeType = m_physicsShapeType; @@ -4664,7 +4667,15 @@ namespace OpenSim.Region.Framework.Scenes /// public void RemoveFromPhysics() { - ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); + PhysicsActor pa = PhysActor; + if (pa != null) + { + pa.OnCollisionUpdate -= PhysicsCollision; + pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; + pa.OnOutOfBounds -= PhysicsOutOfBounds; + + ParentGroup.Scene.PhysicsScene.RemovePrim(pa); + } PhysActor = null; } -- cgit v1.1