mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Stratum ore: Add option for a constant thickness stratum
Add a 'stratum thickness' integer parameter, as an alternative to providing a 2nd noise parameter for thickness variation.
This commit is contained in:
parent
c655984849
commit
4b553ece09
4 changed files with 35 additions and 18 deletions
|
@ -434,13 +434,20 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|||
MapNode n_ore(c_ore, 0, ore_param2);
|
||||
|
||||
if (flags & OREFLAG_USE_NOISE) {
|
||||
if (!(noise && noise_stratum_thickness)) {
|
||||
if (!noise) {
|
||||
int sx = nmax.X - nmin.X + 1;
|
||||
int sz = nmax.Z - nmin.Z + 1;
|
||||
noise = new Noise(&np, 0, sx, sz);
|
||||
noise_stratum_thickness = new Noise(&np_stratum_thickness, 0, sx, sz);
|
||||
}
|
||||
noise->perlinMap2D(nmin.X, nmin.Z);
|
||||
}
|
||||
|
||||
if (flags & OREFLAG_USE_NOISE2) {
|
||||
if (!noise_stratum_thickness) {
|
||||
int sx = nmax.X - nmin.X + 1;
|
||||
int sz = nmax.Z - nmin.Z + 1;
|
||||
noise_stratum_thickness = new Noise(&np_stratum_thickness, 0, sx, sz);
|
||||
}
|
||||
noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
|
||||
}
|
||||
|
||||
|
@ -458,11 +465,13 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|||
int y1;
|
||||
|
||||
if (flags & OREFLAG_USE_NOISE) {
|
||||
float nhalfthick = ((flags & OREFLAG_USE_NOISE2) ?
|
||||
noise_stratum_thickness->result[index] : (float)stratum_thickness) /
|
||||
2.0f;
|
||||
float nmid = noise->result[index];
|
||||
float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
|
||||
y0 = MYMAX(nmin.Y, nmid - nhalfthick);
|
||||
y0 = MYMAX(nmin.Y, ceil(nmid - nhalfthick));
|
||||
y1 = MYMIN(nmax.Y, nmid + nhalfthick);
|
||||
} else {
|
||||
} else { // Simple horizontal stratum
|
||||
y0 = nmin.Y;
|
||||
y1 = nmax.Y;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue