diff --git a/OpenSim.Config/SimConfigDb4o/obj/Debug/OpenSim.Config.SimConfigDb4o.dll b/OpenSim.Config/SimConfigDb4o/obj/Debug/OpenSim.Config.SimConfigDb4o.dll new file mode 100644 index 0000000000..ab27ace81c Binary files /dev/null and b/OpenSim.Config/SimConfigDb4o/obj/Debug/OpenSim.Config.SimConfigDb4o.dll differ diff --git a/OpenSim.Config/SimConfigDb4o/obj/Debug/OpenSim.Config.SimConfigDb4o.pdb b/OpenSim.Config/SimConfigDb4o/obj/Debug/OpenSim.Config.SimConfigDb4o.pdb new file mode 100644 index 0000000000..d724d190ef Binary files /dev/null and b/OpenSim.Config/SimConfigDb4o/obj/Debug/OpenSim.Config.SimConfigDb4o.pdb differ diff --git a/OpenSim.Config/SimConfigDb4o/obj/OpenSim.Config.SimConfigDb4o.csproj.FileList.txt b/OpenSim.Config/SimConfigDb4o/obj/OpenSim.Config.SimConfigDb4o.csproj.FileList.txt new file mode 100644 index 0000000000..2212b41217 --- /dev/null +++ b/OpenSim.Config/SimConfigDb4o/obj/OpenSim.Config.SimConfigDb4o.csproj.FileList.txt @@ -0,0 +1,5 @@ +..\..\bin\OpenSim.Config.SimConfigDb4o.dll +..\..\bin\OpenSim.Config.SimConfigDb4o.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\OpenSim.Config.SimConfigDb4o.dll +obj\Debug\OpenSim.Config.SimConfigDb4o.pdb diff --git a/OpenSim.Framework/ILocalStorage.cs b/OpenSim.Framework/ILocalStorage.cs index 2c45baaaf9..bc11d8ffad 100644 --- a/OpenSim.Framework/ILocalStorage.cs +++ b/OpenSim.Framework/ILocalStorage.cs @@ -39,8 +39,8 @@ namespace OpenSim.Framework.Interfaces void StorePrim(PrimData prim); void RemovePrim(LLUUID primID); void LoadPrimitives(ILocalStorageReceiver receiver); - float[] LoadWorld(); - void SaveMap(float[] heightmap); + float[,] LoadWorld(); + void SaveMap(float[,] heightmap); void ShutDown(); } diff --git a/OpenSim.Physics/Manager/PhysicsScene.cs b/OpenSim.Physics/Manager/PhysicsScene.cs index 0b3dfd2d7d..25e2104361 100644 --- a/OpenSim.Physics/Manager/PhysicsScene.cs +++ b/OpenSim.Physics/Manager/PhysicsScene.cs @@ -49,7 +49,7 @@ namespace OpenSim.Physics.Manager public abstract void GetResults(); - public abstract void SetTerrain(float[] heightMap); + public abstract void SetTerrain(float[,] heightMap); public abstract void DeleteTerrain(); @@ -87,7 +87,7 @@ namespace OpenSim.Physics.Manager OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()"); } - public override void SetTerrain(float[] heightMap) + public override void SetTerrain(float[,] heightMap) { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length); } diff --git a/OpenSim.Physics/OdePlugin/OdePlugin.cs b/OpenSim.Physics/OdePlugin/OdePlugin.cs index 325e2fde85..7c9c684dc5 100644 --- a/OpenSim.Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim.Physics/OdePlugin/OdePlugin.cs @@ -173,7 +173,7 @@ namespace OpenSim.Physics.OdePlugin } } - public override void SetTerrain(float[] heightMap) + public override void SetTerrain(float[,] heightMap) { for (int i = 0; i < 65536; i++) { diff --git a/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs index 10e92fe6ed..74e7cb881f 100644 --- a/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs @@ -173,7 +173,7 @@ namespace OpenSim.Physics.PhysXPlugin } } - public override void SetTerrain(float[] heightMap) + public override void SetTerrain(float[,] heightMap) { if (this._heightMap != null) { diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index 73f523a3ed..44d2635a9a 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {632E1BFD-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenSim.RegionServer @@ -15,9 +16,11 @@ IE50 false Library - + + OpenSim.RegionServer - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,26 +61,27 @@ False False 4 - + + - + System.dll False - + System.Xml.dll False - + ..\bin\libsecondlife.dll False - + ..\bin\Axiom.MathLib.dll False - + ..\bin\Db4objects.Db4o.dll False @@ -84,31 +91,35 @@ OpenSim.Framework {8ACA2445-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework.Console {A7CD0630-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.GenericConfig.Xml {E88EF749-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Physics.Manager {8BE16150-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False + + + {FFD5951C-4002-4ACA-9ADF-68852357B94A} + OpenSim.Terrain.BasicTerrain OpenSim.Servers {8BB20F0A-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False @@ -222,4 +233,4 @@ - + \ No newline at end of file diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index 7b0bd4babe..b159af0ac5 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -156,7 +156,7 @@ namespace OpenSim m_console.WriteLine("Main.cs:Startup() - Starting up messaging system"); LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use - LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap); + LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.map); //should be passing a IGenericConfig object to these so they can read the config data they want from it GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey); diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs index 186fb5c6c3..f507797002 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 5b7b3a1f2d..c23ac2d968 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 a155ffe40d..0643a4e8f7 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; } diff --git a/OpenSim.Terrain.BasicTerrain/Hills.cs b/OpenSim.Terrain.BasicTerrain/Hills.cs new file mode 100644 index 0000000000..40543a998a --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/Hills.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Terrain.BasicTerrain +{ + static class Hills + { + /// + /// Generates a series of spheres which are then either max()'d or added together. Inspired by suggestion from jh. + /// + /// 3-Clause BSD Licensed + /// The number of hills to generate + /// The minimum size of each hill + /// The maximum size of each hill + /// Whether to bias hills towards the center of the map + /// Whether to add hills together or to pick the largest value + /// Generates hill-shaped noise instead of consistent hills + public static void hillsSpheres(float[,] map,int seed, int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) + { + Random random = new Random(seed); + int w = map.GetLength(0); + int h = map.GetLength(1); + int x, y; + int i; + + for (i = 0; i < number; i++) + { + double rx = Math.Min(255.0, random.NextDouble() * w); + double ry = Math.Min(255.0, random.NextDouble() * h); + double rand = random.NextDouble(); + + if (island) + { + // Move everything towards the center + rx -= w / 2; + rx /= 2; + rx += w / 2; + + ry -= h / 2; + ry /= 2; + ry += h / 2; + } + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + if (noisy) + rand = random.NextDouble(); + + double z = (scale_min + (scale_range * rand)); + z *= z; + z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + + if (z < 0) + z = 0; + + if (additive) + { + map[x, y] += (float)z; + } + else + { + map[x, y] = (float)Math.Max(map[x, y], z); + } + } + } + } + } + } +} diff --git a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj index 4da1ede65c..21039027dc 100644 --- a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj +++ b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj @@ -33,7 +33,9 @@ - + + + diff --git a/OpenSim.Terrain.BasicTerrain/RaiseLower.cs b/OpenSim.Terrain.BasicTerrain/RaiseLower.cs new file mode 100644 index 0000000000..384bcc0696 --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/RaiseLower.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Terrain.BasicTerrain +{ + static class RaiseLower + { + /// + /// Raises land around the selection + /// + /// The center the X coordinate of where you wish to raise the land + /// The center the Y coordinate of where you wish to raise the land + /// The radius of the dimple + /// How much impact to add to the terrain (0..2 usually) + public static void raise(float[,] map, double rx, double ry, double size, double amount) + { + raiseSphere(map, rx, ry, size, amount); + } + + /// + /// Raises land in a sphere around the selection + /// + /// The center the X coordinate of where you wish to raise the land + /// The center the Y coordinate of where you wish to raise the land + /// The radius of the sphere dimple + /// How much impact to add to the terrain (0..2 usually) + public static void raiseSphere(float[,] map, double rx, double ry, double size, double amount) + { + int x, y; + int w = map.GetLength(0); + int h = map.GetLength(1); + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + double z = size; + z *= z; + z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + + if (z < 0) + z = 0; + + map[x, y] += (float)(z * amount); + } + } + } + + /// + /// Lowers land in a sphere around the selection + /// + /// The center the X coordinate of where you wish to lower the land + /// The center the Y coordinate of where you wish to lower the land + /// The radius of the sphere dimple + /// How much impact to remove from the terrain (0..2 usually) + public static void lower(float[,] map, double rx, double ry, double size, double amount) + { + lowerSphere(map, rx, ry, size, amount); + } + + /// + /// Lowers land in a sphere around the selection + /// + /// The center the X coordinate of where you wish to lower the land + /// The center the Y coordinate of where you wish to lower the land + /// The radius of the sphere dimple + /// How much impact to remove from the terrain (0..2 usually) + public static void lowerSphere(float[,] map, double rx, double ry, double size, double amount) + { + int x, y; + int w = map.GetLength(0); + int h = map.GetLength(1); + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + double z = size; + z *= z; + z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + + if (z < 0) + z = 0; + + map[x, y] -= (float)(z * amount); + } + } + } + } +} diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs new file mode 100644 index 0000000000..f805d18d7e --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Terrain.BasicTerrain; + +namespace OpenSim.Terrain +{ + public class TerrainEngine + { + public float[,] map; + public float[,] water; + int w, h; + + public TerrainEngine() + { + w = 256; + h = 256; + map = new float[w, h]; + water = new float[w, h]; + + } + + /// + /// Swaps the references between the height and water buffers to allow you to edit the water heightmap. Remember to swap back when you are done. + /// + public void swapWaterBuffer() + { + float[,] temp = map; + map = water; + water = temp; + } + + /// + /// Raises land in a sphere around the specified coordinates + /// + /// Center of the sphere on the X axis + /// Center of the sphere on the Y axis + /// The radius of the sphere + /// Scale the height of the sphere by this amount (recommended 0..2) + public void raise(double rx, double ry, double size, double amount) + { + lock (map) + { + RaiseLower.raiseSphere(this.map, rx, ry, size, amount); + } + } + public void lower(double rx, double ry, double size, double amount) + { + lock (map) + { + RaiseLower.lowerSphere(this.map, rx, ry, size, amount); + } + } + + public void hills() + { + lock (map) + { + Hills.hillsSpheres(this.map, 1337, 200, 20, 40, true, true, false); + } + } + + } +} diff --git a/OpenSim.Terrain.BasicTerrain/TerrainManager.cs b/OpenSim.Terrain.BasicTerrain/TerrainManager.cs deleted file mode 100644 index 65880eb6d5..0000000000 --- a/OpenSim.Terrain.BasicTerrain/TerrainManager.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Terrain -{ - public class TerrainManager - { - - } -} diff --git a/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dll b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dll new file mode 100644 index 0000000000..0cfa5952c6 Binary files /dev/null and b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dll differ diff --git a/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdb b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdb new file mode 100644 index 0000000000..ce440c698c Binary files /dev/null and b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdb differ diff --git a/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dll b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dll new file mode 100644 index 0000000000..0cfa5952c6 Binary files /dev/null and b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dll differ diff --git a/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdb b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdb new file mode 100644 index 0000000000..ce440c698c Binary files /dev/null and b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdb differ diff --git a/OpenSim.Terrain.BasicTerrain/obj/OpenSim.Terrain.BasicTerrain.csproj.FileList.txt b/OpenSim.Terrain.BasicTerrain/obj/OpenSim.Terrain.BasicTerrain.csproj.FileList.txt new file mode 100644 index 0000000000..4728b51253 --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/obj/OpenSim.Terrain.BasicTerrain.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\OpenSim.Terrain.BasicTerrain.dll +bin\Debug\OpenSim.Terrain.BasicTerrain.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\OpenSim.Terrain.BasicTerrain.dll +obj\Debug\OpenSim.Terrain.BasicTerrain.pdb diff --git a/bin/OpenSim.Terrain.BasicTerrain.dll b/bin/OpenSim.Terrain.BasicTerrain.dll new file mode 100644 index 0000000000..10061e0c1b Binary files /dev/null and b/bin/OpenSim.Terrain.BasicTerrain.dll differ