mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:14:34 +02:00
Extend Extents
This commit is contained in:
parent
233d92c315
commit
85b2771c4a
2 changed files with 18 additions and 1 deletions
|
@ -10,12 +10,14 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "Extents.h"
|
||||||
|
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
#include <glm/gtx/quaternion.hpp>
|
#include <glm/gtx/quaternion.hpp>
|
||||||
#include <glm/gtx/transform.hpp>
|
#include <glm/gtx/transform.hpp>
|
||||||
|
|
||||||
#include "AABox.h"
|
#include "AABox.h"
|
||||||
#include "Extents.h"
|
#include "Transform.h"
|
||||||
|
|
||||||
void Extents::reset() {
|
void Extents::reset() {
|
||||||
minimum = glm::vec3(FLT_MAX);
|
minimum = glm::vec3(FLT_MAX);
|
||||||
|
@ -78,3 +80,10 @@ void Extents::rotate(const glm::quat& rotation) {
|
||||||
glm::max(topRightNearRotated,
|
glm::max(topRightNearRotated,
|
||||||
glm::max(topLeftFarRotated,topRightFarRotated)))))));
|
glm::max(topLeftFarRotated,topRightFarRotated)))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Extents::transform(const Transform& transform) {
|
||||||
|
scale(transform.getScale());
|
||||||
|
rotate(transform.getRotation());
|
||||||
|
shiftBy(transform.getTranslation());
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "StreamUtils.h"
|
#include "StreamUtils.h"
|
||||||
|
|
||||||
class AABox;
|
class AABox;
|
||||||
|
class Transform;
|
||||||
|
|
||||||
class Extents {
|
class Extents {
|
||||||
public:
|
public:
|
||||||
|
@ -56,6 +57,13 @@ public:
|
||||||
|
|
||||||
/// rotate the extents around orign by rotation
|
/// rotate the extents around orign by rotation
|
||||||
void rotate(const glm::quat& 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; }
|
glm::vec3 size() const { return maximum - minimum; }
|
||||||
float largestDimension() const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); }
|
float largestDimension() const {glm::vec3 s = size(); return glm::max(s[0], s[1], s[2]); }
|
||||||
|
|
Loading…
Reference in a new issue