diff options
author | Adam Frisby | 2008-03-05 00:52:35 +0000 |
---|---|---|
committer | Adam Frisby | 2008-03-05 00:52:35 +0000 |
commit | f64611862a46c91f416134146cb53fa720a96ec5 (patch) | |
tree | 5032b3c6e85254ec62540f76f7921e47b1f7fb62 /OpenSim/Region/Environment | |
parent | once more on hgignore, now that I think I understand this (diff) | |
download | opensim-SC-f64611862a46c91f416134146cb53fa720a96ec5.zip opensim-SC-f64611862a46c91f416134146cb53fa720a96ec5.tar.gz opensim-SC-f64611862a46c91f416134146cb53fa720a96ec5.tar.bz2 opensim-SC-f64611862a46c91f416134146cb53fa720a96ec5.tar.xz |
* New Terrain Module (disabled, search for 'usingTerrainModule = false' to reenable)
* *Much* faster terraforming (woot!)
* New "Brushes" design, so you can create custom terraforming brushes then apply those inplace of the standard tools. (ie an Erode Brush for example)
* New specialised "Flood Brushes" to do large area effects, ie, raise-area, now takes a bitmap rather than repeats the ordinary raise brush a thousand times.
* New modular file Load/Save systems -- write importers/exporters for multiple formats without having to hard code the whole thing in.
* Coming soon - effects system, ie the old Erosion functions, etc. for one-shot effects.
Diffstat (limited to 'OpenSim/Region/Environment')
9 files changed, 49 insertions, 16 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs index f0d600a..62074cb 100644 --- a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs +++ b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs | |||
@@ -34,5 +34,6 @@ namespace OpenSim.Region.Environment.Interfaces | |||
34 | double this[int x, int y] { get; set; } | 34 | double this[int x, int y] { get; set; } |
35 | int Width { get; } | 35 | int Width { get; } |
36 | float[] GetFloatsSerialised(); | 36 | float[] GetFloatsSerialised(); |
37 | bool Tainted(int x, int y); | ||
37 | } | 38 | } |
38 | } | 39 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs index c1ef9d6..0e98111 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs | |||
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
72 | 72 | ||
73 | #region ITerrainPaintableEffect Members | 73 | #region ITerrainPaintableEffect Members |
74 | 74 | ||
75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) | 75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
76 | { | 76 | { |
77 | int x, y; | 77 | int x, y; |
78 | double[,] tweak = new double[map.Width, map.Height]; | 78 | double[,] tweak = new double[map.Width, map.Height]; |
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
106 | { | 106 | { |
107 | for (y = 0; y < map.Height; y++) | 107 | for (y = 0; y < map.Height; y++) |
108 | { | 108 | { |
109 | double z = SphericalFactor(x, y, rx, ry, strength); | 109 | double z = SphericalFactor(x, y, rx, ry, strength) * duration; |
110 | 110 | ||
111 | if (z > 0) // add in non-zero amount | 111 | if (z > 0) // add in non-zero amount |
112 | { | 112 | { |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs index b6696a9..2201584 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs | |||
@@ -34,7 +34,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
34 | { | 34 | { |
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | int x, y; | 39 | int x, y; |
40 | for (x = 0; x < map.Width; x++) | 40 | for (x = 0; x < map.Width; x++) |
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
56 | 56 | ||
57 | if (z > 0.0) | 57 | if (z > 0.0) |
58 | map[x, y] -= z; | 58 | map[x, y] -= z * duration; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | } | 61 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs index 0471408..776e31f 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
35 | { | 35 | { |
36 | #region ITerrainPaintableEffect Members | 36 | #region ITerrainPaintableEffect Members |
37 | 37 | ||
38 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) | 38 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
39 | { | 39 | { |
40 | int x, y; | 40 | int x, y; |
41 | for (x = 0; x < map.Width; x++) | 41 | for (x = 0; x < map.Width; x++) |
@@ -63,7 +63,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
63 | } | 63 | } |
64 | 64 | ||
65 | if (z > 0.0) | 65 | if (z > 0.0) |
66 | map[x, y] += (noise - 0.5) * z; | 66 | map[x, y] += (noise - 0.5) * z * duration; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs index b0fda8e..5b9f410 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs | |||
@@ -34,7 +34,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
34 | { | 34 | { |
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | int x, y; | 39 | int x, y; |
40 | for (x = 0; x < map.Width; x++) | 40 | for (x = 0; x < map.Width; x++) |
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
56 | 56 | ||
57 | if (z > 0.0) | 57 | if (z > 0.0) |
58 | map[x, y] += z; | 58 | map[x, y] += z * duration; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | } | 61 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs index d3ae73e..90bbafc 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs | |||
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
72 | 72 | ||
73 | #region ITerrainPaintableEffect Members | 73 | #region ITerrainPaintableEffect Members |
74 | 74 | ||
75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) | 75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
76 | { | 76 | { |
77 | int x, y; | 77 | int x, y; |
78 | double[,] tweak = new double[map.Width, map.Height]; | 78 | double[,] tweak = new double[map.Width, map.Height]; |
@@ -116,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
116 | { | 116 | { |
117 | double da = z; | 117 | double da = z; |
118 | double a = (map[x, y] - tweak[x, y]) * da; | 118 | double a = (map[x, y] - tweak[x, y]) * da; |
119 | double newz = map[x, y] - a; | 119 | double newz = map[x, y] - (a * duration); |
120 | 120 | ||
121 | if (newz > 0.0) | 121 | if (newz > 0.0) |
122 | map[x, y] = newz; | 122 | map[x, y] = newz; |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs index 1542230..2cf77ff 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
38 | { | 38 | { |
39 | public interface ITerrainPaintableEffect | 39 | public interface ITerrainPaintableEffect |
40 | { | 40 | { |
41 | void PaintEffect(ITerrainChannel map, double x, double y, double strength); | 41 | void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration); |
42 | } | 42 | } |
43 | 43 | ||
44 | public interface ITerrainFloodEffect | 44 | public interface ITerrainFloodEffect |
@@ -63,6 +63,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
63 | public class TerrainChannel : ITerrainChannel | 63 | public class TerrainChannel : ITerrainChannel |
64 | { | 64 | { |
65 | private double[,] map; | 65 | private double[,] map; |
66 | private bool[,] taint; | ||
66 | 67 | ||
67 | public int Width | 68 | public int Width |
68 | { | 69 | { |
@@ -103,29 +104,41 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
103 | } | 104 | } |
104 | set | 105 | set |
105 | { | 106 | { |
107 | taint[x / 16, y / 16] = true; | ||
106 | map[x, y] = value; | 108 | map[x, y] = value; |
107 | } | 109 | } |
108 | } | 110 | } |
109 | 111 | ||
112 | public bool Tainted(int x, int y) | ||
113 | { | ||
114 | return taint[x / 16, y / 16]; | ||
115 | } | ||
116 | |||
110 | public TerrainChannel() | 117 | public TerrainChannel() |
111 | { | 118 | { |
112 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 119 | map = new double[Constants.RegionSize, Constants.RegionSize]; |
120 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | ||
113 | } | 121 | } |
114 | 122 | ||
115 | public TerrainChannel(double[,] import) | 123 | public TerrainChannel(double[,] import) |
116 | { | 124 | { |
117 | map = import; | 125 | map = import; |
126 | taint = new bool[import.GetLength(0), import.GetLength(1)]; | ||
118 | } | 127 | } |
119 | 128 | ||
120 | public TerrainChannel(bool createMap) | 129 | public TerrainChannel(bool createMap) |
121 | { | 130 | { |
122 | if (createMap) | 131 | if (createMap) |
132 | { | ||
123 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 133 | map = new double[Constants.RegionSize, Constants.RegionSize]; |
134 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | ||
135 | } | ||
124 | } | 136 | } |
125 | 137 | ||
126 | public TerrainChannel(int w, int h) | 138 | public TerrainChannel(int w, int h) |
127 | { | 139 | { |
128 | map = new double[w, h]; | 140 | map = new double[w, h]; |
141 | taint = new bool[w / 16, h / 16]; | ||
129 | } | 142 | } |
130 | } | 143 | } |
131 | 144 | ||
@@ -246,7 +259,14 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
246 | if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) | 259 | if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) |
247 | { | 260 | { |
248 | m_painteffects[(StandardTerrainEffects)action].PaintEffect( | 261 | m_painteffects[(StandardTerrainEffects)action].PaintEffect( |
249 | m_channel, west, south, Math.Pow(size, 2.0)); | 262 | m_channel, west, south, Math.Pow(size, 2.0), seconds); |
263 | |||
264 | bool usingTerrainModule = false; | ||
265 | |||
266 | if (usingTerrainModule) | ||
267 | { | ||
268 | remoteClient.SendLayerData(m_channel.GetFloatsSerialised()); | ||
269 | } | ||
250 | } | 270 | } |
251 | else | 271 | else |
252 | { | 272 | { |
@@ -258,20 +278,32 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
258 | if (m_floodeffects.ContainsKey((StandardTerrainEffects)action)) | 278 | if (m_floodeffects.ContainsKey((StandardTerrainEffects)action)) |
259 | { | 279 | { |
260 | bool[,] fillArea = new bool[m_channel.Width, m_channel.Height]; | 280 | bool[,] fillArea = new bool[m_channel.Width, m_channel.Height]; |
261 | |||
262 | fillArea.Initialize(); | 281 | fillArea.Initialize(); |
263 | 282 | ||
264 | int x, y; | 283 | int x, y; |
284 | |||
265 | for (x = 0; x < m_channel.Width; x++) | 285 | for (x = 0; x < m_channel.Width; x++) |
266 | { | 286 | { |
267 | for (y = 0; y < m_channel.Height; y++) | 287 | for (y = 0; y < m_channel.Height; y++) |
268 | { | 288 | { |
269 | fillArea[x, y] = true; | 289 | if (x < east && x > west) |
290 | { | ||
291 | if (y < south && y > north) | ||
292 | { | ||
293 | fillArea[x, y] = true; | ||
294 | } | ||
295 | } | ||
270 | } | 296 | } |
271 | } | 297 | } |
272 | 298 | ||
273 | m_floodeffects[(StandardTerrainEffects)action].FloodEffect( | 299 | m_floodeffects[(StandardTerrainEffects)action].FloodEffect( |
274 | m_channel, fillArea, Math.Pow(size, 2.0)); | 300 | m_channel, fillArea, Math.Pow(size, 2.0)); |
301 | bool usingTerrainModule = false; | ||
302 | |||
303 | if (usingTerrainModule) | ||
304 | { | ||
305 | remoteClient.SendLayerData(m_channel.GetFloatsSerialised()); | ||
306 | } | ||
275 | } | 307 | } |
276 | else | 308 | else |
277 | { | 309 | { |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 1b1549e..ccdd096 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -869,7 +869,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
869 | 869 | ||
870 | public void SendTerrainUpdate(bool checkForTainted) | 870 | public void SendTerrainUpdate(bool checkForTainted) |
871 | { | 871 | { |
872 | float[] terData = Terrain.GetHeights1D(); | 872 | float[] terData = Heightmap.GetFloatsSerialised(); |
873 | 873 | ||
874 | Broadcast(delegate(IClientAPI client) | 874 | Broadcast(delegate(IClientAPI client) |
875 | { | 875 | { |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 9ee5e0e..2a2dea1 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -112,7 +112,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
112 | /// <param name="RemoteClient">Client to send to</param> | 112 | /// <param name="RemoteClient">Client to send to</param> |
113 | public virtual void SendLayerData(IClientAPI RemoteClient) | 113 | public virtual void SendLayerData(IClientAPI RemoteClient) |
114 | { | 114 | { |
115 | bool usingTerrainModule = true; | 115 | bool usingTerrainModule = false; |
116 | 116 | ||
117 | if (usingTerrainModule) | 117 | if (usingTerrainModule) |
118 | { | 118 | { |