5#ifndef __UTIL_BOUNDBOX_H__
6#define __UTIL_BOUNDBOX_H__
41 max = ccl::max(pt, max);
47 min = ccl::min(pt - shift,
min);
48 max = ccl::max(pt + shift, max);
54 max = ccl::max(bbox.
max, max);
61 if (isfinite(pt.
x) && isfinite(pt.
y) && isfinite(pt.
z)) {
63 max = ccl::max(pt, max);
69 if (isfinite(pt.
x) && isfinite(pt.
y) && isfinite(pt.
z) && isfinite(border)) {
71 min = ccl::min(pt - shift,
min);
72 max = ccl::max(pt + shift, max);
82 max = ccl::max(bbox.
max, max);
89 max = ccl::min(max, bbox.
max);
95 if (!((
min.
x <= max.x) && (
min.
y <= max.y) && (
min.
z <= max.z))) {
110 return (d.
x * d.
z + d.
y * d.
z + d.
x * d.
y);
115 return 0.5f * (
min +
max);
130 return (
min.
x <= max.x) && (
min.
y <= max.y) && (
min.
z <= max.z) &&
131 (isfinite(
min.
x) && isfinite(
min.
y) && isfinite(
min.
z)) &&
132 (isfinite(max.x) && isfinite(max.y) && isfinite(max.z));
139 for (
int i = 0; i < 8; i++) {
142 p.
x = (i & 1) ?
min.
x : max.x;
143 p.
y = (i & 2) ?
min.
y : max.y;
144 p.
z = (i & 4) ?
min.
z : max.z;
154 float3 center_diff =
center() - other.center(), total_size = (
size() + other.size()) * 0.5f;
155 return fabsf(center_diff.
x) <= total_size.
x &&
fabsf(center_diff.
y) <= total_size.y &&
156 fabsf(center_diff.
z) <= total_size.z;
197 BoundBox2D() : left(0.0f), right(1.0f), bottom(0.0f), top(1.0f) {}
201 return (left == other.left && right == other.right && bottom == other.bottom &&
219 result.
left = left * f;
220 result.right = right * f;
221 result.bottom = bottom * f;
222 result.top = top * f;
243 result.
left = ((left - other.left) / (other.right - other.left));
244 result.right = ((right - other.left) / (other.right - other.left));
245 result.bottom = ((bottom - other.bottom) / (other.top - other.bottom));
246 result.top = ((top - other.bottom) / (other.top - other.bottom));
255 result.
left = ccl::clamp(left, mn, mx);
256 result.right = ccl::clamp(right, mn, mx);
257 result.bottom = ccl::clamp(bottom, mn, mx);
258 result.top = ccl::clamp(top, mn, mx);
__forceinline BoundBox merge(const BoundBox &bbox, const float3 &pt)
__forceinline BoundBox intersect(const BoundBox &a, const BoundBox &b)
BoundBox2D clamp(float mn=0.0f, float mx=1.0f)
BoundBox2D make_relative_to(const BoundBox2D &other) const
BoundBox2D operator*(float f) const
BoundBox2D subset(const BoundBox2D &other) const
bool operator==(const BoundBox2D &other) const
local_group_size(16, 16) .push_constant(Type b
#define CCL_NAMESPACE_END
__forceinline void grow(const BoundBox &bbox)
__forceinline float half_area() const
__forceinline BoundBox(empty_t)
__forceinline void grow_safe(const BoundBox &bbox)
__forceinline BoundBox(const float3 &pt)
BoundBox transformed(const Transform *tfm) const
__forceinline bool valid() const
__forceinline float3 center() const
__forceinline BoundBox(const float3 &min_, const float3 &max_)
__forceinline float3 size() const
__forceinline void intersect(const BoundBox &bbox)
__forceinline void grow_safe(const float3 &pt)
__forceinline float safe_area() const
__forceinline bool intersects(const BoundBox &other)
__forceinline void grow(const float3 &pt)
__forceinline float area() const
__forceinline void grow(const float3 &pt, float border)
__forceinline void grow_safe(const float3 &pt, float border)
__forceinline float3 center2() const
ccl_device_inline bool isfinite_safe(float f)