docs: update math API docs

This commit is contained in:
2026-03-20 02:35:15 +08:00
parent e165dbea1c
commit c5b17239ca
243 changed files with 5307 additions and 1327 deletions

View File

@@ -1,45 +1,51 @@
# Frustum
视锥体,用于视锥剔除。
**命名空间**: `XCEngine::Math`
**头文件:** `#include <XCEngine/Math/Frustum.h>`
**类型**: `class`
**命名空间:** `XCEngine::Math`
**头文件**: `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
class Frustum {
public:
Plane planes[6];
Frustum frustum = camera.CalculateFrustum();
Bounds objectBounds = object.GetWorldBounds();
enum class PlaneIndex {
Left = 0,
Right = 1,
Bottom = 2,
Top = 3,
Near = 4,
Far = 5
};
bool Contains(const Vector3& point) const;
bool Contains(const Sphere& sphere) const;
bool Contains(const Bounds& bounds) const;
bool Intersects(const Bounds& bounds) const;
bool Intersects(const Sphere& sphere) const;
};
if (frustum.Contains(objectBounds)) {
// 物体完全在视锥内,必须渲染
Render(object);
} else if (frustum.Intersects(objectBounds)) {
// 物体与视锥相交,可能需要渲染
Render(object);
}
```
## 实例方法
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [Contains(point)](contains-point.md) | `bool` | 点是否在视锥内 |
| [Contains(sphere)](contains-sphere.md) | `bool` | 球体是否完全在视锥内 |
| [Contains(bounds)](contains-bounds.md) | `bool` | Bounds 是否完全在视锥内 |
| [Intersects(bounds)](intersects-bounds.md) | `bool` | Bounds 是否与视锥相交 |
| [Intersects(sphere)](intersects-sphere.md) | `bool` | 球体是否与视锥相交 |
## 相关文档
- [Math 模块总览](../math.md) - 返回 Math 模块总览
- [Math 模块总览](../math.md) - Math 模块总览
- [Plane](../plane/plane.md) - 平面类型
- [Bounds](../bounds/bounds.md) - 包围盒类型
- [Sphere](../sphere/sphere.md) - 球体类型