35 lines
935 B
Markdown
35 lines
935 B
Markdown
# Frustum::Contains
|
||
|
||
```cpp
|
||
bool Contains(const Vector3& point) const
|
||
```
|
||
|
||
检测世界空间中的点是否完全位于视锥体内。判断方式为:依次计算该点到 6 个裁剪平面的有符号距离,若任意一个距离小于 0,则点位于该平面外侧,视锥体不包含该点。
|
||
|
||
**参数:**
|
||
- `point` - 要检测的世界空间三维点
|
||
|
||
**返回:** `bool` - 点完全在视锥内返回 `true`,否则返回 `false`
|
||
|
||
**线程安全:** ✅(只读操作,不修改状态)
|
||
|
||
**复杂度:** O(6),即遍历 6 个裁剪平面
|
||
|
||
**示例:**
|
||
|
||
```cpp
|
||
#include <XCEngine/Math/Frustum.h>
|
||
#include <XCEngine/Math/Vector3.h>
|
||
|
||
void CheckPointInFrustum(const Frustum& frustum, const Vector3& point) {
|
||
if (frustum.Contains(point)) {
|
||
// 点完全在视锥内
|
||
}
|
||
}
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [Frustum 总览](frustum.md) - 返回类总览
|
||
- [Intersects](intersects-bounds.md) - 视锥体相交检测
|