27 r.
bits = (uint32_t(
x) & 31u) | ((uint32_t(
y) & 31u) << 5) | ((uint32_t(
z) & 31u) << 10) |
28 ((uint32_t(
width - 1) & 31u) << 15) | ((uint32_t(
height - 1) & 31u) << 20) |
29 ((uint32_t(
tex) & 127u) << 25);
33 int x()
const {
return int(
bits & 31u); }
34 int y()
const {
return int((
bits >> 5) & 31u); }
35 int z()
const {
return int((
bits >> 10) & 31u); }
36 int width()
const {
return int((
bits >> 15) & 31u) + 1; }
37 int height()
const {
return int((
bits >> 20) & 31u) + 1; }
38 int tex()
const {
return int((
bits >> 25) & 127u); }
41static_assert(
sizeof(PackedRect) == 4,
"PackedRect must be 32-bit");
方块类型定义:名字、各面图集纹理、方向性、组合声明。 方向性方块在注册时按 orientation 绕 Y 轴展开成多个"具体类型"变体, 每个变体持有旋转后的各面纹理;渲染端只消费纹理 id,不接触 ...
constexpr int kChunkSize
Chunk edge length in voxels (fixed).
Packed face-rectangle instance (exactly 32 bits): bits 0..4 : x (0..31) bits 5..9 : y (0....
static PackedRect pack(int x, int y, int z, int width, int height, int tex)