Skip to content

Commit

Permalink
Automapping: Ignore empty outputs per-rule
Browse files Browse the repository at this point in the history
This change introduces a "compileOutputSet" step which is executed as
part of collecting the rules. In this step, each rule only receives as
possible outputs the output indexes that are non-empty for the region of
that rule.

This makes it much easier to add output variation to only some of the
rules. Previously, due to the possibility of empty outputs being chosen,
having rules with various amounts of variation required setting up
separate rule maps.

Closes #3523
  • Loading branch information
bjorn committed Feb 23, 2024
1 parent b184313 commit 7910f9c
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 209 deletions.
20 changes: 10 additions & 10 deletions src/libtiled/tilelayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,16 @@ class TILEDSHARED_EXPORT TileLayer : public Layer
{
if (lhs.mChunkPointer == lhs.mChunkEndPointer || rhs.mChunkPointer == rhs.mChunkEndPointer)
return lhs.mChunkPointer == rhs.mChunkPointer;
else
return lhs.mCellPointer == rhs.mCellPointer;

return lhs.mCellPointer == rhs.mCellPointer;
}

friend bool operator!=(const iterator& lhs, const iterator& rhs)
{
if (lhs.mChunkPointer == lhs.mChunkEndPointer || rhs.mChunkPointer == rhs.mChunkEndPointer)
return lhs.mChunkPointer != rhs.mChunkPointer;
else
return lhs.mCellPointer != rhs.mCellPointer;

return lhs.mCellPointer != rhs.mCellPointer;
}

Cell &value() const { return *mCellPointer; }
Expand Down Expand Up @@ -307,16 +307,16 @@ class TILEDSHARED_EXPORT TileLayer : public Layer
{
if (lhs.mChunkPointer == lhs.mChunkEndPointer || rhs.mChunkPointer == rhs.mChunkEndPointer)
return lhs.mChunkPointer == rhs.mChunkPointer;
else
return lhs.mCellPointer == rhs.mCellPointer;

return lhs.mCellPointer == rhs.mCellPointer;
}

friend bool operator!=(const const_iterator& lhs, const const_iterator& rhs)
{
if (lhs.mChunkPointer == lhs.mChunkEndPointer || rhs.mChunkPointer == rhs.mChunkEndPointer)
return lhs.mChunkPointer != rhs.mChunkPointer;
else
return lhs.mCellPointer != rhs.mCellPointer;

return lhs.mCellPointer != rhs.mCellPointer;
}

const Cell &value() const { return *mCellPointer; }
Expand Down Expand Up @@ -646,8 +646,8 @@ inline const Cell &TileLayer::cellAt(int x, int y) const
{
if (const Chunk *chunk = findChunk(x, y))
return chunk->cellAt(x & CHUNK_MASK, y & CHUNK_MASK);
else
return Cell::empty;

return Cell::empty;
}

inline const Cell &TileLayer::cellAt(QPoint point) const
Expand Down
Loading

0 comments on commit 7910f9c

Please sign in to comment.