Skip to content

Commit beba969

Browse files
committedSep 13, 2015
Ore: Add ore sheet column height range selection
Modders are now able to select the range of ore column height, and the midpoint at which they 'grow' starting from. This commit adds three new parameters for the 'sheet' ore type: column_height_min, column_height_max, and column_midpoint_factor. clust_size is now deprecated for this ore type.
1 parent 1d69116 commit beba969

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed
 

Diff for: ‎doc/lua_api.txt

+14-9
Original file line numberDiff line numberDiff line change
@@ -714,23 +714,28 @@ a non-equal distribution of ore.
714714

715715
### `sheet`
716716
Creates a sheet of ore in a blob shape according to the 2D perlin noise
717-
described by `noise_params`. The relative height of the sheet can be
718-
controlled by the same perlin noise as well, by specifying a non-zero
719-
`scale` parameter in `noise_params`.
717+
described by `noise_params`. This is essentially an improved version of
718+
the so-called "stratus" ore seen in some unofficial mods.
720719

721-
**IMPORTANT**: The noise is not transformed by `offset` or `scale` when comparing
722-
against the noise threshold, but scale is used to determine relative height.
723-
The height of the blob is randomly scattered, with a maximum height of `clust_size`.
720+
This sheet consists of vertical columns of uniform randomly distributed height,
721+
varying between the inclusive range `column_height_min` and `column_height_max`.
722+
If `column_height_min` is not specified, this parameter defaults to 1.
723+
If `column_height_max` is not specified, this parameter defaults to `clust_size`
724+
for reverse compatibility. New code should prefer `column_height_max`.
724725

725-
`clust_scarcity` and `clust_num_ores` are ignored.
726+
The `column_midpoint_factor` parameter controls the position of the column at which
727+
ore eminates from. If 1, columns grow upward. If 0, columns grow downward. If 0.5,
728+
columns grow equally starting from each direction. `column_midpoint_factor` is a
729+
decimal number ranging in value from 0 to 1. If this parameter is not specified,
730+
the default is 0.5.
726731

727-
This is essentially an improved version of the so-called "stratus" ore seen in
728-
some unofficial mods.
732+
The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this ore type.
729733

730734
### `blob`
731735
Creates a deformed sphere of ore according to 3d perlin noise described by
732736
`noise_params`. The maximum size of the blob is `clust_size`, and
733737
`clust_scarcity` has the same meaning as with the `scatter` type.
738+
734739
### `vein
735740
Creates veins of ore varying in density by according to the intersection of two
736741
instances of 3d perlin noise with diffferent seeds, both described by

Diff for: ‎src/mg_ore.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed,
176176
PseudoRandom pr(blockseed + 4234);
177177
MapNode n_ore(c_ore, 0, ore_param2);
178178

179-
int max_height = clust_size;
180-
int y_start = pr.range(nmin.Y, nmax.Y - max_height);
179+
u16 max_height = column_height_max;
180+
int y_start = pr.range(nmin.Y + max_height, nmax.Y - max_height);
181181

182182
if (!noise) {
183183
int sx = nmax.X - nmin.X + 1;
@@ -200,10 +200,12 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed,
200200
continue;
201201
}
202202

203-
int height = max_height * (1. / pr.range(1, 3));
204-
int y0 = y_start + np.scale * noiseval; //pr.range(1, 3) - 1;
203+
u16 height = pr.range(column_height_min, column_height_max);
204+
int ymidpoint = y_start + noiseval;
205+
int y0 = ymidpoint - height * (1 - column_midpoint_factor);
205206
int y1 = y0 + height;
206-
for (int y = y0; y != y1; y++) {
207+
208+
for (int y = y0; y < y1; y++) {
207209
u32 i = vm->m_area.index(x, y, z);
208210
if (!vm->m_area.contains(i))
209211
continue;

Diff for: ‎src/mg_ore.h

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class OreSheet : public Ore {
8787
public:
8888
static const bool NEEDS_NOISE = true;
8989

90+
u16 column_height_min;
91+
u16 column_height_max;
92+
float column_midpoint_factor;
93+
9094
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
9195
v3s16 nmin, v3s16 nmax, u8 *biomemap);
9296
};

Diff for: ‎src/script/lua_api/l_mapgen.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,19 @@ int ModApiMapgen::l_register_ore(lua_State *L)
937937
}
938938
lua_pop(L, 1);
939939

940-
if (oretype == ORE_VEIN) {
940+
//// Get type-specific parameters
941+
if (oretype == ORE_SHEET) {
942+
OreSheet *oresheet = (OreSheet *)ore;
943+
944+
oresheet->column_height_min = getintfield_default(L, index,
945+
"column_height_min", 1);
946+
oresheet->column_height_max = getintfield_default(L, index,
947+
"column_height_max", ore->clust_size);
948+
oresheet->column_midpoint_factor = getfloatfield_default(L, index,
949+
"column_midpoint_factor", 0.5f);
950+
} else if (oretype == ORE_VEIN) {
941951
OreVein *orevein = (OreVein *)ore;
952+
942953
orevein->random_factor = getfloatfield_default(L, index,
943954
"random_factor", 1.f);
944955
}

0 commit comments

Comments
 (0)