Skip to content

Commit bc3980e

Browse files
committedNov 15, 2016
Mgv7: Add optional floatlands, disabled by default
1 parent 5fd1ef9 commit bc3980e

File tree

4 files changed

+221
-68
lines changed

4 files changed

+221
-68
lines changed
 

Diff for: ‎builtin/settingtypes.txt

+20-4
Original file line numberDiff line numberDiff line change
@@ -963,23 +963,39 @@ mgv6_np_apple_trees (Mapgen v6 apple trees noise parameters) noise_params 0, 1,
963963
[***Mapgen v7]
964964

965965
# Map generation attributes specific to Mapgen v7.
966-
# The 'ridges' flag controls the rivers.
966+
# The 'ridges' flag enables the rivers.
967+
# Floatlands are currently experimental and subject to change.
967968
# Flags that are not specified in the flag string are not modified from the default.
968969
# Flags starting with 'no' are used to explicitly disable them.
969-
mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,nomountains,noridges
970+
mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,floatlands,nomountains,noridges,nofloatlands
970971

971972
# Controls width of tunnels, a smaller value creates wider tunnels.
972973
mgv7_cave_width (Mapgen v7 cave width) float 0.2
973974

975+
# Controls the density of floatland mountain terrain.
976+
# Is an offset added to the 'np_mountain' noise value.
977+
mgv7_float_mount_density (Mapgen v7 floatland mountain density) float 0.6
978+
979+
# Typical maximum height, above and below midpoint, of floatland mountain terrain.
980+
mgv7_float_mount_height (Mapgen v7 floatland mountain height) float 128.0
981+
982+
# Y-level of floatland midpoint and lake surface.
983+
mgv7_floatland_level (Mapgen v7 floatland level) int 1280
984+
985+
# Y-level to which floatland shadows extend.
986+
mgv7_shadow_limit (Mapgen v7 shadow limit) int 1024
987+
974988
mgv7_np_terrain_base (Mapgen v7 terrain base noise parameters) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0
975989
mgv7_np_terrain_alt (Mapgen v7 terrain altitude noise parameters) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0
976990
mgv7_np_terrain_persist (Mapgen v7 terrain persistation noise parameters) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0
977991
mgv7_np_height_select (Mapgen v7 height select noise parameters) noise_params -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0
978992
mgv7_np_filler_depth (Mapgen v7 filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0
979993
mgv7_np_mount_height (Mapgen v7 mount height noise parameters) noise_params 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0
980-
mgv7_np_ridge_uwater (Mapgen v7 ridge water noise parameters) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0
994+
mgv7_np_ridge_uwater (Mapgen v7 river course noise parameters) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0
995+
mgv7_np_floatland_base (Mapgen v7 floatland base terrain noise parameters) noise_params -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0
996+
mgv7_np_float_base_height (Mapgen v7 floatland base terrain height noise parameters) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0
981997
mgv7_np_mountain (Mapgen v7 mountain noise parameters) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0
982-
mgv7_np_ridge (Mapgen v7 ridge noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0
998+
mgv7_np_ridge (Mapgen v7 river channel wall noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0
983999
mgv7_np_cave1 (Mapgen v7 cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0
9841000
mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0
9851001

Diff for: ‎minetest.conf.example

+27-2
Original file line numberDiff line numberDiff line change
@@ -1239,16 +1239,35 @@
12391239
#### Mapgen v7
12401240

12411241
# Map generation attributes specific to Mapgen v7.
1242-
# The 'ridges' flag controls the rivers.
1242+
# The 'ridges' flag enables the rivers.
1243+
# Floatlands are currently experimental and subject to change.
12431244
# Flags that are not specified in the flag string are not modified from the default.
12441245
# Flags starting with 'no' are used to explicitly disable them.
1245-
# type: flags possible values: mountains, ridges, nomountains, noridges
1246+
# type: flags possible values: mountains, ridges, floatlands,
1247+
# nomountains, noridges, nofloatlands
12461248
# mgv7_spflags = mountains,ridges
12471249

12481250
# Controls width of tunnels, a smaller value creates wider tunnels.
12491251
# type: float
12501252
# mgv7_cave_width = 0.2
12511253

1254+
# Controls the density of floatland mountain terrain.
1255+
# Is an offset added to the 'np_mountain' noise value.
1256+
# type: float
1257+
# mgv7_float_mount_density = 0.6
1258+
1259+
# Typical maximum height, above and below midpoint, of floatland mountain terrain.
1260+
# type: float
1261+
# mgv7_float_mount_height = 128.0
1262+
1263+
# Y-level of floatland midpoint and lake surface.
1264+
# type: int
1265+
# mgv7_floatland_level = 1280
1266+
1267+
# Y-level to which floatland shadows extend.
1268+
# type: int
1269+
# mgv7_shadow_limit = 1024
1270+
12521271
# type: noise_params
12531272
# mgv7_np_terrain_base = 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0
12541273

@@ -1270,6 +1289,12 @@
12701289
# type: noise_params
12711290
# mgv7_np_ridge_uwater = 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0
12721291

1292+
# type: noise_params
1293+
# mgv7_np_floatland_base = -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0
1294+
1295+
# type: noise_params
1296+
# mgv7_np_float_base_height = 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0
1297+
12731298
# type: noise_params
12741299
# mgv7_np_mountain = -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0
12751300

Diff for: ‎src/mapgen_v7.cpp

+153-59
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4141

4242

4343
FlagDesc flagdesc_mapgen_v7[] = {
44-
{"mountains", MGV7_MOUNTAINS},
45-
{"ridges", MGV7_RIDGES},
46-
{NULL, 0}
44+
{"mountains", MGV7_MOUNTAINS},
45+
{"ridges", MGV7_RIDGES},
46+
{"floatlands", MGV7_FLOATLANDS},
47+
{NULL, 0}
4748
};
4849

4950

@@ -53,17 +54,23 @@ FlagDesc flagdesc_mapgen_v7[] = {
5354
MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
5455
: MapgenBasic(mapgenid, params, emerge)
5556
{
56-
this->spflags = params->spflags;
57-
this->cave_width = params->cave_width;
57+
this->spflags = params->spflags;
58+
this->cave_width = params->cave_width;
59+
this->float_mount_density = params->float_mount_density;
60+
this->float_mount_height = params->float_mount_height;
61+
this->floatland_level = params->floatland_level;
62+
this->shadow_limit = params->shadow_limit;
5863

5964
//// Terrain noise
60-
noise_terrain_base = new Noise(&params->np_terrain_base, seed, csize.X, csize.Z);
61-
noise_terrain_alt = new Noise(&params->np_terrain_alt, seed, csize.X, csize.Z);
62-
noise_terrain_persist = new Noise(&params->np_terrain_persist, seed, csize.X, csize.Z);
63-
noise_height_select = new Noise(&params->np_height_select, seed, csize.X, csize.Z);
64-
noise_filler_depth = new Noise(&params->np_filler_depth, seed, csize.X, csize.Z);
65-
noise_mount_height = new Noise(&params->np_mount_height, seed, csize.X, csize.Z);
66-
noise_ridge_uwater = new Noise(&params->np_ridge_uwater, seed, csize.X, csize.Z);
65+
noise_terrain_base = new Noise(&params->np_terrain_base, seed, csize.X, csize.Z);
66+
noise_terrain_alt = new Noise(&params->np_terrain_alt, seed, csize.X, csize.Z);
67+
noise_terrain_persist = new Noise(&params->np_terrain_persist, seed, csize.X, csize.Z);
68+
noise_height_select = new Noise(&params->np_height_select, seed, csize.X, csize.Z);
69+
noise_filler_depth = new Noise(&params->np_filler_depth, seed, csize.X, csize.Z);
70+
noise_mount_height = new Noise(&params->np_mount_height, seed, csize.X, csize.Z);
71+
noise_ridge_uwater = new Noise(&params->np_ridge_uwater, seed, csize.X, csize.Z);
72+
noise_floatland_base = new Noise(&params->np_floatland_base, seed, csize.X, csize.Z);
73+
noise_float_base_height = new Noise(&params->np_float_base_height, seed, csize.X, csize.Z);
6774

6875
//// 3d terrain noise
6976
// 1-up 1-down overgeneration
@@ -84,65 +91,85 @@ MapgenV7::~MapgenV7()
8491
delete noise_filler_depth;
8592
delete noise_mount_height;
8693
delete noise_ridge_uwater;
94+
delete noise_floatland_base;
95+
delete noise_float_base_height;
8796
delete noise_mountain;
8897
delete noise_ridge;
8998
}
9099

91100

92101
MapgenV7Params::MapgenV7Params()
93102
{
94-
spflags = MGV7_MOUNTAINS | MGV7_RIDGES;
95-
cave_width = 0.2;
96-
97-
np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0);
98-
np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0);
99-
np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0);
100-
np_height_select = NoiseParams(-8, 16, v3f(500, 500, 500), 4213, 6, 0.7, 2.0);
101-
np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
102-
np_mount_height = NoiseParams(256, 112, v3f(1000, 1000, 1000), 72449, 3, 0.6, 2.0);
103-
np_ridge_uwater = NoiseParams(0, 1, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0);
104-
np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.63, 2.0);
105-
np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0);
106-
np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0);
107-
np_cave2 = NoiseParams(0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0);
103+
spflags = MGV7_MOUNTAINS | MGV7_RIDGES;
104+
cave_width = 0.2;
105+
float_mount_density = 0.6;
106+
float_mount_height = 128.0;
107+
floatland_level = 1280;
108+
shadow_limit = 1024;
109+
110+
np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0);
111+
np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0);
112+
np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0);
113+
np_height_select = NoiseParams(-8, 16, v3f(500, 500, 500), 4213, 6, 0.7, 2.0);
114+
np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
115+
np_mount_height = NoiseParams(256, 112, v3f(1000, 1000, 1000), 72449, 3, 0.6, 2.0);
116+
np_ridge_uwater = NoiseParams(0, 1, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0);
117+
np_floatland_base = NoiseParams(-0.6, 1.5, v3f(600, 600, 600), 114, 5, 0.6, 2.0);
118+
np_float_base_height = NoiseParams(48, 24, v3f(300, 300, 300), 907, 4, 0.7, 2.0);
119+
np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.63, 2.0);
120+
np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0);
121+
np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0);
122+
np_cave2 = NoiseParams(0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0);
108123
}
109124

