diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cebd108..6812914 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -790,13 +790,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
790 | /// </summary> | 790 | /// </summary> |
791 | public void SendPrimUpdates() | 791 | public void SendPrimUpdates() |
792 | { | 792 | { |
793 | m_perfMonMS = Environment.TickCount; | 793 | m_perfMonMS = EnvironmentTickCount(); |
794 | 794 | ||
795 | m_sceneViewer.SendPrimUpdates(); | 795 | m_sceneViewer.SendPrimUpdates(); |
796 | 796 | ||
797 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 797 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
798 | } | 798 | } |
799 | 799 | ||
800 | /// <summary> | ||
801 | /// Environment.TickCount is an int but it counts all 32 bits so it goes positive | ||
802 | /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap | ||
803 | /// for the callers. | ||
804 | /// This trims it to a 12 day interval so don't let your frame time get too long. | ||
805 | /// </summary> | ||
806 | /// <returns></returns> | ||
807 | const Int32 EnvironmentTickCountMask = 0x3fffffff; | ||
808 | private static Int32 EnvironmentTickCount() { | ||
809 | return Environment.TickCount & EnvironmentTickCountMask; | ||
810 | } | ||
811 | |||
812 | /// <summary> | ||
813 | /// Environment.TickCount is an int but it counts all 32 bits so it goes positive | ||
814 | /// and negative every 24.9 days. Subtracts the passed value (previously fetched by | ||
815 | /// 'EnvironmentTickCount()') and accounts for any wrapping. | ||
816 | /// </summary> | ||
817 | /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> | ||
818 | private static Int32 EnvironmentTickCountSubtract(Int32 prevValue) { | ||
819 | Int32 diff = EnvironmentTickCount() - prevValue; | ||
820 | return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); | ||
821 | } | ||
822 | |||
823 | |||
800 | #region Status Methods | 824 | #region Status Methods |
801 | 825 | ||
802 | /// <summary> | 826 | /// <summary> |
@@ -1184,7 +1208,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1184 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); | 1208 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); |
1185 | // return; | 1209 | // return; |
1186 | //} | 1210 | //} |
1187 | m_perfMonMS = Environment.TickCount; | 1211 | |
1212 | m_perfMonMS = EnvironmentTickCount(); | ||
1188 | 1213 | ||
1189 | ++m_movementUpdateCount; | 1214 | ++m_movementUpdateCount; |
1190 | if (m_movementUpdateCount < 1) | 1215 | if (m_movementUpdateCount < 1) |
@@ -1514,7 +1539,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1514 | 1539 | ||
1515 | m_scene.EventManager.TriggerOnClientMovement(this); | 1540 | m_scene.EventManager.TriggerOnClientMovement(this); |
1516 | 1541 | ||
1517 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 1542 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
1518 | } | 1543 | } |
1519 | 1544 | ||
1520 | public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) | 1545 | public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) |
@@ -2032,7 +2057,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2032 | return; | 2057 | return; |
2033 | } | 2058 | } |
2034 | 2059 | ||
2035 | m_perfMonMS = Environment.TickCount; | 2060 | m_perfMonMS = EnvironmentTickCount(); |
2036 | 2061 | ||
2037 | Rotation = rotation; | 2062 | Rotation = rotation; |
2038 | Vector3 direc = vec * rotation; | 2063 | Vector3 direc = vec * rotation; |
@@ -2074,7 +2099,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2074 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2099 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2075 | m_forceToApply = direc; | 2100 | m_forceToApply = direc; |
2076 | m_isNudging = Nudging; | 2101 | m_isNudging = Nudging; |
2077 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2102 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCount() - m_perfMonMS); |
2078 | } | 2103 | } |
2079 | 2104 | ||
2080 | #endregion | 2105 | #endregion |
@@ -2143,7 +2168,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2143 | // server. | 2168 | // server. |
2144 | if (remoteClient.IsActive) | 2169 | if (remoteClient.IsActive) |
2145 | { | 2170 | { |
2146 | m_perfMonMS = Environment.TickCount; | 2171 | m_perfMonMS = EnvironmentTickCount(); |
2147 | 2172 | ||
2148 | PhysicsActor actor = m_physicsActor; | 2173 | PhysicsActor actor = m_physicsActor; |
2149 | Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; | 2174 | Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; |
@@ -2156,7 +2181,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2156 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | 2181 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, |
2157 | pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); | 2182 | pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); |
2158 | 2183 | ||
2159 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2184 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
2160 | m_scene.StatsReporter.AddAgentUpdates(1); | 2185 | m_scene.StatsReporter.AddAgentUpdates(1); |
2161 | } | 2186 | } |
2162 | } | 2187 | } |
@@ -2166,11 +2191,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2166 | /// </summary> | 2191 | /// </summary> |
2167 | public void SendTerseUpdateToAllClients() | 2192 | public void SendTerseUpdateToAllClients() |
2168 | { | 2193 | { |
2169 | m_perfMonMS = Environment.TickCount; | 2194 | m_perfMonMS = EnvironmentTickCount(); |
2170 | 2195 | ||
2171 | m_scene.ForEachClient(SendTerseUpdateToClient); | 2196 | m_scene.ForEachClient(SendTerseUpdateToClient); |
2172 | 2197 | ||
2173 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2198 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
2174 | } | 2199 | } |
2175 | 2200 | ||
2176 | public void SendCoarseLocations() | 2201 | public void SendCoarseLocations() |
@@ -2190,7 +2215,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2190 | 2215 | ||
2191 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) | 2216 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) |
2192 | { | 2217 | { |
2193 | m_perfMonMS = Environment.TickCount; | 2218 | m_perfMonMS = EnvironmentTickCount(); |
2194 | 2219 | ||
2195 | List<Vector3> CoarseLocations = new List<Vector3>(); | 2220 | List<Vector3> CoarseLocations = new List<Vector3>(); |
2196 | List<UUID> AvatarUUIDs = new List<UUID>(); | 2221 | List<UUID> AvatarUUIDs = new List<UUID>(); |
@@ -2226,7 +2251,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2226 | 2251 | ||
2227 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); | 2252 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); |
2228 | 2253 | ||
2229 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2254 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
2230 | } | 2255 | } |
2231 | 2256 | ||
2232 | public void CoarseLocationChange() | 2257 | public void CoarseLocationChange() |
@@ -2263,7 +2288,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2263 | /// </summary> | 2288 | /// </summary> |
2264 | public void SendInitialFullUpdateToAllClients() | 2289 | public void SendInitialFullUpdateToAllClients() |
2265 | { | 2290 | { |
2266 | m_perfMonMS = Environment.TickCount; | 2291 | m_perfMonMS = EnvironmentTickCount(); |
2267 | 2292 | ||
2268 | ScenePresence[] avatars = m_scene.GetScenePresences(); | 2293 | ScenePresence[] avatars = m_scene.GetScenePresences(); |
2269 | 2294 | ||
@@ -2289,14 +2314,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2289 | } | 2314 | } |
2290 | 2315 | ||
2291 | m_scene.StatsReporter.AddAgentUpdates(avatars.Length); | 2316 | m_scene.StatsReporter.AddAgentUpdates(avatars.Length); |
2292 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2317 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
2293 | 2318 | ||
2294 | //Animator.SendAnimPack(); | 2319 | //Animator.SendAnimPack(); |
2295 | } | 2320 | } |
2296 | 2321 | ||
2297 | public void SendFullUpdateToAllClients() | 2322 | public void SendFullUpdateToAllClients() |
2298 | { | 2323 | { |
2299 | m_perfMonMS = Environment.TickCount; | 2324 | m_perfMonMS = EnvironmentTickCount(); |
2300 | 2325 | ||
2301 | // only send update from root agents to other clients; children are only "listening posts" | 2326 | // only send update from root agents to other clients; children are only "listening posts" |
2302 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2327 | List<ScenePresence> avatars = m_scene.GetAvatars(); |
@@ -2306,7 +2331,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2306 | 2331 | ||
2307 | } | 2332 | } |
2308 | m_scene.StatsReporter.AddAgentUpdates(avatars.Count); | 2333 | m_scene.StatsReporter.AddAgentUpdates(avatars.Count); |
2309 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2334 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
2310 | 2335 | ||
2311 | Animator.SendAnimPack(); | 2336 | Animator.SendAnimPack(); |
2312 | } | 2337 | } |
@@ -2348,7 +2373,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2348 | /// </summary> | 2373 | /// </summary> |
2349 | public void SendAppearanceToAllOtherAgents() | 2374 | public void SendAppearanceToAllOtherAgents() |
2350 | { | 2375 | { |
2351 | m_perfMonMS = Environment.TickCount; | 2376 | m_perfMonMS = EnvironmentTickCount(); |
2352 | 2377 | ||
2353 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2378 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2354 | { | 2379 | { |
@@ -2358,7 +2383,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2358 | } | 2383 | } |
2359 | }); | 2384 | }); |
2360 | 2385 | ||
2361 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2386 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); |
2362 | } | 2387 | } |
2363 | 2388 | ||
2364 | /// <summary> | 2389 | /// <summary> |