837 B
837 B
Bounds::Intersects
bool Intersects(const Bounds& other) const
检测该包围盒与另一个 Bounds 是否相交(重叠)。使用简化的 AABB 重叠检测算法,通过比较两个包围盒中心距离与它们 extents 之和来判断是否相交。
参数:
other- 另一个 Bounds
返回: bool - true 表示两个 Bounds 相交
线程安全: ✅
复杂度: O(1)
示例:
#include <XCEngine/Math/Bounds.h>
#include <XCEngine/Math/Vector3.h>
using namespace XCEngine::Math;
Bounds a(Vector3(0.0f, 0.0f, 0.0f), Vector3(2.0f, 2.0f, 2.0f));
Bounds b(Vector3(1.0f, 0.0f, 0.0f), Vector3(2.0f, 2.0f, 2.0f));
if (a.Intersects(b)) {
// a and b overlap
}