|
Porytiles
|
Service that mangles duplicate key frame tiles to make them unique. More...
#include <anim_key_frame_mangler.hpp>
Public Member Functions | |
| AnimKeyFrameMangler (gsl::not_null< const UserDiagnostics * > diag, gsl::not_null< const TilePrinter * > tile_printer) | |
| virtual | ~AnimKeyFrameMangler ()=default |
| ChainableResult< MangleResult > | mangle_duplicates (const std::string &anim_name, std::vector< PixelTile< IndexPixel > > tiles, const std::vector< const Palette< Rgba32, palette::max_size > * > &palettes, const Rgba32 &extrinsic_transparency, const std::vector< const std::set< PixelTile< Rgba32 > > * > &existing_canonical_rgba_tiles) const |
| Mangles duplicate tiles to make them unique. | |
Service that mangles duplicate key frame tiles to make them unique.
During animation decompilation, multiple key frame tiles may be identical. This is problematic because recompilation cannot distinguish between identical tiles. This service modifies duplicate tiles by swapping individual pixels to visually similar palette colors, making each tile unique.
Uniqueness is defined on the decoded RGBA form of each tile, which is how the compile pipeline compares key frame tiles. Comparing decoded colors instead of palette slot indices means palettes that hold the same color in more than one slot cannot produce a "mangled" tile that still looks identical to another tile.
The mangling algorithm:
The service uses palette-aware RGB distance to find visually similar color alternatives, ensuring the mangled tile looks as close as possible to the original while still being technically unique.
Definition at line 89 of file anim_key_frame_mangler.hpp.
|
explicit |
Definition at line 289 of file anim_key_frame_mangler.cpp.
|
virtualdefault |
| ChainableResult< MangleResult > porytiles::AnimKeyFrameMangler::mangle_duplicates | ( | const std::string & | anim_name, |
| std::vector< PixelTile< IndexPixel > > | tiles, | ||
| const std::vector< const Palette< Rgba32, palette::max_size > * > & | palettes, | ||
| const Rgba32 & | extrinsic_transparency, | ||
| const std::vector< const std::set< PixelTile< Rgba32 > > * > & | existing_canonical_rgba_tiles | ||
| ) | const |
Mangles duplicate tiles to make them unique.
Processes the input tiles and ensures all duplicates are modified to be unique. The algorithm finds duplicates, selects pixels to modify based on visual impact priority (corners first, then edges, then interior), and swaps colors to visually similar alternatives from the tile's palette.
| anim_name | Animation name (for diagnostic messages) |
| tiles | Key frame tiles to process (will be copied and potentially modified) |
| palettes | Per-tile palettes for color decoding and similarity calculations (one pointer per tile) |
| extrinsic_transparency | The extrinsic transparency color (decodes index 0 pixels) |
| existing_canonical_rgba_tiles | Per-tile sets of canonical decoded RGBA tiles to check uniqueness against |
palettes size must equal tiles size. existing_canonical_rgba_tiles size must equal tiles size. Definition at line 295 of file anim_key_frame_mangler.cpp.