Skip to content

Commit

Permalink
Re-enabled the code in AdjustTileMetaData
Browse files Browse the repository at this point in the history
Needed changing due to WangSet API change away from using WangTile.
  • Loading branch information
bjorn authored and cpetig committed Nov 24, 2020
1 parent fb1e1e0 commit f8f1b63
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/tiled/adjusttileindexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,26 +264,34 @@ AdjustTileMetaData::AdjustTileMetaData(TilesetDocument *tilesetDocument)
QVector<ChangeTileWangId::WangIdChange> changes;

// Move all WangIds to their new tiles
// for (const WangTile &wangTile : wangSet->wangTilesByWangId()) {
// if (Tile *fromTile = wangTile.tile()) {
// if (Tile *newTile = adjustTile(fromTile)) {
// WangId fromWangId = wangSet->wangIdOfTile(newTile);
// WangId toWangId = wangTile.wangId();
// changes.append(ChangeTileWangId::WangIdChange(fromWangId, toWangId, newTile));
// }
// }
// }
QHashIterator<int, WangId> it(wangSet->wangIdByTile());
while (it.hasNext()) {
it.next();

if (Tile *fromTile = tileset.findTile(it.key())) {
if (Tile *newTile = adjustTile(fromTile)) {
const WangId fromWangId = wangSet->wangIdOfTile(newTile);
const WangId toWangId = it.value();
changes.append(ChangeTileWangId::WangIdChange(fromWangId, toWangId, newTile));
}
}
}

// Clear WangIds from other tiles
// for (const WangTile &wangTile : wangSet->wangTilesByWangId()) {
// if (Tile *fromTile = wangTile.tile()) {
// auto matchesTile = [fromTile](const ChangeTileWangId::WangIdChange &change) {
// return change.tile == fromTile;
// };
// if (!std::any_of(changes.begin(), changes.end(), matchesTile))
// changes.append(ChangeTileWangId::WangIdChange(wangTile.wangId(), WangId(), fromTile));
// }
// }
it.toFront();
while (it.hasNext()) {
it.next();

if (Tile *fromTile = tileset.findTile(it.key())) {
auto matchesTile = [fromTile](const ChangeTileWangId::WangIdChange &change) {
return change.tile == fromTile;
};
if (!std::any_of(changes.begin(), changes.end(), matchesTile)) {
const WangId fromWangId = it.value();
changes.append(ChangeTileWangId::WangIdChange(fromWangId, WangId(), fromTile));
}
}
}

if (!changes.isEmpty())
new ChangeTileWangId(tilesetDocument, wangSet, changes, this);
Expand Down

0 comments on commit f8f1b63

Please sign in to comment.