Skip to content

Commit d6a6d31

Browse files
authoredMay 24, 2018
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.
1 parent 53d5b3e commit d6a6d31

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

Diff for: ‎src/mapgen/mg_decoration.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,22 @@ size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceilin
360360
if (p.Y < vm->m_area.MinEdge.Y)
361361
return 0;
362362

363-
if (flags & DECO_PLACE_CENTER_X)
364-
p.X -= (schematic->size.X - 1) / 2;
365-
if (flags & DECO_PLACE_CENTER_Z)
366-
p.Z -= (schematic->size.Z - 1) / 2;
367-
368363
Rotation rot = (rotation == ROTATE_RAND) ?
369364
(Rotation)pr->range(ROTATE_0, ROTATE_270) : rotation;
365+
366+
if (flags & DECO_PLACE_CENTER_X) {
367+
if (rot == ROTATE_0 || rot == ROTATE_180)
368+
p.X -= (schematic->size.X - 1) / 2;
369+
else
370+
p.Z -= (schematic->size.X - 1) / 2;
371+
}
372+
if (flags & DECO_PLACE_CENTER_Z) {
373+
if (rot == ROTATE_0 || rot == ROTATE_180)
374+
p.Z -= (schematic->size.Z - 1) / 2;
375+
else
376+
p.X -= (schematic->size.Z - 1) / 2;
377+
}
378+
370379
bool force_placement = (flags & DECO_FORCE_PLACEMENT);
371380

372381
schematic->blitToVManip(vm, p, rot, force_placement);

0 commit comments

Comments
 (0)
Please sign in to comment.