From fb0dffbf13a79aabe9537f16b7bb151af62c75bf Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 6 Apr 2007 18:48:23 +0000 Subject: **BREAKING CHANGE** Changing the way terrain is stored and used internally. --- OpenSim.RegionServer/world/Avatar.cs | 4 +-- OpenSim.RegionServer/world/World.cs | 30 ++++++++++++----------- OpenSim.RegionServer/world/WorldPacketHandlers.cs | 26 +++----------------- 3 files changed, 22 insertions(+), 38 deletions(-) (limited to 'OpenSim.RegionServer/world') diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs index 186fb5c..f507797 100644 --- a/OpenSim.RegionServer/world/Avatar.cs +++ b/OpenSim.RegionServer/world/Avatar.cs @@ -44,7 +44,7 @@ namespace OpenSim.world OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); ControllingClient = TheClient; localid = 8880000 + (this.m_world._localNumber++); - Pos = new LLVector3(100.0f, 100.0f, m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 1); + Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 1.0f); visualParams = new byte[218]; for (int i = 0; i < 218; i++) { @@ -332,7 +332,7 @@ namespace OpenSim.world public override void LandRenegerated() { - Pos = new LLVector3(100.0f, 100.0f, this.m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 50); + Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 50.0f); } } diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index 5b7b3a1..c23ac2d 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs @@ -14,6 +14,7 @@ using OpenSim.Assets; using OpenSim.world.scripting; using OpenSim.RegionServer.world.scripting; using OpenSim.RegionServer.world.scripting.Scripts; +using OpenSim.Terrain; namespace OpenSim.world { @@ -23,8 +24,9 @@ namespace OpenSim.world public Dictionary Entities; public Dictionary Avatars; public Dictionary Prims; - public float[] LandMap; +// public float[] LandMap; public ScriptEngine Scripts; + public TerrainEngine Terrain; //TODO: Replace TerrainManager with this. public uint _localNumber = 0; private PhysicsScene phyScene; private float timeStep = 0.1f; @@ -189,13 +191,13 @@ namespace OpenSim.world public void RegenerateTerrain() { - HeightmapGenHills hills = new HeightmapGenHills(); - this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); + Terrain.hills(); + lock (this.LockPhysicsEngine) { - this.phyScene.SetTerrain(this.LandMap); + this.phyScene.SetTerrain(Terrain.map); } - this.localStorage.SaveMap(this.LandMap); + this.localStorage.SaveMap(this.Terrain.map); foreach (SimClient client in m_clientThreads.Values) { @@ -208,14 +210,14 @@ namespace OpenSim.world } } - public void RegenerateTerrain(float[] newMap) + public void RegenerateTerrain(float[,] newMap) { - this.LandMap = newMap; + this.Terrain.map = newMap; lock (this.LockPhysicsEngine) { - this.phyScene.SetTerrain(this.LandMap); + this.phyScene.SetTerrain(this.Terrain.map); } - this.localStorage.SaveMap(this.LandMap); + this.localStorage.SaveMap(this.Terrain.map); foreach (SimClient client in m_clientThreads.Values) { @@ -234,9 +236,9 @@ namespace OpenSim.world { lock (this.LockPhysicsEngine) { - this.phyScene.SetTerrain(this.LandMap); + this.phyScene.SetTerrain(this.Terrain.map); } - this.localStorage.SaveMap(this.LandMap); + this.localStorage.SaveMap(this.Terrain.map); foreach (SimClient client in m_clientThreads.Values) { @@ -249,7 +251,7 @@ namespace OpenSim.world public void LoadWorldMap() { - LandMap = this.localStorage.LoadWorld(); + Terrain.map = this.localStorage.LoadWorld(); } public void LoadPrimsFromStorage() @@ -288,7 +290,7 @@ namespace OpenSim.world patches[2] = x + 2 + y * 16; patches[3] = x + 3 + y * 16; - Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); + Packet layerpack = TerrainManager.CreateLandPacket(Terrain.map, patches); RemoteClient.OutPacket(layerpack); } } @@ -310,7 +312,7 @@ namespace OpenSim.world //patches[2] = patchx + 2 + patchy * 16; //patches[3] = patchx + 3 + patchy * 16; - Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); + Packet layerpack = TerrainManager.CreateLandPacket(Terrain.map, patches); RemoteClient.OutPacket(layerpack); } diff --git a/OpenSim.RegionServer/world/WorldPacketHandlers.cs b/OpenSim.RegionServer/world/WorldPacketHandlers.cs index a155ffe..0643a4e 100644 --- a/OpenSim.RegionServer/world/WorldPacketHandlers.cs +++ b/OpenSim.RegionServer/world/WorldPacketHandlers.cs @@ -24,34 +24,16 @@ namespace OpenSim.world // raise terrain if (modify.ParcelData.Length > 0) { - int mody = (int)modify.ParcelData[0].North; - int modx = (int)modify.ParcelData[0].West; - lock (LandMap) - { - LandMap[(mody * 256) + modx - 1] += 0.05f; - LandMap[(mody * 256) + modx] += 0.1f; - LandMap[(mody * 256) + modx + 1] += 0.05f; - LandMap[((mody + 1) * 256) + modx] += 0.05f; - LandMap[((mody - 1) * 256) + modx] += 0.05f; - } - RegenerateTerrain(true, modx, mody); + Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); + RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); } break; case 2: //lower terrain if (modify.ParcelData.Length > 0) { - int mody = (int)modify.ParcelData[0].North; - int modx = (int)modify.ParcelData[0].West; - lock (LandMap) - { - LandMap[(mody * 256) + modx - 1] -= 0.05f; - LandMap[(mody * 256) + modx] -= 0.1f; - LandMap[(mody * 256) + modx + 1] -= 0.05f; - LandMap[((mody + 1) * 256) + modx] -= 0.05f; - LandMap[((mody - 1) * 256) + modx] -= 0.05f; - } - RegenerateTerrain(true, modx, mody); + Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1); + RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West); } break; } -- cgit v1.1