本文整理汇总了C++中AxisAlignedBoundingBox::extents方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBoundingBox::extents方法的具体用法?C++ AxisAlignedBoundingBox::extents怎么用?C++ AxisAlignedBoundingBox::extents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxisAlignedBoundingBox
的用法示例。
在下文中一共展示了AxisAlignedBoundingBox::extents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plane_aabb
IntersectionTest::Result IntersectionTest::plane_aabb(const Vec4f &plane, const AxisAlignedBoundingBox &aabb)
{
Vec3f center = aabb.center();
Vec3f extents = aabb.extents();
float e = extents.x * std::abs(plane.x) + extents.y * std::abs(plane.y) + extents.z * std::abs(plane.z);
float s = center.x * plane.x + center.y * plane.y + center.z * plane.z + plane.w;
if (s - e > 0)
return inside;
else if (s + e < 0)
return outside;
else
return intersecting;
}
示例2: ray_aabb
IntersectionTest::OverlapResult IntersectionTest::ray_aabb(const Vec3f &ray_start, const Vec3f &ray_end, const AxisAlignedBoundingBox &aabb)
{
Vec3f c = (ray_start + ray_end) * 0.5f;
Vec3f w = ray_end - c;
Vec3f h = aabb.extents();
c -= aabb.center();
Vec3f v(std::abs(w.x), std::abs(w.y), std::abs(w.z));
if (std::abs(c.x) > v.x + h.x || std::abs(c.y) > v.y + h.y || std::abs(c.z) > v.z + h.z)
return disjoint;
if (std::abs(c.y * w.z - c.z * w.y) > h.y * v.z + h.z * v.y ||
std::abs(c.x * w.z - c.z * w.x) > h.x * v.z + h.z * v.x ||
std::abs(c.x * w.y - c.y * w.x) > h.x * v.y + h.y * v.x)
return disjoint;
return overlap;
}