Skip to content

Commit

Permalink
Copy metadata into norm tile
Browse files Browse the repository at this point in the history
  • Loading branch information
grunt-lucas committed Aug 10, 2023
1 parent 3d26bc3 commit 476d0cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,6 @@ struct NormalizedTile {
bool hFlip;
bool vFlip;

/*
* TODO : create a way to populate these fields, and then do so at NormTile creation time. We will also need to
* propogate the LayerType forward into assignment field of the compiledTileset, so the metatile attributes emitter
* can use it.
*/
/*
* Metadata Fields:
* These are used by the various components to track metadata around the usage context of a NormalizedTile. Allows
Expand All @@ -483,6 +478,17 @@ struct NormalizedTile {
frames.resize(1);
}

void copyMetadataFrom(const RGBATile &tile)
{
this->type = tile.type;
this->tileIndex = tile.tileIndex;
this->layerType = tile.layerType;
this->layer = tile.layer;
this->metatileIndex = tile.metatileIndex;
this->subtile = tile.subtile;
this->anim = tile.anim;
}

[[nodiscard]] bool transparent() const { return palette.size == 1; }

void setPixel(std::size_t frame, std::size_t row, std::size_t col, uint8_t value)
Expand Down
2 changes: 2 additions & 0 deletions src/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ static std::vector<IndexedNormTile> normalizeDecompTiles(PtContext &ctx, const D
}
DecompiledIndex index{};
auto normalizedTile = normalize(ctx, multiFrameTile);
normalizedTile.copyMetadataFrom(multiFrameTile.at(0));
index.animated = true;
index.animIndex = animIndex;
index.tileIndex = tileIndex;
Expand All @@ -174,6 +175,7 @@ static std::vector<IndexedNormTile> normalizeDecompTiles(PtContext &ctx, const D
for (const auto &tile : decompiledTileset.tiles) {
std::vector<RGBATile> singleFrameTile = {tile};
auto normalizedTile = normalize(ctx, singleFrameTile);
normalizedTile.copyMetadataFrom(tile);
DecompiledIndex index{};
index.tileIndex = tileIndex++;
normalizedTiles.emplace_back(index, normalizedTile);
Expand Down

0 comments on commit 476d0cb

Please sign in to comment.