110125

111126
void MapgenV7Params::readParams(const Settings *settings)
112127
{
113-
settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
114-
settings->getFloatNoEx("mgv7_cave_width", cave_width);
115-
116-
settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base);
117-
settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
118-
settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
119-
settings->getNoiseParams("mgv7_np_height_select", np_height_select);
120-
settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth);
121-
settings->getNoiseParams("mgv7_np_mount_height", np_mount_height);
122-
settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
123-
settings->getNoiseParams("mgv7_np_mountain", np_mountain);
124-
settings->getNoiseParams("mgv7_np_ridge", np_ridge);
125-
settings->getNoiseParams("mgv7_np_cave1", np_cave1);
126-
settings->getNoiseParams("mgv7_np_cave2", np_cave2);
128+
settings->getFlagStrNoEx("mgv7_spflags", spflags, flagdesc_mapgen_v7);
129+
settings->getFloatNoEx("mgv7_cave_width", cave_width);
130+
settings->getFloatNoEx("mgv7_float_mount_density", float_mount_density);
131+
settings->getFloatNoEx("mgv7_float_mount_height", float_mount_height);
132+
settings->getS16NoEx("mgv7_floatland_level", floatland_level);
133+
settings->getS16NoEx("mgv7_shadow_limit", shadow_limit);
134+
135+
settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base);
136+
settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
137+
settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
138+
settings->getNoiseParams("mgv7_np_height_select", np_height_select);
139+
settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth);
140+
settings->getNoiseParams("mgv7_np_mount_height", np_mount_height);
141+
settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
142+
settings->getNoiseParams("mgv7_np_floatland_base", np_floatland_base);
143+
settings->getNoiseParams("mgv7_np_float_base_height", np_float_base_height);
144+
settings->getNoiseParams("mgv7_np_mountain", np_mountain);
145+
settings->getNoiseParams("mgv7_np_ridge", np_ridge);
146+
settings->getNoiseParams("mgv7_np_cave1", np_cave1);
147+
settings->getNoiseParams("mgv7_np_cave2", np_cave2);
127148
}
128149

