Files
XCEngine/docs/api/math/frustum/frustum.md
2026-03-20 02:35:15 +08:00

52 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Frustum
**命名空间**: `XCEngine::Math`
**类型**: `class`
**头文件**: `XCEngine/Math/Frustum.h`
**描述**: 视锥体,用于 3D 裁剪和可见性判断
## 概述
Frustum 表示一个视锥体,由 6 个裁剪平面组成左、右、底、顶、近、远。主要用于视锥剔除Frustum Culling在渲染前判断场景物体是否与相机视锥相交或完全在内从而决定是否需要渲染该物体提升渲染性能。
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Contains(Point)`](contains-point.md) | 点是否完全在视锥内 |
| [`Contains(Sphere)`](contains-sphere.md) | 球体是否完全在视锥内 |
| [`Contains(Bounds)`](contains-bounds.md) | Bounds 是否完全在视锥内 |
| [`Intersects(Bounds)`](intersects-bounds.md) | Bounds 是否与视锥相交 |
| [`Intersects(Sphere)`](intersects-sphere.md) | 球体是否与视锥相交 |
## 嵌套类型
| 类型 | 描述 |
|------|------|
| `PlaneIndex` | 平面索引枚举Left, Right, Bottom, Top, Near, Far |
## 使用示例
```cpp
Frustum frustum = camera.CalculateFrustum();
Bounds objectBounds = object.GetWorldBounds();
if (frustum.Contains(objectBounds)) {
// 物体完全在视锥内,必须渲染
Render(object);
} else if (frustum.Intersects(objectBounds)) {
// 物体与视锥相交,可能需要渲染
Render(object);
}
```
## 相关文档
- [Math 模块总览](../math.md) - Math 模块总览
- [Plane](../plane/plane.md) - 平面类型
- [Bounds](../bounds/bounds.md) - 包围盒类型
- [Sphere](../sphere/sphere.md) - 球体类型