diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 19 | ||||
-rw-r--r-- | OpenSim/Region/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 8683599..6ff3049 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -1881,7 +1881,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1881 | catch (Exception e) | 1881 | catch (Exception e) |
1882 | { | 1882 | { |
1883 | m_log.ErrorFormat( | 1883 | m_log.ErrorFormat( |
1884 | "[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", | 1884 | "[EVENT MANAGER]: Delegate for TriggerGroupMove failed - continuing. {0} {1}", |
1885 | e.Message, e.StackTrace); | 1885 | e.Message, e.StackTrace); |
1886 | } | 1886 | } |
1887 | } | 1887 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 4d491d1..d27af09 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 | |||
340 | obj.ObjectGrabHandler(localID, offsetPos, remoteClient); | 340 | obj.ObjectGrabHandler(localID, offsetPos, remoteClient); |
341 | 341 | ||
342 | // If the touched prim handles touches, deliver it | 342 | // If the touched prim handles touches, deliver it |
343 | // If not, deliver to root prim | ||
344 | if ((part.ScriptEvents & scriptEvents.touch_start) != 0) | 343 | if ((part.ScriptEvents & scriptEvents.touch_start) != 0) |
345 | EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); | 344 | EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); |
346 | 345 | ||
347 | // Deliver to the root prim if the touched prim doesn't handle touches | 346 | // Deliver to the root prim if the touched prim doesn't handle touches |
348 | // or if we're meant to pass on touches anyway. Don't send to root prim | 347 | // or if we're meant to pass on touches anyway. |
349 | // if prim touched is the root prim as we just did it | ||
350 | if (((part.ScriptEvents & scriptEvents.touch_start) == 0) || | 348 | if (((part.ScriptEvents & scriptEvents.touch_start) == 0) || |
351 | (part.PassTouches && (part.LocalId != obj.RootPart.LocalId))) | 349 | (part.PassTouches && (part.LocalId != obj.RootPart.LocalId))) |
352 | { | 350 | { |
@@ -381,12 +379,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
381 | surfaceArg = surfaceArgs[0]; | 379 | surfaceArg = surfaceArgs[0]; |
382 | 380 | ||
383 | // If the touched prim handles touches, deliver it | 381 | // If the touched prim handles touches, deliver it |
384 | // If not, deliver to root prim | ||
385 | if ((part.ScriptEvents & scriptEvents.touch) != 0) | 382 | if ((part.ScriptEvents & scriptEvents.touch) != 0) |
386 | EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); | 383 | EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); |
387 | // Deliver to the root prim if the touched prim doesn't handle touches | 384 | // Deliver to the root prim if the touched prim doesn't handle touches |
388 | // or if we're meant to pass on touches anyway. Don't send to root prim | 385 | // or if we're meant to pass on touches anyway. |
389 | // if prim touched is the root prim as we just did it | ||
390 | if (((part.ScriptEvents & scriptEvents.touch) == 0) || | 386 | if (((part.ScriptEvents & scriptEvents.touch) == 0) || |
391 | (part.PassTouches && (part.LocalId != group.RootPart.LocalId))) | 387 | (part.PassTouches && (part.LocalId != group.RootPart.LocalId))) |
392 | { | 388 | { |
@@ -400,18 +396,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
400 | if (part == null) | 396 | if (part == null) |
401 | return; | 397 | return; |
402 | 398 | ||
403 | SceneObjectGroup obj = part.ParentGroup; | 399 | SceneObjectGroup grp = part.ParentGroup; |
404 | 400 | ||
405 | SurfaceTouchEventArgs surfaceArg = null; | 401 | SurfaceTouchEventArgs surfaceArg = null; |
406 | if (surfaceArgs != null && surfaceArgs.Count > 0) | 402 | if (surfaceArgs != null && surfaceArgs.Count > 0) |
407 | surfaceArg = surfaceArgs[0]; | 403 | surfaceArg = surfaceArgs[0]; |
408 | 404 | ||
409 | // If the touched prim handles touches, deliver it | 405 | // If the touched prim handles touches, deliver it |
410 | // If not, deliver to root prim | ||
411 | if ((part.ScriptEvents & scriptEvents.touch_end) != 0) | 406 | if ((part.ScriptEvents & scriptEvents.touch_end) != 0) |
412 | EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg); | 407 | EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg); |
413 | else | 408 | // if not or PassTouchs, send it also to root. |
414 | EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); | 409 | if (((part.ScriptEvents & scriptEvents.touch_end) == 0) || |
410 | (part.PassTouches && (part.LocalId != grp.RootPart.LocalId))) | ||
411 | { | ||
412 | EventManager.TriggerObjectDeGrab(grp.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); | ||
413 | } | ||
415 | } | 414 | } |
416 | 415 | ||
417 | public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, | 416 | public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b7c5b6b..00951d6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -79,7 +79,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
79 | touch_end = 536870912, | 79 | touch_end = 536870912, |
80 | touch_start = 2097152, | 80 | touch_start = 2097152, |
81 | transaction_result = 33554432, | 81 | transaction_result = 33554432, |
82 | object_rez = 4194304 | 82 | object_rez = 4194304, |
83 | anytouch = touch | touch_end | touch_start | ||
83 | } | 84 | } |
84 | 85 | ||
85 | public struct scriptPosTarget | 86 | public struct scriptPosTarget |
@@ -3497,34 +3498,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3497 | { | 3498 | { |
3498 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3499 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
3499 | { | 3500 | { |
3501 | if (BlockGrabOverride) | ||
3502 | return; | ||
3503 | |||
3500 | SceneObjectPart part = GetPart(partID); | 3504 | SceneObjectPart part = GetPart(partID); |
3501 | 3505 | ||
3502 | if (part == null) | 3506 | if (part == null) |
3503 | return; | 3507 | return; |
3504 | 3508 | ||
3509 | if (part.BlockGrab) | ||
3510 | return; | ||
3511 | |||
3505 | PhysicsActor pa = m_rootPart.PhysActor; | 3512 | PhysicsActor pa = m_rootPart.PhysActor; |
3506 | 3513 | ||
3507 | if (pa != null) | 3514 | if (pa != null && pa.IsPhysical) |
3508 | { | 3515 | { |
3509 | if (pa.IsPhysical) | 3516 | // empirically convert distance diference to a impulse |
3510 | { | 3517 | Vector3 grabforce = pos - AbsolutePosition; |
3511 | if (!BlockGrabOverride && !part.BlockGrab) | 3518 | grabforce = grabforce * (pa.Mass * 0.1f); |
3512 | { | 3519 | pa.AddForce(grabforce, false); |
3513 | /* Vector3 llmoveforce = pos - AbsolutePosition; | 3520 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
3514 | Vector3 grabforce = llmoveforce; | ||
3515 | grabforce = (grabforce / 10) * pa.Mass; | ||
3516 | */ | ||
3517 | // empirically convert distance diference to a impulse | ||
3518 | Vector3 grabforce = pos - AbsolutePosition; | ||
3519 | grabforce = grabforce * (pa.Mass/ 10.0f); | ||
3520 | pa.AddForce(grabforce, false); | ||
3521 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
3522 | } | ||
3523 | } | ||
3524 | else | ||
3525 | { | ||
3526 | NonPhysicalGrabMovement(pos); | ||
3527 | } | ||
3528 | } | 3521 | } |
3529 | else | 3522 | else |
3530 | { | 3523 | { |
@@ -3553,6 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3553 | /// <param name="remoteClient"></param> | 3546 | /// <param name="remoteClient"></param> |
3554 | public void SpinStart(IClientAPI remoteClient) | 3547 | public void SpinStart(IClientAPI remoteClient) |
3555 | { | 3548 | { |
3549 | if (BlockGrabOverride || m_rootPart.BlockGrab) | ||
3550 | return; | ||
3556 | if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) | 3551 | if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) |
3557 | { | 3552 | { |
3558 | PhysicsActor pa = m_rootPart.PhysActor; | 3553 | PhysicsActor pa = m_rootPart.PhysActor; |
@@ -3600,46 +3595,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
3600 | // but it will result in over-shoot or under-shoot of the target orientation. | 3595 | // but it will result in over-shoot or under-shoot of the target orientation. |
3601 | // For the end user, this means that ctrl+shift+drag can be used for relative, | 3596 | // For the end user, this means that ctrl+shift+drag can be used for relative, |
3602 | // but not absolute, adjustments of orientation for physical prims. | 3597 | // but not absolute, adjustments of orientation for physical prims. |
3598 | |||
3599 | if (BlockGrabOverride || m_rootPart.BlockGrab) | ||
3600 | return; | ||
3601 | |||
3603 | if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) | 3602 | if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) |
3604 | { | 3603 | { |
3605 | PhysicsActor pa = m_rootPart.PhysActor; | 3604 | PhysicsActor pa = m_rootPart.PhysActor; |
3606 | 3605 | ||
3607 | if (pa != null) | 3606 | if (pa != null && pa.IsPhysical) |
3608 | { | 3607 | { |
3609 | if (pa.IsPhysical) | 3608 | if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) |
3610 | { | 3609 | { |
3611 | if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) | 3610 | // first time initialization of "old" orientation for calculation of delta rotations |
3612 | { | 3611 | m_rootPart.SpinOldOrientation = newOrientation; |
3613 | // first time initialization of "old" orientation for calculation of delta rotations | 3612 | m_rootPart.IsWaitingForFirstSpinUpdatePacket = false; |
3614 | m_rootPart.SpinOldOrientation = newOrientation; | ||
3615 | m_rootPart.IsWaitingForFirstSpinUpdatePacket = false; | ||
3616 | } | ||
3617 | else | ||
3618 | { | ||
3619 | // save and update old orientation | ||
3620 | Quaternion old = m_rootPart.SpinOldOrientation; | ||
3621 | m_rootPart.SpinOldOrientation = newOrientation; | ||
3622 | //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); | ||
3623 | //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); | ||
3624 | |||
3625 | // compute difference between previous old rotation and new incoming rotation | ||
3626 | Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; | ||
3627 | |||
3628 | float rotationAngle; | ||
3629 | Vector3 rotationAxis; | ||
3630 | minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); | ||
3631 | rotationAxis.Normalize(); | ||
3632 | |||
3633 | //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); | ||
3634 | Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); | ||
3635 | spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor | ||
3636 | pa.AddAngularForce(spinforce,true); | ||
3637 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
3638 | } | ||
3639 | } | 3613 | } |
3640 | else | 3614 | else |
3641 | { | 3615 | { |
3642 | NonPhysicalSpinMovement(newOrientation); | 3616 | // save and update old orientation |
3617 | Quaternion old = m_rootPart.SpinOldOrientation; | ||
3618 | m_rootPart.SpinOldOrientation = newOrientation; | ||
3619 | //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old); | ||
3620 | //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation); | ||
3621 | |||
3622 | // compute difference between previous old rotation and new incoming rotation | ||
3623 | Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation; | ||
3624 | |||
3625 | float rotationAngle; | ||
3626 | Vector3 rotationAxis; | ||
3627 | minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle); | ||
3628 | rotationAxis.Normalize(); | ||
3629 | |||
3630 | //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); | ||
3631 | Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); | ||
3632 | spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor | ||
3633 | pa.AddAngularForce(spinforce,true); | ||
3634 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
3643 | } | 3635 | } |
3644 | } | 3636 | } |
3645 | else | 3637 | else |