|
Porytiles
|
#include <layer_mode_converter.hpp>
Public Member Functions | |
| LayerModeConverter (gsl::not_null< const TextFormatter * > format, gsl::not_null< const UserDiagnostics * > diag, gsl::not_null< const TilePrinter * > tile_printer, const Rgba32 &extrinsic_transparency) | |
| ChainableResult< std::vector< TilemapEntry > > | triple_layerize (const PorymapTilesetComponent &component) |
| Converts a tileset component to triple-layer format. | |
| std::vector< TilemapEntry > | dual_layerize (const std::vector< TilemapEntry > &entries, const std::vector< Metatile< Rgba32 > > &source_metatiles, const std::vector< std::optional< LayerType > > &explicit_layer_types={}) |
| Converts a tileset from triple-layer format to dual-layer format. | |
Definition at line 20 of file layer_mode_converter.hpp.
|
inlineexplicit |
Definition at line 22 of file layer_mode_converter.hpp.
| std::vector< TilemapEntry > porytiles::LayerModeConverter::dual_layerize | ( | const std::vector< TilemapEntry > & | entries, |
| const std::vector< Metatile< Rgba32 > > & | source_metatiles, | ||
| const std::vector< std::optional< LayerType > > & | explicit_layer_types = {} |
||
| ) |
Converts a tileset from triple-layer format to dual-layer format.
Converts triple-layer metatiles (12 entries per metatile) to dual-layer metatiles (8 entries per metatile) by dropping one 4-entry layer group per metatile, selected by the metatile's effective LayerType. When every dropped group is transparent (the case for entries produced by triple_layerize() from dual-compatible content), this is the exact inverse of triple_layerize().
The conversion strategy depends on the metatile's effective LayerType:
"Effective LayerType" is resolved per metatile via the following cascade:
explicit_layer_types value (a fieldmap.role_pins layer_type pin) wins if present.If the dropped group contains an entry that references a visible (non-transparent) tile, a warning is emitted (tag dual-layer-drop). The check inspects the actual tilemap entries at reduction time (after manual animation overrides), not the source RGBA transparency, so it catches entries made visible by post-inference overrides.
A metatile with implied triple-layer content (all three layers visible at some subtile) is legal input: validate_layer_mode gates such content behind the ignore_triple_layer_content option. When it reaches this function it has no inferable layer type (tier 3), so without a pin the fallback to normal drops its bottom group; the dual-layer-drop warning carries a role-pins hint so the user can pin a different group to keep instead.
| entries | The triple-layer tilemap entries to convert |
| source_metatiles | The source metatiles used to infer layer types |
| explicit_layer_types | Per-metatile explicit layer-type overrides; an empty vector (or a nullopt element) means "infer this metatile's layer type". |
Definition at line 83 of file layer_mode_converter.cpp.
| ChainableResult< std::vector< TilemapEntry > > porytiles::LayerModeConverter::triple_layerize | ( | const PorymapTilesetComponent & | component | ) |
Converts a tileset component to triple-layer format.
Converts dual-layer metatiles (8 entries per metatile) to triple-layer metatiles (12 entries per metatile) by inserting transparent tilemap entries based on each metatile's LayerType attribute. If the component is already in triple-layer format, it is returned unchanged.
The conversion strategy depends on the metatile's LayerType:
| component | The tileset component to convert |
Definition at line 14 of file layer_mode_converter.cpp.