diff options
author | Paramat <paramat@users.noreply.github.com> | 2018-05-24 02:52:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-24 02:52:35 +0100 |
commit | d6a6d3176e8ea9be4224c9f1f059654e3d36ea37 (patch) | |
tree | 2f3ff9d5f5af7ae6bcb108c4098c0072b1167bbf | |
parent | 53d5b3ea40ce1c18540a378c5f71f4e1e60dbec8 (diff) | |
download | minetest-d6a6d3176e8ea9be4224c9f1f059654e3d36ea37.tar.gz minetest-d6a6d3176e8ea9be4224c9f1f059654e3d36ea37.tar.bz2 minetest-d6a6d3176e8ea9be4224c9f1f059654e3d36ea37.zip |
Schematic decorations: Fix placement bug when centred and rotated (#7365)
Previously, the centering caused by the 'place center x/z' flags did
not take rotation into account. So schematics with unequal X and Z
dimensions were incorrectly placed. The bug was hidden for schematics
equal in X and Z dimensions.
-rw-r--r-- | src/mapgen/mg_decoration.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mapgen/mg_decoration.cpp b/src/mapgen/mg_decoration.cpp index dd621db11..6daa8216e 100644 --- a/src/mapgen/mg_decoration.cpp +++ b/src/mapgen/mg_decoration.cpp @@ -360,13 +360,22 @@ size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceilin if (p.Y < vm->m_area.MinEdge.Y) return 0; - if (flags & DECO_PLACE_CENTER_X) - p.X -= (schematic->size.X - 1) / 2; - if (flags & DECO_PLACE_CENTER_Z) - p.Z -= (schematic->size.Z - 1) / 2; - Rotation rot = (rotation == ROTATE_RAND) ? (Rotation)pr->range(ROTATE_0, ROTATE_270) : rotation; + + if (flags & DECO_PLACE_CENTER_X) { + if (rot == ROTATE_0 || rot == ROTATE_180) + p.X -= (schematic->size.X - 1) / 2; + else + p.Z -= (schematic->size.X - 1) / 2; + } + if (flags & DECO_PLACE_CENTER_Z) { + if (rot == ROTATE_0 || rot == ROTATE_180) + p.Z -= (schematic->size.Z - 1) / 2; + else + p.X -= (schematic->size.Z - 1) / 2; + } + bool force_placement = (flags & DECO_FORCE_PLACEMENT); schematic->blitToVManip(vm, p, rot, force_placement); |