28 glm::vec3 lo(
n.bminX,
n.bminY,
n.bminZ);
30 glm::vec3 hi(
n.bmaxX,
n.bmaxY,
n.bmaxZ);
32 glm::vec3 mn(std::numeric_limits<float>::max());
34 glm::vec3 mx(std::numeric_limits<float>::lowest());
35 for (
int i = 0; i < 8; ++i) {
37 glm::vec3
p((i & 1) ? hi.x : lo.x, (i & 2) ? hi.y : lo.y,
38 (i & 4) ? hi.z : lo.z);
39 glm::vec4
w =
n.world * glm::vec4(
p, 1.f);
40 for (
int c = 0;
c < 3; ++
c) {
41 mn[
c] = std::min(mn[
c],
w[
c]);
42 mx[
c] = std::max(mx[
c],
w[
c]);
49inline bool rayAABB(
const glm::vec3 &o,
const glm::vec3 &
d,
const AABB3f &
b,
float &t0,
51 t0 = -std::numeric_limits<float>::max();
52 t1 = std::numeric_limits<float>::max();
53 for (
int axis = 0; axis < 3; ++axis) {
54 const float oa = o[axis];
55 const float da =
d[axis];
56 const float mn =
b.min[axis];
57 const float mx =
b.max[axis];
58 if (std::fabs(da) < 1e-12f) {
59 if (oa < mn || oa > mx)
return false;
61 const float inv = 1.f / da;
62 float tA = (mn - oa) * inv;
63 float tB = (mx - oa) * inv;
64 if (tA > tB) std::swap(tA, tB);
65 t0 = std::max(t0, tA);
66 t1 = std::min(t1, tB);
67 if (t0 > t1)
return false;
75 const glm::vec4
c =
m * glm::vec4(
p, 1.f);
76 return c.w > 1e-8f && std::fabs(
c.x) <=
c.w && std::fabs(
c.y) <=
c.w &&
77 c.z >= 0.f &&
c.z <=
c.w;
83 for (
int i = 0; i < 8; ++i) {
85 const glm::vec3
p((i & 1) ?
b.max.x :
b.min.x, (i & 2) ?
b.max.y :
b.min.y,
86 (i & 4) ?
b.max.z :
b.min.z);
89 for (
int i = 0; i < 8; ++i) {
91 const glm::vec3 ndc((i & 1) ? 1.f : -1.f, (i & 2) ? 1.f : -1.f,
93 const glm::vec4
w = invClip * glm::vec4(ndc, 1.f);
94 if (std::fabs(
w.w) < 1e-8f)
continue;
95 const glm::vec3
q = glm::vec3(
w) /
w.w;
96 if (
q.x >=
b.min.x &&
q.x <=
b.max.x &&
q.y >=
b.min.y &&
q.y <=
b.max.y &&
97 q.z >=
b.min.z &&
q.z <=
b.max.z) {
std::array< double, 10 > q
bool aabbIntersectsFrustum(const glm::mat4 &clip, const glm::mat4 &invClip, const AABB3f &b)
Conservative AABB ↔ frustum overlap (AABB corners + frustum corners).
bool cornerInsideClip(const glm::mat4 &m, const glm::vec3 &p)
Corner inside clip.
bool rayAABB(const glm::vec3 &o, const glm::vec3 &d, const AABB3f &b, float &t0, float &t1)
Slab ray-AABB intersection; fills entry/exit t (t0 <= t1).
AABB3f worldBoundsOf(const SceneNode &n)
World-space AABB of a node's local bounds (8 corners through world matrix).
Axis-aligned box in world space.
Retained scene node (arena). Conceptual GameObject; isomorphic to eve::ui::UINode.