diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 078449bd93..84817a050b 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -129,8 +129,6 @@ namespace OpenSim.Region.Framework.Scenes return; float volume = part.CollisionSoundVolume; - if (volume == 0.0f) - return; UUID soundID = part.CollisionSound; @@ -150,6 +148,9 @@ namespace OpenSim.Region.Framework.Scenes break; } + if (volume == 0.0f) + return; + bool doneownsound = false; int thisMaterial = (int)part.Material; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9b7374c048..b7c5b6b35b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2112,6 +2112,12 @@ namespace OpenSim.Region.Framework.Scenes d.AddActiveScripts(count); } + private const scriptEvents PhysicsNeeedSubsEvents = ( + scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | + scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end); + + private scriptEvents lastRootPartPhysEvents = 0; + public void aggregateScriptEvents() { PrimFlags objectflagupdate = (PrimFlags)RootPart.GetEffectiveObjectFlags(); @@ -2148,6 +2154,20 @@ namespace OpenSim.Region.Framework.Scenes m_scene.RemoveGroupTarget(this); } + scriptEvents rootPartPhysEvents = RootPart.AggregateScriptEvents; + rootPartPhysEvents &= PhysicsNeeedSubsEvents; + if (rootPartPhysEvents != lastRootPartPhysEvents) + { + lastRootPartPhysEvents = rootPartPhysEvents; + for (int i = 0; i < parts.Length; i++) + { + SceneObjectPart part = parts[i]; + if (part == null) + continue; + part.UpdatePhysicsSubscribedEvents(); + } + } + ScheduleGroupForFullUpdate(); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dd20a2ffb3..fcc3463b48 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1534,7 +1534,6 @@ namespace OpenSim.Region.Framework.Scenes else m_collisionSoundType = 1; - aggregateScriptEvents(); } } @@ -5033,7 +5032,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter } - private void UpdatePhysicsSubscribedEvents() + internal void UpdatePhysicsSubscribedEvents() { PhysicsActor pa = PhysActor; if (pa == null) @@ -5107,8 +5106,6 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; } - UpdatePhysicsSubscribedEvents(); - LocalFlags = (PrimFlags)objectflagupdate; if (ParentGroup != null && ParentGroup.RootPart == this) @@ -5119,6 +5116,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter { // m_log.DebugFormat( // "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId); + UpdatePhysicsSubscribedEvents(); ScheduleFullUpdate(); } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 914644ab73..50ee9d4219 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1246,7 +1246,7 @@ namespace OpenSim.Region.Framework.Scenes physActor_OnPhysicsRequestingCameraData; partPhysActor.OnPhysicsRequestingCameraData += physActor_OnPhysicsRequestingCameraData; - } + } } ParentUUID = UUID.Zero; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c046a0c52e..66cb30c5ec 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5109,6 +5109,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.CollisionSoundVolume = (float)impact_volume; m_host.CollisionSound = m_host.invalidCollisionSoundUUID; m_host.CollisionSoundType = -1; // disable all sounds + m_host.aggregateScriptEvents(); return; } @@ -5122,6 +5123,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else m_host.CollisionSoundType = -1; + + m_host.aggregateScriptEvents(); } public LSL_String llGetAnimation(string id) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 6168fe03d2..4af433926d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -4266,6 +4266,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.CollisionSoundType = 0; // full return to default sounds else m_host.CollisionSoundType = 2; // default sounds with volume + m_host.aggregateScriptEvents(); return; } // TODO: Parameter check logic required. @@ -4278,6 +4279,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else m_host.CollisionSoundType = -1; + + m_host.aggregateScriptEvents(); } // still not very usefull, detector is lost on rez, restarts, etc