diff --git a/modules/wfc/propagator.h b/modules/wfc/propagator.h index 2ceed6b8b..3673016c5 100644 --- a/modules/wfc/propagator.h +++ b/modules/wfc/propagator.h @@ -13,12 +13,10 @@ public: Vector directions[4]; }; - using PropagatorState = Vector; - private: const uint32_t patterns_size; - PropagatorState propagator_state; + Vector 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 propagator_state) : patterns_size(propagator_state.size()), propagator_state(propagator_state), wave_width(wave_width), diff --git a/modules/wfc/tiling_wfc.h b/modules/wfc/tiling_wfc.h index 866ae5fa7..f785b2f21 100644 --- a/modules/wfc/tiling_wfc.h +++ b/modules/wfc/tiling_wfc.h @@ -179,9 +179,7 @@ public: private: // Generate mapping from id to oriented tiles and vice versa. - static std::pair>, - Vector>> - generate_oriented_tile_ids(const Vector> &tiles) { + static std::pair>, Vector>> generate_oriented_tile_ids(const Vector> &tiles) { Vector> id_to_oriented_tile; Vector> oriented_tile_ids; @@ -215,8 +213,10 @@ private: Vector> tiles, Vector> id_to_oriented_tile, Vector> oriented_tile_ids) { + size_t nb_oriented_tiles = id_to_oriented_tile.size(); - Vector dense_propagator(nb_oriented_tiles, { Vector(nb_oriented_tiles, false), Vector(nb_oriented_tiles, false), Vector(nb_oriented_tiles, false), Vector(nb_oriented_tiles, false) }); + + Vector 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> action_map1 = - Tile::generate_action_map(tiles[tile1].symmetry); - Vector> action_map2 = - Tile::generate_action_map(tiles[tile2].symmetry); + Vector> action_map1 = Tile::generate_action_map(tiles[tile1].symmetry); + Vector> action_map2 = Tile::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; } diff --git a/modules/wfc/wfc.cpp b/modules/wfc/wfc.cpp index 92a35c606..d6f11a29f 100644 --- a/modules/wfc/wfc.cpp +++ b/modules/wfc/wfc.cpp @@ -36,8 +36,7 @@ Array2D WFC::wave_to_output() const { WFC::WFC(bool periodic_output, int seed, Vector patterns_frequencies, - Propagator::PropagatorState propagator, uint32_t wave_height, - uint32_t wave_width) : + Vector 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 WFC::run() { diff --git a/modules/wfc/wfc.h b/modules/wfc/wfc.h index 0bb782cc7..fb5df6745 100644 --- a/modules/wfc/wfc.h +++ b/modules/wfc/wfc.h @@ -33,7 +33,7 @@ private: public: // Basic constructor initializing the algorithm. WFC(bool periodic_output, int seed, Vector patterns_frequencies, - Propagator::PropagatorState propagator, uint32_t wave_height, + Vector propagator, uint32_t wave_height, uint32_t wave_width); // Run the algorithm, and return a result if it succeeded.