forked from Mirrorlandia_minetest/minetest
Cavegen: Cleanup code. Define constant for MGV7_LAVA_DEPTH
This commit is contained in:
parent
d75009a758
commit
c0dafa1c10
@ -253,7 +253,8 @@ void CaveV5::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
|
|||||||
if (!is_ravine && mg->heightmap && should_make_cave_hole &&
|
if (!is_ravine && mg->heightmap && should_make_cave_hole &&
|
||||||
p.X <= node_max.X && p.Z <= node_max.Z) {
|
p.X <= node_max.X && p.Z <= node_max.Z) {
|
||||||
int maplen = node_max.X - node_min.X + 1;
|
int maplen = node_max.X - node_min.X + 1;
|
||||||
int idx = (p.Z - node_min.Z) * maplen + (p.X - node_min.X);
|
int idx = (p.Z - node_min.Z) * maplen +
|
||||||
|
(p.X - node_min.X);
|
||||||
if (p.Y >= mg->heightmap[idx] - 2)
|
if (p.Y >= mg->heightmap[idx] - 2)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -269,10 +270,13 @@ void CaveV5::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
|
|||||||
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
|
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
|
||||||
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
|
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
|
||||||
|
|
||||||
if (flooded && full_ymin < water_level && full_ymax > water_level)
|
if (flooded && full_ymin < water_level &&
|
||||||
vm->m_data[i] = (p.Y <= water_level) ? waternode : airnode;
|
full_ymax > water_level)
|
||||||
|
vm->m_data[i] = (p.Y <= water_level) ?
|
||||||
|
waternode : airnode;
|
||||||
else if (flooded && full_ymax < water_level)
|
else if (flooded && full_ymax < water_level)
|
||||||
vm->m_data[i] = (p.Y < startp.Y - 4) ? liquidnode : airnode;
|
vm->m_data[i] = (p.Y < startp.Y - 4) ?
|
||||||
|
liquidnode : airnode;
|
||||||
else
|
else
|
||||||
vm->m_data[i] = airnode;
|
vm->m_data[i] = airnode;
|
||||||
}
|
}
|
||||||
@ -438,7 +442,8 @@ void CaveV6::makeTunnel(bool dirswitch) {
|
|||||||
v3s16 p1 = orpi + veci + of + rs / 2;
|
v3s16 p1 = orpi + veci + of + rs / 2;
|
||||||
if (p1.Z >= node_min.Z && p1.Z <= node_max.Z &&
|
if (p1.Z >= node_min.Z && p1.Z <= node_max.Z &&
|
||||||
p1.X >= node_min.X && p1.X <= node_max.X) {
|
p1.X >= node_min.X && p1.X <= node_max.X) {
|
||||||
u32 index1 = (p1.Z - node_min.Z) * mg->ystride + (p1.X - node_min.X);
|
u32 index1 = (p1.Z - node_min.Z) * mg->ystride +
|
||||||
|
(p1.X - node_min.X);
|
||||||
h1 = mg->heightmap[index1];
|
h1 = mg->heightmap[index1];
|
||||||
} else {
|
} else {
|
||||||
h1 = water_level; // If not in heightmap
|
h1 = water_level; // If not in heightmap
|
||||||
@ -447,7 +452,8 @@ void CaveV6::makeTunnel(bool dirswitch) {
|
|||||||
v3s16 p2 = orpi + of + rs / 2;
|
v3s16 p2 = orpi + of + rs / 2;
|
||||||
if (p2.Z >= node_min.Z && p2.Z <= node_max.Z &&
|
if (p2.Z >= node_min.Z && p2.Z <= node_max.Z &&
|
||||||
p2.X >= node_min.X && p2.X <= node_max.X) {
|
p2.X >= node_min.X && p2.X <= node_max.X) {
|
||||||
u32 index2 = (p2.Z - node_min.Z) * mg->ystride + (p2.X - node_min.X);
|
u32 index2 = (p2.Z - node_min.Z) * mg->ystride +
|
||||||
|
(p2.X - node_min.X);
|
||||||
h2 = mg->heightmap[index2];
|
h2 = mg->heightmap[index2];
|
||||||
} else {
|
} else {
|
||||||
h2 = water_level;
|
h2 = water_level;
|
||||||
@ -540,10 +546,13 @@ void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
|
|||||||
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
|
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
|
||||||
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
|
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
|
||||||
|
|
||||||
if (flooded && full_ymin < water_level && full_ymax > water_level) {
|
if (flooded && full_ymin < water_level &&
|
||||||
vm->m_data[i] = (p.Y <= water_level) ? waternode : airnode;
|
full_ymax > water_level) {
|
||||||
|
vm->m_data[i] = (p.Y <= water_level) ?
|
||||||
|
waternode : airnode;
|
||||||
} else if (flooded && full_ymax < water_level) {
|
} else if (flooded && full_ymax < water_level) {
|
||||||
vm->m_data[i] = (p.Y < startp.Y - 2) ? lavanode : airnode;
|
vm->m_data[i] = (p.Y < startp.Y - 2) ?
|
||||||
|
lavanode : airnode;
|
||||||
} else {
|
} else {
|
||||||
vm->m_data[i] = airnode;
|
vm->m_data[i] = airnode;
|
||||||
}
|
}
|
||||||
@ -749,7 +758,8 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
|
|||||||
|
|
||||||
float nval = NoisePerlin3D(np_caveliquids, startp.X,
|
float nval = NoisePerlin3D(np_caveliquids, startp.X,
|
||||||
startp.Y, startp.Z, mg->seed);
|
startp.Y, startp.Z, mg->seed);
|
||||||
MapNode liquidnode = (nval < 0.40 && node_max.Y < -256) ? lavanode : waternode;
|
MapNode liquidnode = (nval < 0.40 && node_max.Y < MGV7_LAVA_DEPTH) ?
|
||||||
|
lavanode : waternode;
|
||||||
|
|
||||||
v3f fp = orp + vec * f;
|
v3f fp = orp + vec * f;
|
||||||
fp.X += 0.1 * ps->range(-10, 10);
|
fp.X += 0.1 * ps->range(-10, 10);
|
||||||
@ -786,7 +796,8 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
|
|||||||
if (!is_ravine && mg->heightmap && should_make_cave_hole &&
|
if (!is_ravine && mg->heightmap && should_make_cave_hole &&
|
||||||
p.X <= node_max.X && p.Z <= node_max.Z) {
|
p.X <= node_max.X && p.Z <= node_max.Z) {
|
||||||
int maplen = node_max.X - node_min.X + 1;
|
int maplen = node_max.X - node_min.X + 1;
|
||||||
int idx = (p.Z - node_min.Z) * maplen + (p.X - node_min.X);
|
int idx = (p.Z - node_min.Z) * maplen +
|
||||||
|
(p.X - node_min.X);
|
||||||
if (p.Y >= mg->heightmap[idx] - 2)
|
if (p.Y >= mg->heightmap[idx] - 2)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -802,10 +813,13 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
|
|||||||
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
|
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
|
||||||
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
|
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
|
||||||
|
|
||||||
if (flooded && full_ymin < water_level && full_ymax > water_level)
|
if (flooded && full_ymin < water_level &&
|
||||||
vm->m_data[i] = (p.Y <= water_level) ? waternode : airnode;
|
full_ymax > water_level)
|
||||||
|
vm->m_data[i] = (p.Y <= water_level) ?
|
||||||
|
waternode : airnode;
|
||||||
else if (flooded && full_ymax < water_level)
|
else if (flooded && full_ymax < water_level)
|
||||||
vm->m_data[i] = (p.Y < startp.Y - 4) ? liquidnode : airnode;
|
vm->m_data[i] = (p.Y < startp.Y - 4) ?
|
||||||
|
liquidnode : airnode;
|
||||||
else
|
else
|
||||||
vm->m_data[i] = airnode;
|
vm->m_data[i] = airnode;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define CAVEGEN_HEADER
|
#define CAVEGEN_HEADER
|
||||||
|
|
||||||
#define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
|
#define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
|
||||||
|
#define MGV7_LAVA_DEPTH -256
|
||||||
|
|
||||||
class MapgenV5;
|
class MapgenV5;
|
||||||
class MapgenV6;
|
class MapgenV6;
|
||||||
|
Loading…
Reference in New Issue
Block a user