summaryrefslogtreecommitdiff
path: root/src/mapgen.cpp
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2017-10-11 01:06:40 +0100
committerparamat <mat.gregory@virginmedia.com>2017-10-29 12:02:55 +0000
commit241fe649f7357271d5c02c3d5f7a987ad7811d6d (patch)
tree59ec80835fa44387a3ae4acffc0dc3ef4c712ac1 /src/mapgen.cpp
parenta637107a4e81be88938d68df4deae50e68cf2cd8 (diff)
downloadminetest-241fe649f7357271d5c02c3d5f7a987ad7811d6d.tar.gz
minetest-241fe649f7357271d5c02c3d5f7a987ad7811d6d.tar.bz2
minetest-241fe649f7357271d5c02c3d5f7a987ad7811d6d.zip
Biome API: Add decoration flags for underground decorations
Add "all_floors" and "all_ceilings" flags for simple and schematic decorations. Decorations are placed on all floor and/or ceiling surfaces. Decorations are placed before dungeon generation so placement in dungeons is not possible. Add 'getSurfaces()' function to mapgen.cpp that returns 2 arrays of y coordinates for all floor and ceiling surfaces in a specified node column. Move 'getHeight()' checks into DecoSimple and DecoSchematic. Delete 'getHeight()' functions.
Diffstat (limited to 'src/mapgen.cpp')
-rw-r--r--src/mapgen.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 7b32ffab1..f73e16dd0 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -299,6 +299,41 @@ void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax)
}
}
+
+void Mapgen::getSurfaces(v2s16 p2d, s16 ymin, s16 ymax,
+ s16 *floors, s16 *ceilings, u16 *num_floors, u16 *num_ceilings)
+{
+ u16 floor_i = 0;
+ u16 ceiling_i = 0;
+ const v3s16 &em = vm->m_area.getExtent();
+
+ bool is_walkable = false;
+ u32 vi = vm->m_area.index(p2d.X, ymax, p2d.Y);
+ MapNode mn_max = vm->m_data[vi];
+ bool walkable_above = ndef->get(mn_max).walkable;
+ vm->m_area.add_y(em, vi, -1);
+
+ for (s16 y = ymax - 1; y >= ymin; y--) {
+ MapNode mn = vm->m_data[vi];
+ is_walkable = ndef->get(mn).walkable;
+
+ if (is_walkable && !walkable_above) {
+ floors[floor_i] = y;
+ floor_i++;
+ } else if (!is_walkable && walkable_above) {
+ ceilings[ceiling_i] = y + 1;
+ ceiling_i++;
+ }
+
+ vm->m_area.add_y(em, vi, -1);
+ walkable_above = is_walkable;
+ }
+
+ *num_floors = floor_i;
+ *num_ceilings = ceiling_i;
+}
+
+
inline bool Mapgen::isLiquidHorizontallyFlowable(u32 vi, v3s16 em)
{
u32 vi_neg_x = vi;