mirror of
https://github.com/overte-org/overte.git
synced 2025-05-28 18:02:02 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into deference
This commit is contained in:
commit
76728e4fb1
17 changed files with 351 additions and 117 deletions
|
@ -3387,7 +3387,7 @@ void Application::updateWindowTitle(){
|
|||
#ifndef WIN32
|
||||
// crashes with vs2013/win32
|
||||
qDebug("Application title set to: %s", title.toStdString().c_str());
|
||||
#endif !WIN32
|
||||
#endif //!WIN32
|
||||
_window->setWindowTitle(title);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,9 +102,9 @@ Audio::Audio(QObject* parent) :
|
|||
_scopeOutputOffset(0),
|
||||
_framesPerScope(DEFAULT_FRAMES_PER_SCOPE),
|
||||
_samplesPerScope(NETWORK_SAMPLES_PER_FRAME * _framesPerScope),
|
||||
_peqEnabled(false),
|
||||
_noiseSourceEnabled(false),
|
||||
_toneSourceEnabled(true),
|
||||
_peqEnabled(false),
|
||||
_scopeInput(0),
|
||||
_scopeOutputLeft(0),
|
||||
_scopeOutputRight(0),
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "AudioSourceTone.h"
|
||||
#include "AudioSourceNoise.h"
|
||||
#include "AudioGain.h"
|
||||
#include "AudioPan.h"
|
||||
#include "AudioFilter.h"
|
||||
#include "AudioFilterBank.h"
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
float depth = unRotatedExtents.z;
|
||||
|
||||
Extents rotatedExtents = _model->getUnscaledMeshExtents();
|
||||
calculateRotatedExtents(rotatedExtents, rotation);
|
||||
rotatedExtents.rotate(rotation);
|
||||
|
||||
glm::vec3 rotatedSize = rotatedExtents.maximum - rotatedExtents.minimum;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void ModelOverlay::render() {
|
|||
float depth = unRotatedExtents.z;
|
||||
|
||||
Extents rotatedExtents = _model.getUnscaledMeshExtents();
|
||||
calculateRotatedExtents(rotatedExtents, _rotation);
|
||||
rotatedExtents.rotate(_rotation);
|
||||
|
||||
glm::vec3 rotatedSize = rotatedExtents.maximum - rotatedExtents.minimum;
|
||||
|
||||
|
|
23
libraries/audio/src/AudioPan.cpp
Normal file
23
libraries/audio/src/AudioPan.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// AudioSourceTone.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Craig Hansen-Sturm on 8/10/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <SharedUtil.h>
|
||||
#include "AudioRingBuffer.h"
|
||||
#include "AudioFormat.h"
|
||||
#include "AudioBuffer.h"
|
||||
#include "AudioPan.h"
|
||||
|
||||
float32_t AudioPan::ONE_MINUS_EPSILON = 1.0f - EPSILON;
|
||||
float32_t AudioPan::ZERO_PLUS_EPSILON = 0.0f + EPSILON;
|
||||
float32_t AudioPan::ONE_HALF_MINUS_EPSILON = 0.5f - EPSILON;
|
||||
float32_t AudioPan::ONE_HALF_PLUS_EPSILON = 0.5f + EPSILON;
|
141
libraries/audio/src/AudioPan.h
Normal file
141
libraries/audio/src/AudioPan.h
Normal file
|
@ -0,0 +1,141 @@
|
|||
//
|
||||
// AudioPan.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Craig Hansen-Sturm on 9/1/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_AudioPan_h
|
||||
#define hifi_AudioPan_h
|
||||
|
||||
class AudioPan
|
||||
{
|
||||
float32_t _pan;
|
||||
float32_t _gainLeft;
|
||||
float32_t _gainRight;
|
||||
|
||||
static float32_t ONE_MINUS_EPSILON;
|
||||
static float32_t ZERO_PLUS_EPSILON;
|
||||
static float32_t ONE_HALF_MINUS_EPSILON;
|
||||
static float32_t ONE_HALF_PLUS_EPSILON;
|
||||
|
||||
void updateCoefficients() {
|
||||
|
||||
// implement constant power sin^2 + cos^2 = 1 panning law
|
||||
|
||||
if (_pan >= ONE_MINUS_EPSILON) { // full right
|
||||
_gainLeft = 0.0f;
|
||||
_gainRight = 1.0f;
|
||||
}
|
||||
else if (_pan <= ZERO_PLUS_EPSILON) { // full left
|
||||
_gainLeft = 1.0f;
|
||||
_gainRight = 0.0f;
|
||||
}
|
||||
else if ((_pan >= ONE_HALF_MINUS_EPSILON) && (_pan <= ONE_HALF_PLUS_EPSILON)) { // center
|
||||
_gainLeft = 1.0f / SQUARE_ROOT_OF_2;
|
||||
_gainRight = 1.0f / SQUARE_ROOT_OF_2;
|
||||
}
|
||||
else { // intermediate cases
|
||||
_gainLeft = cosf( TWO_PI * _pan );
|
||||
_gainRight = sinf( TWO_PI * _pan );
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
AudioPan() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
~AudioPan() {
|
||||
finalize();
|
||||
}
|
||||
|
||||
void initialize() {
|
||||
setParameters(0.5f);
|
||||
}
|
||||
|
||||
void finalize() {
|
||||
}
|
||||
|
||||
void reset() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
void setParameters(const float32_t pan) {
|
||||
// pan ranges between 0.0 and 1.0f inclusive. 0.5f is midpoint between full left and full right
|
||||
_pan = std::min(std::max(pan, 0.0f), 1.0f);
|
||||
updateCoefficients();
|
||||
}
|
||||
|
||||
void getParameters(float32_t& pan) {
|
||||
pan = _pan;
|
||||
}
|
||||
|
||||
void render(AudioBufferFloat32& frameBuffer) {
|
||||
|
||||
if (frameBuffer.getChannelCount() != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
float32_t** samples = frameBuffer.getFrameData();
|
||||
|
||||
bool frameAlignment16 = (frameBuffer.getFrameCount() & 0x0F) == 0;
|
||||
if (frameAlignment16) {
|
||||
|
||||
if (frameBuffer.getChannelCount() == 2) {
|
||||
|
||||
for (uint16_t i = 0; i < frameBuffer.getFrameCount(); i += 16) {
|
||||
samples[0][i + 0] *= _gainLeft;
|
||||
samples[0][i + 1] *= _gainLeft;
|
||||
samples[0][i + 2] *= _gainLeft;
|
||||
samples[0][i + 3] *= _gainLeft;
|
||||
samples[0][i + 4] *= _gainLeft;
|
||||
samples[0][i + 5] *= _gainLeft;
|
||||
samples[0][i + 6] *= _gainLeft;
|
||||
samples[0][i + 7] *= _gainLeft;
|
||||
samples[0][i + 8] *= _gainLeft;
|
||||
samples[0][i + 9] *= _gainLeft;
|
||||
samples[0][i + 10] *= _gainLeft;
|
||||
samples[0][i + 11] *= _gainLeft;
|
||||
samples[0][i + 12] *= _gainLeft;
|
||||
samples[0][i + 13] *= _gainLeft;
|
||||
samples[0][i + 14] *= _gainLeft;
|
||||
samples[0][i + 15] *= _gainLeft;
|
||||
samples[1][i + 0] *= _gainRight;
|
||||
samples[1][i + 1] *= _gainRight;
|
||||
samples[1][i + 2] *= _gainRight;
|
||||
samples[1][i + 3] *= _gainRight;
|
||||
samples[1][i + 4] *= _gainRight;
|
||||
samples[1][i + 5] *= _gainRight;
|
||||
samples[1][i + 6] *= _gainRight;
|
||||
samples[1][i + 7] *= _gainRight;
|
||||
samples[1][i + 8] *= _gainRight;
|
||||
samples[1][i + 9] *= _gainRight;
|
||||
samples[1][i + 10] *= _gainRight;
|
||||
samples[1][i + 11] *= _gainRight;
|
||||
samples[1][i + 12] *= _gainRight;
|
||||
samples[1][i + 13] *= _gainRight;
|
||||
samples[1][i + 14] *= _gainRight;
|
||||
samples[1][i + 15] *= _gainRight;
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert("unsupported channel format");
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (uint16_t i = 0; i < frameBuffer.getFrameCount(); i += 1) {
|
||||
samples[0][i] *= _gainLeft;
|
||||
samples[1][i] *= _gainRight;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // AudioPan_h
|
||||
|
||||
|
|
@ -509,7 +509,7 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
|
|||
|
||||
Extents rotatedExtents = extents;
|
||||
|
||||
calculateRotatedExtents(rotatedExtents, entity->getRotation());
|
||||
rotatedExtents.rotate(entity->getRotation());
|
||||
|
||||
rotatedExtents.minimum += entity->getPosition();
|
||||
rotatedExtents.maximum += entity->getPosition();
|
||||
|
|
|
@ -33,27 +33,6 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
void Extents::reset() {
|
||||
minimum = glm::vec3(FLT_MAX);
|
||||
maximum = glm::vec3(-FLT_MAX);
|
||||
}
|
||||
|
||||
bool Extents::containsPoint(const glm::vec3& point) const {
|
||||
return (point.x >= minimum.x && point.x <= maximum.x
|
||||
&& point.y >= minimum.y && point.y <= maximum.y
|
||||
&& point.z >= minimum.z && point.z <= maximum.z);
|
||||
}
|
||||
|
||||
void Extents::addExtents(const Extents& extents) {
|
||||
minimum = glm::min(minimum, extents.minimum);
|
||||
maximum = glm::max(maximum, extents.maximum);
|
||||
}
|
||||
|
||||
void Extents::addPoint(const glm::vec3& point) {
|
||||
minimum = glm::min(minimum, point);
|
||||
maximum = glm::max(maximum, point);
|
||||
}
|
||||
|
||||
bool FBXMesh::hasSpecularTexture() const {
|
||||
foreach (const FBXMeshPart& part, parts) {
|
||||
if (!part.specularTexture.filename.isEmpty()) {
|
||||
|
@ -2132,40 +2111,3 @@ FBXGeometry readSVO(const QByteArray& model) {
|
|||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
void calculateRotatedExtents(Extents& extents, const glm::quat& rotation) {
|
||||
glm::vec3 bottomLeftNear(extents.minimum.x, extents.minimum.y, extents.minimum.z);
|
||||
glm::vec3 bottomRightNear(extents.maximum.x, extents.minimum.y, extents.minimum.z);
|
||||
glm::vec3 bottomLeftFar(extents.minimum.x, extents.minimum.y, extents.maximum.z);
|
||||
glm::vec3 bottomRightFar(extents.maximum.x, extents.minimum.y, extents.maximum.z);
|
||||
glm::vec3 topLeftNear(extents.minimum.x, extents.maximum.y, extents.minimum.z);
|
||||
glm::vec3 topRightNear(extents.maximum.x, extents.maximum.y, extents.minimum.z);
|
||||
glm::vec3 topLeftFar(extents.minimum.x, extents.maximum.y, extents.maximum.z);
|
||||
glm::vec3 topRightFar(extents.maximum.x, extents.maximum.y, extents.maximum.z);
|
||||
|
||||
glm::vec3 bottomLeftNearRotated = rotation * bottomLeftNear;
|
||||
glm::vec3 bottomRightNearRotated = rotation * bottomRightNear;
|
||||
glm::vec3 bottomLeftFarRotated = rotation * bottomLeftFar;
|
||||
glm::vec3 bottomRightFarRotated = rotation * bottomRightFar;
|
||||
glm::vec3 topLeftNearRotated = rotation * topLeftNear;
|
||||
glm::vec3 topRightNearRotated = rotation * topRightNear;
|
||||
glm::vec3 topLeftFarRotated = rotation * topLeftFar;
|
||||
glm::vec3 topRightFarRotated = rotation * topRightFar;
|
||||
|
||||
extents.minimum = glm::min(bottomLeftNearRotated,
|
||||
glm::min(bottomRightNearRotated,
|
||||
glm::min(bottomLeftFarRotated,
|
||||
glm::min(bottomRightFarRotated,
|
||||
glm::min(topLeftNearRotated,
|
||||
glm::min(topRightNearRotated,
|
||||
glm::min(topLeftFarRotated,topRightFarRotated)))))));
|
||||
|
||||
extents.maximum = glm::max(bottomLeftNearRotated,
|
||||
glm::max(bottomRightNearRotated,
|
||||
glm::max(bottomLeftFarRotated,
|
||||
glm::max(bottomRightFarRotated,
|
||||
glm::max(topLeftNearRotated,
|
||||
glm::max(topRightNearRotated,
|
||||
glm::max(topLeftFarRotated,topRightFarRotated)))))));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
#include <QVariant>
|
||||
#include <QVector>
|
||||
|
||||
#include <Extents.h>
|
||||
#include <Shape.h>
|
||||
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
|
@ -35,31 +37,6 @@ extern const int NUM_FACESHIFT_BLENDSHAPES;
|
|||
/// The names of the joints in the Maya HumanIK rig, terminated with an empty string.
|
||||
extern const char* HUMANIK_JOINTS[];
|
||||
|
||||
class Extents {
|
||||
public:
|
||||
/// set minimum and maximum to FLT_MAX and -FLT_MAX respectively
|
||||
void reset();
|
||||
|
||||
/// \param extents another intance of extents
|
||||
/// expand current limits to contain other extents
|
||||
void addExtents(const Extents& extents);
|
||||
|
||||
/// \param point new point to compare against existing limits
|
||||
/// compare point to current limits and expand them if necessary to contain point
|
||||
void addPoint(const glm::vec3& point);
|
||||
|
||||
/// \param point
|
||||
/// \return true if point is within current limits
|
||||
bool containsPoint(const glm::vec3& point) const;
|
||||
|
||||
/// \return whether or not the extents are empty
|
||||
bool isEmpty() const { return minimum == maximum; }
|
||||
bool isValid() const { return !((minimum == glm::vec3(FLT_MAX)) && (maximum == glm::vec3(-FLT_MAX))); }
|
||||
|
||||
glm::vec3 minimum;
|
||||
glm::vec3 maximum;
|
||||
};
|
||||
|
||||
/// A node within an FBX document.
|
||||
class FBXNode {
|
||||
public:
|
||||
|
@ -254,6 +231,4 @@ FBXGeometry readFBX(const QByteArray& model, const QVariantHash& mapping);
|
|||
/// Reads SVO geometry from the supplied model data.
|
||||
FBXGeometry readSVO(const QByteArray& model);
|
||||
|
||||
void calculateRotatedExtents(Extents& extents, const glm::quat& rotation);
|
||||
|
||||
#endif // hifi_FBXReader_h
|
||||
|
|
|
@ -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) {
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
};
|
||||
|
|
|
@ -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() {};
|
||||
|
|
74
libraries/shared/src/Extents.cpp
Normal file
74
libraries/shared/src/Extents.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Extents.cpp
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Andrzej Kapolka on 9/18/13.
|
||||
// Moved to shared by Brad Hefta-Gaub on 9/11/14
|
||||
// Copyright 2013-2104 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
#include "Extents.h"
|
||||
|
||||
void Extents::reset() {
|
||||
minimum = glm::vec3(FLT_MAX);
|
||||
maximum = glm::vec3(-FLT_MAX);
|
||||
}
|
||||
|
||||
bool Extents::containsPoint(const glm::vec3& point) const {
|
||||
return (point.x >= minimum.x && point.x <= maximum.x
|
||||
&& point.y >= minimum.y && point.y <= maximum.y
|
||||
&& point.z >= minimum.z && point.z <= maximum.z);
|
||||
}
|
||||
|
||||
void Extents::addExtents(const Extents& extents) {
|
||||
minimum = glm::min(minimum, extents.minimum);
|
||||
maximum = glm::max(maximum, extents.maximum);
|
||||
}
|
||||
|
||||
void Extents::addPoint(const glm::vec3& point) {
|
||||
minimum = glm::min(minimum, point);
|
||||
maximum = glm::max(maximum, point);
|
||||
}
|
||||
|
||||
void Extents::rotate(const glm::quat& rotation) {
|
||||
glm::vec3 bottomLeftNear(minimum.x, minimum.y, minimum.z);
|
||||
glm::vec3 bottomRightNear(maximum.x, minimum.y, minimum.z);
|
||||
glm::vec3 bottomLeftFar(minimum.x, minimum.y, maximum.z);
|
||||
glm::vec3 bottomRightFar(maximum.x, minimum.y, maximum.z);
|
||||
glm::vec3 topLeftNear(minimum.x, maximum.y, minimum.z);
|
||||
glm::vec3 topRightNear(maximum.x, maximum.y, minimum.z);
|
||||
glm::vec3 topLeftFar(minimum.x, maximum.y, maximum.z);
|
||||
glm::vec3 topRightFar(maximum.x, maximum.y, maximum.z);
|
||||
|
||||
glm::vec3 bottomLeftNearRotated = rotation * bottomLeftNear;
|
||||
glm::vec3 bottomRightNearRotated = rotation * bottomRightNear;
|
||||
glm::vec3 bottomLeftFarRotated = rotation * bottomLeftFar;
|
||||
glm::vec3 bottomRightFarRotated = rotation * bottomRightFar;
|
||||
glm::vec3 topLeftNearRotated = rotation * topLeftNear;
|
||||
glm::vec3 topRightNearRotated = rotation * topRightNear;
|
||||
glm::vec3 topLeftFarRotated = rotation * topLeftFar;
|
||||
glm::vec3 topRightFarRotated = rotation * topRightFar;
|
||||
|
||||
minimum = glm::min(bottomLeftNearRotated,
|
||||
glm::min(bottomRightNearRotated,
|
||||
glm::min(bottomLeftFarRotated,
|
||||
glm::min(bottomRightFarRotated,
|
||||
glm::min(topLeftNearRotated,
|
||||
glm::min(topRightNearRotated,
|
||||
glm::min(topLeftFarRotated,topRightFarRotated)))))));
|
||||
|
||||
maximum = glm::max(bottomLeftNearRotated,
|
||||
glm::max(bottomRightNearRotated,
|
||||
glm::max(bottomLeftFarRotated,
|
||||
glm::max(bottomRightFarRotated,
|
||||
glm::max(topLeftNearRotated,
|
||||
glm::max(topRightNearRotated,
|
||||
glm::max(topLeftFarRotated,topRightFarRotated)))))));
|
||||
}
|
53
libraries/shared/src/Extents.h
Normal file
53
libraries/shared/src/Extents.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// Extents.h
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Andrzej Kapolka on 9/18/13.
|
||||
// Moved to shared by Brad Hefta-Gaub on 9/11/14
|
||||
// Copyright 2013-2104 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_Extents_h
|
||||
#define hifi_Extents_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class Extents {
|
||||
public:
|
||||
/// set minimum and maximum to FLT_MAX and -FLT_MAX respectively
|
||||
void reset();
|
||||
|
||||
/// \param extents another intance of extents
|
||||
/// expand current limits to contain other extents
|
||||
void addExtents(const Extents& extents);
|
||||
|
||||
/// \param point new point to compare against existing limits
|
||||
/// compare point to current limits and expand them if necessary to contain point
|
||||
void addPoint(const glm::vec3& point);
|
||||
|
||||
/// \param point
|
||||
/// \return true if point is within current limits
|
||||
bool containsPoint(const glm::vec3& point) const;
|
||||
|
||||
/// \return whether or not the extents are empty
|
||||
bool isEmpty() const { return minimum == maximum; }
|
||||
bool isValid() const { return !((minimum == glm::vec3(FLT_MAX)) && (maximum == glm::vec3(-FLT_MAX))); }
|
||||
|
||||
/// rotate the extents around orign by rotation
|
||||
void rotate(const glm::quat& rotation);
|
||||
|
||||
/// \return new Extents which is original rotated around orign by rotation
|
||||
Extents getRotated(const glm::quat& rotation) const {
|
||||
Extents temp = { minimum, maximum };
|
||||
temp.rotate(rotation);
|
||||
return temp;
|
||||
}
|
||||
|
||||
glm::vec3 minimum;
|
||||
glm::vec3 maximum;
|
||||
};
|
||||
|
||||
#endif // hifi_Extents_h
|
|
@ -49,7 +49,7 @@ public:
|
|||
Enum lastFlag() const { return (Enum)_maxFlag; }
|
||||
|
||||
void setHasProperty(Enum flag, bool value = true);
|
||||
bool getHasProperty(Enum flag);
|
||||
bool getHasProperty(Enum flag) const;
|
||||
QByteArray encode();
|
||||
void decode(const QByteArray& fromEncoded);
|
||||
|
||||
|
@ -61,42 +61,42 @@ public:
|
|||
|
||||
PropertyFlags& operator=(const PropertyFlags& other);
|
||||
|
||||
PropertyFlags& operator|=(PropertyFlags other);
|
||||
PropertyFlags& operator|=(const PropertyFlags& other);
|
||||
PropertyFlags& operator|=(Enum flag);
|
||||
|
||||
PropertyFlags& operator&=(PropertyFlags other);
|
||||
PropertyFlags& operator&=(const PropertyFlags& other);
|
||||
PropertyFlags& operator&=(Enum flag);
|
||||
|
||||
PropertyFlags& operator+=(PropertyFlags other);
|
||||
PropertyFlags& operator+=(const PropertyFlags& other);
|
||||
PropertyFlags& operator+=(Enum flag);
|
||||
|
||||
PropertyFlags& operator-=(PropertyFlags other);
|
||||
PropertyFlags& operator-=(const PropertyFlags& other);
|
||||
PropertyFlags& operator-=(Enum flag);
|
||||
|
||||
PropertyFlags& operator<<=(PropertyFlags other);
|
||||
PropertyFlags& operator<<=(const PropertyFlags& other);
|
||||
PropertyFlags& operator<<=(Enum flag);
|
||||
|
||||
PropertyFlags operator|(PropertyFlags other) const;
|
||||
PropertyFlags operator|(const PropertyFlags& other) const;
|
||||
PropertyFlags operator|(Enum flag) const;
|
||||
|
||||
PropertyFlags operator&(PropertyFlags other) const;
|
||||
PropertyFlags operator&(const PropertyFlags& other) const;
|
||||
PropertyFlags operator&(Enum flag) const;
|
||||
|
||||
PropertyFlags operator+(PropertyFlags other) const;
|
||||
PropertyFlags operator+(const PropertyFlags& other) const;
|
||||
PropertyFlags operator+(Enum flag) const;
|
||||
|
||||
PropertyFlags operator-(PropertyFlags other) const;
|
||||
PropertyFlags operator-(const PropertyFlags& other) const;
|
||||
PropertyFlags operator-(Enum flag) const;
|
||||
|
||||
PropertyFlags operator<<(PropertyFlags other) const;
|
||||
PropertyFlags operator<<(const PropertyFlags& other) const;
|
||||
PropertyFlags operator<<(Enum flag) const;
|
||||
|
||||
// NOTE: due to the nature of the compact storage of these property flags, and the fact that the upper bound of the
|
||||
// enum is not know, these operators will only perform their bitwise operations on the set of properties that have
|
||||
// been previously set
|
||||
PropertyFlags& operator^=(PropertyFlags other);
|
||||
PropertyFlags& operator^=(const PropertyFlags& other);
|
||||
PropertyFlags& operator^=(Enum flag);
|
||||
PropertyFlags operator^(PropertyFlags other) const;
|
||||
PropertyFlags operator^(const PropertyFlags& other) const;
|
||||
PropertyFlags operator^(Enum flag) const;
|
||||
PropertyFlags operator~() const;
|
||||
|
||||
|
@ -146,7 +146,7 @@ template<typename Enum> inline void PropertyFlags<Enum>::setHasProperty(Enum fla
|
|||
}
|
||||
}
|
||||
|
||||
template<typename Enum> inline bool PropertyFlags<Enum>::getHasProperty(Enum flag) {
|
||||
template<typename Enum> inline bool PropertyFlags<Enum>::getHasProperty(Enum flag) const {
|
||||
if (flag > _maxFlag) {
|
||||
return _trailingFlipped; // usually false
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operato
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator|=(PropertyFlags other) {
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator|=(const PropertyFlags& other) {
|
||||
_flags |= other._flags;
|
||||
_maxFlag = std::max(_maxFlag, other._maxFlag);
|
||||
_minFlag = std::min(_minFlag, other._minFlag);
|
||||
|
@ -268,7 +268,7 @@ template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operato
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator&=(PropertyFlags other) {
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator&=(const PropertyFlags& other) {
|
||||
_flags &= other._flags;
|
||||
shinkIfNeeded();
|
||||
return *this;
|
||||
|
@ -281,7 +281,7 @@ template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operato
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator^=(PropertyFlags other) {
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator^=(const PropertyFlags& other) {
|
||||
_flags ^= other._flags;
|
||||
shinkIfNeeded();
|
||||
return *this;
|
||||
|
@ -294,7 +294,7 @@ template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operato
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator+=(PropertyFlags other) {
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator+=(const PropertyFlags& other) {
|
||||
for(int flag = (int)other.firstFlag(); flag <= (int)other.lastFlag(); flag++) {
|
||||
if (other.getHasProperty((Enum)flag)) {
|
||||
setHasProperty((Enum)flag, true);
|
||||
|
@ -308,7 +308,7 @@ template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operato
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator-=(PropertyFlags other) {
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator-=(const PropertyFlags& other) {
|
||||
for(int flag = (int)other.firstFlag(); flag <= (int)other.lastFlag(); flag++) {
|
||||
if (other.getHasProperty((Enum)flag)) {
|
||||
setHasProperty((Enum)flag, false);
|
||||
|
@ -322,7 +322,7 @@ template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operato
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator<<=(PropertyFlags other) {
|
||||
template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operator<<=(const PropertyFlags& other) {
|
||||
for(int flag = (int)other.firstFlag(); flag <= (int)other.lastFlag(); flag++) {
|
||||
if (other.getHasProperty((Enum)flag)) {
|
||||
setHasProperty((Enum)flag, true);
|
||||
|
@ -336,7 +336,7 @@ template<typename Enum> inline PropertyFlags<Enum>& PropertyFlags<Enum>::operato
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator|(PropertyFlags other) const {
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator|(const PropertyFlags& other) const {
|
||||
PropertyFlags result(*this);
|
||||
result |= other;
|
||||
return result;
|
||||
|
@ -349,7 +349,7 @@ template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator&(PropertyFlags other) const {
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator&(const PropertyFlags& other) const {
|
||||
PropertyFlags result(*this);
|
||||
result &= other;
|
||||
return result;
|
||||
|
@ -362,7 +362,7 @@ template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator^(PropertyFlags other) const {
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator^(const PropertyFlags& other) const {
|
||||
PropertyFlags result(*this);
|
||||
result ^= other;
|
||||
return result;
|
||||
|
@ -375,7 +375,7 @@ template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator+(PropertyFlags other) const {
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator+(const PropertyFlags& other) const {
|
||||
PropertyFlags result(*this);
|
||||
result += other;
|
||||
return result;
|
||||
|
@ -387,7 +387,7 @@ template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator-(PropertyFlags other) const {
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator-(const PropertyFlags& other) const {
|
||||
PropertyFlags result(*this);
|
||||
result -= other;
|
||||
return result;
|
||||
|
@ -399,7 +399,7 @@ template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator<<(PropertyFlags other) const {
|
||||
template<typename Enum> inline PropertyFlags<Enum> PropertyFlags<Enum>::operator<<(const PropertyFlags& other) const {
|
||||
PropertyFlags result(*this);
|
||||
result <<= other;
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue