From fb46eb3344f50aecf2796e3940a66ee6e3d57915 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Sep 2016 19:23:56 +0100 Subject: [PATCH] pass touch_end as other touchs, make blockgrab work on nonphysical also --- .../Region/Framework/Scenes/EventManager.cs | 2 +- .../Framework/Scenes/Scene.PacketHandlers.cs | 19 ++-- .../Framework/Scenes/SceneObjectGroup.cs | 96 +++++++++---------- 3 files changed, 54 insertions(+), 63 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 868359921d..6ff30490f5 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -1881,7 +1881,7 @@ namespace OpenSim.Region.Framework.Scenes catch (Exception e) { m_log.ErrorFormat( - "[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", + "[EVENT MANAGER]: Delegate for TriggerGroupMove failed - continuing. {0} {1}", e.Message, e.StackTrace); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 4d491d177a..d27af09e05 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -340,13 +340,11 @@ namespace OpenSim.Region.Framework.Scenes obj.ObjectGrabHandler(localID, offsetPos, remoteClient); // If the touched prim handles touches, deliver it - // If not, deliver to root prim if ((part.ScriptEvents & scriptEvents.touch_start) != 0) EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, 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. Don't send to root prim - // if prim touched is the root prim as we just did it + // or if we're meant to pass on touches anyway. if (((part.ScriptEvents & scriptEvents.touch_start) == 0) || (part.PassTouches && (part.LocalId != obj.RootPart.LocalId))) { @@ -381,12 +379,10 @@ namespace OpenSim.Region.Framework.Scenes surfaceArg = surfaceArgs[0]; // If the touched prim handles touches, deliver it - // If not, deliver to root prim if ((part.ScriptEvents & scriptEvents.touch) != 0) EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, 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. Don't send to root prim - // if prim touched is the root prim as we just did it + // or if we're meant to pass on touches anyway. if (((part.ScriptEvents & scriptEvents.touch) == 0) || (part.PassTouches && (part.LocalId != group.RootPart.LocalId))) { @@ -400,18 +396,21 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; - SceneObjectGroup obj = part.ParentGroup; + SceneObjectGroup grp = part.ParentGroup; SurfaceTouchEventArgs surfaceArg = null; if (surfaceArgs != null && surfaceArgs.Count > 0) surfaceArg = surfaceArgs[0]; // If the touched prim handles touches, deliver it - // If not, deliver to root prim if ((part.ScriptEvents & scriptEvents.touch_end) != 0) EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg); - else - EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); + // if not or PassTouchs, send it also to root. + if (((part.ScriptEvents & scriptEvents.touch_end) == 0) || + (part.PassTouches && (part.LocalId != grp.RootPart.LocalId))) + { + EventManager.TriggerObjectDeGrab(grp.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); + } } public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b7c5b6b35b..00951d6623 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -79,7 +79,8 @@ namespace OpenSim.Region.Framework.Scenes touch_end = 536870912, touch_start = 2097152, transaction_result = 33554432, - object_rez = 4194304 + object_rez = 4194304, + anytouch = touch | touch_end | touch_start } public struct scriptPosTarget @@ -3497,34 +3498,26 @@ namespace OpenSim.Region.Framework.Scenes { if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { + if (BlockGrabOverride) + return; + SceneObjectPart part = GetPart(partID); if (part == null) return; + if (part.BlockGrab) + return; + PhysicsActor pa = m_rootPart.PhysActor; - if (pa != null) + if (pa != null && pa.IsPhysical) { - if (pa.IsPhysical) - { - if (!BlockGrabOverride && !part.BlockGrab) - { -/* Vector3 llmoveforce = pos - AbsolutePosition; - Vector3 grabforce = llmoveforce; - grabforce = (grabforce / 10) * pa.Mass; - */ - // empirically convert distance diference to a impulse - Vector3 grabforce = pos - AbsolutePosition; - grabforce = grabforce * (pa.Mass/ 10.0f); - pa.AddForce(grabforce, false); - m_scene.PhysicsScene.AddPhysicsActorTaint(pa); - } - } - else - { - NonPhysicalGrabMovement(pos); - } + // empirically convert distance diference to a impulse + Vector3 grabforce = pos - AbsolutePosition; + grabforce = grabforce * (pa.Mass * 0.1f); + pa.AddForce(grabforce, false); + m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } else { @@ -3553,6 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void SpinStart(IClientAPI remoteClient) { + if (BlockGrabOverride || m_rootPart.BlockGrab) + return; if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) { PhysicsActor pa = m_rootPart.PhysActor; @@ -3600,46 +3595,43 @@ namespace OpenSim.Region.Framework.Scenes // but it will result in over-shoot or under-shoot of the target orientation. // For the end user, this means that ctrl+shift+drag can be used for relative, // but not absolute, adjustments of orientation for physical prims. + + if (BlockGrabOverride || m_rootPart.BlockGrab) + return; + if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) { PhysicsActor pa = m_rootPart.PhysActor; - if (pa != null) + if (pa != null && pa.IsPhysical) { - if (pa.IsPhysical) + if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) { - if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) - { - // first time initialization of "old" orientation for calculation of delta rotations - m_rootPart.SpinOldOrientation = newOrientation; - m_rootPart.IsWaitingForFirstSpinUpdatePacket = false; - } - else - { - // save and update old orientation - Quaternion old = m_rootPart.SpinOldOrientation; - m_rootPart.SpinOldOrientation = newOrientation; - //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); - //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); - - // compute difference between previous old rotation and new incoming rotation - Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; - - float rotationAngle; - Vector3 rotationAxis; - minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); - rotationAxis.Normalize(); - - //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); - Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); - spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor - pa.AddAngularForce(spinforce,true); - m_scene.PhysicsScene.AddPhysicsActorTaint(pa); - } + // first time initialization of "old" orientation for calculation of delta rotations + m_rootPart.SpinOldOrientation = newOrientation; + m_rootPart.IsWaitingForFirstSpinUpdatePacket = false; } else { - NonPhysicalSpinMovement(newOrientation); + // save and update old orientation + Quaternion old = m_rootPart.SpinOldOrientation; + m_rootPart.SpinOldOrientation = newOrientation; + //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); + //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); + + // compute difference between previous old rotation and new incoming rotation + Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; + + float rotationAngle; + Vector3 rotationAxis; + minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); + rotationAxis.Normalize(); + + //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); + Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); + spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor + pa.AddAngularForce(spinforce,true); + m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } } else