goat3d

diff src/aabox.cc @ 75:76dea247f75c

in progress
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 May 2014 00:50:16 +0300
parents
children 70b7c41a4f17
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/aabox.cc	Thu May 08 00:50:16 2014 +0300
     1.3 @@ -0,0 +1,27 @@
     1.4 +#include <float.h>
     1.5 +#include <algorithm>
     1.6 +#include "aabox.h"
     1.7 +
     1.8 +using namespace g3dimpl;
     1.9 +
    1.10 +AABox::AABox()
    1.11 +	: bmin(FLT_MAX, FLT_MAX, FLT_MAX), bmax(-FLT_MAX, -FLT_MAX, -FLT_MAX)
    1.12 +{
    1.13 +}
    1.14 +
    1.15 +AABox::AABox(const Vector3 &b0, const Vector3 &b1)
    1.16 +	: bmin(b0), bmax(b1)
    1.17 +{
    1.18 +}
    1.19 +
    1.20 +AABox g3dimpl::aabox_union(const AABox &a, const AABox &b)
    1.21 +{
    1.22 +	Vector3 bmin, bmax;
    1.23 +
    1.24 +	for(int i=0; i<3; i++) {
    1.25 +		bmin[i] = std::min(a.bmin[i], b.bmin[i]);
    1.26 +		bmax[i] = std::max(a.bmax[i], b.bmax[i]);
    1.27 +	}
    1.28 +
    1.29 +	return AABox(bmin, bmax);
    1.30 +}