aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs142
1 files changed, 75 insertions, 67 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1e717d9..3452f90 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1456,6 +1456,7 @@ namespace OpenSim.Region.Framework.Scenes
1456 PhysicsActor actor = PhysicsActor; 1456 PhysicsActor actor = PhysicsActor;
1457 if (actor == null) 1457 if (actor == null)
1458 { 1458 {
1459 SendControlsToScripts(flagsForScripts);
1459 return; 1460 return;
1460 } 1461 }
1461 1462
@@ -1632,15 +1633,7 @@ namespace OpenSim.Region.Framework.Scenes
1632 if (update_movementflag && ParentID == 0) 1633 if (update_movementflag && ParentID == 0)
1633 Animator.UpdateMovementAnimations(); 1634 Animator.UpdateMovementAnimations();
1634 1635
1635 lock (scriptedcontrols) 1636 SendControlsToScripts(flagsForScripts);
1636 {
1637 if (scriptedcontrols.Count > 0)
1638 {
1639 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
1640 // (e.g., a walking script) checks which animation is active it will be the correct animation.
1641 SendControlToScripts(flagsForScripts);
1642 }
1643 }
1644 } 1637 }
1645 1638
1646 m_scene.EventManager.TriggerOnClientMovement(this); 1639 m_scene.EventManager.TriggerOnClientMovement(this);
@@ -3830,77 +3823,92 @@ namespace OpenSim.Region.Framework.Scenes
3830 } 3823 }
3831 } 3824 }
3832 3825
3833 internal void SendControlToScripts(uint flags) 3826 private void SendControlsToScripts(uint flags)
3834 { 3827 {
3835 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3828 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3836 3829 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3837 if (MouseDown) 3830 lock (scriptedcontrols)
3838 { 3831 {
3839 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3832 if (scriptedcontrols.Count <= 0)
3840 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) 3833 return;
3834
3835 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
3836
3837 if (MouseDown)
3841 { 3838 {
3842 allflags = ScriptControlled.CONTROL_ZERO; 3839 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
3840 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
3841 {
3842 allflags = ScriptControlled.CONTROL_ZERO;
3843 MouseDown = true;
3844 }
3845 }
3846
3847 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
3848 {
3849 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3843 MouseDown = true; 3850 MouseDown = true;
3844 } 3851 }
3845 } 3852
3853 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
3854 {
3855 allflags |= ScriptControlled.CONTROL_LBUTTON;
3856 MouseDown = true;
3857 }
3858
3859 // find all activated controls, whether the scripts are interested in them or not
3860 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
3861 {
3862 allflags |= ScriptControlled.CONTROL_FWD;
3863 }
3864
3865 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3866 {
3867 allflags |= ScriptControlled.CONTROL_BACK;
3868 }
3869
3870 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3871 {
3872 allflags |= ScriptControlled.CONTROL_UP;
3873 }
3874
3875 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3876 {
3877 allflags |= ScriptControlled.CONTROL_DOWN;
3878 }
3846 3879
3847 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) 3880 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3848 { 3881 {
3849 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 3882 allflags |= ScriptControlled.CONTROL_LEFT;
3850 MouseDown = true; 3883 }
3851 } 3884
3852 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) 3885 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3853 { 3886 {
3854 allflags |= ScriptControlled.CONTROL_LBUTTON; 3887 allflags |= ScriptControlled.CONTROL_RIGHT;
3855 MouseDown = true; 3888 }
3856 } 3889
3890 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3891 {
3892 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3893 }
3894
3895 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3896 {
3897 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3898 }
3857 3899
3858 // find all activated controls, whether the scripts are interested in them or not 3900 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3859 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 3901 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3860 {
3861 allflags |= ScriptControlled.CONTROL_FWD;
3862 }
3863 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3864 {
3865 allflags |= ScriptControlled.CONTROL_BACK;
3866 }
3867 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3868 {
3869 allflags |= ScriptControlled.CONTROL_UP;
3870 }
3871 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3872 {
3873 allflags |= ScriptControlled.CONTROL_DOWN;
3874 }
3875 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3876 {
3877 allflags |= ScriptControlled.CONTROL_LEFT;
3878 }
3879 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3880 {
3881 allflags |= ScriptControlled.CONTROL_RIGHT;
3882 }
3883 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3884 {
3885 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3886 }
3887 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3888 {
3889 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3890 }
3891 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3892 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3893 {
3894 lock (scriptedcontrols)
3895 { 3902 {
3896 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 3903 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3897 { 3904 {
3898 UUID scriptUUID = kvp.Key; 3905 UUID scriptUUID = kvp.Key;
3899 ScriptControllers scriptControlData = kvp.Value; 3906 ScriptControllers scriptControlData = kvp.Value;
3900 3907
3901 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 3908 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3902 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle 3909 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
3903 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 3910 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
3911
3904 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 3912 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3905 { 3913 {
3906 // only send if still pressed or just changed 3914 // only send if still pressed or just changed
@@ -3908,9 +3916,9 @@ namespace OpenSim.Region.Framework.Scenes
3908 } 3916 }
3909 } 3917 }
3910 } 3918 }
3919
3920 LastCommands = allflags;
3911 } 3921 }
3912
3913 LastCommands = allflags;
3914 } 3922 }
3915 3923
3916 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 3924 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)