From 618c6ceda514190924e8003d4ee895f3e2e9f0cc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 1 Aug 2019 04:14:31 +0100 Subject: mantis8569: do aggregate script events when a script is deleted; block nonphysical drag if a touch event is triggered, add a time guard on that --- .../Framework/Scenes/Scene.PacketHandlers.cs | 7 +--- .../Region/Framework/Scenes/SceneObjectGroup.cs | 48 +++++++++++++++------- .../Framework/Scenes/SceneObjectPartInventory.cs | 7 +++- 3 files changed, 40 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 2995091..b0ecb80 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -341,7 +341,7 @@ namespace OpenSim.Region.Framework.Scenes if(group == null || group.IsDeleted) return; - if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.) + if (Permissions.CanMoveObject(group, remoteClient)) { group.GrabMovement(objectID, offset, pos, remoteClient); } @@ -359,16 +359,13 @@ namespace OpenSim.Region.Framework.Scenes Vector3 grabOffset = pos - part.AbsolutePosition; // If the touched prim handles touches, deliver it if ((part.ScriptEvents & scriptEvents.touch) != 0) -// EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); EventManager.TriggerObjectGrabbing(part.LocalId, 0, grabOffset, remoteClient, surfaceArg); + // Deliver to the root prim if the touched prim doesn't handle touches // or if we're meant to pass on touches anyway. if (((part.ScriptEvents & scriptEvents.touch) == 0) || (part.PassTouches && (part.LocalId != group.RootPart.LocalId))) - { -// EventManager.TriggerObjectGrabbing(group.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg); EventManager.TriggerObjectGrabbing(group.RootPart.LocalId, part.LocalId, grabOffset, remoteClient, surfaceArg); - } } public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List surfaceArgs) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c0bafc5..dcfe79b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2086,13 +2086,20 @@ namespace OpenSim.Region.Framework.Scenes public void ObjectGrabHandler(uint localId, Vector3 offsetPos, IClientAPI remoteClient) { + if (m_rootPart.LocalId == localId) { + if((RootPart.ScriptEvents & scriptEvents.anytouch) != 0) + lastTouchTime = Util.GetTimeStampMS(); OnGrabGroup(offsetPos, remoteClient); } else { SceneObjectPart part = GetPart(localId); + + if (((part.ScriptEvents & scriptEvents.anytouch) != 0) || + (part.PassTouches && (RootPart.ScriptEvents & scriptEvents.anytouch) != 0)) + lastTouchTime = Util.GetTimeStampMS(); OnGrabPart(part, offsetPos, remoteClient); } } @@ -3615,6 +3622,10 @@ namespace OpenSim.Region.Framework.Scenes // part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); } + double lastTouchTime = 0; + + + /// /// If object is physical, apply force to move it around /// If object is not physical, just put it at the resulting location @@ -3623,7 +3634,7 @@ namespace OpenSim.Region.Framework.Scenes /// Always seems to be 0,0,0, so ignoring /// New position. We do the math here to turn it into a force /// - public void GrabMovement(UUID partID, Vector3 offset, Vector3 pos, IClientAPI remoteClient) + public void GrabMovement(UUID partID, Vector3 offset, Vector3 pos, IClientAPI remoteClienth) { if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { @@ -3650,25 +3661,32 @@ namespace OpenSim.Region.Framework.Scenes } else { - NonPhysicalGrabMovement(pos); + if(IsAttachment) + return; + + // block movement if there was a touch at start + double now = Util.GetTimeStampMS(); + if (now - lastTouchTime < 250) + { + lastTouchTime = now; + return; + } + + // a touch or pass may had become active ?? + if (((part.ScriptEvents & scriptEvents.anytouch) != 0) || + (part.PassTouches && (RootPart.ScriptEvents & scriptEvents.anytouch) != 0)) + { + lastTouchTime = now; + return; + } + + lastTouchTime = 0; + UpdateGroupPosition(pos); } } } /// - /// Apply possition for grabbing non-physical linksets (Ctrl+Drag) - /// This MUST be blocked for linksets that contain touch scripts because the viewer triggers grab on the touch - /// event (Viewer Bug?) This would allow anyone to drag a linkset with a touch script. SL behaviour is also to - /// block grab on prims with touch events. - /// - /// New Position - public void NonPhysicalGrabMovement(Vector3 pos) - { - if(!IsAttachment && ScriptCount() == 0) - UpdateGroupPosition(pos); - } - - /// /// If object is physical, prepare for spinning torques (set flag to save old orientation) /// /// Rotation. We do the math here to turn it into a torque diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a0f8959..1ba74f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1091,7 +1091,6 @@ namespace OpenSim.Region.Framework.Scenes m_part.ParentGroup.InvalidateDeepEffectivePerms(); m_inventorySerial++; - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; @@ -1113,8 +1112,12 @@ namespace OpenSim.Region.Framework.Scenes m_part.RemFlag(PrimFlags.Scripted); } - m_part.ScheduleFullUpdate(); + if (type == (int)InventoryType.LSL) + m_part.aggregateScriptEvents(); // this also does full update + else + m_part.ScheduleFullUpdate(); + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); return type; } else -- cgit v1.1