129150

130151
void MapgenV7Params::writeParams(Settings *settings) const
131152
{
132-
settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX);
133-
settings->setFloat("mgv7_cave_width", cave_width);
134-
135-
settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base);
136-
settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
137-
settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
138-
settings->setNoiseParams("mgv7_np_height_select", np_height_select);
139-
settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth);
140-
settings->setNoiseParams("mgv7_np_mount_height", np_mount_height);
141-
settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
142-
settings->setNoiseParams("mgv7_np_mountain", np_mountain);
143-
settings->setNoiseParams("mgv7_np_ridge", np_ridge);
144-
settings->setNoiseParams("mgv7_np_cave1", np_cave1);
145-
settings->setNoiseParams("mgv7_np_cave2", np_cave2);
153+
settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX);
154+
settings->setFloat("mgv7_cave_width", cave_width);
155+
settings->setFloat("mgv7_float_mount_density", float_mount_density);
156+
settings->setFloat("mgv7_float_mount_height", float_mount_height);
157+
settings->setS16("mgv7_floatland_level", floatland_level);
158+
settings->setS16("mgv7_shadow_limit", shadow_limit);
159+
160+
settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base);
161+
settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt);
162+
settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist);
163+
settings->setNoiseParams("mgv7_np_height_select", np_height_select);
164+
settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth);
165+
settings->setNoiseParams("mgv7_np_mount_height", np_mount_height);
166+
settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater);
167+
settings->setNoiseParams("mgv7_np_floatland_base", np_floatland_base);
168+
settings->setNoiseParams("mgv7_np_float_base_height", np_float_base_height);
169+
settings->setNoiseParams("mgv7_np_mountain", np_mountain);
170+
settings->setNoiseParams("mgv7_np_ridge", np_ridge);
171+
settings->setNoiseParams("mgv7_np_cave1", np_cave1);
172+
settings->setNoiseParams("mgv7_np_cave2", np_cave2);
146173
}
147174

148175

@@ -249,9 +276,13 @@ void MapgenV7::makeChunk(BlockMakeData *data)
249276

250277
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
251278

279+
// Limit floatland shadow
280+
bool propagate_shadow = !((spflags & MGV7_FLOATLANDS) &&
281+
node_min.Y <= shadow_limit && node_max.Y >= shadow_limit);
282+
252283
if (flags & MG_LIGHT)
253284
calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0),
254-
full_node_min, full_node_max);
285+
full_node_min, full_node_max, propagate_shadow);
255286

256287
//setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
257288
// node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE, 0xFF);
@@ -313,6 +344,47 @@ bool MapgenV7::getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y)
313344
}
314345

315346

347+
bool MapgenV7::getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y)
348+
{
349+
float density_gradient =
350+
-pow(fabs((float)(y - floatland_level) / float_mount_height), 0.8f);
351+
float floatn = noise_mountain->result[idx_xyz] + float_mount_density;
352+
353+
return floatn + density_gradient >= 0.0f;
354+
}
355+
356+
357+
void MapgenV7::floatBaseExtentFromMap(s16 *float_base_min, s16 *float_base_max, int idx_xz)
358+
{
359+
// '+1' to avoid a layer of stone at y = MAX_MAP_GENERATION_LIMIT
360+
s16 base_min = MAX_MAP_GENERATION_LIMIT + 1;
361+
s16 base_max = MAX_MAP_GENERATION_LIMIT;
362+
363+
float n_base = noise_floatland_base->result[idx_xz];
364+
if (n_base > 0.0f) {
365+
float n_base_height =
366+
MYMAX(noise_float_base_height->result[idx_xz], 0.0f);
367+
float amp = n_base * n_base_height;
368+
float ridge = n_base_height / 3.0f;
369+
base_min = floatland_level - amp / 2.0f;
370+
371+
if (amp > ridge * 2.0f) {
372+
// Lake bed
373+
base_max = floatland_level - (amp - ridge * 2.0f) / 2.0f;
374+
} else {
375+
// Hills and ridges
376+
float diff = fabs(amp - ridge) / ridge;
377+
// Smooth ridges using the 'smoothstep function'
378+
float smooth_diff = diff * diff * (3.0f - 2.0f * diff);
379+
base_max = floatland_level + ridge - smooth_diff * ridge;
380+
}
381+
}
382+
383+
*float_base_min = base_min;
384+
*float_base_max = base_max;
385+
}
386+
387+
316388
int MapgenV7::generateTerrain()
317389
{
318390
MapNode n_air(CONTENT_AIR);
@@ -327,11 +399,19 @@ int MapgenV7::generateTerrain()
327399
noise_terrain_alt->perlinMap2D(node_min.X, node_min.Z, persistmap);
328400
noise_height_select->perlinMap2D(node_min.X, node_min.Z);
329401

330-
if (spflags & MGV7_MOUNTAINS) {
402+
if ((spflags & MGV7_MOUNTAINS) || (spflags & MGV7_FLOATLANDS)) {
331403
noise_mountain->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
404+
}
405+
406+
if (spflags & MGV7_MOUNTAINS) {
332407
noise_mount_height->perlinMap2D(node_min.X, node_min.Z);
333408
}
334409

410+
if (spflags & MGV7_FLOATLANDS) {
411+
noise_floatland_base->perlinMap2D(node_min.X, node_min.Z);
412+
noise_float_base_height->perlinMap2D(node_min.X, node_min.Z);
413+
}
414+
335415
//// Place nodes
336416
v3s16 em = vm->m_area.getExtent();
337417
s16 stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
@@ -340,10 +420,16 @@ int MapgenV7::generateTerrain()
340420
for (s16 z = node_min.Z; z <= node_max.Z; z++)
341421
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
342422
s16 surface_y = baseTerrainLevelFromMap(index2d);
343-
344423
if (surface_y > stone_surface_max_y)
345424
stone_surface_max_y = surface_y;
346425

426+
// Get extent of floatland base terrain
427+
// '+1' to avoid a layer of stone at y = MAX_MAP_GENERATION_LIMIT
428+
s16 float_base_min = MAX_MAP_GENERATION_LIMIT + 1;
429+
s16 float_base_max = MAX_MAP_GENERATION_LIMIT;
430+
if (spflags & MGV7_FLOATLANDS)
431+
floatBaseExtentFromMap(&float_base_min, &float_base_max, index2d);
432+
347433
u32 vi = vm->m_area.index(x, node_min.Y - 1, z);
348434
u32 index3d = (z - node_min.Z) * zstride_1u1d + (x - node_min.X);
349435

@@ -356,8 +442,16 @@ int MapgenV7::generateTerrain()
356442
vm->m_data[vi] = n_stone; // Mountain terrain
357443
if (y > stone_surface_max_y)
358444
stone_surface_max_y = y;
445+
} else if ((spflags & MGV7_FLOATLANDS) &&
446+
((y >= float_base_min && y <= float_base_max) ||
447+
getFloatlandMountainFromMap(index3d, index2d, y))) {
448+
vm->m_data[vi] = n_stone; // Floatland terrain
449+
stone_surface_max_y = node_max.Y;
359450
} else if (y <= water_level) {
360-
vm->m_data[vi] = n_water;
451+
vm->m_data[vi] = n_water; // Ground level water
452+
} else if ((spflags & MGV7_FLOATLANDS) &&
453+
(y >= float_base_max && y <= floatland_level)) {
454+
vm->m_data[vi] = n_water; // Floatland water
361455
} else {
362456
vm->m_data[vi] = n_air;
363457
}
@@ -373,7 +467,7 @@ int MapgenV7::generateTerrain()
373467

374468
void MapgenV7::generateRidgeTerrain()
375469
{
376-
if (node_max.Y < water_level - 16)
470+
if ((node_max.Y < water_level - 16) || (node_max.Y > shadow_limit))
377471
return;
378472

379473
noise_ridge->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);

Diff for: ‎src/mapgen_v7.h

+21-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2323

2424
#include "mapgen.h"
2525

26-
/////////////////// Mapgen V7 flags
27-
#define MGV7_MOUNTAINS 0x01
28-
#define MGV7_RIDGES 0x02
26+
////////////// Mapgen V7 flags
27+
#define MGV7_MOUNTAINS 0x01
28+
#define MGV7_RIDGES 0x02
29+
#define MGV7_FLOATLANDS 0x04
2930

3031
class BiomeManager;
3132

@@ -35,13 +36,20 @@ extern FlagDesc flagdesc_mapgen_v7[];
3536
struct MapgenV7Params : public MapgenParams {
3637
u32 spflags;
3738
float cave_width;
39+
float float_mount_density;
40+
float float_mount_height;
41+
s16 floatland_level;
42+
s16 shadow_limit;
43+
3844
NoiseParams np_terrain_base;
3945
NoiseParams np_terrain_alt;
4046
NoiseParams np_terrain_persist;
4147
NoiseParams np_height_select;
4248
NoiseParams np_filler_depth;
4349
NoiseParams np_mount_height;
4450
NoiseParams np_ridge_uwater;
51+
NoiseParams np_floatland_base;
52+
NoiseParams np_float_base_height;
4553
NoiseParams np_mountain;
4654
NoiseParams np_ridge;
4755
NoiseParams np_cave1;
@@ -68,16 +76,26 @@ class MapgenV7 : public MapgenBasic {
6876
float baseTerrainLevelFromMap(int index);
6977
bool getMountainTerrainAtPoint(s16 x, s16 y, s16 z);
7078
bool getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y);
79+
bool getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y);
80+
void floatBaseExtentFromMap(s16 *float_base_min, s16 *float_base_max, int idx_xz);
81+
7182
int generateTerrain();
7283
void generateRidgeTerrain();
7384

7485
private:
86+
float float_mount_density;
87+
float float_mount_height;
88+
s16 floatland_level;
89+
s16 shadow_limit;
90+
7591
Noise *noise_terrain_base;
7692
Noise *noise_terrain_alt;
7793
Noise *noise_terrain_persist;
7894
Noise *noise_height_select;
7995
Noise *noise_mount_height;
8096
Noise *noise_ridge_uwater;
97+
Noise *noise_floatland_base;
98+
Noise *noise_float_base_height;
8199
Noise *noise_mountain;
82100
Noise *noise_ridge;
83101
};

0 commit comments

Comments
 (0)
Please sign in to comment.