diff options
author | UbitUmarov | 2016-09-23 12:32:40 +0100 |
---|---|---|
committer | UbitUmarov | 2016-09-23 12:32:40 +0100 |
commit | 984cb385831e6613fade75046d352a2f68f3ae2b (patch) | |
tree | 042f22c7d97f456fbdbab84ba81f41f063abe821 /OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |
parent | bug fix: add a missing return; add some error messages (diff) | |
download | opensim-SC_OLD-984cb385831e6613fade75046d352a2f68f3ae2b.zip opensim-SC_OLD-984cb385831e6613fade75046d352a2f68f3ae2b.tar.gz opensim-SC_OLD-984cb385831e6613fade75046d352a2f68f3ae2b.tar.bz2 opensim-SC_OLD-984cb385831e6613fade75046d352a2f68f3ae2b.tar.xz |
move wind generation out of heartbeat to a pool job. Use that to send to all clients and not one per client
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Wind/WindModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Wind/WindModule.cs | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 2f401bf..9f13d90 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules | |||
51 | //private Random m_rndnums = new Random(Environment.TickCount); | 51 | //private Random m_rndnums = new Random(Environment.TickCount); |
52 | private Scene m_scene = null; | 52 | private Scene m_scene = null; |
53 | private bool m_ready = false; | 53 | private bool m_ready = false; |
54 | private bool m_inUpdate = false; | ||
54 | 55 | ||
55 | private bool m_enabled = false; | 56 | private bool m_enabled = false; |
56 | private IConfig m_windConfig; | 57 | private IConfig m_windConfig; |
@@ -160,7 +161,7 @@ namespace OpenSim.Region.CoreModules | |||
160 | m_scene.RegisterModuleInterface<IWindModule>(this); | 161 | m_scene.RegisterModuleInterface<IWindModule>(this); |
161 | 162 | ||
162 | // Generate initial wind values | 163 | // Generate initial wind values |
163 | GenWindPos(); | 164 | GenWind(); |
164 | 165 | ||
165 | // Mark Module Ready for duty | 166 | // Mark Module Ready for duty |
166 | m_ready = true; | 167 | m_ready = true; |
@@ -416,67 +417,63 @@ namespace OpenSim.Region.CoreModules | |||
416 | /// </summary> | 417 | /// </summary> |
417 | public void WindUpdate() | 418 | public void WindUpdate() |
418 | { | 419 | { |
419 | if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready) | 420 | if ((!m_ready || m_inUpdate || (m_frame++ % m_frameUpdateRate) != 0)) |
420 | { | ||
421 | return; | 421 | return; |
422 | } | ||
423 | 422 | ||
424 | GenWindPos(); | 423 | m_inUpdate = true; |
425 | 424 | Util.FireAndForget(delegate | |
426 | SendWindAllClients(); | ||
427 | } | ||
428 | /* | ||
429 | public void OnAgentEnteredRegion(ScenePresence avatar) | ||
430 | { | ||
431 | if (m_ready) | ||
432 | { | 425 | { |
433 | if (m_activeWindPlugin != null) | 426 | try |
434 | { | 427 | { |
435 | // Ask wind plugin to generate a LL wind array to be cached locally | 428 | if(GenWind()) |
436 | // Try not to update this too often, as it may involve array copies | 429 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); |
437 | if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate)) | ||
438 | { | ||
439 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | ||
440 | m_frameLastUpdateClientArray = m_frame; | ||
441 | } | ||
442 | } | ||
443 | 430 | ||
444 | avatar.ControllingClient.SendWindData(windSpeeds); | 431 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
445 | } | 432 | { |
433 | client.SendWindData(windSpeeds); | ||
434 | }); | ||
435 | |||
436 | } | ||
437 | finally | ||
438 | { | ||
439 | m_inUpdate = false; | ||
440 | } | ||
441 | }, | ||
442 | null, "WindModuleUpdate"); | ||
446 | } | 443 | } |
447 | */ | 444 | /* |
448 | private void SendWindAllClients() | 445 | private void SendWindAllClients() |
449 | { | 446 | { |
450 | if (m_ready) | 447 | if (!m_ready || m_scene.GetRootAgentCount() == 0) |
451 | { | 448 | return; |
452 | if (m_scene.GetRootAgentCount() > 0) | ||
453 | { | ||
454 | // Ask wind plugin to generate a LL wind array to be cached locally | ||
455 | // Try not to update this too often, as it may involve array copies | ||
456 | if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate)) | ||
457 | { | ||
458 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | ||
459 | m_frameLastUpdateClientArray = m_frame; | ||
460 | } | ||
461 | 449 | ||
462 | m_scene.ForEachRootClient(delegate(IClientAPI client) | 450 | // Ask wind plugin to generate a LL wind array to be cached locally |
463 | { | 451 | // Try not to update this too often, as it may involve array copies |
464 | client.SendWindData(windSpeeds); | 452 | if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate)) |
465 | }); | 453 | { |
466 | } | 454 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); |
455 | m_frameLastUpdateClientArray = m_frame; | ||
467 | } | 456 | } |
457 | |||
458 | m_scene.ForEachRootClient(delegate(IClientAPI client) | ||
459 | { | ||
460 | client.SendWindData(windSpeeds); | ||
461 | }); | ||
468 | } | 462 | } |
463 | */ | ||
469 | /// <summary> | 464 | /// <summary> |
470 | /// Calculate the sun's orbital position and its velocity. | 465 | /// Calculate new wind |
466 | /// returns false if no change | ||
471 | /// </summary> | 467 | /// </summary> |
472 | 468 | ||
473 | private void GenWindPos() | 469 | private bool GenWind() |
474 | { | 470 | { |
475 | if (m_activeWindPlugin != null) | 471 | if (m_activeWindPlugin != null) |
476 | { | 472 | { |
477 | // Tell Wind Plugin to update it's wind data | 473 | // Tell Wind Plugin to update it's wind data |
478 | m_activeWindPlugin.WindUpdate(m_frame); | 474 | return m_activeWindPlugin.WindUpdate(m_frame); |
479 | } | 475 | } |
476 | return false; | ||
480 | } | 477 | } |
481 | } | 478 | } |
482 | } | 479 | } |