diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 148 |
1 files changed, 75 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3cf7b2a..f1d0926 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1336,7 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1336 | PhysicsActor actor = PhysicsActor; | 1336 | PhysicsActor actor = PhysicsActor; |
1337 | if (actor == null) | 1337 | if (actor == null) |
1338 | { | 1338 | { |
1339 | SafeSendControlsToScripts(flagsForScripts); | 1339 | SendControlsToScripts(flagsForScripts); |
1340 | return; | 1340 | return; |
1341 | } | 1341 | } |
1342 | 1342 | ||
@@ -1513,25 +1513,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1513 | if (update_movementflag && ParentID == 0) | 1513 | if (update_movementflag && ParentID == 0) |
1514 | Animator.UpdateMovementAnimations(); | 1514 | Animator.UpdateMovementAnimations(); |
1515 | 1515 | ||
1516 | SafeSendControlsToScripts(flagsForScripts); | 1516 | SendControlsToScripts(flagsForScripts); |
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | m_scene.EventManager.TriggerOnClientMovement(this); | 1519 | m_scene.EventManager.TriggerOnClientMovement(this); |
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | private void SafeSendControlsToScripts(uint flagsForScripts) | ||
1523 | { | ||
1524 | lock (scriptedcontrols) | ||
1525 | { | ||
1526 | if (scriptedcontrols.Count > 0) | ||
1527 | { | ||
1528 | // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script | ||
1529 | // (e.g., a walking script) checks which animation is active it will be the correct animation. | ||
1530 | SendControlToScripts(flagsForScripts); | ||
1531 | } | ||
1532 | } | ||
1533 | } | ||
1534 | |||
1535 | /// <summary> | 1522 | /// <summary> |
1536 | /// Calculate an update to move the presence to the set target. | 1523 | /// Calculate an update to move the presence to the set target. |
1537 | /// </summary> | 1524 | /// </summary> |
@@ -3687,77 +3674,92 @@ namespace OpenSim.Region.Framework.Scenes | |||
3687 | } | 3674 | } |
3688 | } | 3675 | } |
3689 | 3676 | ||
3690 | internal void SendControlToScripts(uint flags) | 3677 | private void SendControlsToScripts(uint flags) |
3691 | { | 3678 | { |
3692 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; | 3679 | // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script |
3693 | 3680 | // (e.g., a walking script) checks which animation is active it will be the correct animation. | |
3694 | if (MouseDown) | 3681 | lock (scriptedcontrols) |
3695 | { | 3682 | { |
3696 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); | 3683 | if (scriptedcontrols.Count <= 0) |
3697 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) | 3684 | return; |
3685 | |||
3686 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; | ||
3687 | |||
3688 | if (MouseDown) | ||
3698 | { | 3689 | { |
3699 | allflags = ScriptControlled.CONTROL_ZERO; | 3690 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); |
3691 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) | ||
3692 | { | ||
3693 | allflags = ScriptControlled.CONTROL_ZERO; | ||
3694 | MouseDown = true; | ||
3695 | } | ||
3696 | } | ||
3697 | |||
3698 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) | ||
3699 | { | ||
3700 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; | ||
3700 | MouseDown = true; | 3701 | MouseDown = true; |
3701 | } | 3702 | } |
3702 | } | 3703 | |
3704 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) | ||
3705 | { | ||
3706 | allflags |= ScriptControlled.CONTROL_LBUTTON; | ||
3707 | MouseDown = true; | ||
3708 | } | ||
3709 | |||
3710 | // find all activated controls, whether the scripts are interested in them or not | ||
3711 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) | ||
3712 | { | ||
3713 | allflags |= ScriptControlled.CONTROL_FWD; | ||
3714 | } | ||
3715 | |||
3716 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) | ||
3717 | { | ||
3718 | allflags |= ScriptControlled.CONTROL_BACK; | ||
3719 | } | ||
3720 | |||
3721 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) | ||
3722 | { | ||
3723 | allflags |= ScriptControlled.CONTROL_UP; | ||
3724 | } | ||
3725 | |||
3726 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) | ||
3727 | { | ||
3728 | allflags |= ScriptControlled.CONTROL_DOWN; | ||
3729 | } | ||
3703 | 3730 | ||
3704 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) | 3731 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) |
3705 | { | 3732 | { |
3706 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; | 3733 | allflags |= ScriptControlled.CONTROL_LEFT; |
3707 | MouseDown = true; | 3734 | } |
3708 | } | 3735 | |
3709 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) | 3736 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) |
3710 | { | 3737 | { |
3711 | allflags |= ScriptControlled.CONTROL_LBUTTON; | 3738 | allflags |= ScriptControlled.CONTROL_RIGHT; |
3712 | MouseDown = true; | 3739 | } |
3713 | } | 3740 | |
3741 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | ||
3742 | { | ||
3743 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; | ||
3744 | } | ||
3745 | |||
3746 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | ||
3747 | { | ||
3748 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; | ||
3749 | } | ||
3714 | 3750 | ||
3715 | // find all activated controls, whether the scripts are interested in them or not | 3751 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that |
3716 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) | 3752 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) |
3717 | { | ||
3718 | allflags |= ScriptControlled.CONTROL_FWD; | ||
3719 | } | ||
3720 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) | ||
3721 | { | ||
3722 | allflags |= ScriptControlled.CONTROL_BACK; | ||
3723 | } | ||
3724 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) | ||
3725 | { | ||
3726 | allflags |= ScriptControlled.CONTROL_UP; | ||
3727 | } | ||
3728 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) | ||
3729 | { | ||
3730 | allflags |= ScriptControlled.CONTROL_DOWN; | ||
3731 | } | ||
3732 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) | ||
3733 | { | ||
3734 | allflags |= ScriptControlled.CONTROL_LEFT; | ||
3735 | } | ||
3736 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) | ||
3737 | { | ||
3738 | allflags |= ScriptControlled.CONTROL_RIGHT; | ||
3739 | } | ||
3740 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | ||
3741 | { | ||
3742 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; | ||
3743 | } | ||
3744 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | ||
3745 | { | ||
3746 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; | ||
3747 | } | ||
3748 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that | ||
3749 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) | ||
3750 | { | ||
3751 | lock (scriptedcontrols) | ||
3752 | { | 3753 | { |
3753 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) | 3754 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) |
3754 | { | 3755 | { |
3755 | UUID scriptUUID = kvp.Key; | 3756 | UUID scriptUUID = kvp.Key; |
3756 | ScriptControllers scriptControlData = kvp.Value; | 3757 | ScriptControllers scriptControlData = kvp.Value; |
3757 | 3758 | ||
3758 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us | 3759 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us |
3759 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle | 3760 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle |
3760 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits | 3761 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits |
3762 | |||
3761 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) | 3763 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) |
3762 | { | 3764 | { |
3763 | // only send if still pressed or just changed | 3765 | // only send if still pressed or just changed |
@@ -3765,9 +3767,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3765 | } | 3767 | } |
3766 | } | 3768 | } |
3767 | } | 3769 | } |
3770 | |||
3771 | LastCommands = allflags; | ||
3768 | } | 3772 | } |
3769 | |||
3770 | LastCommands = allflags; | ||
3771 | } | 3773 | } |
3772 | 3774 | ||
3773 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) | 3775 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) |