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(); }