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.cs243
1 files changed, 152 insertions, 91 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 80f21ce..35c920b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -45,6 +45,7 @@ using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
45 45
46namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
47{ 47{
48 [Flags]
48 enum ScriptControlled : uint 49 enum ScriptControlled : uint
49 { 50 {
50 CONTROL_ZERO = 0, 51 CONTROL_ZERO = 0,
@@ -1065,19 +1066,7 @@ namespace OpenSim.Region.Framework.Scenes
1065 /// <param name="pos"></param> 1066 /// <param name="pos"></param>
1066 public void Teleport(Vector3 pos) 1067 public void Teleport(Vector3 pos)
1067 { 1068 {
1068 bool isFlying = Flying; 1069 TeleportWithMomentum(pos, Vector3.Zero);
1069 RemoveFromPhysicalScene();
1070 Velocity = Vector3.Zero;
1071 CheckLandingPoint(ref pos);
1072 AbsolutePosition = pos;
1073 AddToPhysicalScene(isFlying);
1074
1075 SendTerseUpdateToAllClients();
1076 }
1077
1078 public void TeleportWithMomentum(Vector3 pos)
1079 {
1080 TeleportWithMomentum(pos, null);
1081 } 1070 }
1082 1071
1083 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1072 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
@@ -1264,7 +1253,10 @@ namespace OpenSim.Region.Framework.Scenes
1264 1253
1265 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1254 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1266 { 1255 {
1267 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1256 m_log.DebugFormat(
1257 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
1258 client.Name, client.AgentId, m_callbackURI);
1259
1268 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); 1260 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1269 m_callbackURI = null; 1261 m_callbackURI = null;
1270 } 1262 }
@@ -1339,7 +1331,7 @@ namespace OpenSim.Region.Framework.Scenes
1339 { 1331 {
1340// m_log.DebugFormat( 1332// m_log.DebugFormat(
1341// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1333// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1342// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); 1334// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1343 1335
1344 if (IsChildAgent) 1336 if (IsChildAgent)
1345 { 1337 {
@@ -1449,14 +1441,8 @@ namespace OpenSim.Region.Framework.Scenes
1449 } 1441 }
1450 } 1442 }
1451 1443
1452 lock (scriptedcontrols) 1444 uint flagsForScripts = (uint)flags;
1453 { 1445 flags = RemoveIgnoredControls(flags, IgnoredControls);
1454 if (scriptedcontrols.Count > 0)
1455 {
1456 SendControlToScripts((uint)flags);
1457 flags = RemoveIgnoredControls(flags, IgnoredControls);
1458 }
1459 }
1460 1446
1461 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) 1447 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
1462 HandleAgentSitOnGround(); 1448 HandleAgentSitOnGround();
@@ -1470,6 +1456,7 @@ namespace OpenSim.Region.Framework.Scenes
1470 PhysicsActor actor = PhysicsActor; 1456 PhysicsActor actor = PhysicsActor;
1471 if (actor == null) 1457 if (actor == null)
1472 { 1458 {
1459 SendControlsToScripts(flagsForScripts);
1473 return; 1460 return;
1474 } 1461 }
1475 1462
@@ -1549,7 +1536,7 @@ namespace OpenSim.Region.Framework.Scenes
1549 MovementFlag |= (byte)nudgehack; 1536 MovementFlag |= (byte)nudgehack;
1550 } 1537 }
1551 1538
1552// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 1539 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1553 MovementFlag += (byte)(uint)DCF; 1540 MovementFlag += (byte)(uint)DCF;
1554 update_movementflag = true; 1541 update_movementflag = true;
1555 } 1542 }
@@ -1562,7 +1549,7 @@ namespace OpenSim.Region.Framework.Scenes
1562 && ((MovementFlag & (byte)nudgehack) == nudgehack)) 1549 && ((MovementFlag & (byte)nudgehack) == nudgehack))
1563 ) // This or is for Nudge forward 1550 ) // This or is for Nudge forward
1564 { 1551 {
1565// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 1552 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
1566 MovementFlag -= ((byte)(uint)DCF); 1553 MovementFlag -= ((byte)(uint)DCF);
1567 update_movementflag = true; 1554 update_movementflag = true;
1568 1555
@@ -1643,8 +1630,10 @@ namespace OpenSim.Region.Framework.Scenes
1643// } 1630// }
1644// } 1631// }
1645 1632
1646// if (update_movementflag && ParentID == 0) 1633 if (update_movementflag && ParentID == 0)
1647// Animator.UpdateMovementAnimations(); 1634 Animator.UpdateMovementAnimations();
1635
1636 SendControlsToScripts(flagsForScripts);
1648 } 1637 }
1649 1638
1650 m_scene.EventManager.TriggerOnClientMovement(this); 1639 m_scene.EventManager.TriggerOnClientMovement(this);
@@ -3060,8 +3049,8 @@ namespace OpenSim.Region.Framework.Scenes
3060 x = x / Constants.RegionSize; 3049 x = x / Constants.RegionSize;
3061 y = y / Constants.RegionSize; 3050 y = y / Constants.RegionSize;
3062 3051
3063 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3052// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3064 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3053// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3065 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) 3054 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3066 { 3055 {
3067 byebyeRegions.Add(handle); 3056 byebyeRegions.Add(handle);
@@ -3580,6 +3569,63 @@ namespace OpenSim.Region.Framework.Scenes
3580 return m_attachments.Count > 0; 3569 return m_attachments.Count > 0;
3581 } 3570 }
3582 3571
3572 /// <summary>
3573 /// Returns the total count of scripts in all parts inventories.
3574 /// </summary>
3575 public int ScriptCount()
3576 {
3577 int count = 0;
3578 lock (m_attachments)
3579 {
3580 foreach (SceneObjectGroup gobj in m_attachments)
3581 {
3582 if (gobj != null)
3583 {
3584 count += gobj.ScriptCount();
3585 }
3586 }
3587 }
3588 return count;
3589 }
3590
3591 /// <summary>
3592 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3593 /// </summary>
3594 public float ScriptExecutionTime()
3595 {
3596 float time = 0.0f;
3597 lock (m_attachments)
3598 {
3599 foreach (SceneObjectGroup gobj in m_attachments)
3600 {
3601 if (gobj != null)
3602 {
3603 time += gobj.ScriptExecutionTime();
3604 }
3605 }
3606 }
3607 return time;
3608 }
3609
3610 /// <summary>
3611 /// Returns the total count of running scripts in all parts.
3612 /// </summary>
3613 public int RunningScriptCount()
3614 {
3615 int count = 0;
3616 lock (m_attachments)
3617 {
3618 foreach (SceneObjectGroup gobj in m_attachments)
3619 {
3620 if (gobj != null)
3621 {
3622 count += gobj.RunningScriptCount();
3623 }
3624 }
3625 }
3626 return count;
3627 }
3628
3583 public bool HasScriptedAttachments() 3629 public bool HasScriptedAttachments()
3584 { 3630 {
3585 lock (m_attachments) 3631 lock (m_attachments)
@@ -3777,77 +3823,92 @@ namespace OpenSim.Region.Framework.Scenes
3777 } 3823 }
3778 } 3824 }
3779 3825
3780 internal void SendControlToScripts(uint flags) 3826 private void SendControlsToScripts(uint flags)
3781 { 3827 {
3782 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3828 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3783 3829 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3784 if (MouseDown) 3830 lock (scriptedcontrols)
3785 { 3831 {
3786 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3832 if (scriptedcontrols.Count <= 0)
3787 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)
3838 {
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)
3788 { 3848 {
3789 allflags = ScriptControlled.CONTROL_ZERO; 3849 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3790 MouseDown = true; 3850 MouseDown = true;
3791 } 3851 }
3792 } 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 }
3793 3879
3794 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)
3795 { 3881 {
3796 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 3882 allflags |= ScriptControlled.CONTROL_LEFT;
3797 MouseDown = true; 3883 }
3798 } 3884
3799 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)
3800 { 3886 {
3801 allflags |= ScriptControlled.CONTROL_LBUTTON; 3887 allflags |= ScriptControlled.CONTROL_RIGHT;
3802 MouseDown = true; 3888 }
3803 } 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 }
3804 3899
3805 // 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
3806 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)
3807 {
3808 allflags |= ScriptControlled.CONTROL_FWD;
3809 }
3810 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3811 {
3812 allflags |= ScriptControlled.CONTROL_BACK;
3813 }
3814 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3815 {
3816 allflags |= ScriptControlled.CONTROL_UP;
3817 }
3818 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3819 {
3820 allflags |= ScriptControlled.CONTROL_DOWN;
3821 }
3822 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3823 {
3824 allflags |= ScriptControlled.CONTROL_LEFT;
3825 }
3826 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3827 {
3828 allflags |= ScriptControlled.CONTROL_RIGHT;
3829 }
3830 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3831 {
3832 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3833 }
3834 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3835 {
3836 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3837 }
3838 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3839 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3840 {
3841 lock (scriptedcontrols)
3842 { 3902 {
3843 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 3903 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3844 { 3904 {
3845 UUID scriptUUID = kvp.Key; 3905 UUID scriptUUID = kvp.Key;
3846 ScriptControllers scriptControlData = kvp.Value; 3906 ScriptControllers scriptControlData = kvp.Value;
3847 3907
3848 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 3908 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3849 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
3850 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 3910 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
3911
3851 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 3912 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3852 { 3913 {
3853 // only send if still pressed or just changed 3914 // only send if still pressed or just changed
@@ -3855,9 +3916,9 @@ namespace OpenSim.Region.Framework.Scenes
3855 } 3916 }
3856 } 3917 }
3857 } 3918 }
3919
3920 LastCommands = allflags;
3858 } 3921 }
3859
3860 LastCommands = allflags;
3861 } 3922 }
3862 3923
3863 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 3924 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
@@ -3937,7 +3998,7 @@ namespace OpenSim.Region.Framework.Scenes
3937 land.LandData.UserLocation != Vector3.Zero && 3998 land.LandData.UserLocation != Vector3.Zero &&
3938 land.LandData.OwnerID != m_uuid && 3999 land.LandData.OwnerID != m_uuid &&
3939 (!m_scene.Permissions.IsGod(m_uuid)) && 4000 (!m_scene.Permissions.IsGod(m_uuid)) &&
3940 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) 4001 (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)))
3941 { 4002 {
3942 float curr = Vector3.Distance(AbsolutePosition, pos); 4003 float curr = Vector3.Distance(AbsolutePosition, pos);
3943 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) 4004 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
@@ -3957,7 +4018,7 @@ namespace OpenSim.Region.Framework.Scenes
3957 { 4018 {
3958 if (GodLevel < 200 && 4019 if (GodLevel < 200 &&
3959 ((!m_scene.Permissions.IsGod(m_uuid) && 4020 ((!m_scene.Permissions.IsGod(m_uuid) &&
3960 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4021 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
3961 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4022 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
3962 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4023 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
3963 { 4024 {
@@ -4031,7 +4092,7 @@ namespace OpenSim.Region.Framework.Scenes
4031 GodLevel < 200 && 4092 GodLevel < 200 &&
4032 ((land.LandData.OwnerID != m_uuid && 4093 ((land.LandData.OwnerID != m_uuid &&
4033 !m_scene.Permissions.IsGod(m_uuid) && 4094 !m_scene.Permissions.IsGod(m_uuid) &&
4034 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4095 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4035 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4096 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4036 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4097 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4037 { 4098 {