77 const std::string &anim_name,
79 std::size_t tile_offset,
80 const Rgba32 &extrinsic_transparency,
81 bool is_cross_tileset =
false);
97 [[nodiscard]] std::optional<AnimTileMatch>
116 [[nodiscard]] std::optional<std::size_t>
tile_offset_for(
const std::string &anim_name)
const;
124 [[nodiscard]] std::optional<std::size_t>
tile_count_for(
const std::string &anim_name)
const;
147 struct KeyframeTileInfo {
148 std::string anim_name;
149 std::size_t tile_index;
150 std::size_t keyframe_tile_idx;
153 bool is_cross_tileset;
159 struct AnimRegistration {
160 std::size_t tile_offset;
161 std::size_t tile_count;
173 PixelTile<Rgba32> tile;
174 Rgba32 extrinsic_transparency;
186 struct KeyframeKeyCompare {
187 using is_transparent = void;
189 bool operator()(
const KeyframeKey &a,
const KeyframeKey &b)
const
192 a.tile, a.extrinsic_transparency, b.tile, b.extrinsic_transparency) < 0;
197 std::map<KeyframeKey, KeyframeTileInfo, KeyframeKeyCompare> lookup_map_;
198 std::size_t total_tiles_{0};
199 std::map<std::string, AnimRegistration> animation_registrations_;
Matches tiles against animation keyframe tiles for compilation.
std::size_t total_keyframe_tiles() const
Returns the total number of keyframe tiles registered across all animations.
void clear()
Clears all registered animations.
std::optional< std::size_t > tile_count_for(const std::string &anim_name) const
Returns the tile count for a registered animation.
bool is_in_animation_range(std::size_t tile_index) const
Checks whether a tile index falls within any registered animation range.
void register_animation(const std::string &anim_name, const Animation< Rgba32 > &animation, std::size_t tile_offset, const Rgba32 &extrinsic_transparency, bool is_cross_tileset=false)
Registers an animation's keyframe tiles for matching.
std::optional< AnimTileMatch > find_match(const CanonicalPixelTile< Rgba32 > &tile, const Rgba32 &extrinsic_transparency) const
Attempts to match a tile against registered animation keyframes.
std::optional< std::size_t > tile_offset_for(const std::string &anim_name) const
Returns the tile offset for a registered animation.
A complete tileset animation with name, configuration, and frame data.
A PixelTile representation that stores the canonical (lexicographically minimal) orientation among al...
static std::weak_ordering cross_et_compare(const PixelTile &a, const PixelType &a_et, const PixelTile &b, const PixelType &b_et)
Strict weak ordering that treats transparent pixels under each side's own ET as equivalent.
Represents a 32-bit RGBA color.
Result of matching a tile against animation keyframes.
bool v_flip
Vertical flip required to match.
std::size_t tile_index
Absolute tile index in tiles.png.
std::string anim_name
Name of the animation this keyframe belongs to.
bool h_flip
Horizontal flip required to match.
bool is_cross_tileset
True if this match is against a primary animation (cross-tileset linking)
std::size_t keyframe_tile_idx
Index within the keyframe (0, 1, 2, ...)