You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
32 lines
1.2 KiB
//
|
|
// Created by dtouch on 23-5-14.
|
|
//
|
|
|
|
#include "aabb.h"
|
|
#include "algorithm"
|
|
#include "cmath"
|
|
|
|
float minFloat = -std::numeric_limits<float>::max();
|
|
float maxFloat = std::numeric_limits<float>::max();
|
|
|
|
AABB::AABB() {
|
|
pMax = EVec3f(minFloat, minFloat, minFloat);
|
|
pMin = EVec3f(maxFloat, maxFloat, maxFloat);
|
|
}
|
|
|
|
AABB::AABB(const EVec3f &p) : pMin(p), pMax(p) {}
|
|
|
|
AABB::AABB(const EVec3f &p1, const EVec3f &p2) {
|
|
pMin = EVec3f(smallerFloat(p1.x(), p2.x()), smallerFloat(p1.y(), p2.y()), smallerFloat(p1.z(), p2.z()));
|
|
pMax = EVec3f(greaterFloat(p1.x(), p2.x()), greaterFloat(p1.y(), p2.y()), greaterFloat(p1.z(), p2.z()));
|
|
}
|
|
|
|
void AABB::unionSelf(const AABB &b2) {
|
|
pMin = EVec3f(smallerFloat(pMin.x(), b2.pMin.x()), smallerFloat(pMin.y(), b2.pMin.y()), smallerFloat(pMin.z(), b2.pMin.z()));
|
|
pMax = EVec3f(greaterFloat(pMax.x(), b2.pMax.x()), greaterFloat(pMax.y(), b2.pMax.y()), greaterFloat(pMax.z(), b2.pMax.z()));
|
|
}
|
|
|
|
void AABB::unionSelf(const EVec3f &p) {
|
|
pMin = EVec3f(smallerFloat(pMin.x(), p.x()), smallerFloat(pMin.y(), p.y()), smallerFloat(pMin.z(), p.z()));
|
|
pMax = EVec3f(greaterFloat(pMax.x(), p.x()), greaterFloat(pMax.y(), p.y()), greaterFloat(pMax.z(), p.z()));
|
|
}
|