From d5fff1abc1e2d0f3c36cee6394cd3fd535174c7e Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Sat, 10 Oct 2009 21:54:21 +0000 Subject: [PATCH] LIBOMV-712: TerrainManager updating Wind from Wrong Simulators git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3141 52acb1d6-8a22-11de-b505-999d5b087335 --- OpenMetaverse/TerrainManager.cs | 14 +++++++++++--- .../TestClient/Commands/Land/WindCommand.cs | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OpenMetaverse/TerrainManager.cs b/OpenMetaverse/TerrainManager.cs index e4db396c..26e85b60 100644 --- a/OpenMetaverse/TerrainManager.cs +++ b/OpenMetaverse/TerrainManager.cs @@ -46,7 +46,7 @@ namespace OpenMetaverse public event LandPatchCallback OnLandPatch; public InternalDictionary SimPatches = new InternalDictionary(); - public Vector2[] WindSpeeds = new Vector2[256]; + public InternalDictionary WindSpeeds = new InternalDictionary(); private GridClient Client; @@ -180,9 +180,17 @@ namespace OpenMetaverse header = TerrainCompressor.DecodePatchHeader(bitpack); TerrainCompressor.DecodePatch(patches, bitpack, header, group.PatchSize); float[] yvalues = TerrainCompressor.DecompressPatch(patches, header, group); - + ulong handle = simulator.Handle; + Vector2[] windSpeeds; + lock (WindSpeeds.Dictionary) + { + if (!WindSpeeds.TryGetValue(handle,out windSpeeds)) + { + windSpeeds = WindSpeeds[handle] = new Vector2[256]; + } + } for (int i = 0; i < 256; i++) - WindSpeeds[i] = new Vector2(xvalues[i], yvalues[i]); + windSpeeds[i] = new Vector2(xvalues[i], yvalues[i]); } private void DecompressCloud(Simulator simulator, BitPack bitpack, TerrainPatch.GroupHeader group) diff --git a/Programs/examples/TestClient/Commands/Land/WindCommand.cs b/Programs/examples/TestClient/Commands/Land/WindCommand.cs index 46459727..50290e5e 100644 --- a/Programs/examples/TestClient/Commands/Land/WindCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/WindCommand.cs @@ -20,7 +20,7 @@ namespace OpenMetaverse.TestClient int xPos = (int)Utils.Clamp(agentPos.X, 0.0f, 255.0f) / 16; int yPos = (int)Utils.Clamp(agentPos.Y, 0.0f, 255.0f) / 16; - Vector2 windSpeed = Client.Terrain.WindSpeeds[yPos * 16 + xPos]; + Vector2 windSpeed = Client.Terrain.WindSpeeds[Client.Network.CurrentSim.Handle][yPos * 16 + xPos]; return "Local wind speed is " + windSpeed.ToString(); }