From 6b13730bc7451a407c6370d289545542c66a74ea Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 26 Sep 2008 12:56:17 +0000 Subject: * Wind updates. Still random.. but in 4 directions instead of two! * It seems kind of silly to be building a 256x256 array just to use two 16 float blocks.. but for now the layerdata routine requires it so we'll go along with that. * We only fill a 32x16 area of the 256x256 float array with data. * We use patches 0,0 and 0,1 for the first and second patch to determine the direction and magnitude of the wind. --- OpenSim/Framework/IClientAPI.cs | 2 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 50 +++++++++++--------- .../Environment/Modules/World/NPC/NPCAvatar.cs | 2 +- .../Environment/Modules/World/Wind/WindModule.cs | 54 +++++++++++----------- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 2 +- 5 files changed, 58 insertions(+), 52 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 244a2f3..0e6a9da 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -559,7 +559,7 @@ namespace OpenSim.Framework void SendLayerData(int px, int py, float[] map); void SendWindData(float[] map); - void SendWindData(int px, int py, float[] map); + void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map); void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look); void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index e21bf7c..39bda70 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1235,7 +1235,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// heightmap public virtual void SendWindData(float[] map) { - ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)map); + //ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)map); } /// @@ -1244,12 +1244,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private void DoSendWindData(object o) { - float[] map = (float[])o; + //float[] map = (float[])o; - try - { - for (int y = 0; y < 16; y++) - { + //try + //{ + //for (int y = 0; y < 16; y++) + //{ // For some terrains, sending more than one terrain patch at once results in a libsecondlife exception // see http://opensimulator.org/mantis/view.php?id=1662 //for (int x = 0; x < 16; x += 4) @@ -1257,17 +1257,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP // SendLayerPacket(map, y, x); // Thread.Sleep(150); //} - for (int x = 0; x < 16; x++) - { - SendWindData(x, y, map); - Thread.Sleep(35); - } - } - } - catch (Exception e) - { - m_log.Warn("[CLIENT]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); - } + // for (int x = 0; x < 16; x++) + //{ + //SendWindData(x, y, map); + //Thread.Sleep(35); + //} + //} + //} + //catch (Exception e) + //{ + // m_log.Warn("[CLIENT]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); + // } } /// @@ -1294,16 +1294,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Patch coordinate (x) 0..15 /// Patch coordinate (y) 0..15 /// heightmap - public void SendWindData(int px, int py, float[] map) + public void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map) { try { - int[] patches = new int[1]; - int patchx, patchy; - patchx = px; - patchy = py; + int[] patches = new int[2]; + int patch1x, patch1y, patch2x, patch2y; + patch1x = p1x; + patch1y = p1y; + patch2x = p2x; + patch2y = p2y; - patches[0] = patchx + 0 + patchy * 16; + + patches[0] = patch1x + 0 + patch1y * 16; + patches[1] = patch2x + 0 + patch2y * 16; LayerDataPacket layerpack = TerrainCompressor.CreateWindPacket(map, patches); layerpack.Header.Zerocoded = true; diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 653932c..a8ed498 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -483,7 +483,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC } public virtual void SendWindData(float[] map) { } - public virtual void SendWindData(int px, int py, float[] map) { } + public virtual void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map) { } public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) { diff --git a/OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs b/OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs index 190cc0b..d7bc42f 100644 --- a/OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs @@ -149,28 +149,11 @@ namespace OpenSim.Region.Environment.Modules { if (!avatar.IsChildAgent) { - spotxp = (int)avatar.CameraPosition.X + 3; - spotxm = (int)avatar.CameraPosition.X - 3; - spotyp = (int)avatar.CameraPosition.Y + 3; - spotym = (int)avatar.CameraPosition.Y - 3; - if (spotxm < 0) - spotxm = 0; - if (spotym < 0) - spotym = 0; - if (spotxp > 255) - spotxp = 255; - if (spotyp > 255) - spotyp = 255; - for (int x = spotxm; x