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.cs139
1 files changed, 84 insertions, 55 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 7c3875d..a6ee40a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -135,6 +135,11 @@ namespace OpenSim.Region.Framework.Scenes
135 protected SceneCommunicationService m_sceneGridService; 135 protected SceneCommunicationService m_sceneGridService;
136 public bool loginsdisabled = true; 136 public bool loginsdisabled = true;
137 137
138 public new float TimeDilation
139 {
140 get { return m_sceneGraph.PhysicsScene.TimeDilation; }
141 }
142
138 public SceneCommunicationService SceneGridService 143 public SceneCommunicationService SceneGridService
139 { 144 {
140 get { return m_sceneGridService; } 145 get { return m_sceneGridService; }
@@ -252,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes
252 // Central Update Loop 257 // Central Update Loop
253 258
254 protected int m_fps = 10; 259 protected int m_fps = 10;
255 protected int m_frame; 260 protected uint m_frame;
256 protected float m_timespan = 0.089f; 261 protected float m_timespan = 0.089f;
257 protected DateTime m_lastupdate = DateTime.UtcNow; 262 protected DateTime m_lastupdate = DateTime.UtcNow;
258 263
@@ -269,6 +274,23 @@ namespace OpenSim.Region.Framework.Scenes
269 private int physicsMS2; 274 private int physicsMS2;
270 private int physicsMS; 275 private int physicsMS;
271 private int otherMS; 276 private int otherMS;
277 private int tempOnRezMS;
278 private int eventMS;
279 private int backupMS;
280 private int terrainMS;
281 private int landMS;
282 private int lastCompletedFrame;
283
284 public int MonitorFrameTime { get { return frameMS; } }
285 public int MonitorPhysicsUpdateTime { get { return physicsMS; } }
286 public int MonitorPhysicsSyncTime { get { return physicsMS2; } }
287 public int MonitorOtherTime { get { return otherMS; } }
288 public int MonitorTempOnRezTime { get { return tempOnRezMS; } }
289 public int MonitorEventTime { get { return eventMS; } } // This may need to be divided into each event?
290 public int MonitorBackupTime { get { return backupMS; } }
291 public int MonitorTerrainTime { get { return terrainMS; } }
292 public int MonitorLandTime { get { return landMS; } }
293 public int MonitorLastFrameTick { get { return lastCompletedFrame; } }
272 294
273 private bool m_physics_enabled = true; 295 private bool m_physics_enabled = true;
274 private bool m_scripts_enabled = true; 296 private bool m_scripts_enabled = true;
@@ -1013,36 +1035,25 @@ namespace OpenSim.Region.Framework.Scenes
1013 /// </summary> 1035 /// </summary>
1014 public override void Update() 1036 public override void Update()
1015 { 1037 {
1016 int maintc = 0; 1038 float physicsFPS;
1039 int maintc;
1040
1017 while (!shuttingdown) 1041 while (!shuttingdown)
1018 { 1042 {
1019//#if DEBUG
1020// int w = 0, io = 0;
1021// ThreadPool.GetAvailableThreads(out w, out io);
1022// if ((w < 10) || (io < 10))
1023// m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io);
1024//#endif
1025 maintc = Environment.TickCount;
1026
1027 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; 1043 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1028 float physicsFPS = 0; 1044 physicsFPS = 0f;
1045
1046 maintc = maintc = otherMS = Environment.TickCount;
1047 int tmpFrameMS = maintc;
1029 1048
1030 frameMS = Environment.TickCount; 1049 // Increment the frame counter
1050 ++m_frame;
1031 1051
1032 try 1052 try
1033 { 1053 {
1034 // Increment the frame counter
1035 m_frame++;
1036
1037 // Loop it
1038 if (m_frame == Int32.MaxValue)
1039 m_frame = 0;
1040
1041 otherMS = Environment.TickCount;
1042
1043 // Check if any objects have reached their targets 1054 // Check if any objects have reached their targets
1044 CheckAtTargets(); 1055 CheckAtTargets();
1045 1056
1046 // Update SceneObjectGroups that have scheduled themselves for updates 1057 // Update SceneObjectGroups that have scheduled themselves for updates
1047 // Objects queue their updates onto all scene presences 1058 // Objects queue their updates onto all scene presences
1048 if (m_frame % m_update_objects == 0) 1059 if (m_frame % m_update_objects == 0)
@@ -1053,62 +1064,92 @@ namespace OpenSim.Region.Framework.Scenes
1053 if (m_frame % m_update_presences == 0) 1064 if (m_frame % m_update_presences == 0)
1054 m_sceneGraph.UpdatePresences(); 1065 m_sceneGraph.UpdatePresences();
1055 1066
1056 physicsMS2 = Environment.TickCount; 1067 int TempPhysicsMS2 = Environment.TickCount;
1057 if ((m_frame % m_update_physics == 0) && m_physics_enabled) 1068 if ((m_frame % m_update_physics == 0) && m_physics_enabled)
1058 m_sceneGraph.UpdatePreparePhysics(); 1069 m_sceneGraph.UpdatePreparePhysics();
1059 physicsMS2 = Environment.TickCount - physicsMS2; 1070 TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2;
1071 physicsMS2 = TempPhysicsMS2;
1060 1072
1061 if (m_frame % m_update_entitymovement == 0) 1073 if (m_frame % m_update_entitymovement == 0)
1062 m_sceneGraph.UpdateScenePresenceMovement(); 1074 m_sceneGraph.UpdateScenePresenceMovement();
1063 1075
1064 physicsMS = Environment.TickCount; 1076 int TempPhysicsMS = Environment.TickCount;
1065 if ((m_frame % m_update_physics == 0) && m_physics_enabled) 1077 if (m_frame % m_update_physics == 0)
1066 physicsFPS = m_sceneGraph.UpdatePhysics( 1078 {
1067 Math.Max(SinceLastFrame.TotalSeconds, m_timespan) 1079 if (m_physics_enabled)
1068 ); 1080 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
1069 if (m_frame % m_update_physics == 0 && SynchronizeScene != null) 1081 if (SynchronizeScene != null)
1070 SynchronizeScene(this); 1082 SynchronizeScene(this);
1071 1083 }
1072 physicsMS = Environment.TickCount - physicsMS; 1084 TempPhysicsMS = Environment.TickCount - TempPhysicsMS;
1073 physicsMS += physicsMS2; 1085 physicsMS = TempPhysicsMS;
1074 1086
1075 // Delete temp-on-rez stuff 1087 // Delete temp-on-rez stuff
1076 if (m_frame % m_update_backup == 0) 1088 if (m_frame % m_update_backup == 0)
1089 {
1090 int tozMS = Environment.TickCount;
1077 CleanTempObjects(); 1091 CleanTempObjects();
1092 tozMS -= Environment.TickCount;
1093 tempOnRezMS = tozMS;
1094 }
1078 1095
1079 if (RegionStatus != RegionStatus.SlaveScene) 1096 if (RegionStatus != RegionStatus.SlaveScene)
1080 { 1097 {
1081 if (m_frame % m_update_events == 0) 1098 if (m_frame % m_update_events == 0)
1099 {
1100 int evMS = Environment.TickCount;
1082 UpdateEvents(); 1101 UpdateEvents();
1102 evMS -= Environment.TickCount;
1103 eventMS = evMS;
1104 }
1083 1105
1084 if (m_frame % m_update_backup == 0) 1106 if (m_frame % m_update_backup == 0)
1107 {
1108 int backMS = Environment.TickCount;
1085 UpdateStorageBackup(); 1109 UpdateStorageBackup();
1110 backMS -= Environment.TickCount;
1111 backupMS = backMS;
1112 }
1086 1113
1087 if (m_frame % m_update_terrain == 0) 1114 if (m_frame % m_update_terrain == 0)
1115 {
1116 int terMS = Environment.TickCount;
1088 UpdateTerrain(); 1117 UpdateTerrain();
1118 terMS -= Environment.TickCount;
1119 terrainMS = terMS;
1120 }
1089 1121
1090 if (m_frame % m_update_land == 0) 1122 if (m_frame % m_update_land == 0)
1123 {
1124 int ldMS = Environment.TickCount;
1091 UpdateLand(); 1125 UpdateLand();
1126 ldMS -= Environment.TickCount;
1127 landMS = ldMS;
1128 }
1129
1130 int tickCount = Environment.TickCount;
1131 otherMS = tickCount - otherMS;
1132 tmpFrameMS -= tickCount;
1133 frameMS = tmpFrameMS;
1134 lastCompletedFrame = tickCount;
1092 1135
1093 otherMS = Environment.TickCount - otherMS;
1094 // if (m_frame%m_update_avatars == 0) 1136 // if (m_frame%m_update_avatars == 0)
1095 // UpdateInWorldTime(); 1137 // UpdateInWorldTime();
1096 StatsReporter.AddPhysicsFPS(physicsFPS); 1138 StatsReporter.AddPhysicsFPS(physicsFPS);
1097 StatsReporter.AddTimeDilation(m_timedilation); 1139 StatsReporter.AddTimeDilation(TimeDilation);
1098 StatsReporter.AddFPS(1); 1140 StatsReporter.AddFPS(1);
1099 StatsReporter.AddInPackets(0);
1100 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); 1141 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1101 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); 1142 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1102 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); 1143 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1103 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); 1144 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1104 frameMS = Environment.TickCount - frameMS;
1105 StatsReporter.addFrameMS(frameMS); 1145 StatsReporter.addFrameMS(frameMS);
1106 StatsReporter.addPhysicsMS(physicsMS); 1146 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1107 StatsReporter.addOtherMS(otherMS); 1147 StatsReporter.addOtherMS(otherMS);
1108 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); 1148 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1109 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); 1149 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1110 } 1150 }
1111 if (loginsdisabled && (m_frame > 20)) 1151
1152 if (loginsdisabled && m_frame > 20)
1112 { 1153 {
1113 // In 99.9% of cases it is a bad idea to manually force garbage collection. However, 1154 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
1114 // this is a rare case where we know we have just went through a long cycle of heap 1155 // this is a rare case where we know we have just went through a long cycle of heap
@@ -1141,18 +1182,6 @@ namespace OpenSim.Region.Framework.Scenes
1141 } 1182 }
1142 finally 1183 finally
1143 { 1184 {
1144 //updateLock.ReleaseMutex();
1145 // Get actual time dilation
1146 float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds);
1147
1148 // If actual time dilation is greater then one, we're catching up, so subtract
1149 // the amount that's greater then 1 from the time dilation
1150 if (tmpval > 1.0)
1151 {
1152 tmpval = tmpval - (tmpval - 1.0f);
1153 }
1154 m_timedilation = tmpval;
1155
1156 m_lastupdate = DateTime.UtcNow; 1185 m_lastupdate = DateTime.UtcNow;
1157 } 1186 }
1158 maintc = Environment.TickCount - maintc; 1187 maintc = Environment.TickCount - maintc;
@@ -1183,9 +1212,9 @@ namespace OpenSim.Region.Framework.Scenes
1183 { 1212 {
1184 lock (m_groupsWithTargets) 1213 lock (m_groupsWithTargets)
1185 { 1214 {
1186 foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in m_groupsWithTargets) 1215 foreach (SceneObjectGroup entry in m_groupsWithTargets.Values)
1187 { 1216 {
1188 kvp.Value.checkAtTargets(); 1217 entry.checkAtTargets();
1189 } 1218 }
1190 } 1219 }
1191 } 1220 }
@@ -4606,7 +4635,7 @@ namespace OpenSim.Region.Framework.Scenes
4606 SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup 4635 SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup
4607 if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy. 4636 if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy.
4608 jointProxyObject.Velocity = trackedBody.Velocity; 4637 jointProxyObject.Velocity = trackedBody.Velocity;
4609 jointProxyObject.RotationalVelocity = trackedBody.RotationalVelocity; 4638 jointProxyObject.AngularVelocity = trackedBody.AngularVelocity;
4610 switch (joint.Type) 4639 switch (joint.Type)
4611 { 4640 {
4612 case PhysicsJointType.Ball: 4641 case PhysicsJointType.Ball: