handy conversions between AABox, AACube, and Extents

This commit is contained in:
ZappoMan 2014-09-11 12:23:35 -07:00
parent 7cadc3433a
commit d616c7fa0c
4 changed files with 26 additions and 1 deletions

View file

@ -11,6 +11,7 @@
#include "AABox.h"
#include "AACube.h"
#include "Extents.h"
#include "GeometryUtil.h"
#include "SharedUtil.h"
@ -19,6 +20,11 @@ AABox::AABox(const AACube& other) :
_corner(other.getCorner()), _scale(other.getScale(), other.getScale(), other.getScale()) {
}
AABox::AABox(const Extents& other) :
_corner(other.minimum),
_scale(other.maximum - other.minimum) {
}
AABox::AABox(const glm::vec3& corner, float size) :
_corner(corner), _scale(size, size, size) {
};

View file

@ -23,11 +23,13 @@
#include "StreamUtils.h"
class AACube;
class Extents;
class AABox {
public:
AABox(const AACube& other);
AABox(const Extents& other);
AABox(const glm::vec3& corner, float size);
AABox(const glm::vec3& corner, const glm::vec3& dimensions);
AABox();

View file

@ -9,11 +9,25 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <glm/gtx/extented_min_max.hpp>
#include "AABox.h"
#include "AACube.h"
#include "Extents.h"
#include "GeometryUtil.h"
#include "SharedUtil.h"
AACube::AACube(const AABox& other) :
_corner(other.getCorner()), _scale(other.getLargestDimension()) {
}
AACube::AACube(const Extents& other) :
_corner(other.minimum)
{
glm::vec3 dimensions = other.maximum - other.minimum;
_scale = glm::max(dimensions.x, dimensions.y, dimensions.z);
}
AACube::AACube(const glm::vec3& corner, float size) :
_corner(corner), _scale(size) {
};

View file

@ -1,6 +1,6 @@
//
// AACube.h
// libraries/octree/src
// libraries/shared/src
//
// Created by Brad Hefta-Gaub on 04/11/13.
// Copyright 2013 High Fidelity, Inc.
@ -22,10 +22,13 @@
#include "BoxBase.h"
class AABox;
class Extents;
class AACube {
public:
AACube(const AABox& other);
AACube(const Extents& other);
AACube(const glm::vec3& corner, float size);
AACube();
~AACube() {};