mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 12:26:59 +01:00
Use error macros in the wfc module instead of asserts.
This commit is contained in:
parent
ec6b52f5d8
commit
e4a2429b45
@ -1,7 +1,6 @@
|
|||||||
#ifndef FAST_WFC_UTILS_ARRAY2D_HPP_
|
#ifndef FAST_WFC_UTILS_ARRAY2D_HPP_
|
||||||
#define FAST_WFC_UTILS_ARRAY2D_HPP_
|
#define FAST_WFC_UTILS_ARRAY2D_HPP_
|
||||||
|
|
||||||
#include "assert.h"
|
|
||||||
#include "core/vector.h"
|
#include "core/vector.h"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -26,12 +25,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const T &get(uint32_t i, uint32_t j) const {
|
const T &get(uint32_t i, uint32_t j) const {
|
||||||
assert(i < height && j < width);
|
CRASH_BAD_INDEX(i, height);
|
||||||
|
CRASH_BAD_INDEX(j, width);
|
||||||
|
|
||||||
return data[j + i * width];
|
return data[j + i * width];
|
||||||
}
|
}
|
||||||
|
|
||||||
T &get(uint32_t i, uint32_t j) {
|
T &get(uint32_t i, uint32_t j) {
|
||||||
assert(i < height && j < width);
|
CRASH_BAD_INDEX(i, height);
|
||||||
|
CRASH_BAD_INDEX(j, width);
|
||||||
|
|
||||||
return data.write[j + i * width];
|
return data.write[j + i * width];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef FAST_WFC_UTILS_ARRAY3D_HPP_
|
#ifndef FAST_WFC_UTILS_ARRAY3D_HPP_
|
||||||
#define FAST_WFC_UTILS_ARRAY3D_HPP_
|
#define FAST_WFC_UTILS_ARRAY3D_HPP_
|
||||||
|
|
||||||
#include "assert.h"
|
|
||||||
#include "core/vector.h"
|
#include "core/vector.h"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -29,11 +28,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const T &get(uint32_t i, uint32_t j, uint32_t k) const {
|
const T &get(uint32_t i, uint32_t j, uint32_t k) const {
|
||||||
assert(i < height && j < width && k < depth);
|
CRASH_BAD_INDEX(i, height);
|
||||||
|
CRASH_BAD_INDEX(j, width);
|
||||||
|
CRASH_BAD_INDEX(k, depth);
|
||||||
|
|
||||||
return data[i * width * depth + j * depth + k];
|
return data[i * width * depth + j * depth + k];
|
||||||
}
|
}
|
||||||
|
|
||||||
T &get(uint32_t i, uint32_t j, uint32_t k) {
|
T &get(uint32_t i, uint32_t j, uint32_t k) {
|
||||||
|
CRASH_BAD_INDEX(i, height);
|
||||||
|
CRASH_BAD_INDEX(j, width);
|
||||||
|
CRASH_BAD_INDEX(k, depth);
|
||||||
|
|
||||||
return data.write[i * width * depth + j * depth + k];
|
return data.write[i * width * depth + j * depth + k];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +85,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The pattern exists.
|
ERR_FAIL_V(0);
|
||||||
assert(false);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the list of patterns, as well as their probabilities of apparition.
|
//Return the list of patterns, as well as their probabilities of apparition.
|
||||||
@ -98,22 +96,14 @@ private:
|
|||||||
// The number of time a pattern is seen in the input image.
|
// The number of time a pattern is seen in the input image.
|
||||||
Vector<double> patterns_weight;
|
Vector<double> patterns_weight;
|
||||||
|
|
||||||
Vector<Array2D<T>> symmetries(
|
Vector<Array2D<T>> symmetries(8, Array2D<T>(options.pattern_size, options.pattern_size));
|
||||||
8, Array2D<T>(options.pattern_size, options.pattern_size));
|
uint32_t max_i = options.periodic_input ? input.height : input.height - options.pattern_size + 1;
|
||||||
uint32_t max_i = options.periodic_input
|
uint32_t max_j = options.periodic_input ? input.width : input.width - options.pattern_size + 1;
|
||||||
? input.height
|
|
||||||
: input.height - options.pattern_size + 1;
|
|
||||||
uint32_t max_j = options.periodic_input
|
|
||||||
? input.width
|
|
||||||
: input.width - options.pattern_size + 1;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < max_i; i++) {
|
for (uint32_t i = 0; i < max_i; i++) {
|
||||||
for (uint32_t j = 0; j < max_j; j++) {
|
for (uint32_t j = 0; j < max_j; j++) {
|
||||||
// Compute the symmetries of every pattern in the image.
|
// Compute the symmetries of every pattern in the image.
|
||||||
symmetries[0].data =
|
symmetries[0].data = input.get_sub_array(i, j, options.pattern_size, options.pattern_size).data;
|
||||||
input
|
|
||||||
.get_sub_array(i, j, options.pattern_size, options.pattern_size)
|
|
||||||
.data;
|
|
||||||
symmetries[1].data = symmetries[0].reflected().data;
|
symmetries[1].data = symmetries[0].reflected().data;
|
||||||
symmetries[2].data = symmetries[0].rotated().data;
|
symmetries[2].data = symmetries[0].rotated().data;
|
||||||
symmetries[3].data = symmetries[2].reflected().data;
|
symmetries[3].data = symmetries[2].reflected().data;
|
||||||
|
Loading…
Reference in New Issue
Block a user