diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 60 |
3 files changed, 59 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index cf000a4..ef9c95c 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -86,6 +86,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
86 | private volatile bool m_tainted; | 86 | private volatile bool m_tainted; |
87 | private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); | 87 | private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); |
88 | 88 | ||
89 | private String m_InitialTerrain = "pinhead-island"; | ||
90 | |||
89 | /// <summary> | 91 | /// <summary> |
90 | /// Human readable list of terrain file extensions that are supported. | 92 | /// Human readable list of terrain file extensions that are supported. |
91 | /// </summary> | 93 | /// </summary> |
@@ -109,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
109 | /// <param name="config">Config for the region</param> | 111 | /// <param name="config">Config for the region</param> |
110 | public void Initialise(IConfigSource config) | 112 | public void Initialise(IConfigSource config) |
111 | { | 113 | { |
114 | IConfig terrainConfig = config.Configs["Terrain"]; | ||
115 | if (terrainConfig != null) | ||
116 | m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); | ||
112 | } | 117 | } |
113 | 118 | ||
114 | public void AddRegion(Scene scene) | 119 | public void AddRegion(Scene scene) |
@@ -120,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
120 | { | 125 | { |
121 | if (m_scene.Heightmap == null) | 126 | if (m_scene.Heightmap == null) |
122 | { | 127 | { |
123 | m_channel = new TerrainChannel(); | 128 | m_channel = new TerrainChannel(m_InitialTerrain); |
124 | m_scene.Heightmap = m_channel; | 129 | m_scene.Heightmap = m_channel; |
125 | m_revert = new TerrainChannel(); | 130 | m_revert = new TerrainChannel(); |
126 | UpdateRevertMap(); | 131 | UpdateRevertMap(); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9bca654..6f2dd78 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1583,8 +1583,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1583 | double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); | 1583 | double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); |
1584 | if (map == null) | 1584 | if (map == null) |
1585 | { | 1585 | { |
1586 | m_log.Info("[TERRAIN]: No default terrain. Generating a new terrain."); | 1586 | // This should be in the Terrain module, but it isn't because |
1587 | Heightmap = new TerrainChannel(); | 1587 | // the heightmap is needed _way_ before the modules are initialized... |
1588 | IConfig terrainConfig = m_config.Configs["Terrain"]; | ||
1589 | String m_InitialTerrain = "pinhead-island"; | ||
1590 | if (terrainConfig != null) | ||
1591 | m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); | ||
1592 | |||
1593 | m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); | ||
1594 | Heightmap = new TerrainChannel(m_InitialTerrain); | ||
1588 | 1595 | ||
1589 | SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1596 | SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1590 | } | 1597 | } |
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index ca6210d..c0ca48e 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs | |||
@@ -46,23 +46,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
46 | public TerrainChannel() | 46 | public TerrainChannel() |
47 | { | 47 | { |
48 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 48 | map = new double[Constants.RegionSize, Constants.RegionSize]; |
49 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | 49 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; |
50 | 50 | ||
51 | int x; | 51 | PinHeadIsland(); |
52 | for (x = 0; x < Constants.RegionSize; x++) | 52 | } |
53 | { | 53 | |
54 | int y; | 54 | public TerrainChannel(String type) |
55 | for (y = 0; y < Constants.RegionSize; y++) | 55 | { |
56 | { | 56 | map = new double[Constants.RegionSize, Constants.RegionSize]; |
57 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; | 57 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; |
58 | double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; | 58 | |
59 | double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; | 59 | if (type.Equals("flat")) |
60 | if (map[x, y] < spherFacA) | 60 | FlatLand(); |
61 | map[x, y] = spherFacA; | 61 | else |
62 | if (map[x, y] < spherFacB) | 62 | PinHeadIsland(); |
63 | map[x, y] = spherFacB; | ||
64 | } | ||
65 | } | ||
66 | } | 63 | } |
67 | 64 | ||
68 | public TerrainChannel(double[,] import) | 65 | public TerrainChannel(double[,] import) |
@@ -238,5 +235,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
238 | } | 235 | } |
239 | } | 236 | } |
240 | } | 237 | } |
238 | |||
239 | private void PinHeadIsland() | ||
240 | { | ||
241 | int x; | ||
242 | for (x = 0; x < Constants.RegionSize; x++) | ||
243 | { | ||
244 | int y; | ||
245 | for (y = 0; y < Constants.RegionSize; y++) | ||
246 | { | ||
247 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; | ||
248 | double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; | ||
249 | double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; | ||
250 | if (map[x, y] < spherFacA) | ||
251 | map[x, y] = spherFacA; | ||
252 | if (map[x, y] < spherFacB) | ||
253 | map[x, y] = spherFacB; | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | |||
258 | private void FlatLand() | ||
259 | { | ||
260 | int x; | ||
261 | for (x = 0; x < Constants.RegionSize; x++) | ||
262 | { | ||
263 | int y; | ||
264 | for (y = 0; y < Constants.RegionSize; y++) | ||
265 | map[x, y] = 21; | ||
266 | } | ||
267 | } | ||
268 | |||
241 | } | 269 | } |
242 | } | 270 | } |