diff options
Diffstat (limited to 'OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs')
-rw-r--r-- | OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs b/OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs index 2f2c04e..325b788 100644 --- a/OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs +++ b/OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs | |||
@@ -1,80 +1,80 @@ | |||
1 | using System; | 1 | using System; |
2 | using OpenSim.Region.Environment.Interfaces; | 2 | using OpenSim.Region.Environment.Interfaces; |
3 | using OpenSim.Region.Environment.Modules.Terrain; | 3 | using OpenSim.Region.Environment.Modules.Terrain; |
4 | using OpenSim.Region.Environment.Modules.Terrain.FloodBrushes; | 4 | using OpenSim.Region.Environment.Modules.Terrain.FloodBrushes; |
5 | 5 | ||
6 | namespace OpenSim.Region.Modules.Terrain.Extensions.DefaultEffects.Effects | 6 | namespace OpenSim.Region.Modules.Terrain.Extensions.DefaultEffects.Effects |
7 | { | 7 | { |
8 | public class ChannelDigger : ITerrainEffect | 8 | public class ChannelDigger : ITerrainEffect |
9 | { | 9 | { |
10 | private readonly int num_h = 4; | 10 | private readonly int num_h = 4; |
11 | private readonly int num_w = 4; | 11 | private readonly int num_w = 4; |
12 | 12 | ||
13 | private readonly ITerrainFloodEffect raiseFunction = new RaiseArea(); | 13 | private readonly ITerrainFloodEffect raiseFunction = new RaiseArea(); |
14 | private readonly ITerrainFloodEffect smoothFunction = new SmoothArea(); | 14 | private readonly ITerrainFloodEffect smoothFunction = new SmoothArea(); |
15 | 15 | ||
16 | #region ITerrainEffect Members | 16 | #region ITerrainEffect Members |
17 | 17 | ||
18 | public void RunEffect(ITerrainChannel map) | 18 | public void RunEffect(ITerrainChannel map) |
19 | { | 19 | { |
20 | FillMap(map, 15); | 20 | FillMap(map, 15); |
21 | BuildTiles(map, 7); | 21 | BuildTiles(map, 7); |
22 | SmoothMap(map, 3); | 22 | SmoothMap(map, 3); |
23 | } | 23 | } |
24 | 24 | ||
25 | #endregion | 25 | #endregion |
26 | 26 | ||
27 | private void SmoothMap(ITerrainChannel map, int rounds) | 27 | private void SmoothMap(ITerrainChannel map, int rounds) |
28 | { | 28 | { |
29 | Boolean[,] bitmap = new bool[map.Width,map.Height]; | 29 | Boolean[,] bitmap = new bool[map.Width,map.Height]; |
30 | for (int x = 0; x < map.Width; x++) | 30 | for (int x = 0; x < map.Width; x++) |
31 | { | 31 | { |
32 | for (int y = 0; y < map.Height; y++) | 32 | for (int y = 0; y < map.Height; y++) |
33 | { | 33 | { |
34 | bitmap[x, y] = true; | 34 | bitmap[x, y] = true; |
35 | } | 35 | } |
36 | } | 36 | } |
37 | 37 | ||
38 | for (int i = 0; i < rounds; i++) | 38 | for (int i = 0; i < rounds; i++) |
39 | { | 39 | { |
40 | smoothFunction.FloodEffect(map, bitmap, 1.0); | 40 | smoothFunction.FloodEffect(map, bitmap, 1.0); |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | private void FillMap(ITerrainChannel map, double val) | 44 | private void FillMap(ITerrainChannel map, double val) |
45 | { | 45 | { |
46 | for (int x = 0; x < map.Width; x++) | 46 | for (int x = 0; x < map.Width; x++) |
47 | for (int y = 0; y < map.Height; y++) | 47 | for (int y = 0; y < map.Height; y++) |
48 | map[x, y] = val; | 48 | map[x, y] = val; |
49 | } | 49 | } |
50 | 50 | ||
51 | private void BuildTiles(ITerrainChannel map, double height) | 51 | private void BuildTiles(ITerrainChannel map, double height) |
52 | { | 52 | { |
53 | int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8); | 53 | int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8); |
54 | int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8); | 54 | int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8); |
55 | int channelXOffset = (map.Width / num_w) - channelWidth; | 55 | int channelXOffset = (map.Width / num_w) - channelWidth; |
56 | int channelYOffset = (map.Height / num_h) - channelHeight; | 56 | int channelYOffset = (map.Height / num_h) - channelHeight; |
57 | 57 | ||
58 | for (int x = 0; x < num_w; x++) | 58 | for (int x = 0; x < num_w; x++) |
59 | { | 59 | { |
60 | for (int y = 0; y < num_h; y++) | 60 | for (int y = 0; y < num_h; y++) |
61 | { | 61 | { |
62 | int xoff = ((channelXOffset + channelWidth) * x) + (channelXOffset / 2); | 62 | int xoff = ((channelXOffset + channelWidth) * x) + (channelXOffset / 2); |
63 | int yoff = ((channelYOffset + channelHeight) * y) + (channelYOffset / 2); | 63 | int yoff = ((channelYOffset + channelHeight) * y) + (channelYOffset / 2); |
64 | 64 | ||
65 | Boolean[,] bitmap = new bool[map.Width,map.Height]; | 65 | Boolean[,] bitmap = new bool[map.Width,map.Height]; |
66 | 66 | ||
67 | for (int dx = 0; dx < channelWidth; dx++) | 67 | for (int dx = 0; dx < channelWidth; dx++) |
68 | { | 68 | { |
69 | for (int dy = 0; dy < channelHeight; dy++) | 69 | for (int dy = 0; dy < channelHeight; dy++) |
70 | { | 70 | { |
71 | bitmap[dx + xoff, dy + yoff] = true; | 71 | bitmap[dx + xoff, dy + yoff] = true; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | raiseFunction.FloodEffect(map, bitmap, height); | 75 | raiseFunction.FloodEffect(map, bitmap, height); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | } | 79 | } |
80 | } \ No newline at end of file | 80 | } \ No newline at end of file |