From 85b2771c4a3ec73a3bd6ac969524bd2f3c37d8df Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 23 Jun 2015 16:36:57 -0700 Subject: [PATCH] Extend Extents --- libraries/shared/src/Extents.cpp | 11 ++++++++++- libraries/shared/src/Extents.h | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/Extents.cpp b/libraries/shared/src/Extents.cpp index f48ba3c99f..ad00683cf2 100644 --- a/libraries/shared/src/Extents.cpp +++ b/libraries/shared/src/Extents.cpp @@ -10,12 +10,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Extents.h" + #include #include #include #include "AABox.h" -#include "Extents.h" +#include "Transform.h" void Extents::reset() { minimum = glm::vec3(FLT_MAX); @@ -78,3 +80,10 @@ void Extents::rotate(const glm::quat& rotation) { glm::max(topRightNearRotated, glm::max(topLeftFarRotated,topRightFarRotated))))))); } + + +void Extents::transform(const Transform& transform) { + scale(transform.getScale()); + rotate(transform.getRotation()); + shiftBy(transform.getTranslation()); +} diff --git a/libraries/shared/src/Extents.h b/libraries/shared/src/Extents.h index 647f33699a..3d5a2dbcec 100644 --- a/libraries/shared/src/Extents.h +++ b/libraries/shared/src/Extents.h @@ -20,6 +20,7 @@ #include "StreamUtils.h" class AABox; +class Transform; class Extents { public: @@ -56,6 +57,13 @@ public: /// rotate the extents around orign by rotation void rotate(const glm::quat& rotation); + + /// scale the extents around orign by scale + void scale(float scale) { minimum *= scale; maximum *= scale; } + void scale(const glm::vec3& scale) { minimum *= scale; maximum *= scale; } + + // Transform the extents with transform + void transform(const Transform& transform); glm::vec3 size() const { return maximum - minimum; } float largestDimension() const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); }