Porytiles
Loading...
Searching...
No Matches
anim_key_frame_mangler.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <compare>
4#include <cstddef>
5#include <set>
6#include <string>
7#include <vector>
8
9#include "gsl/pointers"
10
18
19namespace porytiles {
20
29 std::size_t pixel_index{};
32};
33
47 std::size_t tile_index{};
48 std::vector<PixelMangleChange> pixel_changes;
49
51 [[nodiscard]] friend auto operator<=>(const TileMangleRecord &lhs, const TileMangleRecord &rhs)
52 {
53 return lhs.tile_index <=> rhs.tile_index;
54 }
55
56 [[nodiscard]] friend bool operator==(const TileMangleRecord &lhs, const TileMangleRecord &rhs)
57 {
58 return lhs.tile_index == rhs.tile_index;
59 }
60};
61
70 std::vector<PixelTile<IndexPixel>> tiles;
71 // Keyed by tile_index: the set structurally enforces that each record targets a distinct tile.
72 std::set<TileMangleRecord> mangle_records;
73};
74
93 public:
94 explicit AnimKeyFrameMangler(
95 gsl::not_null<const UserDiagnostics *> diag, gsl::not_null<const TilePrinter *> tile_printer);
96
97 virtual ~AnimKeyFrameMangler() = default;
98
116 const std::string &anim_name,
117 std::vector<PixelTile<IndexPixel>> tiles,
118 const std::vector<const Palette<Rgba32, pal::max_size> *> &palettes,
119 const Rgba32 &extrinsic_transparency,
120 const std::set<PixelTile<IndexPixel>> &existing_tiles) const;
121
122 private:
123 const UserDiagnostics *diag_;
124 const TilePrinter *tile_printer_;
125};
126
127} // namespace porytiles
Service that mangles duplicate key frame tiles to make them unique.
ChainableResult< MangleResult > mangle_duplicates(const std::string &anim_name, std::vector< PixelTile< IndexPixel > > tiles, const std::vector< const Palette< Rgba32, pal::max_size > * > &palettes, const Rgba32 &extrinsic_transparency, const std::set< PixelTile< IndexPixel > > &existing_tiles) const
Mangles duplicate tiles to make them unique.
virtual ~AnimKeyFrameMangler()=default
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Represents an indexed color pixel.
A generic palette container for colors that support transparency checking.
Definition palette.hpp:47
An 8x8 tile backed by literal-array-based per-pixel storage of an arbitrary pixel type.
Represents a 32-bit RGBA color.
Definition rgba32.hpp:23
A collection of printer functions for various tile types.
Abstract class for structured error reporting and diagnostic output.
Result of the mangling operation.
std::set< TileMangleRecord > mangle_records
Record of all modifications made (ordered by tile_index)
std::vector< PixelTile< IndexPixel > > tiles
The tiles after mangling (unique)
A single pixel modification within a tile.
std::size_t pixel_index
Which pixel in the tile (0-63, linear index)
IndexPixel mangled_pixel
The pixel value after mangling.
IndexPixel original_pixel
The pixel value before mangling.
Record of all pixel modifications made to a single tile during mangling.
std::size_t tile_index
Which tile in the key frame (0-based index, unique across records)
friend bool operator==(const TileMangleRecord &lhs, const TileMangleRecord &rhs)
friend auto operator<=>(const TileMangleRecord &lhs, const TileMangleRecord &rhs)
Orders records by tile_index, enabling storage in std::set to enforce the non-overlapping invariant.
std::vector< PixelMangleChange > pixel_changes
One or more pixel modifications applied to this tile.