diff --git a/modules/wfc/array_2d.h b/modules/wfc/array_2d.h index 2f6585eff..def37d558 100644 --- a/modules/wfc/array_2d.h +++ b/modules/wfc/array_2d.h @@ -73,7 +73,7 @@ public: return false; } - for (uint32_t i = 0; i < data.size(); i++) { + for (int i = 0; i < data.size(); i++) { if (a.data[i] != data[i]) { return false; } diff --git a/modules/wfc/array_3d.h b/modules/wfc/array_3d.h index 1087caeb8..c25011795 100644 --- a/modules/wfc/array_3d.h +++ b/modules/wfc/array_3d.h @@ -48,7 +48,7 @@ public: return false; } - for (uint32_t i = 0; i < data.size(); i++) { + for (int i = 0; i < data.size(); i++) { if (a.data[i] != data[i]) { return false; } diff --git a/modules/wfc/overlapping_wfc.h b/modules/wfc/overlapping_wfc.h index 7fbdf9609..c0840d9cd 100644 --- a/modules/wfc/overlapping_wfc.h +++ b/modules/wfc/overlapping_wfc.h @@ -79,7 +79,7 @@ private: Array2D ground_pattern = input.get_sub_array(input.height - 1, input.width / 2, options.pattern_size, options.pattern_size); // Retrieve the id of the pattern. - for (uint32_t i = 0; i < patterns.size(); i++) { + for (int i = 0; i < patterns.size(); i++) { if (ground_pattern == patterns[i]) { return i; } @@ -115,8 +115,7 @@ private: // The number of symmetries in the option class define which symetries // will be used. for (uint32_t k = 0; k < options.symmetry; k++) { - auto res = patterns_id.insert( - std::make_pair(symmetries[k], patterns.size())); + auto res = patterns_id.insert(std::make_pair(symmetries[k], patterns.size())); // If the pattern already exist, we just have to increase its number // of appearance. @@ -149,6 +148,7 @@ private: } } } + return true; } @@ -157,12 +157,13 @@ private: // contains pattern2, where direction is the direction defined by (dy, dx) // (see direction.hpp). static Vector generate_compatible(const Vector> &patterns) { - Vector compatible = Vector(patterns.size()); + Vector compatible; + compatible.resize(patterns.size()); // Iterate on every dy, dx, pattern1 and pattern2 - for (uint32_t pattern1 = 0; pattern1 < patterns.size(); pattern1++) { + for (int pattern1 = 0; pattern1 < patterns.size(); pattern1++) { for (uint32_t direction = 0; direction < 4; direction++) { - for (uint32_t pattern2 = 0; pattern2 < patterns.size(); pattern2++) { + for (int pattern2 = 0; pattern2 < patterns.size(); pattern2++) { if (agrees(patterns[pattern1], patterns[pattern2], directions_y[direction], directions_x[direction])) { compatible[pattern1][direction].push_back(pattern2); } @@ -230,7 +231,7 @@ private: // Set the pattern at a specific position, given its pattern id // pattern_id needs to be a valid pattern id, and i and j needs to be in the wave range void set_pattern(uint32_t pattern_id, uint32_t i, uint32_t j) { - for (uint32_t p = 0; p < patterns.size(); p++) { + for (int p = 0; p < patterns.size(); p++) { if (pattern_id != p) { wfc.remove_wave_pattern(i, j, p); } diff --git a/modules/wfc/tiling_wfc.h b/modules/wfc/tiling_wfc.h index ea33f6bba..866ae5fa7 100644 --- a/modules/wfc/tiling_wfc.h +++ b/modules/wfc/tiling_wfc.h @@ -90,23 +90,23 @@ struct Tile { static Vector> generate_action_map(const Symmetry &symmetry) { Vector rotation_map = generate_rotation_map(symmetry); Vector reflection_map = generate_reflection_map(symmetry); - size_t size = rotation_map.size(); - Vector> action_map(8, - Vector(size)); - for (size_t i = 0; i < size; ++i) { + int size = rotation_map.size(); + Vector> action_map(8, Vector(size)); + + for (int i = 0; i < size; ++i) { action_map[0][i] = i; } - for (size_t a = 1; a < 4; ++a) { - for (size_t i = 0; i < size; ++i) { + for (int a = 1; a < 4; ++a) { + for (int i = 0; i < size; ++i) { action_map[a][i] = rotation_map[action_map[a - 1][i]]; } } - for (size_t i = 0; i < size; ++i) { + for (int i = 0; i < size; ++i) { action_map[4][i] = reflection_map[action_map[0][i]]; } - for (size_t a = 5; a < 8; ++a) { - for (size_t i = 0; i < size; ++i) { + for (int a = 5; a < 8; ++a) { + for (int i = 0; i < size; ++i) { action_map[a][i] = rotation_map[action_map[a - 1][i]]; } } @@ -114,8 +114,7 @@ struct Tile { } // Generate all distincts rotations of a 2D array given its symmetries; - static Vector> generate_oriented(Array2D data, - Symmetry symmetry) { + static Vector> generate_oriented(Array2D data, Symmetry symmetry) { Vector> oriented; oriented.push_back(data); @@ -187,9 +186,9 @@ private: Vector> oriented_tile_ids; uint32_t id = 0; - for (uint32_t i = 0; i < tiles.size(); i++) { + for (int i = 0; i < tiles.size(); i++) { oriented_tile_ids.push_back({}); - for (uint32_t j = 0; j < tiles[i].data.size(); j++) { + for (int j = 0; j < tiles[i].data.size(); j++) { id_to_oriented_tile.push_back({ i, j }); oriented_tile_ids[i].push_back(id); id++; @@ -272,8 +271,8 @@ private: static Vector get_tiles_weights(const Vector> &tiles) { Vector frequencies; - for (size_t i = 0; i < tiles.size(); ++i) { - for (size_t j = 0; j < tiles[i].data.size(); ++j) { + for (int i = 0; i < tiles.size(); ++i) { + for (int j = 0; j < tiles[i].data.size(); ++j) { frequencies.push_back(tiles[i].weight / tiles[i].data.size()); } } @@ -302,7 +301,7 @@ private: } void set_tile(uint32_t tile_id, uint32_t i, uint32_t j) { - for (uint32_t p = 0; p < id_to_oriented_tile.size(); p++) { + for (int p = 0; p < id_to_oriented_tile.size(); p++) { if (tile_id != p) { wfc.remove_wave_pattern(i, j, p); } diff --git a/modules/wfc/wave.cpp b/modules/wfc/wave.cpp index 4c1d0703e..e925ee9db 100644 --- a/modules/wfc/wave.cpp +++ b/modules/wfc/wave.cpp @@ -8,7 +8,7 @@ namespace { Vector get_plogp(const Vector &distribution) { Vector plogp; - for (uint32_t i = 0; i < distribution.size(); i++) { + for (int i = 0; i < distribution.size(); i++) { plogp.push_back(distribution[i] * log(distribution[i])); } @@ -19,7 +19,7 @@ Vector get_plogp(const Vector &distribution) { double get_min_abs_half(const Vector &v) { double min_abs_half = std::numeric_limits::infinity(); - for (uint32_t i = 0; i < v.size(); i++) { + for (int i = 0; i < v.size(); i++) { min_abs_half = std::min(min_abs_half, std::abs(v[i] / 2.0)); }