Blender V5.3
draw_aabb.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "draw_shape.bsl.hh"
12
13/* ---------------------------------------------------------------------- */
16
17struct AABB {
19};
20
22{
23 AABB aabb;
24 aabb.min = min;
25 aabb.max = max;
26 return aabb;
27}
28
30{
31 AABB aabb;
32 aabb.min = float3(1.0e30f);
33 aabb.max = float3(-1.0e30f);
34 return aabb;
35}
36
37void aabb_merge(AABB &aabb, float3 v)
38{
39 aabb.min = min(aabb.min, v);
40 aabb.max = max(aabb.max, v);
41}
42
47{
48 return all(greaterThanEqual(min(a.max, b.max), max(a.min, b.min)));
49}
50
55bool aabb_clip(AABB a, AABB b, AABB &c)
56{
57 c.min = max(a.min, b.min);
58 c.max = min(a.max, b.max);
59 return all(greaterThanEqual(c.max, c.min));
60}
61
63{
64 Box box;
65 box.corners[0] = aabb.min;
66 box.corners[1] = float3(aabb.max.x, aabb.min.y, aabb.min.z);
67 box.corners[2] = float3(aabb.max.x, aabb.max.y, aabb.min.z);
68 box.corners[3] = float3(aabb.min.x, aabb.max.y, aabb.min.z);
69 box.corners[4] = float3(aabb.min.x, aabb.min.y, aabb.max.z);
70 box.corners[5] = float3(aabb.max.x, aabb.min.y, aabb.max.z);
71 box.corners[6] = aabb.max;
72 box.corners[7] = float3(aabb.min.x, aabb.max.y, aabb.max.z);
73 return box;
74}
75
btScalar max
Box aabb_to_box(AABB aabb)
AABB aabb_init_min_max()
AABB shape_aabb(float3 min, float3 max)
bool aabb_clip(AABB a, AABB b, AABB &c)
bool aabb_intersect(AABB a, AABB b)
void aabb_merge(AABB &aabb, float3 v)
VecBase< bool, D > greaterThanEqual(VecOp< T, D >, VecOp< T, D >) RET
bool all(VecOp< bool, D >) RET
VecBase< float, 3 > float3
#define min(a, b)
Definition sort.cc:38
float3 max
float3 min
float3 corners[8]