aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs230
1 files changed, 144 insertions, 86 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 03111a6..fba9ea8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -117,6 +117,8 @@ namespace OpenSim.Region.Framework.Scenes
117 private volatile bool m_backingup = false; 117 private volatile bool m_backingup = false;
118 118
119 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 119 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
120
121 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
120 122
121 protected string m_simulatorVersion = "OpenSimulator Server"; 123 protected string m_simulatorVersion = "OpenSimulator Server";
122 124
@@ -246,8 +248,7 @@ namespace OpenSim.Region.Framework.Scenes
246 248
247 private int m_update_physics = 1; 249 private int m_update_physics = 1;
248 private int m_update_entitymovement = 1; 250 private int m_update_entitymovement = 1;
249 private int m_update_entities = 1; // Run through all objects checking for updates 251 private int m_update_objects = 1; // Update objects which have scheduled themselves for updates
250 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates
251 private int m_update_presences = 1; // Update scene presence movements 252 private int m_update_presences = 1; // Update scene presence movements
252 private int m_update_events = 1; 253 private int m_update_events = 1;
253 private int m_update_backup = 200; 254 private int m_update_backup = 200;
@@ -867,7 +868,7 @@ namespace OpenSim.Region.Framework.Scenes
867 Thread.Sleep(500); 868 Thread.Sleep(500);
868 869
869 // Stop all client threads. 870 // Stop all client threads.
870 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); }); 871 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); });
871 872
872 // Stop updating the scene objects and agents. 873 // Stop updating the scene objects and agents.
873 //m_heartbeatTimer.Close(); 874 //m_heartbeatTimer.Close();
@@ -979,28 +980,7 @@ namespace OpenSim.Region.Framework.Scenes
979 maintc = Environment.TickCount; 980 maintc = Environment.TickCount;
980 981
981 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; 982 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate;
982 // Aquire a lock so only one update call happens at once
983 //updateLock.WaitOne();
984 float physicsFPS = 0; 983 float physicsFPS = 0;
985 //m_log.Info("sadfadf" + m_neighbours.Count.ToString());
986 int agentsInScene = m_sceneGraph.GetRootAgentCount() + m_sceneGraph.GetChildAgentCount();
987
988 if (agentsInScene > 21)
989 {
990 if (m_update_entities == 1)
991 {
992 m_update_entities = 5;
993 StatsReporter.SetUpdateMS(6000);
994 }
995 }
996 else
997 {
998 if (m_update_entities == 5)
999 {
1000 m_update_entities = 1;
1001 StatsReporter.SetUpdateMS(3000);
1002 }
1003 }
1004 984
1005 frameMS = Environment.TickCount; 985 frameMS = Environment.TickCount;
1006 try 986 try
@@ -1013,30 +993,17 @@ namespace OpenSim.Region.Framework.Scenes
1013 m_frame = 0; 993 m_frame = 0;
1014 994
1015 otherMS = Environment.TickCount; 995 otherMS = Environment.TickCount;
1016 // run through all entities looking for updates (slow)
1017 if (m_frame % m_update_entities == 0)
1018 {
1019 /* // Adam Experimental
1020 if (m_updateEntitiesThread == null)
1021 {
1022 m_updateEntitiesThread = new Thread(m_sceneGraph.UpdateEntities);
1023
1024 ThreadTracker.Add(m_updateEntitiesThread);
1025 }
1026
1027 if (m_updateEntitiesThread.ThreadState == ThreadState.Stopped)
1028 m_updateEntitiesThread.Start();
1029 */
1030 996
1031 m_sceneGraph.UpdateEntities(); 997 // Check if any objects have reached their targets
1032 } 998 CheckAtTargets();
999
1000 // Update SceneObjectGroups that have scheduled themselves for updates
1001 // Objects queue their updates onto all scene presences
1002 if (m_frame % m_update_objects == 0)
1003 m_sceneGraph.UpdateObjectGroups();
1033 1004
1034 // run through entities that have scheduled themselves for 1005 // Run through all ScenePresences looking for updates
1035 // updates looking for updates(faster) 1006 // Presence updates and queued object updates for each presence are sent to clients
1036 if (m_frame % m_update_entitiesquick == 0)
1037 m_sceneGraph.ProcessUpdates();
1038
1039 // Run through scenepresences looking for updates
1040 if (m_frame % m_update_presences == 0) 1007 if (m_frame % m_update_presences == 0)
1041 m_sceneGraph.UpdatePresences(); 1008 m_sceneGraph.UpdatePresences();
1042 1009
@@ -1140,6 +1107,31 @@ namespace OpenSim.Region.Framework.Scenes
1140 } 1107 }
1141 } 1108 }
1142 1109
1110
1111 public void AddGroupTarget(SceneObjectGroup grp)
1112 {
1113 lock(m_groupsWithTargets)
1114 m_groupsWithTargets[grp.UUID] = grp;
1115 }
1116
1117 public void RemoveGroupTarget(SceneObjectGroup grp)
1118 {
1119 lock(m_groupsWithTargets)
1120 m_groupsWithTargets.Remove(grp.UUID);
1121 }
1122
1123 private void CheckAtTargets()
1124 {
1125 lock (m_groupsWithTargets)
1126 {
1127 foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in m_groupsWithTargets)
1128 {
1129 kvp.Value.checkAtTargets();
1130 }
1131 }
1132 }
1133
1134
1143 /// <summary> 1135 /// <summary>
1144 /// Send out simstats data to all clients 1136 /// Send out simstats data to all clients
1145 /// </summary> 1137 /// </summary>
@@ -1186,10 +1178,10 @@ namespace OpenSim.Region.Framework.Scenes
1186 if (!m_backingup) 1178 if (!m_backingup)
1187 { 1179 {
1188 m_backingup = true; 1180 m_backingup = true;
1189 Thread backupthread = new Thread(Backup); 1181
1190 backupthread.Name = "BackupWriter"; 1182 System.ComponentModel.BackgroundWorker backupWorker = new System.ComponentModel.BackgroundWorker();
1191 backupthread.IsBackground = true; 1183 backupWorker.DoWork += delegate(object sender, System.ComponentModel.DoWorkEventArgs e) { Backup(); };
1192 backupthread.Start(); 1184 backupWorker.RunWorkerAsync();
1193 } 1185 }
1194 } 1186 }
1195 1187
@@ -1780,36 +1772,87 @@ namespace OpenSim.Region.Framework.Scenes
1780 1772
1781 Vector3 pos = attemptedPosition; 1773 Vector3 pos = attemptedPosition;
1782 1774
1775 int changeX = 1;
1776 int changeY = 1;
1777
1783 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) 1778 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
1784 { 1779 {
1785 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1780 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1786 { 1781 {
1787 //Border crossedBorderx = GetCrossedBorder(attemptedPosition,Cardinals.W); 1782
1788 //Border crossedBordery = GetCrossedBorder(attemptedPosition, Cardinals.S); 1783 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1784
1785 if (crossedBorderx.BorderLine.Z > 0)
1786 {
1787 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1788 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
1789 }
1790 else
1791 pos.X = ((pos.X + Constants.RegionSize));
1792
1793 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1789 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) 1794 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1790 pos.X = ((pos.X + Constants.RegionSize)); 1795
1791 pos.Y = ((pos.Y + Constants.RegionSize)); 1796 if (crossedBordery.BorderLine.Z > 0)
1797 {
1798 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1799 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1800 }
1801 else
1802 pos.Y = ((pos.Y + Constants.RegionSize));
1803
1804
1805
1792 newRegionHandle 1806 newRegionHandle
1793 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), 1807 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1794 (uint)((thisy - 1) * Constants.RegionSize)); 1808 (uint)((thisy - changeY) * Constants.RegionSize));
1795 // x - 1 1809 // x - 1
1796 // y - 1 1810 // y - 1
1797 } 1811 }
1798 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) 1812 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
1799 { 1813 {
1800 pos.X = ((pos.X + Constants.RegionSize)); 1814 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1801 pos.Y = ((pos.Y - Constants.RegionSize)); 1815
1816 if (crossedBorderx.BorderLine.Z > 0)
1817 {
1818 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1819 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1820 }
1821 else
1822 pos.X = ((pos.X + Constants.RegionSize));
1823
1824
1825 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1826 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1827
1828 if (crossedBordery.BorderLine.Z > 0)
1829 {
1830 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1831 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1832 }
1833 else
1834 pos.Y = ((pos.Y + Constants.RegionSize));
1835
1802 newRegionHandle 1836 newRegionHandle
1803 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), 1837 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1804 (uint)((thisy + 1) * Constants.RegionSize)); 1838 (uint)((thisy + changeY) * Constants.RegionSize));
1805 // x - 1 1839 // x - 1
1806 // y + 1 1840 // y + 1
1807 } 1841 }
1808 else 1842 else
1809 { 1843 {
1810 pos.X = ((pos.X + Constants.RegionSize)); 1844 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1845
1846 if (crossedBorderx.BorderLine.Z > 0)
1847 {
1848 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1849 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1850 }
1851 else
1852 pos.X = ((pos.X + Constants.RegionSize));
1853
1811 newRegionHandle 1854 newRegionHandle
1812 = Util.UIntsToLong((uint) ((thisx - 1)*Constants.RegionSize), 1855 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1813 (uint) (thisy*Constants.RegionSize)); 1856 (uint) (thisy*Constants.RegionSize));
1814 // x - 1 1857 // x - 1
1815 } 1858 }
@@ -1818,11 +1861,23 @@ namespace OpenSim.Region.Framework.Scenes
1818 { 1861 {
1819 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1862 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1820 { 1863 {
1864
1821 pos.X = ((pos.X - Constants.RegionSize)); 1865 pos.X = ((pos.X - Constants.RegionSize));
1822 pos.Y = ((pos.Y + Constants.RegionSize)); 1866 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1867 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1868
1869 if (crossedBordery.BorderLine.Z > 0)
1870 {
1871 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1872 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1873 }
1874 else
1875 pos.Y = ((pos.Y + Constants.RegionSize));
1876
1877
1823 newRegionHandle 1878 newRegionHandle
1824 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), 1879 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1825 (uint)((thisy - 1) * Constants.RegionSize)); 1880 (uint)((thisy - changeY) * Constants.RegionSize));
1826 // x + 1 1881 // x + 1
1827 // y - 1 1882 // y - 1
1828 } 1883 }
@@ -1831,8 +1886,8 @@ namespace OpenSim.Region.Framework.Scenes
1831 pos.X = ((pos.X - Constants.RegionSize)); 1886 pos.X = ((pos.X - Constants.RegionSize));
1832 pos.Y = ((pos.Y - Constants.RegionSize)); 1887 pos.Y = ((pos.Y - Constants.RegionSize));
1833 newRegionHandle 1888 newRegionHandle
1834 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), 1889 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1835 (uint)((thisy + 1) * Constants.RegionSize)); 1890 (uint)((thisy + changeY) * Constants.RegionSize));
1836 // x + 1 1891 // x + 1
1837 // y + 1 1892 // y + 1
1838 } 1893 }
@@ -1840,16 +1895,26 @@ namespace OpenSim.Region.Framework.Scenes
1840 { 1895 {
1841 pos.X = ((pos.X - Constants.RegionSize)); 1896 pos.X = ((pos.X - Constants.RegionSize));
1842 newRegionHandle 1897 newRegionHandle
1843 = Util.UIntsToLong((uint) ((thisx + 1)*Constants.RegionSize), 1898 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1844 (uint) (thisy*Constants.RegionSize)); 1899 (uint) (thisy*Constants.RegionSize));
1845 // x + 1 1900 // x + 1
1846 } 1901 }
1847 } 1902 }
1848 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1903 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1849 { 1904 {
1850 pos.Y = ((pos.Y + Constants.RegionSize)); 1905 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1906 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1907
1908 if (crossedBordery.BorderLine.Z > 0)
1909 {
1910 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1911 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1912 }
1913 else
1914 pos.Y = ((pos.Y + Constants.RegionSize));
1915
1851 newRegionHandle 1916 newRegionHandle
1852 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); 1917 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
1853 // y - 1 1918 // y - 1
1854 } 1919 }
1855 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) 1920 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
@@ -1857,7 +1922,7 @@ namespace OpenSim.Region.Framework.Scenes
1857 1922
1858 pos.Y = ((pos.Y - Constants.RegionSize)); 1923 pos.Y = ((pos.Y - Constants.RegionSize));
1859 newRegionHandle 1924 newRegionHandle
1860 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); 1925 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
1861 // y + 1 1926 // y + 1
1862 } 1927 }
1863 1928
@@ -2363,6 +2428,8 @@ namespace OpenSim.Region.Framework.Scenes
2363 /// <param name="client"></param> 2428 /// <param name="client"></param>
2364 public override void AddNewClient(IClientAPI client) 2429 public override void AddNewClient(IClientAPI client)
2365 { 2430 {
2431 ClientManager.Add(client);
2432
2366 CheckHeartbeat(); 2433 CheckHeartbeat();
2367 SubscribeToClientEvents(client); 2434 SubscribeToClientEvents(client);
2368 ScenePresence presence; 2435 ScenePresence presence;
@@ -2572,6 +2639,7 @@ namespace OpenSim.Region.Framework.Scenes
2572 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 2639 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
2573 { 2640 {
2574 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 2641 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
2642 client.OnViewerEffect += ProcessViewerEffect;
2575 } 2643 }
2576 2644
2577 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2645 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
@@ -2726,11 +2794,9 @@ namespace OpenSim.Region.Framework.Scenes
2726 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 2794 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
2727 { 2795 {
2728 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; 2796 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
2797 client.OnViewerEffect -= ProcessViewerEffect;
2729 } 2798 }
2730 2799
2731
2732
2733
2734 /// <summary> 2800 /// <summary>
2735 /// Teleport an avatar to their home region 2801 /// Teleport an avatar to their home region
2736 /// </summary> 2802 /// </summary>
@@ -3003,7 +3069,9 @@ namespace OpenSim.Region.Framework.Scenes
3003 agentTransactions.RemoveAgentAssetTransactions(agentID); 3069 agentTransactions.RemoveAgentAssetTransactions(agentID);
3004 } 3070 }
3005 3071
3072 // Remove the avatar from the scene
3006 m_sceneGraph.RemoveScenePresence(agentID); 3073 m_sceneGraph.RemoveScenePresence(agentID);
3074 ClientManager.Remove(agentID);
3007 3075
3008 try 3076 try
3009 { 3077 {
@@ -3053,16 +3121,6 @@ namespace OpenSim.Region.Framework.Scenes
3053 } 3121 }
3054 3122
3055 /// <summary> 3123 /// <summary>
3056 /// Closes all endpoints with the circuitcode provided.
3057 /// </summary>
3058 /// <param name="circuitcode">Circuit Code of the endpoint to close</param>
3059 public override void CloseAllAgents(uint circuitcode)
3060 {
3061 // Called by ClientView to kill all circuit codes
3062 ClientManager.CloseAllAgents(circuitcode);
3063 }
3064
3065 /// <summary>
3066 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap. 3124 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap.
3067 /// </summary> 3125 /// </summary>
3068 public void NotifyMyCoarseLocationChange() 3126 public void NotifyMyCoarseLocationChange()
@@ -3383,7 +3441,7 @@ namespace OpenSim.Region.Framework.Scenes
3383 loggingOffUser.ControllingClient.Kick(message); 3441 loggingOffUser.ControllingClient.Kick(message);
3384 // Give them a second to receive the message! 3442 // Give them a second to receive the message!
3385 Thread.Sleep(1000); 3443 Thread.Sleep(1000);
3386 loggingOffUser.ControllingClient.Close(true); 3444 loggingOffUser.ControllingClient.Close();
3387 } 3445 }
3388 else 3446 else
3389 { 3447 {
@@ -3554,7 +3612,7 @@ namespace OpenSim.Region.Framework.Scenes
3554 presence.ControllingClient.SendShutdownConnectionNotice(); 3612 presence.ControllingClient.SendShutdownConnectionNotice();
3555 } 3613 }
3556 3614
3557 presence.ControllingClient.Close(true); 3615 presence.ControllingClient.Close();
3558 return true; 3616 return true;
3559 } 3617 }
3560 3618