mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 12:47:12 +01:00
Small improvements.
This commit is contained in:
parent
4e8d254ba9
commit
dc1064aac4
@ -13,12 +13,10 @@ public:
|
||||
Vector<uint32_t> directions[4];
|
||||
};
|
||||
|
||||
using PropagatorState = Vector<PropagatorEntry>;
|
||||
|
||||
private:
|
||||
const uint32_t patterns_size;
|
||||
|
||||
PropagatorState propagator_state;
|
||||
Vector<PropagatorEntry> propagator_state;
|
||||
|
||||
const uint32_t wave_width;
|
||||
const uint32_t wave_height;
|
||||
@ -66,8 +64,7 @@ private:
|
||||
void init_compatible();
|
||||
|
||||
public:
|
||||
Propagator(uint32_t wave_height, uint32_t wave_width, bool periodic_output,
|
||||
PropagatorState propagator_state) :
|
||||
Propagator(uint32_t wave_height, uint32_t wave_width, bool periodic_output, Vector<PropagatorEntry> propagator_state) :
|
||||
patterns_size(propagator_state.size()),
|
||||
propagator_state(propagator_state),
|
||||
wave_width(wave_width),
|
||||
|
@ -179,9 +179,7 @@ public:
|
||||
|
||||
private:
|
||||
// Generate mapping from id to oriented tiles and vice versa.
|
||||
static std::pair<Vector<std::pair<uint32_t, uint32_t>>,
|
||||
Vector<Vector<uint32_t>>>
|
||||
generate_oriented_tile_ids(const Vector<Tile<T>> &tiles) {
|
||||
static std::pair<Vector<std::pair<uint32_t, uint32_t>>, Vector<Vector<uint32_t>>> generate_oriented_tile_ids(const Vector<Tile<T>> &tiles) {
|
||||
Vector<std::pair<uint32_t, uint32_t>> id_to_oriented_tile;
|
||||
Vector<Vector<uint32_t>> oriented_tile_ids;
|
||||
|
||||
@ -215,8 +213,10 @@ private:
|
||||
Vector<Tile<T>> tiles,
|
||||
Vector<std::pair<uint32_t, uint32_t>> id_to_oriented_tile,
|
||||
Vector<Vector<uint32_t>> oriented_tile_ids) {
|
||||
|
||||
size_t nb_oriented_tiles = id_to_oriented_tile.size();
|
||||
Vector<DensePropagatorHelper> dense_propagator(nb_oriented_tiles, { Vector<bool>(nb_oriented_tiles, false), Vector<bool>(nb_oriented_tiles, false), Vector<bool>(nb_oriented_tiles, false), Vector<bool>(nb_oriented_tiles, false) });
|
||||
|
||||
Vector<DensePropagatorHelper> dense_propagator;
|
||||
dense_propagator.resize(nb_oriented_tiles);
|
||||
for (int i = 0; i < nb_oriented_tiles; ++i) {
|
||||
dense_propagator.write[i].resize(nb_oriented_tiles);
|
||||
@ -227,10 +227,8 @@ private:
|
||||
uint32_t orientation1 = std::get<1>(neighbor);
|
||||
uint32_t tile2 = std::get<2>(neighbor);
|
||||
uint32_t orientation2 = std::get<3>(neighbor);
|
||||
Vector<Vector<uint32_t>> action_map1 =
|
||||
Tile<T>::generate_action_map(tiles[tile1].symmetry);
|
||||
Vector<Vector<uint32_t>> action_map2 =
|
||||
Tile<T>::generate_action_map(tiles[tile2].symmetry);
|
||||
Vector<Vector<uint32_t>> action_map1 = Tile<T>::generate_action_map(tiles[tile1].symmetry);
|
||||
Vector<Vector<uint32_t>> action_map2 = Tile<T>::generate_action_map(tiles[tile2].symmetry);
|
||||
|
||||
auto add = [&](uint32_t action, uint32_t direction) {
|
||||
uint32_t temp_orientation1 = action_map1[action][orientation1];
|
||||
@ -346,6 +344,7 @@ public:
|
||||
|
||||
uint32_t oriented_tile_id = oriented_tile_ids[tile_id][orientation];
|
||||
set_tile(oriented_tile_id, i, j);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,7 @@ Array2D<uint32_t> WFC::wave_to_output() const {
|
||||
|
||||
WFC::WFC(bool periodic_output, int seed,
|
||||
Vector<double> patterns_frequencies,
|
||||
Propagator::PropagatorState propagator, uint32_t wave_height,
|
||||
uint32_t wave_width) :
|
||||
Vector<Propagator::PropagatorEntry> propagator, uint32_t wave_height, uint32_t wave_width) :
|
||||
gen(seed), patterns_frequencies(normalize(patterns_frequencies)), wave(wave_height, wave_width, patterns_frequencies), nb_patterns(propagator.size()), propagator(wave.height, wave.width, periodic_output, propagator) {}
|
||||
|
||||
Array2D<uint32_t> WFC::run() {
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
public:
|
||||
// Basic constructor initializing the algorithm.
|
||||
WFC(bool periodic_output, int seed, Vector<double> patterns_frequencies,
|
||||
Propagator::PropagatorState propagator, uint32_t wave_height,
|
||||
Vector<Propagator::PropagatorEntry> propagator, uint32_t wave_height,
|
||||
uint32_t wave_width);
|
||||
|
||||
// Run the algorithm, and return a result if it succeeded.
|
||||
|
Loading…
Reference in New Issue
Block a user