mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Cavegen: Prevent caves from occuring above ground level, and superfluous mixing of lava and water in caves
This commit is contained in:
parent
8161ab573f
commit
fe4ce03d52
@ -24,6 +24,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "mapgen_v7.h"
|
||||
#include "cavegen.h"
|
||||
|
||||
NoiseParams nparams_caveliquids =
|
||||
{0, 1, v3f(150.0, 150.0, 150.0), 776, 3, 0.6};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_cave) {
|
||||
this->mg = mg;
|
||||
@ -269,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->np_caveliquids = &nparams_caveliquids;
|
||||
|
||||
dswitchint = ps->range(1, 14);
|
||||
flooded = ps->range(1, 2) == 2;
|
||||
@ -303,7 +310,7 @@ void CaveV7::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
|
||||
// Allow a bit more
|
||||
//(this should be more than the maximum radius of the tunnel)
|
||||
s16 insure = 10;
|
||||
s16 more = MAP_BLOCKSIZE - max_tunnel_diameter / 2 - insure;
|
||||
s16 more = MYMAX(MAP_BLOCKSIZE - max_tunnel_diameter / 2 - insure, 1);
|
||||
ar += v3s16(1,0,1) * more * 2;
|
||||
of -= v3s16(1,0,1) * more;
|
||||
|
||||
@ -462,11 +469,14 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
|
||||
MapNode airnode(CONTENT_AIR);
|
||||
MapNode waternode(c_water_source);
|
||||
MapNode lavanode(c_lava_source);
|
||||
MapNode liquidnode = ps->range(0, 4) ? lavanode : waternode;
|
||||
|
||||
v3s16 startp(orp.X, orp.Y, orp.Z);
|
||||
startp += of;
|
||||
|
||||
float nval = NoisePerlin3D(np_caveliquids, startp.X,
|
||||
startp.Y, startp.Z, mg->seed);
|
||||
MapNode liquidnode = nval < 0.40 ? lavanode : waternode;
|
||||
|
||||
v3f fp = orp + vec * f;
|
||||
fp.X += 0.1 * ps->range(-10, 10);
|
||||
fp.Z += 0.1 * ps->range(-10, 10);
|
||||
@ -502,6 +512,13 @@ 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) {
|
||||
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])
|
||||
continue;
|
||||
}
|
||||
|
||||
if (vm->m_area.contains(p) == false)
|
||||
continue;
|
||||
|
@ -75,6 +75,8 @@ public:
|
||||
ManualMapVoxelManipulator *vm;
|
||||
INodeDefManager *ndef;
|
||||
|
||||
NoiseParams *np_caveliquids;
|
||||
|
||||
s16 min_tunnel_diameter;
|
||||
s16 max_tunnel_diameter;
|
||||
u16 tunnel_routepoints;
|
||||
|
Loading…
Reference in New Issue
Block a user