71 const std::string &anim_name,
73 std::size_t tile_offset,
74 const Rgba32 &extrinsic_transparency,
75 bool is_cross_tileset =
false);
89 [[nodiscard]] std::optional<AnimTileMatch>
109 [[nodiscard]] std::optional<std::size_t>
tile_offset_for(
const std::string &anim_name)
const;
115 [[nodiscard]] std::optional<std::size_t>
tile_count_for(
const std::string &anim_name)
const;
132 struct KeyframeTileInfo {
133 std::string anim_name;
134 std::size_t tile_index;
135 std::size_t keyframe_tile_idx;
138 bool is_cross_tileset;
142 struct AnimRegistration {
143 std::size_t tile_offset;
144 std::size_t tile_count;
154 PixelTile<Rgba32> tile;
155 Rgba32 extrinsic_transparency;
165 struct KeyframeKeyCompare {
166 using is_transparent = void;
168 bool operator()(
const KeyframeKey &a,
const KeyframeKey &b)
const
171 a.tile, a.extrinsic_transparency, b.tile, b.extrinsic_transparency) < 0;
176 std::map<KeyframeKey, KeyframeTileInfo, KeyframeKeyCompare> lookup_map_;
177 std::size_t total_tiles_{0};
178 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, ...)