diff options
author | paramat <paramat@users.noreply.github.com> | 2017-10-09 20:13:10 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-10-10 19:57:28 +0100 |
commit | 9a41a3d0f1b5f2bcd16b61122f6a34434fea7a7d (patch) | |
tree | 666efb4dde4718d93ad13b61b0019eb123b656f7 /src/mg_decoration.cpp | |
parent | 2cf9014160085303cda333334784ac4938edc086 (diff) | |
download | minetest-9a41a3d0f1b5f2bcd16b61122f6a34434fea7a7d.tar.gz minetest-9a41a3d0f1b5f2bcd16b61122f6a34434fea7a7d.tar.bz2 minetest-9a41a3d0f1b5f2bcd16b61122f6a34434fea7a7d.zip |
Simple decorations: Make 'place_offset_y' usable with simple decorations
Necessary for placing the base cube of 'plantlike_rooted' drawtype in the
seabed instead of on it.
Useful for placing decorations sunk into, or buried in, the ground.
Diffstat (limited to 'src/mg_decoration.cpp')
-rw-r--r-- | src/mg_decoration.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp index cb4705177..ada37bab4 100644 --- a/src/mg_decoration.cpp +++ b/src/mg_decoration.cpp @@ -219,6 +219,10 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p) if (c_decos.empty()) return 0; + // Check for a negative place_offset_y causing placement below the voxelmanip + if (p.Y + 1 + place_offset_y < vm->m_area.MinEdge.Y) + return 0; + if (!canPlaceDecoration(vm, p)) return 0; @@ -234,9 +238,10 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p) const v3s16 &em = vm->m_area.getExtent(); u32 vi = vm->m_area.index(p); + vm->m_area.add_y(em, vi, place_offset_y); + for (int i = 0; i < height; i++) { vm->m_area.add_y(em, vi, 1); - content_t c = vm->m_data[vi].getContent(); if (c != CONTENT_AIR && c != CONTENT_IGNORE && !force_placement) @@ -251,7 +256,8 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p) int DecoSimple::getHeight() { - return (deco_height_max > 0) ? deco_height_max : deco_height; + return ((deco_height_max > 0) ? deco_height_max : deco_height) + + place_offset_y; } |