diff options
author | UbitUmarov | 2019-11-27 16:44:45 +0000 |
---|---|---|
committer | UbitUmarov | 2019-11-27 16:44:45 +0000 |
commit | 5c5e4bd8304dbb607a4008ec41ecacf716cfd0db (patch) | |
tree | 105c8b5292c17521803869bc94324ef626b780f8 /OpenSim/Region/Framework/Scenes | |
parent | and yes mono-addins .... (diff) | |
download | opensim-SC-5c5e4bd8304dbb607a4008ec41ecacf716cfd0db.zip opensim-SC-5c5e4bd8304dbb607a4008ec41ecacf716cfd0db.tar.gz opensim-SC-5c5e4bd8304dbb607a4008ec41ecacf716cfd0db.tar.bz2 opensim-SC-5c5e4bd8304dbb607a4008ec41ecacf716cfd0db.tar.xz |
a few changes on check targets for lsl
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneBase.cs | 18 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 193 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 |
4 files changed, 111 insertions, 122 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a0a2882..0c5007a 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -410,7 +410,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
410 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 410 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
411 | private volatile bool m_backingup; | 411 | private volatile bool m_backingup; |
412 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 412 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
413 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); | 413 | private HashSet<UUID> m_groupsWithTargets = new HashSet<UUID>(); |
414 | 414 | ||
415 | private string m_defaultScriptEngine; | 415 | private string m_defaultScriptEngine; |
416 | 416 | ||
@@ -837,7 +837,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
837 | 837 | ||
838 | Random random = new Random(); | 838 | Random random = new Random(); |
839 | 839 | ||
840 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4); | 840 | m_lastAllocatedLocalId = (int)(random.NextDouble() * (uint.MaxValue / 4)); |
841 | m_lastAllocatedIntId = (int)(random.NextDouble() * (int.MaxValue / 4)); | ||
841 | m_authenticateHandler = authen; | 842 | m_authenticateHandler = authen; |
842 | m_sceneGridService = new SceneCommunicationService(); | 843 | m_sceneGridService = new SceneCommunicationService(); |
843 | m_SimulationDataService = simDataService; | 844 | m_SimulationDataService = simDataService; |
@@ -1633,7 +1634,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1633 | 1634 | ||
1634 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1635 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1635 | 1636 | ||
1636 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0f; | 1637 | otherMS = agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0f; |
1637 | 1638 | ||
1638 | try | 1639 | try |
1639 | { | 1640 | { |
@@ -1713,6 +1714,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1713 | if (Frame % m_update_objects == 0) | 1714 | if (Frame % m_update_objects == 0) |
1714 | m_sceneGraph.UpdateObjectGroups(); | 1715 | m_sceneGraph.UpdateObjectGroups(); |
1715 | 1716 | ||
1717 | tmpMS2 = Util.GetTimeStampMS(); | ||
1718 | otherMS = (float)(tmpMS2 - tmpMS); | ||
1719 | tmpMS = tmpMS2; | ||
1720 | |||
1716 | // Run through all ScenePresences looking for updates | 1721 | // Run through all ScenePresences looking for updates |
1717 | // Presence updates and queued object updates for each presence are sent to clients | 1722 | // Presence updates and queued object updates for each presence are sent to clients |
1718 | if (Frame % m_update_presences == 0) | 1723 | if (Frame % m_update_presences == 0) |
@@ -1828,7 +1833,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1828 | m_firstHeartbeat = false; | 1833 | m_firstHeartbeat = false; |
1829 | Watchdog.UpdateThread(); | 1834 | Watchdog.UpdateThread(); |
1830 | 1835 | ||
1831 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1836 | otherMS += tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
1832 | 1837 | ||
1833 | tmpMS = Util.GetTimeStampMS(); | 1838 | tmpMS = Util.GetTimeStampMS(); |
1834 | 1839 | ||
@@ -1912,7 +1917,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1912 | public void AddGroupTarget(SceneObjectGroup grp) | 1917 | public void AddGroupTarget(SceneObjectGroup grp) |
1913 | { | 1918 | { |
1914 | lock (m_groupsWithTargets) | 1919 | lock (m_groupsWithTargets) |
1915 | m_groupsWithTargets[grp.UUID] = 0; | 1920 | m_groupsWithTargets.Add(grp.UUID); |
1916 | } | 1921 | } |
1917 | 1922 | ||
1918 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1923 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1928,13 +1933,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1928 | lock (m_groupsWithTargets) | 1933 | lock (m_groupsWithTargets) |
1929 | { | 1934 | { |
1930 | if (m_groupsWithTargets.Count != 0) | 1935 | if (m_groupsWithTargets.Count != 0) |
1931 | objs = new List<UUID>(m_groupsWithTargets.Keys); | 1936 | objs = new List<UUID>(m_groupsWithTargets); |
1932 | } | 1937 | } |
1933 | 1938 | ||
1934 | if (objs != null) | 1939 | if (objs != null) |
1935 | { | 1940 | { |
1936 | foreach (UUID entry in objs) | 1941 | for(int i = 0; i< objs.Count; ++i) |
1937 | { | 1942 | { |
1943 | UUID entry = objs[i]; | ||
1938 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | 1944 | SceneObjectGroup grp = GetSceneObjectGroup(entry); |
1939 | if (grp == null) | 1945 | if (grp == null) |
1940 | m_groupsWithTargets.Remove(entry); | 1946 | m_groupsWithTargets.Remove(entry); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index e3e54e2..a3c8112 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -105,9 +105,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
105 | /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is | 105 | /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is |
106 | /// dispensed. | 106 | /// dispensed. |
107 | /// </summary> | 107 | /// </summary> |
108 | protected uint m_lastAllocatedLocalId = 720000; | 108 | protected int m_lastAllocatedLocalId = 720000; |
109 | 109 | protected int m_lastAllocatedIntId = 7200; | |
110 | private readonly Mutex _primAllocateMutex = new Mutex(false); | ||
111 | 110 | ||
112 | protected readonly ClientManager m_clientManager = new ClientManager(); | 111 | protected readonly ClientManager m_clientManager = new ClientManager(); |
113 | 112 | ||
@@ -299,15 +298,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
299 | /// <returns>A brand new local ID</returns> | 298 | /// <returns>A brand new local ID</returns> |
300 | public uint AllocateLocalId() | 299 | public uint AllocateLocalId() |
301 | { | 300 | { |
302 | uint myID; | 301 | return (uint)Interlocked.Increment(ref m_lastAllocatedLocalId); |
303 | 302 | } | |
304 | _primAllocateMutex.WaitOne(); | ||
305 | myID = ++m_lastAllocatedLocalId; | ||
306 | _primAllocateMutex.ReleaseMutex(); | ||
307 | 303 | ||
308 | return myID; | 304 | public int AllocateIntId() |
305 | { | ||
306 | return Interlocked.Increment(ref m_lastAllocatedLocalId); | ||
309 | } | 307 | } |
310 | 308 | ||
309 | |||
310 | |||
311 | #region Module Methods | 311 | #region Module Methods |
312 | 312 | ||
313 | /// <summary> | 313 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 199aa92..ca37d08 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -87,14 +87,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
87 | { | 87 | { |
88 | public Vector3 targetPos; | 88 | public Vector3 targetPos; |
89 | public float tolerance; | 89 | public float tolerance; |
90 | public uint handle; | 90 | public int handle; |
91 | } | 91 | } |
92 | 92 | ||
93 | public struct scriptRotTarget | 93 | public struct scriptRotTarget |
94 | { | 94 | { |
95 | public Quaternion targetRot; | 95 | public Quaternion targetRot; |
96 | public float tolerance; | 96 | public float tolerance; |
97 | public uint handle; | 97 | public int handle; |
98 | } | 98 | } |
99 | 99 | ||
100 | public delegate void PrimCountTaintedDelegate(); | 100 | public delegate void PrimCountTaintedDelegate(); |
@@ -357,15 +357,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
357 | protected SceneObjectPart m_rootPart; | 357 | protected SceneObjectPart m_rootPart; |
358 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 358 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
359 | 359 | ||
360 | private SortedDictionary<uint, scriptPosTarget> m_targets = new SortedDictionary<uint, scriptPosTarget>(); | 360 | private SortedDictionary<int, scriptPosTarget> m_targets = new SortedDictionary<int, scriptPosTarget>(); |
361 | private SortedDictionary<uint, scriptRotTarget> m_rotTargets = new SortedDictionary<uint, scriptRotTarget>(); | 361 | private SortedDictionary<int, scriptRotTarget> m_rotTargets = new SortedDictionary<int, scriptRotTarget>(); |
362 | 362 | ||
363 | public SortedDictionary<uint, scriptPosTarget> AtTargets | 363 | public SortedDictionary<int, scriptPosTarget> AtTargets |
364 | { | 364 | { |
365 | get { return m_targets; } | 365 | get { return m_targets; } |
366 | } | 366 | } |
367 | 367 | ||
368 | public SortedDictionary<uint, scriptRotTarget> RotTargets | 368 | public SortedDictionary<int, scriptRotTarget> RotTargets |
369 | { | 369 | { |
370 | get { return m_rotTargets; } | 370 | get { return m_rotTargets; } |
371 | } | 371 | } |
@@ -2906,7 +2906,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2906 | { | 2906 | { |
2907 | // if (IsAttachment) | 2907 | // if (IsAttachment) |
2908 | // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); | 2908 | // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); |
2909 | checkAtTargets(); | ||
2910 | if (Scene.GetNumberOfClients() == 0) | 2909 | if (Scene.GetNumberOfClients() == 0) |
2911 | return; | 2910 | return; |
2912 | 2911 | ||
@@ -2925,8 +2924,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2925 | { | 2924 | { |
2926 | // if (IsAttachment) | 2925 | // if (IsAttachment) |
2927 | // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); | 2926 | // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); |
2928 | checkAtTargets(); | ||
2929 | |||
2930 | if (Scene.GetNumberOfClients() == 0) | 2927 | if (Scene.GetNumberOfClients() == 0) |
2931 | return; | 2928 | return; |
2932 | 2929 | ||
@@ -4809,7 +4806,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4809 | scriptRotTarget waypoint = new scriptRotTarget(); | 4806 | scriptRotTarget waypoint = new scriptRotTarget(); |
4810 | waypoint.targetRot = target; | 4807 | waypoint.targetRot = target; |
4811 | waypoint.tolerance = tolerance; | 4808 | waypoint.tolerance = tolerance; |
4812 | uint handle = m_scene.AllocateLocalId(); | 4809 | int handle = m_scene.AllocateIntId(); |
4813 | waypoint.handle = handle; | 4810 | waypoint.handle = handle; |
4814 | lock (m_rotTargets) | 4811 | lock (m_rotTargets) |
4815 | { | 4812 | { |
@@ -4818,14 +4815,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4818 | m_rotTargets.Add(handle, waypoint); | 4815 | m_rotTargets.Add(handle, waypoint); |
4819 | } | 4816 | } |
4820 | m_scene.AddGroupTarget(this); | 4817 | m_scene.AddGroupTarget(this); |
4821 | return (int)handle; | 4818 | return handle; |
4822 | } | 4819 | } |
4823 | 4820 | ||
4824 | public void unregisterRotTargetWaypoint(int handle) | 4821 | public void unregisterRotTargetWaypoint(int handle) |
4825 | { | 4822 | { |
4826 | lock (m_targets) | 4823 | lock (m_targets) |
4827 | { | 4824 | { |
4828 | m_rotTargets.Remove((uint)handle); | 4825 | m_rotTargets.Remove(handle); |
4829 | if (m_targets.Count == 0) | 4826 | if (m_targets.Count == 0) |
4830 | m_scene.RemoveGroupTarget(this); | 4827 | m_scene.RemoveGroupTarget(this); |
4831 | } | 4828 | } |
@@ -4836,7 +4833,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4836 | scriptPosTarget waypoint = new scriptPosTarget(); | 4833 | scriptPosTarget waypoint = new scriptPosTarget(); |
4837 | waypoint.targetPos = target; | 4834 | waypoint.targetPos = target; |
4838 | waypoint.tolerance = tolerance; | 4835 | waypoint.tolerance = tolerance; |
4839 | uint handle = m_scene.AllocateLocalId(); | 4836 | int handle = m_scene.AllocateIntId(); |
4840 | waypoint.handle = handle; | 4837 | waypoint.handle = handle; |
4841 | lock (m_targets) | 4838 | lock (m_targets) |
4842 | { | 4839 | { |
@@ -4852,7 +4849,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4852 | { | 4849 | { |
4853 | lock (m_targets) | 4850 | lock (m_targets) |
4854 | { | 4851 | { |
4855 | m_targets.Remove((uint)handle); | 4852 | m_targets.Remove(handle); |
4856 | if (m_targets.Count == 0) | 4853 | if (m_targets.Count == 0) |
4857 | m_scene.RemoveGroupTarget(this); | 4854 | m_scene.RemoveGroupTarget(this); |
4858 | } | 4855 | } |
@@ -4860,141 +4857,127 @@ namespace OpenSim.Region.Framework.Scenes | |||
4860 | 4857 | ||
4861 | public void checkAtTargets() | 4858 | public void checkAtTargets() |
4862 | { | 4859 | { |
4863 | if (m_scriptListens_atTarget || m_scriptListens_notAtTarget) | 4860 | if (m_targets.Count > 0 && (m_scriptListens_atTarget || m_scriptListens_notAtTarget)) |
4864 | { | 4861 | { |
4865 | if (m_targets.Count > 0) | 4862 | bool not_target = true; |
4863 | |||
4864 | List<scriptPosTarget> atTargets = new List<scriptPosTarget>(m_targets.Count); | ||
4865 | lock (m_targets) | ||
4866 | { | 4866 | { |
4867 | bool at_target = false; | 4867 | if (m_scriptListens_atTarget) |
4868 | //Vector3 targetPos; | ||
4869 | //uint targetHandle; | ||
4870 | Dictionary<uint, scriptPosTarget> atTargets = new Dictionary<uint, scriptPosTarget>(); | ||
4871 | lock (m_targets) | ||
4872 | { | 4868 | { |
4873 | foreach (uint idx in m_targets.Keys) | 4869 | foreach (scriptPosTarget target in m_targets.Values) |
4874 | { | 4870 | { |
4875 | scriptPosTarget target = m_targets[idx]; | ||
4876 | if (Vector3.DistanceSquared(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance * target.tolerance) | 4871 | if (Vector3.DistanceSquared(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance * target.tolerance) |
4877 | { | 4872 | { |
4878 | at_target = true; | 4873 | not_target = false; |
4879 | 4874 | atTargets.Add(target); | |
4880 | // trigger at_target | ||
4881 | if (m_scriptListens_atTarget) | ||
4882 | { | ||
4883 | scriptPosTarget att = new scriptPosTarget(); | ||
4884 | att.targetPos = target.targetPos; | ||
4885 | att.tolerance = target.tolerance; | ||
4886 | att.handle = target.handle; | ||
4887 | atTargets.Add(idx, att); | ||
4888 | } | ||
4889 | } | 4875 | } |
4890 | } | 4876 | } |
4891 | } | 4877 | } |
4892 | 4878 | else | |
4893 | if (atTargets.Count > 0) | ||
4894 | { | 4879 | { |
4895 | SceneObjectPart[] parts = m_parts.GetArray(); | 4880 | foreach (scriptPosTarget target in m_targets.Values) |
4896 | uint[] localids = new uint[parts.Length]; | ||
4897 | for (int i = 0; i < parts.Length; i++) | ||
4898 | localids[i] = parts[i].LocalId; | ||
4899 | |||
4900 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
4901 | { | 4881 | { |
4902 | foreach (uint target in atTargets.Keys) | 4882 | if (Vector3.DistanceSquared(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance * target.tolerance) |
4903 | { | 4883 | { |
4904 | scriptPosTarget att = atTargets[target]; | 4884 | not_target = false; |
4905 | m_scene.EventManager.TriggerAtTargetEvent( | 4885 | break; |
4906 | localids[ctr], att.handle, att.targetPos, m_rootPart.GroupPosition); | ||
4907 | } | 4886 | } |
4908 | } | 4887 | } |
4909 | |||
4910 | return; | ||
4911 | } | 4888 | } |
4889 | } | ||
4912 | 4890 | ||
4913 | if (m_scriptListens_notAtTarget && !at_target) | 4891 | if (atTargets.Count > 0) |
4892 | { | ||
4893 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4894 | for (int ctr = 0; ctr < parts.Length; ++ctr) | ||
4914 | { | 4895 | { |
4915 | //trigger not_at_target | 4896 | uint pid = parts[ctr].LocalId; |
4916 | SceneObjectPart[] parts = m_parts.GetArray(); | 4897 | for(int target = 0; target < atTargets.Count; ++target) |
4917 | uint[] localids = new uint[parts.Length]; | ||
4918 | for (int i = 0; i < parts.Length; i++) | ||
4919 | localids[i] = parts[i].LocalId; | ||
4920 | |||
4921 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
4922 | { | 4898 | { |
4923 | m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); | 4899 | scriptPosTarget att = atTargets[target]; |
4900 | m_scene.EventManager.TriggerAtTargetEvent( | ||
4901 | pid, (uint)att.handle, att.targetPos, m_rootPart.GroupPosition); | ||
4924 | } | 4902 | } |
4925 | } | 4903 | } |
4926 | } | 4904 | } |
4905 | |||
4906 | if (not_target && m_scriptListens_notAtTarget) | ||
4907 | { | ||
4908 | //trigger not_at_target | ||
4909 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4910 | for (int ctr = 0; ctr < parts.Length; ctr++) | ||
4911 | { | ||
4912 | m_scene.EventManager.TriggerNotAtTargetEvent(parts[ctr].LocalId); | ||
4913 | } | ||
4914 | } | ||
4927 | } | 4915 | } |
4928 | if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget) | 4916 | |
4917 | if (m_rotTargets.Count > 0 && (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget)) | ||
4929 | { | 4918 | { |
4930 | if (m_rotTargets.Count > 0) | 4919 | bool not_Rottarget = true; |
4920 | |||
4921 | List<scriptRotTarget> atRotTargets = new List<scriptRotTarget>(m_rotTargets.Count); | ||
4922 | lock (m_rotTargets) | ||
4931 | { | 4923 | { |
4932 | bool at_Rottarget = false; | 4924 | if (m_scriptListens_atRotTarget) |
4933 | Dictionary<uint, scriptRotTarget> atRotTargets = new Dictionary<uint, scriptRotTarget>(); | ||
4934 | lock (m_rotTargets) | ||
4935 | { | 4925 | { |
4936 | foreach (uint idx in m_rotTargets.Keys) | 4926 | foreach (scriptRotTarget target in m_rotTargets.Values) |
4937 | { | 4927 | { |
4938 | scriptRotTarget target = m_rotTargets[idx]; | 4928 | double angle = 2 * Math.Acos(Quaternion.Dot(target.targetRot, m_rootPart.RotationOffset)); |
4939 | double angle | 4929 | if (angle < 0) |
4940 | = Math.Acos( | 4930 | angle = -angle; |
4941 | target.targetRot.X * m_rootPart.RotationOffset.X | 4931 | if (angle > Math.PI) |
4942 | + target.targetRot.Y * m_rootPart.RotationOffset.Y | 4932 | angle = (2 * Math.PI - angle); |
4943 | + target.targetRot.Z * m_rootPart.RotationOffset.Z | ||
4944 | + target.targetRot.W * m_rootPart.RotationOffset.W) | ||
4945 | * 2; | ||
4946 | if (angle < 0) angle = -angle; | ||
4947 | if (angle > Math.PI) angle = (Math.PI * 2 - angle); | ||
4948 | if (angle <= target.tolerance) | 4933 | if (angle <= target.tolerance) |
4949 | { | 4934 | { |
4950 | // trigger at_rot_target | 4935 | // trigger at_rot_target |
4951 | if (m_scriptListens_atRotTarget) | 4936 | not_Rottarget = false; |
4952 | { | 4937 | atRotTargets.Add(target); |
4953 | at_Rottarget = true; | ||
4954 | scriptRotTarget att = new scriptRotTarget(); | ||
4955 | att.targetRot = target.targetRot; | ||
4956 | att.tolerance = target.tolerance; | ||
4957 | att.handle = target.handle; | ||
4958 | atRotTargets.Add(idx, att); | ||
4959 | } | ||
4960 | } | 4938 | } |
4961 | } | 4939 | } |
4962 | } | 4940 | } |
4963 | 4941 | else | |
4964 | if (atRotTargets.Count > 0) | ||
4965 | { | 4942 | { |
4966 | SceneObjectPart[] parts = m_parts.GetArray(); | 4943 | foreach (scriptRotTarget target in m_rotTargets.Values) |
4967 | uint[] localids = new uint[parts.Length]; | ||
4968 | for (int i = 0; i < parts.Length; i++) | ||
4969 | localids[i] = parts[i].LocalId; | ||
4970 | |||
4971 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
4972 | { | 4944 | { |
4973 | foreach (uint target in atRotTargets.Keys) | 4945 | double angle = 2 * Math.Acos(Quaternion.Dot(target.targetRot, m_rootPart.RotationOffset)); |
4946 | if (angle < 0) | ||
4947 | angle = -angle; | ||
4948 | if (angle > Math.PI) | ||
4949 | angle = (2 * Math.PI - angle); | ||
4950 | if (angle <= target.tolerance) | ||
4974 | { | 4951 | { |
4975 | scriptRotTarget att = atRotTargets[target]; | 4952 | not_Rottarget = false; |
4976 | m_scene.EventManager.TriggerAtRotTargetEvent( | 4953 | break; |
4977 | localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset); | ||
4978 | } | 4954 | } |
4979 | } | 4955 | } |
4980 | |||
4981 | return; | ||
4982 | } | 4956 | } |
4957 | } | ||
4983 | 4958 | ||
4984 | if (m_scriptListens_notAtRotTarget && !at_Rottarget) | 4959 | if (atRotTargets.Count > 0) |
4960 | { | ||
4961 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4962 | for (int ctr = 0; ctr < parts.Length; ++ctr) | ||
4985 | { | 4963 | { |
4986 | //trigger not_at_target | 4964 | uint pid = parts[ctr].LocalId; |
4987 | SceneObjectPart[] parts = m_parts.GetArray(); | 4965 | for (int target = 0; target < atRotTargets.Count; ++target) |
4988 | uint[] localids = new uint[parts.Length]; | ||
4989 | for (int i = 0; i < parts.Length; i++) | ||
4990 | localids[i] = parts[i].LocalId; | ||
4991 | |||
4992 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
4993 | { | 4966 | { |
4994 | m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]); | 4967 | scriptRotTarget att = atRotTargets[target]; |
4968 | m_scene.EventManager.TriggerAtRotTargetEvent( | ||
4969 | pid, (uint)att.handle, att.targetRot, m_rootPart.RotationOffset); | ||
4995 | } | 4970 | } |
4996 | } | 4971 | } |
4997 | } | 4972 | } |
4973 | |||
4974 | if (not_Rottarget && m_scriptListens_notAtRotTarget) | ||
4975 | { | ||
4976 | //trigger not_at_target | ||
4977 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4978 | for (int ctr = 0; ctr < parts.Length; ++ctr) | ||
4979 | m_scene.EventManager.TriggerNotAtRotTargetEvent(parts[ctr].LocalId); | ||
4980 | } | ||
4998 | } | 4981 | } |
4999 | } | 4982 | } |
5000 | 4983 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ec58b97..6cbdc43 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -3344,7 +3344,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3344 | private const float VELOCITY_TOLERANCE = 0.1f; | 3344 | private const float VELOCITY_TOLERANCE = 0.1f; |
3345 | private const float ANGVELOCITY_TOLERANCE = 0.005f; | 3345 | private const float ANGVELOCITY_TOLERANCE = 0.005f; |
3346 | private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary | 3346 | private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
3347 | private const double TIME_MS_TOLERANCE = 200.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds. | 3347 | private const double TIME_MS_TOLERANCE = 250.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
3348 | 3348 | ||
3349 | private Vector3 ClampVectorForTerseUpdate(Vector3 v, float max) | 3349 | private Vector3 ClampVectorForTerseUpdate(Vector3 v, float max) |
3350 | { | 3350 | { |