Files
XCEngine/docs/api/math/frustum/intersects-bounds.md
ssdfasd b414bc5326 refactor(docs): Fix broken links across multiple modules
Fixed broken references:
- texture-import-settings: Fix 16 files referencing wrong overview filename
- math/rectint: Fix 9 method links (rectint-* → get*, contains, intersects)
- rhi/opengl/device: Fix 8 cross-references (opengl-* → */**)
- resources/mesh: Fix meshsection and vertexattribute links
- rhi/d3d12/sampler: Fix RHISampler reference path
- math/vector3: Fix projectonplane → project-on-plane
- rhi/opengl/command-list: Remove broken ClearFlag enum ref
- rhi/opengl/device: Create 2 new method docs (MakeContextCurrent, GetNativeContext)
- rhi/device: Fix device-info types reference

All 0 broken references remaining.
2026-03-26 02:41:00 +08:00

1.4 KiB
Raw Blame History

Frustum::Intersects

bool Intersects(const Bounds& bounds) const

检测轴对齐包围盒Axis-Aligned Bounding BoxAABB是否与视锥体相交。判断方式为对每个裁剪平面检查 8 个顶点是否全部在该平面外侧allNegative或全部在内侧allPositive。若存在某个平面使得全部 8 个顶点都在其外侧,则视锥与包围盒不相交;否则认为两者相交。

注意:此方法与 Contains(Bounds) 的区别在于——Contains 要求包围盒完全在视锥内,而 Intersects 只要有任意重叠就返回 true

参数:

  • bounds - 要检测的轴对齐包围盒

返回: bool - 视锥与 Bounds 相交返回 true,否则返回 false

线程安全: (只读操作,不修改状态)

复杂度: O(48),即遍历 6 个平面 × 8 个顶点

示例:

#include <XCEngine/Core/Math/Frustum.h>
#include <XCEngine/Core/Math/Bounds.h>

void FrustumCullingExample(const Frustum& frustum, const std::vector<Bounds>& objectBounds) {
    for (const auto& bounds : objectBounds) {
        if (frustum.Intersects(bounds)) {
            // 物体与视锥相交,需要渲染
            Render(bounds);
        }
    }
}

相关文档