mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
migrate blocks interaction (scripting) to global chunks storage (WIP)
This commit is contained in:
parent
53cc8d3c7b
commit
e0b3425eff
16 changed files with 228 additions and 145 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue