aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorAdam Frisby2008-03-06 15:49:53 +0000
committerAdam Frisby2008-03-06 15:49:53 +0000
commita3601165029f8484988b5c322798a341ff1e9400 (patch)
tree4b761e7d0694dffb0b67018915fc240e7bbaa154 /OpenSim/Region/Environment/Modules
parent* Killed 4 more warnings (at 16 now) (diff)
downloadopensim-SC_OLD-a3601165029f8484988b5c322798a341ff1e9400.zip
opensim-SC_OLD-a3601165029f8484988b5c322798a341ff1e9400.tar.gz
opensim-SC_OLD-a3601165029f8484988b5c322798a341ff1e9400.tar.bz2
opensim-SC_OLD-a3601165029f8484988b5c322798a341ff1e9400.tar.xz
* Disabled ancient TerrainEngine.
* Enabled new TerrainModule. (The king is dead, long live the king!) * Use the console command: "script terrain save file.r32" / "script terrain load file.r32" to load/save terrain. Now uses the extension to determine file format. * MANY of the old terrain features do not have a replacement function in the new module yet, this needs to be corrected, but has not been done so far. This being said, the new module is faster and more efficient and should be a good replacement.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs94
-rw-r--r--OpenSim/Region/Environment/Modules/TreePopulatorModule.cs2
2 files changed, 88 insertions, 8 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index 2cf77ff..7ab1e2b 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -96,6 +96,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
96 return heights; 96 return heights;
97 } 97 }
98 98
99 public double[,] GetDoubles()
100 {
101 return map;
102 }
103
99 public double this[int x, int y] 104 public double this[int x, int y]
100 { 105 {
101 get 106 get
@@ -104,14 +109,25 @@ namespace OpenSim.Region.Environment.Modules.Terrain
104 } 109 }
105 set 110 set
106 { 111 {
107 taint[x / 16, y / 16] = true; 112 if (map[x, y] != value)
108 map[x, y] = value; 113 {
114 taint[x / 16, y / 16] = true;
115 map[x, y] = value;
116 }
109 } 117 }
110 } 118 }
111 119
112 public bool Tainted(int x, int y) 120 public bool Tainted(int x, int y)
113 { 121 {
114 return taint[x / 16, y / 16]; 122 if (taint[x / 16, y / 16] != false)
123 {
124 taint[x / 16, y / 16] = false;
125 return true;
126 }
127 else
128 {
129 return false;
130 }
115 } 131 }
116 132
117 public TerrainChannel() 133 public TerrainChannel()
@@ -163,6 +179,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
163 private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); 179 private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
164 Scene m_scene; 180 Scene m_scene;
165 ITerrainChannel m_channel; 181 ITerrainChannel m_channel;
182 bool m_tainted = false;
166 private IConfigSource m_gConfig; 183 private IConfigSource m_gConfig;
167 184
168 private void InstallDefaultEffects() 185 private void InstallDefaultEffects()
@@ -241,6 +258,44 @@ namespace OpenSim.Region.Environment.Modules.Terrain
241 } 258 }
242 259
243 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 260 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
261 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
262 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
263 }
264
265 void EventManager_OnTerrainTick()
266 {
267 if (m_tainted)
268 {
269 m_tainted = false;
270 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
271 m_scene.SaveTerrain();
272
273 //m_scene.CreateTerrainTexture(true);
274 }
275 }
276
277 void EventManager_OnPluginConsole(string[] args)
278 {
279 if (args[0] == "terrain")
280 {
281 string command = args[1];
282 string param = args[2];
283
284
285 switch (command)
286 {
287 case "load":
288 LoadFromFile(param);
289 SendUpdatedLayerData();
290 break;
291 case "save":
292 SaveToFile(param);
293 break;
294 default:
295 m_log.Warn("Unknown terrain command.");
296 break;
297 }
298 }
244 } 299 }
245 300
246 void EventManager_OnNewClient(IClientAPI client) 301 void EventManager_OnNewClient(IClientAPI client)
@@ -248,6 +303,31 @@ namespace OpenSim.Region.Environment.Modules.Terrain
248 client.OnModifyTerrain += client_OnModifyTerrain; 303 client.OnModifyTerrain += client_OnModifyTerrain;
249 } 304 }
250 305
306 void SendUpdatedLayerData()
307 {
308 bool shouldTaint = false;
309 float[] serialised = m_channel.GetFloatsSerialised();
310 int x, y;
311 for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize)
312 {
313 for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize)
314 {
315 if (m_channel.Tainted(x, y))
316 {
317 m_scene.ForEachClient(delegate(IClientAPI controller)
318 {
319 controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised);
320 });
321 shouldTaint = true;
322 }
323 }
324 }
325 if (shouldTaint)
326 {
327 m_tainted = true;
328 }
329 }
330
251 void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, float south, float east, IClientAPI remoteClient) 331 void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, float south, float east, IClientAPI remoteClient)
252 { 332 {
253 // Not a good permissions check, if in area mode, need to check the entire area. 333 // Not a good permissions check, if in area mode, need to check the entire area.
@@ -261,11 +341,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
261 m_painteffects[(StandardTerrainEffects)action].PaintEffect( 341 m_painteffects[(StandardTerrainEffects)action].PaintEffect(
262 m_channel, west, south, Math.Pow(size, 2.0), seconds); 342 m_channel, west, south, Math.Pow(size, 2.0), seconds);
263 343
264 bool usingTerrainModule = false; 344 bool usingTerrainModule = true;
265 345
266 if (usingTerrainModule) 346 if (usingTerrainModule)
267 { 347 {
268 remoteClient.SendLayerData(m_channel.GetFloatsSerialised()); 348 SendUpdatedLayerData();
269 } 349 }
270 } 350 }
271 else 351 else
@@ -298,11 +378,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
298 378
299 m_floodeffects[(StandardTerrainEffects)action].FloodEffect( 379 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(
300 m_channel, fillArea, Math.Pow(size, 2.0)); 380 m_channel, fillArea, Math.Pow(size, 2.0));
301 bool usingTerrainModule = false; 381 bool usingTerrainModule = true;
302 382
303 if (usingTerrainModule) 383 if (usingTerrainModule)
304 { 384 {
305 remoteClient.SendLayerData(m_channel.GetFloatsSerialised()); 385 SendUpdatedLayerData();
306 } 386 }
307 } 387 }
308 else 388 else
diff --git a/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
index edd4286..8aa2223 100644
--- a/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
+++ b/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
@@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules
205 205
206 private void CreateTree(LLVector3 position) 206 private void CreateTree(LLVector3 position)
207 { 207 {
208 position.Z = (float)m_scene.Terrain.heightmap.Get((int)position.X, (int)position.Y); 208 position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y];
209 209
210 SceneObjectGroup tree = 210 SceneObjectGroup tree =
211 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), 211 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f),