VoxelEngine
 
Loading...
Searching...
No Matches
Index.h
1#pragma once
2
3#include <cstddef>
4
5namespace engine {
6
9 inline constexpr size_t index2D(size_t x, size_t y, size_t width) {
10 return y * width + x;
11 }
12
15 inline constexpr size_t index3D(size_t x, size_t y, size_t z, size_t width, size_t height) {
16 return z * width * height + y * width + x;
17 }
18
21 inline constexpr size_t index4D(
22 size_t x, size_t y, size_t z, size_t w, size_t width, size_t height, size_t depth
23 ) {
24 return w * width * height * depth + z * width * height + y * width + x;
25 }
26} // namespace engine