migrate blocks interaction (scripting) to global chunks storage (WIP)

This commit is contained in:
MihailRis
2024-12-13 05:54:41 +03:00
parent 53cc8d3c7b
commit e0b3425eff
16 changed files with 227 additions and 144 deletions
+17 -2
View File
@@ -1,7 +1,5 @@
#pragma once
#include "typedefs.hpp"
inline constexpr int floordiv(int a, int b) {
if (a < 0 && a % b) {
return (a / b) - 1;
@@ -9,6 +7,23 @@ inline constexpr int floordiv(int a, int b) {
return a / b;
}
inline constexpr bool is_pot(int a) {
return (a > 0) && ((a & (a - 1)) == 0);
}
inline constexpr unsigned floorlog2(unsigned x) {
return x == 1 ? 0 : 1 + floorlog2(x >> 1);
}
template<int b>
inline constexpr int floordiv(int a) {
if constexpr (is_pot(b)) {
return a >> floorlog2(b);
} else {
return floordiv(a, b);
}
}
inline constexpr int ceildiv(int a, int b) {
if (a > 0 && a % b) {
return a / b + 1;