19 auto m = [&](
int row,
int col) ->
float {
return m16[col * 4 + row]; };
20 auto set = [&](
int i,
float a,
float b,
float c,
float d) {
21 const float len = std::sqrt(
a *
a +
b *
b +
c *
c);
23 f.planes[i][0] =
a / len;
24 f.planes[i][1] =
b / len;
25 f.planes[i][2] =
c / len;
26 f.planes[i][3] =
d / len;
35 set(0,
m(3, 0) +
m(0, 0),
m(3, 1) +
m(0, 1),
m(3, 2) +
m(0, 2),
m(3, 3) +
m(0, 3));
36 set(1,
m(3, 0) -
m(0, 0),
m(3, 1) -
m(0, 1),
m(3, 2) -
m(0, 2),
m(3, 3) -
m(0, 3));
37 set(2,
m(3, 0) +
m(1, 0),
m(3, 1) +
m(1, 1),
m(3, 2) +
m(1, 2),
m(3, 3) +
m(1, 3));
38 set(3,
m(3, 0) -
m(1, 0),
m(3, 1) -
m(1, 1),
m(3, 2) -
m(1, 2),
m(3, 3) -
m(1, 3));
39 set(4,
m(3, 0) +
m(2, 0),
m(3, 1) +
m(2, 1),
m(3, 2) +
m(2, 2),
m(3, 3) +
m(2, 3));
40 set(5,
m(3, 0) -
m(2, 0),
m(3, 1) -
m(2, 1),
m(3, 2) -
m(2, 2),
m(3, 3) -
m(2, 3));
44 bool intersectsAABB(
float minX,
float minY,
float minZ,
float maxX,
float maxY,
46 for (
int i = 0; i < 6; ++i) {
48 const float x =
p[0] >= 0.f ? maxX : minX;
49 const float y =
p[1] >= 0.f ? maxY : minY;
50 const float z =
p[2] >= 0.f ? maxZ : minZ;
51 if (
p[0] *
x +
p[1] *
y +
p[2] *
z +
p[3] < 0.f)
return false;
方块类型定义:名字、各面图集纹理、方向性、组合声明。 方向性方块在注册时按 orientation 绕 Y 轴展开成多个"具体类型"变体, 每个变体持有旋转后的各面纹理;渲染端只消费纹理 id,不接触 ...
Six frustum planes in ax+by+cz+d >= 0 form (normals point inward).
static Frustum fromViewProjColumnMajor(const float *m16)
Extract from a column-major 4x4 view-projection matrix (RH + Vulkan ZO). Layout matches glm::mat4 mem...
bool intersectsAABB(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) const