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

35 lines
708 B
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.
# OBB::Intersects (OBB)
```cpp
bool Intersects(const OBB& other) const;
```
检测该 OBB 与另一个 OBB 是否相交。采用分离轴定理SAT进行检测通过测试 15 条可能的分离轴来判断两个盒子是否重叠。
**参数:**
- `other` - 另一个 OBB 包围盒
**返回:** 两 OBB 相交返回 `true`,否则返回 `false`
**异常:**
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
#include "AABB.h"
#include "Vector3.h"
#include "Matrix4.h"
using namespace XCEngine::Math;
OBB obb1(Vector3(0.0f, 0.0f, 0.0f), Vector3(1.0f, 0.5f, 1.0f));
OBB obb2(Vector3(1.5f, 0.0f, 0.0f), Vector3(1.0f, 0.5f, 1.0f));
if (obb1.Intersects(obb2)) {
}
```