2 goat3d - 3D scene, and animation file format library.
3 Copyright (C) 2013-2018 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 void g3dimpl_aabox_init(struct aabox *box)
23 cgm_vcons(&box->bmin, FLT_MAX, FLT_MAX, FLT_MAX);
24 cgm_vcons(&box->bmax, -FLT_MAX, -FLT_MAX, -FLT_MAX);
27 void g3dimpl_aabox_cons(struct aabox *box, float x0, float y0, float z0,
28 float x1, float y1, float z1)
30 cgm_vcons(&box->bmin, x0, y0, z0);
31 cgm_vcons(&box->bmax, x1, y1, z1);
35 int g3dimpl_aabox_equal(const struct aabox *a, const struct aabox *b)
37 if(a->bmin.x != b->bmin.x || a->bmin.y != b->bmin.y || a->bmin.z != b->bmin.z) {
40 if(a->bmax.x != b->bmax.x || a->bmax.y != b->bmax.y || a->bmax.z != b->bmax.z) {
46 #define MIN(a, b) ((a) < (b) ? (a) : (b))
47 #define MAX(a, b) ((a) > (b) ? (a) : (b))
48 void g3dimpl_aabox_union(struct aabox *res, const struct aabox *a, const struct aabox *b)
50 res->bmin.x = MIN(a->bmin.x, b->bmin.x);
51 res->bmin.y = MIN(a->bmin.y, b->bmin.y);
52 res->bmin.z = MIN(a->bmin.z, b->bmin.z);
53 res->bmax.x = MAX(a->bmax.x, b->bmax.x);
54 res->bmax.y = MAX(a->bmax.y, b->bmax.y);
55 res->bmax.z = MAX(a->bmax.z, b->bmax.z);