#ifndef VOXELS_VOXEL_HPP_ #define VOXELS_VOXEL_HPP_ #include "../typedefs.hpp" inline constexpr int BLOCK_DIR_NORTH = 0x0; inline constexpr int BLOCK_DIR_WEST = 0x1; inline constexpr int BLOCK_DIR_SOUTH = 0x2; inline constexpr int BLOCK_DIR_EAST = 0x3; inline constexpr int BLOCK_DIR_UP = 0x4; inline constexpr int BLOCK_DIR_DOWN = 0x5; struct blockstate { uint8_t rotation : 3; uint8_t segment : 2; // planned to 0.22 uint8_t reserved : 3; uint8_t userbits : 8; }; static_assert (sizeof(blockstate) == 2); inline constexpr blockstate_t blockstate2int(blockstate b) { return static_cast(b.rotation) | static_cast(b.segment) << 3 | static_cast(b.reserved) << 5 | static_cast(b.userbits) << 8; } inline constexpr blockstate int2blockstate(blockstate_t i) { return { static_cast(i & 0b111), static_cast((i >> 3) & 0b11), static_cast((i >> 5) & 0b111), static_cast((i >> 8) & 0xFF) }; } struct voxel { blockid_t id; blockstate state; }; static_assert(sizeof(voxel) == 4); #endif // VOXELS_VOXEL_HPP_