aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world
diff options
context:
space:
mode:
authorAdam Frisby2007-04-06 18:48:23 +0000
committerAdam Frisby2007-04-06 18:48:23 +0000
commitfb0dffbf13a79aabe9537f16b7bb151af62c75bf (patch)
tree28a8d468e5499a7af1e33eec7bbdeb9e82ae8732 /OpenSim.RegionServer/world
parentAnd now for some solution files... (diff)
downloadopensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.zip
opensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.tar.gz
opensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.tar.bz2
opensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.tar.xz
**BREAKING CHANGE** Changing the way terrain is stored and used internally.
Diffstat (limited to 'OpenSim.RegionServer/world')
-rw-r--r--OpenSim.RegionServer/world/Avatar.cs4
-rw-r--r--OpenSim.RegionServer/world/World.cs30
-rw-r--r--OpenSim.RegionServer/world/WorldPacketHandlers.cs26
3 files changed, 22 insertions, 38 deletions
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
44 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); 44 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
45 ControllingClient = TheClient; 45 ControllingClient = TheClient;
46 localid = 8880000 + (this.m_world._localNumber++); 46 localid = 8880000 + (this.m_world._localNumber++);
47 Pos = new LLVector3(100.0f, 100.0f, m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 1); 47 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 1.0f);
48 visualParams = new byte[218]; 48 visualParams = new byte[218];
49 for (int i = 0; i < 218; i++) 49 for (int i = 0; i < 218; i++)
50 { 50 {
@@ -332,7 +332,7 @@ namespace OpenSim.world
332 332
333 public override void LandRenegerated() 333 public override void LandRenegerated()
334 { 334 {
335 Pos = new LLVector3(100.0f, 100.0f, this.m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 50); 335 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 50.0f);
336 } 336 }
337 } 337 }
338 338
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;
14using OpenSim.world.scripting; 14using OpenSim.world.scripting;
15using OpenSim.RegionServer.world.scripting; 15using OpenSim.RegionServer.world.scripting;
16using OpenSim.RegionServer.world.scripting.Scripts; 16using OpenSim.RegionServer.world.scripting.Scripts;
17using OpenSim.Terrain;
17 18
18namespace OpenSim.world 19namespace OpenSim.world
19{ 20{
@@ -23,8 +24,9 @@ namespace OpenSim.world
23 public Dictionary<libsecondlife.LLUUID, Entity> Entities; 24 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
24 public Dictionary<libsecondlife.LLUUID, Avatar> Avatars; 25 public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
25 public Dictionary<libsecondlife.LLUUID, Primitive> Prims; 26 public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
26 public float[] LandMap; 27// public float[] LandMap;
27 public ScriptEngine Scripts; 28 public ScriptEngine Scripts;
29 public TerrainEngine Terrain; //TODO: Replace TerrainManager with this.
28 public uint _localNumber = 0; 30 public uint _localNumber = 0;
29 private PhysicsScene phyScene; 31 private PhysicsScene phyScene;
30 private float timeStep = 0.1f; 32 private float timeStep = 0.1f;
@@ -189,13 +191,13 @@ namespace OpenSim.world
189 191
190 public void RegenerateTerrain() 192 public void RegenerateTerrain()
191 { 193 {
192 HeightmapGenHills hills = new HeightmapGenHills(); 194 Terrain.hills();
193 this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); 195
194 lock (this.LockPhysicsEngine) 196 lock (this.LockPhysicsEngine)
195 { 197 {
196 this.phyScene.SetTerrain(this.LandMap); 198 this.phyScene.SetTerrain(Terrain.map);
197 } 199 }
198 this.localStorage.SaveMap(this.LandMap); 200 this.localStorage.SaveMap(this.Terrain.map);
199 201
200 foreach (SimClient client in m_clientThreads.Values) 202 foreach (SimClient client in m_clientThreads.Values)
201 { 203 {
@@ -208,14 +210,14 @@ namespace OpenSim.world
208 } 210 }
209 } 211 }
210 212
211 public void RegenerateTerrain(float[] newMap) 213 public void RegenerateTerrain(float[,] newMap)
212 { 214 {
213 this.LandMap = newMap; 215 this.Terrain.map = newMap;
214 lock (this.LockPhysicsEngine) 216 lock (this.LockPhysicsEngine)
215 { 217 {
216 this.phyScene.SetTerrain(this.LandMap); 218 this.phyScene.SetTerrain(this.Terrain.map);
217 } 219 }
218 this.localStorage.SaveMap(this.LandMap); 220 this.localStorage.SaveMap(this.Terrain.map);
219 221
220 foreach (SimClient client in m_clientThreads.Values) 222 foreach (SimClient client in m_clientThreads.Values)
221 { 223 {
@@ -234,9 +236,9 @@ namespace OpenSim.world
234 { 236 {
235 lock (this.LockPhysicsEngine) 237 lock (this.LockPhysicsEngine)
236 { 238 {
237 this.phyScene.SetTerrain(this.LandMap); 239 this.phyScene.SetTerrain(this.Terrain.map);
238 } 240 }
239 this.localStorage.SaveMap(this.LandMap); 241 this.localStorage.SaveMap(this.Terrain.map);
240 242
241 foreach (SimClient client in m_clientThreads.Values) 243 foreach (SimClient client in m_clientThreads.Values)
242 { 244 {
@@ -249,7 +251,7 @@ namespace OpenSim.world
249 251
250 public void LoadWorldMap() 252 public void LoadWorldMap()
251 { 253 {
252 LandMap = this.localStorage.LoadWorld(); 254 Terrain.map = this.localStorage.LoadWorld();
253 } 255 }
254 256
255 public void LoadPrimsFromStorage() 257 public void LoadPrimsFromStorage()
@@ -288,7 +290,7 @@ namespace OpenSim.world
288 patches[2] = x + 2 + y * 16; 290 patches[2] = x + 2 + y * 16;
289 patches[3] = x + 3 + y * 16; 291 patches[3] = x + 3 + y * 16;
290 292
291 Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); 293 Packet layerpack = TerrainManager.CreateLandPacket(Terrain.map, patches);
292 RemoteClient.OutPacket(layerpack); 294 RemoteClient.OutPacket(layerpack);
293 } 295 }
294 } 296 }
@@ -310,7 +312,7 @@ namespace OpenSim.world
310 //patches[2] = patchx + 2 + patchy * 16; 312 //patches[2] = patchx + 2 + patchy * 16;
311 //patches[3] = patchx + 3 + patchy * 16; 313 //patches[3] = patchx + 3 + patchy * 16;
312 314
313 Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); 315 Packet layerpack = TerrainManager.CreateLandPacket(Terrain.map, patches);
314 RemoteClient.OutPacket(layerpack); 316 RemoteClient.OutPacket(layerpack);
315 } 317 }
316 318
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
24 // raise terrain 24 // raise terrain
25 if (modify.ParcelData.Length > 0) 25 if (modify.ParcelData.Length > 0)
26 { 26 {
27 int mody = (int)modify.ParcelData[0].North; 27 Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
28 int modx = (int)modify.ParcelData[0].West; 28 RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
29 lock (LandMap)
30 {
31 LandMap[(mody * 256) + modx - 1] += 0.05f;
32 LandMap[(mody * 256) + modx] += 0.1f;
33 LandMap[(mody * 256) + modx + 1] += 0.05f;
34 LandMap[((mody + 1) * 256) + modx] += 0.05f;
35 LandMap[((mody - 1) * 256) + modx] += 0.05f;
36 }
37 RegenerateTerrain(true, modx, mody);
38 } 29 }
39 break; 30 break;
40 case 2: 31 case 2:
41 //lower terrain 32 //lower terrain
42 if (modify.ParcelData.Length > 0) 33 if (modify.ParcelData.Length > 0)
43 { 34 {
44 int mody = (int)modify.ParcelData[0].North; 35 Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
45 int modx = (int)modify.ParcelData[0].West; 36 RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
46 lock (LandMap)
47 {
48 LandMap[(mody * 256) + modx - 1] -= 0.05f;
49 LandMap[(mody * 256) + modx] -= 0.1f;
50 LandMap[(mody * 256) + modx + 1] -= 0.05f;
51 LandMap[((mody + 1) * 256) + modx] -= 0.05f;
52 LandMap[((mody - 1) * 256) + modx] -= 0.05f;
53 }
54 RegenerateTerrain(true, modx, mody);
55 } 37 }
56 break; 38 break;
57 } 39 }