mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-10 21:09:38 +01:00
std::size_t to uint32_t for the wfc module.
This commit is contained in:
parent
f080f5e027
commit
531dc783d8
@ -7,38 +7,38 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class Array2D {
|
class Array2D {
|
||||||
public:
|
public:
|
||||||
std::size_t height;
|
uint32_t height;
|
||||||
std::size_t width;
|
uint32_t width;
|
||||||
|
|
||||||
Vector<T> data;
|
Vector<T> data;
|
||||||
|
|
||||||
Array2D(std::size_t p_height, std::size_t p_width) {
|
Array2D(uint32_t p_height, uint32_t p_width) {
|
||||||
height = p_height;
|
height = p_height;
|
||||||
width = p_width;
|
width = p_width;
|
||||||
data.resize(width * height);
|
data.resize(width * height);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array2D(std::size_t p_height, std::size_t p_width, T p_value) {
|
Array2D(uint32_t p_height, uint32_t p_width, T p_value) {
|
||||||
height = p_height;
|
height = p_height;
|
||||||
width = p_width;
|
width = p_width;
|
||||||
data.resize(width * height);
|
data.resize(width * height);
|
||||||
data.fill(p_value);
|
data.fill(p_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const T &get(std::size_t i, std::size_t j) const {
|
const T &get(uint32_t i, uint32_t j) const {
|
||||||
assert(i < height && j < width);
|
assert(i < height && j < width);
|
||||||
return data[j + i * width];
|
return data[j + i * width];
|
||||||
}
|
}
|
||||||
|
|
||||||
T &get(std::size_t i, std::size_t j) {
|
T &get(uint32_t i, uint32_t j) {
|
||||||
assert(i < height && j < width);
|
assert(i < height && j < width);
|
||||||
return data.write[j + i * width];
|
return data.write[j + i * width];
|
||||||
}
|
}
|
||||||
|
|
||||||
Array2D<T> reflected() const {
|
Array2D<T> reflected() const {
|
||||||
Array2D<T> result = Array2D<T>(width, height);
|
Array2D<T> result = Array2D<T>(width, height);
|
||||||
for (std::size_t y = 0; y < height; y++) {
|
for (uint32_t y = 0; y < height; y++) {
|
||||||
for (std::size_t x = 0; x < width; x++) {
|
for (uint32_t x = 0; x < width; x++) {
|
||||||
result.get(y, x) = get(y, width - 1 - x);
|
result.get(y, x) = get(y, width - 1 - x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,18 +47,18 @@ public:
|
|||||||
|
|
||||||
Array2D<T> rotated() const {
|
Array2D<T> rotated() const {
|
||||||
Array2D<T> result = Array2D<T>(width, height);
|
Array2D<T> result = Array2D<T>(width, height);
|
||||||
for (std::size_t y = 0; y < width; y++) {
|
for (uint32_t y = 0; y < width; y++) {
|
||||||
for (std::size_t x = 0; x < height; x++) {
|
for (uint32_t x = 0; x < height; x++) {
|
||||||
result.get(y, x) = get(x, width - 1 - y);
|
result.get(y, x) = get(x, width - 1 - y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array2D<T> get_sub_array(std::size_t y, std::size_t x, std::size_t sub_width, std::size_t sub_height) const {
|
Array2D<T> get_sub_array(uint32_t y, uint32_t x, uint32_t sub_width, uint32_t sub_height) const {
|
||||||
Array2D<T> sub_array_2d = Array2D<T>(sub_width, sub_height);
|
Array2D<T> sub_array_2d = Array2D<T>(sub_width, sub_height);
|
||||||
for (std::size_t ki = 0; ki < sub_height; ki++) {
|
for (uint32_t ki = 0; ki < sub_height; ki++) {
|
||||||
for (std::size_t kj = 0; kj < sub_width; kj++) {
|
for (uint32_t kj = 0; kj < sub_width; kj++) {
|
||||||
sub_array_2d.get(ki, kj) = get((y + ki) % height, (x + kj) % width);
|
sub_array_2d.get(ki, kj) = get((y + ki) % height, (x + kj) % width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i = 0; i < data.size(); i++) {
|
for (uint32_t i = 0; i < data.size(); i++) {
|
||||||
if (a.data[i] != data[i]) {
|
if (a.data[i] != data[i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -7,20 +7,20 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class Array3D {
|
class Array3D {
|
||||||
public:
|
public:
|
||||||
std::size_t height;
|
uint32_t height;
|
||||||
std::size_t width;
|
uint32_t width;
|
||||||
std::size_t depth;
|
uint32_t depth;
|
||||||
|
|
||||||
Vector<T> data;
|
Vector<T> data;
|
||||||
|
|
||||||
Array3D(std::size_t p_height, std::size_t p_width, std::size_t p_depth) {
|
Array3D(uint32_t p_height, uint32_t p_width, uint32_t p_depth) {
|
||||||
height = p_height;
|
height = p_height;
|
||||||
width = p_width;
|
width = p_width;
|
||||||
depth = p_depth;
|
depth = p_depth;
|
||||||
data.resize(width * height * depth);
|
data.resize(width * height * depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array3D(std::size_t p_height, std::size_t p_width, std::size_t p_depth, T value) {
|
Array3D(uint32_t p_height, uint32_t p_width, uint32_t p_depth, T value) {
|
||||||
height = p_height;
|
height = p_height;
|
||||||
width = p_width;
|
width = p_width;
|
||||||
depth = p_depth;
|
depth = p_depth;
|
||||||
@ -28,12 +28,12 @@ public:
|
|||||||
data.fill(value);
|
data.fill(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const T &get(std::size_t i, std::size_t j, std::size_t k) const {
|
const T &get(uint32_t i, uint32_t j, uint32_t k) const {
|
||||||
assert(i < height && j < width && k < depth);
|
assert(i < height && j < width && k < depth);
|
||||||
return data[i * width * depth + j * depth + k];
|
return data[i * width * depth + j * depth + k];
|
||||||
}
|
}
|
||||||
|
|
||||||
T &get(std::size_t i, std::size_t j, std::size_t k) {
|
T &get(uint32_t i, uint32_t j, uint32_t k) {
|
||||||
return data.write[i * width * depth + j * depth + k];
|
return data.write[i * width * depth + j * depth + k];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i = 0; i < data.size(); i++) {
|
for (uint32_t i = 0; i < data.size(); i++) {
|
||||||
if (a.data[i] != data[i]) {
|
if (a.data[i] != data[i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public:
|
|||||||
using PropagatorState = Vector<std::array<Vector<unsigned>, 4>>;
|
using PropagatorState = Vector<std::array<Vector<unsigned>, 4>>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::size_t patterns_size;
|
const uint32_t patterns_size;
|
||||||
|
|
||||||
PropagatorState propagator_state;
|
PropagatorState propagator_state;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user