From 6c6e9599c25b9f5a17369ad2717c19e06794be8c Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 22 Apr 2022 00:50:57 +0200 Subject: [PATCH] Revert the previous change for now. --- modules/wfc/wave_form_collapse.cpp | 10 ++++++---- modules/wfc/wave_form_collapse.h | 23 ++++++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/modules/wfc/wave_form_collapse.cpp b/modules/wfc/wave_form_collapse.cpp index b1fceb12d..1399db1bd 100644 --- a/modules/wfc/wave_form_collapse.cpp +++ b/modules/wfc/wave_form_collapse.cpp @@ -230,11 +230,13 @@ void WaveFormCollapse::propagate() { while (propagating.size() != 0) { // The cell and pattern that has been set to false. - uint32_t y1 = propagating[propagating.size() - 1]; - uint32_t x1 = propagating[propagating.size() - 2]; - uint32_t pattern = propagating[propagating.size() - 3]; + const PropagatingEntry &e = propagating[propagating.size() - 1]; - propagating.resize(propagating.size() - 3); + uint32_t y1 = e.data[0]; + uint32_t x1 = e.data[1]; + uint32_t pattern = e.data[2]; + + propagating.resize(propagating.size() - 1); // We propagate the information in all 4 directions. for (uint32_t direction = 0; direction < 4; direction++) { diff --git a/modules/wfc/wave_form_collapse.h b/modules/wfc/wave_form_collapse.h index d5fee998a..d47a045cd 100644 --- a/modules/wfc/wave_form_collapse.h +++ b/modules/wfc/wave_form_collapse.h @@ -7,7 +7,6 @@ #include "array_2d.h" #include "array_3d.h" #include "core/vector.h" -#include "core/pool_vector.h" #include "core/reference.h" @@ -25,6 +24,22 @@ public: Vector directions[4]; }; + struct PropagatingEntry { + uint32_t data[3]; + + PropagatingEntry() { + for (int i = 0; i < 3; ++i) { + data[i] = 0; + } + } + + PropagatingEntry(uint32_t x, uint32_t y, uint32_t z) { + data[0] = x; + data[1] = y; + data[2] = z; + } + }; + struct CompatibilityEntry { int direction[4]; @@ -90,9 +105,7 @@ public: CompatibilityEntry temp; compatible.get(y, x, pattern) = temp; - propagating.push_back(pattern); - propagating.push_back(x); - propagating.push_back(y); + propagating.push_back(PropagatingEntry(y, x, pattern)); } constexpr uint32_t get_opposite_direction(uint32_t direction) { @@ -159,7 +172,7 @@ private: // All the tuples (y, x, pattern) that should be propagated. // The tuple should be propagated when wave.get(y, x, pattern) is set to false. - Vector propagating; + Vector propagating; // compatible.get(y, x, pattern)[direction] contains the number of patterns // present in the wave that can be placed in the cell next to (y,x) in the