From 4004172106d2f736916bd2b3729edfce43699e1e Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 25 Sep 2008 11:46:05 +0000 Subject: * Adds some Wind * A little wind wouldn't hurt anyone, right? This is the 'slightly breezy' setting.. hopefully you won't notice 'much' of a difference. * It turns out the terrain patch routine is similar enough to the wind version that it can be used to hack together a breeze generator with a few mods. * Not much configuration.. yet. You only get breeze updates in the general vicinity of your camera now to keep bandwidth usage down.. and we're not talking about 'much' movement at the moment. * initial version... could use improvement I'm sure. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 93 +++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/LindenUDP') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 983e1a9..3a90cff 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1219,8 +1219,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(map, patches); layerpack.Header.Zerocoded = true; - + OutPacket(layerpack, ThrottleOutPacketType.Land); + } catch (Exception e) { @@ -1229,6 +1230,96 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// + /// Send the region heightmap to the client + /// + /// heightmap + public virtual void SendWindData(float[] map) + { + ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)map); + } + + /// + /// Send terrain layer information to the client. + /// + /// + private void DoSendWindData(object o) + { + float[] map = (float[])o; + + 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) + //{ + // 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()); + } + } + + /// + /// Sends a set of four patches (x, x+1, ..., x+3) to the client + /// + /// heightmap + /// X coordinate for patches 0..12 + /// Y coordinate for patches 0..15 + // private void SendLayerPacket(float[] map, int y, int x) + // { + // int[] patches = new int[4]; + // patches[0] = x + 0 + y * 16; + // patches[1] = x + 1 + y * 16; + // patches[2] = x + 2 + y * 16; + // patches[3] = x + 3 + y * 16; + + // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); + // OutPacket(layerpack, ThrottleOutPacketType.Land); + // } + + /// + /// Sends a specified patch to a client + /// + /// Patch coordinate (x) 0..15 + /// Patch coordinate (y) 0..15 + /// heightmap + public void SendWindData(int px, int py, float[] map) + { + try + { + int[] patches = new int[1]; + int patchx, patchy; + patchx = px; + patchy = py; + + patches[0] = patchx + 0 + patchy * 16; + + LayerDataPacket layerpack = TerrainCompressor.CreateWindPacket(map, patches); + layerpack.Header.Zerocoded = true; + + OutPacket(layerpack, ThrottleOutPacketType.Wind); + + } + catch (Exception e) + { + m_log.Warn("[client]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); + } + } + + + + /// /// Tell the client that the given neighbour region is ready to receive a child agent. /// /// -- cgit v1.1