Skip to content

Commit

Permalink
Fixed WangBrush rotational symmetry mode
Browse files Browse the repository at this point in the history
Also slightly optimized it based on WangId::mergeWith.
  • Loading branch information
bjorn committed Jul 6, 2023
1 parent 8ae0ced commit 523f3e3
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/tiled/wangbrush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,19 +567,13 @@ void WangBrush::updateBrush()
for (int x = rect.left(); x <= rect.right(); ++x) {
const QPoint targetPos(w - x - 1, h - y - 1);
const WangFiller::CellInfo &sourceInfo = fill.grid.get(x, y);
WangFiller::CellInfo targetInfo = fill.grid.get(targetPos);
WangFiller::CellInfo &targetInfo = wangFiller.changePosition(targetPos);

const WangId rotatedDesired = sourceInfo.desired.rotated(2);
const WangId rotatedMask = sourceInfo.mask.rotated(2);

for (int i = 0; i < WangId::NumIndexes; ++i) {
if (rotatedMask.indexColor(i)) {
targetInfo.desired.setIndexColor(i, rotatedDesired.indexColor(i));
targetInfo.mask.setIndexColor(i, WangId::INDEX_MASK);
}
}

fill.grid.set(targetPos, targetInfo);
targetInfo.desired.mergeWith(rotatedDesired, rotatedMask);
targetInfo.mask.mergeWith(rotatedMask, rotatedMask);
}
}

Expand Down

0 comments on commit 523f3e3

Please sign in to comment.