diff options
author | UbitUmarov | 2016-09-23 13:55:23 +0100 |
---|---|---|
committer | UbitUmarov | 2016-09-23 13:55:23 +0100 |
commit | 8d7f10e36bbb4de101b900f6b455de09c47d079c (patch) | |
tree | 464cf396422aaea042943bef78a0e0b9dc442284 /OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |
parent | add a version tag to wind and cloud data updates to iclient (diff) | |
download | opensim-SC_OLD-8d7f10e36bbb4de101b900f6b455de09c47d079c.zip opensim-SC_OLD-8d7f10e36bbb4de101b900f6b455de09c47d079c.tar.gz opensim-SC_OLD-8d7f10e36bbb4de101b900f6b455de09c47d079c.tar.bz2 opensim-SC_OLD-8d7f10e36bbb4de101b900f6b455de09c47d079c.tar.xz |
cache wind compressed data so cpu burning compression is only done after a change. Not happy with version scheme for several regions on same instance, but should be ok for now
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Wind/WindModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Wind/WindModule.cs | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index f1de0bc..bc92582 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |||
@@ -46,7 +46,8 @@ namespace OpenSim.Region.CoreModules | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private uint m_frame = 0; | 48 | private uint m_frame = 0; |
49 | private uint m_frameLastUpdateClientArray = 0; | 49 | private int m_dataVersion = 0; |
50 | private int m_regionID = 0; | ||
50 | private int m_frameUpdateRate = 150; | 51 | private int m_frameUpdateRate = 150; |
51 | //private Random m_rndnums = new Random(Environment.TickCount); | 52 | //private Random m_rndnums = new Random(Environment.TickCount); |
52 | private Scene m_scene = null; | 53 | private Scene m_scene = null; |
@@ -97,7 +98,6 @@ namespace OpenSim.Region.CoreModules | |||
97 | 98 | ||
98 | m_scene = scene; | 99 | m_scene = scene; |
99 | m_frame = 0; | 100 | m_frame = 0; |
100 | |||
101 | // Register all the Wind Model Plug-ins | 101 | // Register all the Wind Model Plug-ins |
102 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) | 102 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) |
103 | { | 103 | { |
@@ -119,7 +119,6 @@ namespace OpenSim.Region.CoreModules | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | |||
123 | // if the plug-in wasn't found, default to no wind. | 122 | // if the plug-in wasn't found, default to no wind. |
124 | if (m_activeWindPlugin == null) | 123 | if (m_activeWindPlugin == null) |
125 | { | 124 | { |
@@ -155,14 +154,14 @@ namespace OpenSim.Region.CoreModules | |||
155 | 154 | ||
156 | // Register event handlers for when Avatars enter the region, and frame ticks | 155 | // Register event handlers for when Avatars enter the region, and frame ticks |
157 | m_scene.EventManager.OnFrame += WindUpdate; | 156 | m_scene.EventManager.OnFrame += WindUpdate; |
158 | // m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion; | ||
159 | 157 | ||
160 | // Register the wind module | 158 | // Register the wind module |
161 | m_scene.RegisterModuleInterface<IWindModule>(this); | 159 | m_scene.RegisterModuleInterface<IWindModule>(this); |
162 | 160 | ||
163 | // Generate initial wind values | 161 | // Generate initial wind values |
164 | GenWind(); | 162 | GenWind(); |
165 | 163 | // hopefully this will not be the same for all regions on same instance | |
164 | m_dataVersion = (int)m_scene.AllocateLocalId(); | ||
166 | // Mark Module Ready for duty | 165 | // Mark Module Ready for duty |
167 | m_ready = true; | 166 | m_ready = true; |
168 | } | 167 | } |
@@ -425,13 +424,11 @@ namespace OpenSim.Region.CoreModules | |||
425 | { | 424 | { |
426 | try | 425 | try |
427 | { | 426 | { |
428 | if(GenWind()) | 427 | GenWind(); |
429 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | 428 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
430 | 429 | { | |
431 | m_scene.ForEachRootClient(delegate(IClientAPI client) | 430 | client.SendWindData(m_dataVersion, windSpeeds); |
432 | { | 431 | }); |
433 | client.SendWindData(0, windSpeeds); | ||
434 | }); | ||
435 | 432 | ||
436 | } | 433 | } |
437 | finally | 434 | finally |
@@ -441,26 +438,7 @@ namespace OpenSim.Region.CoreModules | |||
441 | }, | 438 | }, |
442 | null, "WindModuleUpdate"); | 439 | null, "WindModuleUpdate"); |
443 | } | 440 | } |
444 | /* | ||
445 | private void SendWindAllClients() | ||
446 | { | ||
447 | if (!m_ready || m_scene.GetRootAgentCount() == 0) | ||
448 | return; | ||
449 | 441 | ||
450 | // Ask wind plugin to generate a LL wind array to be cached locally | ||
451 | // Try not to update this too often, as it may involve array copies | ||
452 | if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate)) | ||
453 | { | ||
454 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | ||
455 | m_frameLastUpdateClientArray = m_frame; | ||
456 | } | ||
457 | |||
458 | m_scene.ForEachRootClient(delegate(IClientAPI client) | ||
459 | { | ||
460 | client.SendWindData(windSpeeds); | ||
461 | }); | ||
462 | } | ||
463 | */ | ||
464 | /// <summary> | 442 | /// <summary> |
465 | /// Calculate new wind | 443 | /// Calculate new wind |
466 | /// returns false if no change | 444 | /// returns false if no change |
@@ -468,10 +446,11 @@ namespace OpenSim.Region.CoreModules | |||
468 | 446 | ||
469 | private bool GenWind() | 447 | private bool GenWind() |
470 | { | 448 | { |
471 | if (m_activeWindPlugin != null) | 449 | if (m_activeWindPlugin != null && m_activeWindPlugin.WindUpdate(m_frame)) |
472 | { | 450 | { |
473 | // Tell Wind Plugin to update it's wind data | 451 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); |
474 | return m_activeWindPlugin.WindUpdate(m_frame); | 452 | m_dataVersion++; |
453 | return true; | ||
475 | } | 454 | } |
476 | return false; | 455 | return false; |
477 | } | 456 | } |