mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Stratum ore: Allow use with no noise for simple horizontal strata
If either of the 2 noise parameters are omitted the ore will occur from y_min to y_max in a simple horizontal stratum. As this does not compute noise performance improves, and is ideal for placing many layers. Clean up some nearby ore documentation.
This commit is contained in:
parent
9fa78b7387
commit
e2afcf85ce
4 changed files with 62 additions and 25 deletions
|
@ -433,14 +433,16 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|||
PcgRandom pr(blockseed + 4234);
|
||||
MapNode n_ore(c_ore, 0, ore_param2);
|
||||
|
||||
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);
|
||||
if (flags & OREFLAG_USE_NOISE) {
|
||||
if (!(noise && noise_stratum_thickness)) {
|
||||
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);
|
||||
noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
|
||||
}
|
||||
noise->perlinMap2D(nmin.X, nmin.Z);
|
||||
noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
|
||||
|
||||
size_t index = 0;
|
||||
|
||||
|
@ -452,10 +454,18 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|||
continue;
|
||||
}
|
||||
|
||||
float nmid = noise->result[index];
|
||||
float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
|
||||
int y0 = MYMAX(nmin.Y, nmid - nhalfthick);
|
||||
int y1 = MYMIN(nmax.Y, nmid + nhalfthick);
|
||||
int y0;
|
||||
int y1;
|
||||
|
||||
if (flags & OREFLAG_USE_NOISE) {
|
||||
float nmid = noise->result[index];
|
||||
float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
|
||||
y0 = MYMAX(nmin.Y, nmid - nhalfthick);
|
||||
y1 = MYMIN(nmax.Y, nmid + nhalfthick);
|
||||
} else {
|
||||
y0 = nmin.Y;
|
||||
y1 = nmax.Y;
|
||||
}
|
||||
|
||||
for (int y = y0; y <= y1; y++) {
|
||||
if (pr.range(1, clust_scarcity) != 1)
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
|
||||
class OreStratum : public Ore {
|
||||
public:
|
||||
static const bool NEEDS_NOISE = true;
|
||||
static const bool NEEDS_NOISE = false;
|
||||
|
||||
NoiseParams np_stratum_thickness;
|
||||
Noise *noise_stratum_thickness = nullptr;
|
||||
|
|
|
@ -1156,7 +1156,9 @@ int ModApiMapgen::l_register_ore(lua_State *L)
|
|||
OreStratum *orestratum = (OreStratum *)ore;
|
||||
|
||||
lua_getfield(L, index, "np_stratum_thickness");
|
||||
read_noiseparams(L, -1, &orestratum->np_stratum_thickness);
|
||||
// If thickness noise missing unset 'use noise' flag
|
||||
if (!read_noiseparams(L, -1, &orestratum->np_stratum_thickness))
|
||||
ore->flags &= ~OREFLAG_USE_NOISE;
|
||||
lua_pop(L, 1);
|
||||
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue