1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Mapgen V7: Huge rewrite, also tweaks to cavegen et al.

This commit is contained in:
kwolekr 2013-07-06 02:21:35 -04:00
parent 3607fae75a
commit 18d7bc7fa1
12 changed files with 452 additions and 196 deletions

View file

@ -275,6 +275,7 @@ CaveV7::CaveV7(MapgenV7 *mg, PseudoRandom *ps, bool is_large_cave) {
this->ps = ps;
this->c_water_source = mg->c_water_source;
this->c_lava_source = mg->c_lava_source;
this->c_ice = mg->c_ice;
this->np_caveliquids = &nparams_caveliquids;
dswitchint = ps->range(1, 14);
@ -454,8 +455,9 @@ void CaveV7::makeTunnel(bool dirswitch) {
bool randomize_xz = (ps->range(1, 2) == 1);
// Make a ravine every once in a while if it's long enough
float xylen = vec.X * vec.X + vec.Z * vec.Z;
bool is_ravine = (xylen > 500.0) && !large_cave && (ps->range(1, 8) == 1);
//float xylen = vec.X * vec.X + vec.Z * vec.Z;
//disable ravines for now
bool is_ravine = false; //(xylen > 500.0) && !large_cave && (ps->range(1, 8) == 1);
// Carve routes
for (float f = 0; f < 1.0; f += 1.0 / veclen)
@ -490,6 +492,7 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
}
bool flat_cave_floor = !large_cave && ps->range(0, 2) == 2;
bool should_make_cave_hole = ps->range(1, 10) == 1;
for (s16 z0 = d0; z0 <= d1; z0++) {
s16 si = rs / 2 - MYMAX(0, abs(z0) - rs / 7 - 1);
@ -513,10 +516,10 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
p += of;
if (!is_ravine && mg->heightmap) {
if (!is_ravine && mg->heightmap && should_make_cave_hole) {
int maplen = node_max.X - node_min.X + 1;
int idx = (p.Z - node_min.Z) * maplen + (p.X - node_min.X);
if (p.Y >= mg->heightmap[idx])
if (p.Y >= mg->heightmap[idx] - 2)
continue;
}
@ -525,9 +528,10 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
u32 i = vm->m_area.index(p);
// Don't replace air or water or lava
// Don't replace air, water, lava, or ice
content_t c = vm->m_data[i].getContent();
if (c == CONTENT_AIR || c == c_water_source || c == c_lava_source)
if (c == CONTENT_AIR || c == c_water_source ||
c == c_lava_source || c == c_ice)
continue;
if (large_cave) {
@ -541,6 +545,9 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
else
vm->m_data[i] = airnode;
} else {
if (c == CONTENT_IGNORE)
continue;
vm->m_data[i] = airnode;
vm->m_flags[i] |= VMANIP_FLAG_CAVE;
}