Porytiles
Loading...
Searching...
No Matches
packing_strategy.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <bitset>
4#include <optional>
5#include <set>
6#include <string>
7#include <vector>
8
15
16namespace porytiles {
17
25 std::vector<PackableTile> tiles_{};
26
34 std::vector<PackableTile> hints_{};
35
43 std::set<PrefilledPalette> prefilled_pals_{};
44
58
65 std::size_t pal_capacity_ = pal::max_size - 1;
66
78 std::optional<ShapeGroupMetadata> shape_group_metadata_{};
79};
80
91 std::vector<PackedPalette> pals_;
92
100 std::map<PackableTile::Id, std::size_t> tile_to_pal_;
101};
102
114 public:
115 virtual ~PackingStrategy() = default;
116
127 [[nodiscard]] virtual ChainableResult<PackingOutput> pack(const PackingInput &input) const = 0;
128
134 [[nodiscard]] virtual std::string name() const = 0;
135};
136
137} // namespace porytiles
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Abstract interface for palette packing algorithms.
virtual ChainableResult< PackingOutput > pack(const PackingInput &input) const =0
Packs tile colors into palettes according to the strategy's algorithm.
virtual std::string name() const =0
Returns the human-readable name of this strategy.
virtual ~PackingStrategy()=default
Manages allocation of hardware palette indexes with stack-based checkout semantics.
constexpr std::size_t max_size
Definition palette.hpp:19
Input data aggregate for the low-level palette packing algorithm.
std::optional< ShapeGroupMetadata > shape_group_metadata_
Optional shape group metadata for sharing-aware packing.
std::set< PrefilledPalette > prefilled_pals_
Pre-assigned palettes with fixed colors.
std::size_t pal_capacity_
Maximum number of colors per palette.
std::vector< PackableTile > hints_
Priority "hint" tiles that can be assigned before regular tiles.
std::vector< PackableTile > tiles_
Regular tiles to pack into palettes.
PalettePool pal_pool_
A bitset marking which palettes are available for editing.
The final palette assignments after a successful packing operation.
std::map< PackableTile::Id, std::size_t > tile_to_pal_
Maps tile IDs to their assigned hardware palette indices.
std::vector< PackedPalette > pals_
The packed palettes with their colors and assigned tiles.