mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Mgv7: Clean up divide-by-zero fix
This commit is contained in:
parent
90ed6fc732
commit
cad10ce3b7
@ -59,13 +59,16 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
|
|||||||
this->large_cave_depth = params->large_cave_depth;
|
this->large_cave_depth = params->large_cave_depth;
|
||||||
this->lava_depth = params->lava_depth;
|
this->lava_depth = params->lava_depth;
|
||||||
this->float_mount_density = params->float_mount_density;
|
this->float_mount_density = params->float_mount_density;
|
||||||
float_mount_height_lim = MYMAX(params->float_mount_height, 1.0f);
|
|
||||||
this->floatland_level = params->floatland_level;
|
this->floatland_level = params->floatland_level;
|
||||||
this->shadow_limit = params->shadow_limit;
|
this->shadow_limit = params->shadow_limit;
|
||||||
this->cavern_limit = params->cavern_limit;
|
this->cavern_limit = params->cavern_limit;
|
||||||
this->cavern_taper = params->cavern_taper;
|
this->cavern_taper = params->cavern_taper;
|
||||||
this->cavern_threshold = params->cavern_threshold;
|
this->cavern_threshold = params->cavern_threshold;
|
||||||
|
|
||||||
|
// This is to avoid a divide-by-zero.
|
||||||
|
// Parameter will be saved to map_meta.txt in limited form.
|
||||||
|
params->float_mount_height = MYMAX(params->float_mount_height, 1.0f);
|
||||||
|
|
||||||
// 2D noise
|
// 2D noise
|
||||||
noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Z);
|
noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Z);
|
||||||
noise_terrain_alt = new Noise(¶ms->np_terrain_alt, seed, csize.X, csize.Z);
|
noise_terrain_alt = new Noise(¶ms->np_terrain_alt, seed, csize.X, csize.Z);
|
||||||
@ -405,8 +408,8 @@ bool MapgenV7::getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y)
|
|||||||
{
|
{
|
||||||
// Make rim 2 nodes thick to match floatland base terrain
|
// Make rim 2 nodes thick to match floatland base terrain
|
||||||
float density_gradient = (y >= floatland_level) ?
|
float density_gradient = (y >= floatland_level) ?
|
||||||
-pow((float)(y - floatland_level) / float_mount_height_lim, 0.75f) :
|
-pow((float)(y - floatland_level) / float_mount_height, 0.75f) :
|
||||||
-pow((float)(floatland_level - 1 - y) / float_mount_height_lim, 0.75f);
|
-pow((float)(floatland_level - 1 - y) / float_mount_height, 0.75f);
|
||||||
|
|
||||||
float floatn = noise_mountain->result[idx_xyz] + float_mount_density;
|
float floatn = noise_mountain->result[idx_xyz] + float_mount_density;
|
||||||
|
|
||||||
|
@ -106,8 +106,6 @@ private:
|
|||||||
Noise *noise_float_base_height;
|
Noise *noise_float_base_height;
|
||||||
Noise *noise_mountain;
|
Noise *noise_mountain;
|
||||||
Noise *noise_ridge;
|
Noise *noise_ridge;
|
||||||
|
|
||||||
float float_mount_height_lim;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user