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
27 std::size_t pixel_index{};
30};
31
43 std::size_t tile_index{};
44 std::vector<PixelMangleChange> pixel_changes;
45
47 [[nodiscard]] friend auto operator<=>(const TileMangleRecord &lhs, const TileMangleRecord &rhs)
48 {
49 return lhs.tile_index <=> rhs.tile_index;
50 }
51
52 [[nodiscard]] friend bool operator==(const TileMangleRecord &lhs, const TileMangleRecord &rhs)
53 {
54 return lhs.tile_index == rhs.tile_index;
55 }
56};
57
64 std::vector<PixelTile<IndexPixel>> tiles;
65 // Keyed by tile_index: the set structurally enforces that each record targets a distinct tile.
66 std::set<TileMangleRecord> mangle_records;
67};
68
90 public:
91 explicit AnimKeyFrameMangler(
92 gsl::not_null<const UserDiagnostics *> diag, gsl::not_null<const TilePrinter *> tile_printer);
93
94 virtual ~AnimKeyFrameMangler() = default;
95
112 const std::string &anim_name,
113 std::vector<PixelTile<IndexPixel>> tiles,
114 const std::vector<const Palette<Rgba32, palette::max_size> *> &palettes,
115 const Rgba32 &extrinsic_transparency,
116 const std::vector<const std::set<PixelTile<Rgba32>> *> &existing_canonical_rgba_tiles) const;
117
118 private:
119 const UserDiagnostics *diag_;
120 const TilePrinter *tile_printer_;
121};
122
123} // 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, 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.
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:45
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:21
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.