Files
XCEngine/docs/api/math/bounds/bounds.md
ssdfasd f5a34f8adc docs: 重构 API 文档 - components 和 scene 模块
- components: 修复英文标题为中文,添加缺失组件文档
  - 新增 camera-component, light-component, audio-source-component, audio-listener-component 类总览
  - 修复 get-position.md 格式
  - 更新 components.md 模块总览
- scene: 修复方法文档格式,新增缺失方法
  - 修复 find.md, create-game-object.md 英文标题
  - 新增 FindByID, SerializeToString, DeserializeFromString 方法文档
  - 更新 scene.md 类总览方法列表
2026-03-26 01:50:27 +08:00

65 lines
1.9 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.
# Bounds
**命名空间**: `XCEngine::Math`
**类型**: `struct`
**头文件**: `XCEngine/Core/Math/Bounds.h`
**描述**: 轴对齐包围盒,用于场景管理中的快速剔除
## 概述
Bounds 表示一个轴对齐包围盒AABB使用中心点 `center` 和范围 `extents` 定义。`extents` 是从中心到包围盒每个面的距离,因此实际尺寸为 `extents * 2`。常用于视锥剔除、碰撞检测和场景管理中的快速排除不可见物体。
## 结构体成员
| 成员 | 类型 | 描述 |
|------|------|------|
| `center` | `Vector3` | 包围盒中心点 |
| `extents` | `Vector3` | 从中心到每个面的距离(实际尺寸 = extents * 2 |
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Bounds`](bounds.constructors.md) | 构造函数 |
| [`GetMin`](getmin.md) | 获取包围盒最小点 |
| [`GetMax`](getmax.md) | 获取包围盒最大点 |
| [`SetMinMax`](setminmax.md) | 从最小/最大点设置包围盒 |
| [`Intersects`](intersects.md) | 检测与另一个 Bounds 是否相交 |
| [`Contains`](contains.md) | 检测点是否在盒内 |
| [`Encapsulate`](encapsulate.md) | 扩展包围盒以包含点或另一个 Bounds |
| [`Expand`](expand.md) | 扩展包围盒 |
| [`GetClosestPoint`](getclosestpoint.md) | 获取盒上最接近给定点的点 |
| [`GetVolume`](getvolume.md) | 计算包围盒体积 |
## 使用示例
```cpp
#include <XCEngine/Core/Math/Bounds.h>
#include <XCEngine/Core/Math/Vector3.h>
using namespace XCEngine::Math;
Bounds bounds(Vector3(0.0f, 0.0f, 0.0f), Vector3(2.0f, 2.0f, 2.0f));
Vector3 min = bounds.GetMin();
Vector3 max = bounds.GetMax();
bounds.Expand(1.0f);
if (bounds.Contains(Vector3(0.0f, 0.0f, 0.0f))) {
// point is inside
}
Bounds other(Vector3(5.0f, 0.0f, 0.0f), Vector3(1.0f, 1.0f, 1.0f));
if (bounds.Intersects(other)) {
// bounds intersect
}
```
## 相关文档
- [Math 模块总览](../math.md) - 返回 Math 模块总览