diff options
author | UbitUmarov | 2015-12-17 12:20:02 +0000 |
---|---|---|
committer | UbitUmarov | 2015-12-17 12:20:02 +0000 |
commit | a4ed6111b0c6c95404526df373b0107351b2d6cf (patch) | |
tree | af52cd2deafb0518ebec1ae8beafd564b4d453ec /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | dont bother another thread to try to send if there is no one to listen (diff) | |
download | opensim-SC-a4ed6111b0c6c95404526df373b0107351b2d6cf.zip opensim-SC-a4ed6111b0c6c95404526df373b0107351b2d6cf.tar.gz opensim-SC-a4ed6111b0c6c95404526df373b0107351b2d6cf.tar.bz2 opensim-SC-a4ed6111b0c6c95404526df373b0107351b2d6cf.tar.xz |
change updates reprioritization control code. Do it under normal avatar updates timing and with a workjob not a timer issued thread.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 117 |
1 files changed, 56 insertions, 61 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f5ca3ef..9b82380 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -209,7 +209,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
209 | */ | 209 | */ |
210 | } | 210 | } |
211 | 211 | ||
212 | |||
213 | public bool ParcelAllowThisAvatarSounds | 212 | public bool ParcelAllowThisAvatarSounds |
214 | { | 213 | { |
215 | get | 214 | get |
@@ -281,7 +280,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
281 | 280 | ||
282 | private bool m_followCamAuto = false; | 281 | private bool m_followCamAuto = false; |
283 | 282 | ||
284 | |||
285 | private Vector3? m_forceToApply; | 283 | private Vector3? m_forceToApply; |
286 | private int m_userFlags; | 284 | private int m_userFlags; |
287 | public int UserFlags | 285 | public int UserFlags |
@@ -349,10 +347,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | 347 | ||
350 | private readonly Vector3[] Dir_Vectors = new Vector3[12]; | 348 | private readonly Vector3[] Dir_Vectors = new Vector3[12]; |
351 | 349 | ||
352 | protected Timer m_reprioritization_timer; | 350 | protected int m_reprioritizationLastTime; |
353 | protected bool m_reprioritizing; | 351 | protected bool m_reprioritizationBusy; |
354 | protected bool m_reprioritization_called; | 352 | |
355 | |||
356 | private Quaternion m_headrotation = Quaternion.Identity; | 353 | private Quaternion m_headrotation = Quaternion.Identity; |
357 | 354 | ||
358 | //PauPaw:Proper PID Controler for autopilot************ | 355 | //PauPaw:Proper PID Controler for autopilot************ |
@@ -371,7 +368,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
371 | //private int m_moveToPositionStateStatus; | 368 | //private int m_moveToPositionStateStatus; |
372 | //***************************************************** | 369 | //***************************************************** |
373 | 370 | ||
374 | private bool m_collisionEventFlag = false; | 371 | //private bool m_collisionEventFlag = false; |
375 | private object m_collisionEventLock = new Object(); | 372 | private object m_collisionEventLock = new Object(); |
376 | 373 | ||
377 | private int m_movementAnimationUpdateCounter = 0; | 374 | private int m_movementAnimationUpdateCounter = 0; |
@@ -1033,12 +1030,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1033 | AbsolutePosition = posLastMove = posLastSignificantMove = CameraPosition = | 1030 | AbsolutePosition = posLastMove = posLastSignificantMove = CameraPosition = |
1034 | m_lastCameraPosition = ControllingClient.StartPos; | 1031 | m_lastCameraPosition = ControllingClient.StartPos; |
1035 | 1032 | ||
1036 | childUpdatesBusy = true; // disable it for now | 1033 | // disable updates workjobs for now |
1037 | 1034 | childUpdatesBusy = true; | |
1038 | m_reprioritization_timer = new Timer(world.ReprioritizationInterval); | 1035 | m_reprioritizationBusy = true; |
1039 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); | 1036 | |
1040 | m_reprioritization_timer.AutoReset = false; | ||
1041 | |||
1042 | AdjustKnownSeeds(); | 1037 | AdjustKnownSeeds(); |
1043 | 1038 | ||
1044 | RegisterToEvents(); | 1039 | RegisterToEvents(); |
@@ -2047,6 +2042,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2047 | if (m_teleportFlags > 0 && !isNPC || m_currentParcelHide) | 2042 | if (m_teleportFlags > 0 && !isNPC || m_currentParcelHide) |
2048 | SendInitialDataToMe(); | 2043 | SendInitialDataToMe(); |
2049 | 2044 | ||
2045 | m_lastCameraPosition = CameraPosition; | ||
2046 | m_reprioritizationLastTime = Util.EnvironmentTickCount() + 15000; // delay it | ||
2047 | m_reprioritizationBusy = false; | ||
2048 | |||
2050 | m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | 2049 | m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
2051 | 2050 | ||
2052 | if (!IsChildAgent && openChildAgents) | 2051 | if (!IsChildAgent && openChildAgents) |
@@ -2544,12 +2543,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2544 | // Camera location in world. We'll need to raytrace | 2543 | // Camera location in world. We'll need to raytrace |
2545 | // from this location from time to time. | 2544 | // from this location from time to time. |
2546 | CameraPosition = agentData.CameraCenter; | 2545 | CameraPosition = agentData.CameraCenter; |
2547 | if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance) | ||
2548 | { | ||
2549 | ReprioritizeUpdates(); | ||
2550 | m_lastCameraPosition = CameraPosition; | ||
2551 | } | ||
2552 | |||
2553 | // Use these three vectors to figure out what the agent is looking at | 2546 | // Use these three vectors to figure out what the agent is looking at |
2554 | // Convert it to a Matrix and/or Quaternion | 2547 | // Convert it to a Matrix and/or Quaternion |
2555 | CameraAtAxis = agentData.CameraAtAxis; | 2548 | CameraAtAxis = agentData.CameraAtAxis; |
@@ -2560,7 +2553,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2560 | // When we get to the point of re-computing neighbors everytime this | 2553 | // When we get to the point of re-computing neighbors everytime this |
2561 | // changes, then start using the agent's drawdistance rather than the | 2554 | // changes, then start using the agent's drawdistance rather than the |
2562 | // region's draw distance. | 2555 | // region's draw distance. |
2563 | 2556 | ||
2564 | DrawDistance = agentData.Far; | 2557 | DrawDistance = agentData.Far; |
2565 | 2558 | ||
2566 | // Check if Client has camera in 'follow cam' or 'build' mode. | 2559 | // Check if Client has camera in 'follow cam' or 'build' mode. |
@@ -3875,6 +3868,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
3875 | 3868 | ||
3876 | #region Significant Movement Method | 3869 | #region Significant Movement Method |
3877 | 3870 | ||
3871 | private void checkRePrioritization() | ||
3872 | { | ||
3873 | if(IsDeleted || !ControllingClient.IsActive) | ||
3874 | return; | ||
3875 | |||
3876 | if(m_reprioritizationBusy) | ||
3877 | return; | ||
3878 | |||
3879 | int tdiff = Util.EnvironmentTickCountSubtract(m_reprioritizationLastTime); | ||
3880 | if(tdiff < Scene.ReprioritizationInterval) | ||
3881 | return; | ||
3882 | |||
3883 | Vector3 diff = CameraPosition - m_lastCameraPosition; | ||
3884 | float limit; | ||
3885 | if(IsChildAgent) | ||
3886 | limit = (float)Scene.ChildReprioritizationDistance; | ||
3887 | else | ||
3888 | limit = (float)Scene.RootReprioritizationDistance; | ||
3889 | |||
3890 | limit *= limit; | ||
3891 | if (diff.LengthSquared() < limit) | ||
3892 | return; | ||
3893 | |||
3894 | m_reprioritizationBusy = true; | ||
3895 | m_lastCameraPosition = CameraPosition; | ||
3896 | |||
3897 | Util.FireAndForget( | ||
3898 | o => | ||
3899 | { | ||
3900 | ControllingClient.ReprioritizeUpdates(); | ||
3901 | m_reprioritizationLastTime = Util.EnvironmentTickCount(); | ||
3902 | m_reprioritizationBusy = false; | ||
3903 | }, null, "ScenePresence.Reprioritization"); | ||
3904 | } | ||
3878 | /// <summary> | 3905 | /// <summary> |
3879 | /// This checks for a significant movement and sends a coarselocationchange update | 3906 | /// This checks for a significant movement and sends a coarselocationchange update |
3880 | /// </summary> | 3907 | /// </summary> |
@@ -3896,6 +3923,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3896 | m_scene.EventManager.TriggerSignificantClientMovement(this); | 3923 | m_scene.EventManager.TriggerSignificantClientMovement(this); |
3897 | } | 3924 | } |
3898 | 3925 | ||
3926 | // updates priority recalc | ||
3927 | checkRePrioritization(); | ||
3928 | |||
3899 | if(childUpdatesBusy) | 3929 | if(childUpdatesBusy) |
3900 | return; | 3930 | return; |
3901 | 3931 | ||
@@ -4222,12 +4252,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4222 | if (cAgentData.Position != marker) // UGH!! | 4252 | if (cAgentData.Position != marker) // UGH!! |
4223 | m_pos = cAgentData.Position + offset; | 4253 | m_pos = cAgentData.Position + offset; |
4224 | 4254 | ||
4225 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) | ||
4226 | { | ||
4227 | posLastSignificantMove = AbsolutePosition; | ||
4228 | ReprioritizeUpdates(); | ||
4229 | } | ||
4230 | |||
4231 | CameraPosition = cAgentData.Center + offset; | 4255 | CameraPosition = cAgentData.Center + offset; |
4232 | 4256 | ||
4233 | if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) | 4257 | if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) |
@@ -4262,6 +4286,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4262 | 4286 | ||
4263 | //cAgentData.AVHeight; | 4287 | //cAgentData.AVHeight; |
4264 | //m_velocity = cAgentData.Velocity; | 4288 | //m_velocity = cAgentData.Velocity; |
4289 | checkRePrioritization(); | ||
4265 | } | 4290 | } |
4266 | 4291 | ||
4267 | public void CopyTo(AgentData cAgent) | 4292 | public void CopyTo(AgentData cAgent) |
@@ -4669,12 +4694,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4669 | { | 4694 | { |
4670 | // Clear known regions | 4695 | // Clear known regions |
4671 | KnownRegions = new Dictionary<ulong, string>(); | 4696 | KnownRegions = new Dictionary<ulong, string>(); |
4672 | |||
4673 | lock (m_reprioritization_timer) | ||
4674 | { | ||
4675 | m_reprioritization_timer.Enabled = false; | ||
4676 | m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); | ||
4677 | } | ||
4678 | 4697 | ||
4679 | // I don't get it but mono crashes when you try to dispose of this timer, | 4698 | // I don't get it but mono crashes when you try to dispose of this timer, |
4680 | // unsetting the elapsed callback should be enough to allow for cleanup however. | 4699 | // unsetting the elapsed callback should be enough to allow for cleanup however. |
@@ -5450,31 +5469,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
5450 | return flags; | 5469 | return flags; |
5451 | } | 5470 | } |
5452 | 5471 | ||
5453 | private void ReprioritizeUpdates() | ||
5454 | { | ||
5455 | if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) | ||
5456 | { | ||
5457 | lock (m_reprioritization_timer) | ||
5458 | { | ||
5459 | if (!m_reprioritizing) | ||
5460 | m_reprioritization_timer.Enabled = m_reprioritizing = true; | ||
5461 | else | ||
5462 | m_reprioritization_called = true; | ||
5463 | } | ||
5464 | } | ||
5465 | } | ||
5466 | |||
5467 | private void Reprioritize(object sender, ElapsedEventArgs e) | ||
5468 | { | ||
5469 | ControllingClient.ReprioritizeUpdates(); | ||
5470 | |||
5471 | lock (m_reprioritization_timer) | ||
5472 | { | ||
5473 | m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; | ||
5474 | m_reprioritization_called = false; | ||
5475 | } | ||
5476 | } | ||
5477 | |||
5478 | // returns true it local teleport allowed and sets the destiny position into pos | 5472 | // returns true it local teleport allowed and sets the destiny position into pos |
5479 | 5473 | ||
5480 | private bool CheckLocalTPLandingPoint(ref Vector3 pos) | 5474 | private bool CheckLocalTPLandingPoint(ref Vector3 pos) |
@@ -5946,10 +5940,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5946 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | 5940 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); |
5947 | } | 5941 | } |
5948 | } | 5942 | } |
5949 | finally | 5943 | catch { } |
5950 | { | 5944 | // finally |
5951 | m_collisionEventFlag = false; | 5945 | // { |
5952 | } | 5946 | // m_collisionEventFlag = false; |
5947 | // } | ||
5953 | } | 5948 | } |
5954 | 5949 | ||
5955 | private void TeleportFlagsDebug() { | 5950 | private void TeleportFlagsDebug() { |