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/OpenSim.RegionServer.csproj | 49 ++++++++++++++---------
OpenSim.RegionServer/OpenSimMain.cs | 2 +-
OpenSim.RegionServer/world/Avatar.cs | 4 +-
OpenSim.RegionServer/world/World.cs | 30 +++++++-------
OpenSim.RegionServer/world/WorldPacketHandlers.cs | 26 ++----------
5 files changed, 53 insertions(+), 58 deletions(-)
(limited to 'OpenSim.RegionServer')
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
index 73f523a..44d2635 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 7b0bd4b..b159af0 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 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