mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
added isVec3NaN and isQuatNaN functions
This commit is contained in:
parent
6294939095
commit
a9cf836cb0
7 changed files with 24 additions and 12 deletions
|
@ -480,7 +480,7 @@ AACube& AACube::operator += (const glm::vec3& point) {
|
|||
}
|
||||
|
||||
bool AACube::containsNaN() const {
|
||||
if (isNaN(_corner.x) || isNaN(_corner.y) || isNaN(_corner.z)) {
|
||||
if (isVec3NaN(_corner)) {
|
||||
return true;
|
||||
}
|
||||
if (isNaN(_scale)) {
|
||||
|
|
|
@ -425,3 +425,10 @@ void generateBasisVectors(const glm::vec3& primaryAxis, const glm::vec3& seconda
|
|||
vAxisOut = glm::cross(wAxisOut, uAxisOut);
|
||||
}
|
||||
|
||||
bool isVec3NaN(glm::vec3 value) {
|
||||
return isNaN(value.x) || isNaN(value.y) || isNaN(value.z);
|
||||
}
|
||||
|
||||
bool isQuatNaN(glm::quat value) {
|
||||
return isNaN(value.w) || isNaN(value.x) || isNaN(value.y) || isNaN(value.z);
|
||||
}
|
||||
|
|
|
@ -224,4 +224,8 @@ glm::vec3 transformVector(const glm::mat4& m, const glm::vec3& v);
|
|||
void generateBasisVectors(const glm::vec3& primaryAxis, const glm::vec3& secondaryAxis,
|
||||
glm::vec3& uAxisOut, glm::vec3& vAxisOut, glm::vec3& wAxisOut);
|
||||
|
||||
|
||||
bool isVec3NaN(glm::vec3 value);
|
||||
bool isQuatNaN(glm::quat value);
|
||||
|
||||
#endif // hifi_GLMHelpers_h
|
||||
|
|
|
@ -624,8 +624,8 @@ void debug::checkDeadBeef(void* memoryVoid, int size) {
|
|||
assert(memcmp((unsigned char*)memoryVoid, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0);
|
||||
}
|
||||
|
||||
bool isNaN(float value) {
|
||||
return value != value;
|
||||
bool isNaN(float value) {
|
||||
return value != value;
|
||||
}
|
||||
|
||||
QString formatUsecTime(float usecs, int prec) {
|
||||
|
|
|
@ -162,6 +162,7 @@ bool isBetween(int64_t value, int64_t max, int64_t min);
|
|||
/// \return bool is the float NaN
|
||||
bool isNaN(float value);
|
||||
|
||||
|
||||
QString formatUsecTime(float usecs, int prec = 3);
|
||||
QString formatSecondsElapsed(float seconds);
|
||||
bool similarStrings(const QString& stringA, const QString& stringB);
|
||||
|
|
|
@ -315,7 +315,7 @@ glm::vec3 SpatiallyNestable::getPosition(int jointIndex, bool& success) const {
|
|||
|
||||
void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(position.x) || isNaN(position.y) || isNaN(position.z)) {
|
||||
if (isVec3NaN(position)) {
|
||||
success = false;
|
||||
return;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ glm::quat SpatiallyNestable::getOrientation(int jointIndex, bool& success) const
|
|||
|
||||
void SpatiallyNestable::setOrientation(const glm::quat& orientation, bool& success) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(orientation.x) || isNaN(orientation.y) || isNaN(orientation.z) || isNaN(orientation.w)) {
|
||||
if (isQuatNaN(orientation)) {
|
||||
success = false;
|
||||
return;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ glm::vec3 SpatiallyNestable::getScale(int jointIndex) const {
|
|||
|
||||
void SpatiallyNestable::setScale(const glm::vec3& scale) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(scale.x) || isNaN(scale.y) || isNaN(scale.z)) {
|
||||
if (isVec3NaN(scale)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalScale -- scale contains NaN";
|
||||
return;
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ glm::vec3 SpatiallyNestable::getLocalPosition() const {
|
|||
|
||||
void SpatiallyNestable::setLocalPosition(const glm::vec3& position) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(position.x) || isNaN(position.y) || isNaN(position.z)) {
|
||||
if (isVec3NaN(position)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalPosition -- position contains NaN";
|
||||
return;
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ glm::quat SpatiallyNestable::getLocalOrientation() const {
|
|||
|
||||
void SpatiallyNestable::setLocalOrientation(const glm::quat& orientation) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(orientation.x) || isNaN(orientation.y) || isNaN(orientation.z) || isNaN(orientation.w)) {
|
||||
if (isQuatNaN(orientation)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalOrientation -- orientation contains NaN";
|
||||
return;
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ glm::vec3 SpatiallyNestable::getLocalScale() const {
|
|||
|
||||
void SpatiallyNestable::setLocalScale(const glm::vec3& scale) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(scale.x) || isNaN(scale.y) || isNaN(scale.z)) {
|
||||
if (isVec3NaN(scale)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalScale -- scale contains NaN";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -152,13 +152,13 @@ QJsonObject Transform::toJson(const Transform& transform) {
|
|||
}
|
||||
|
||||
bool Transform::containsNaN() const {
|
||||
if (isNaN(_rotation.x) || isNaN(_rotation.y) || isNaN(_rotation.z) || isNaN(_rotation.w)) {
|
||||
if (isQuatNaN(_rotation)) {
|
||||
return true;
|
||||
}
|
||||
if (isNaN(_scale.x) || isNaN(_scale.y) || isNaN(_scale.z)) {
|
||||
if (isVec3NaN(_scale)) {
|
||||
return true;
|
||||
}
|
||||
if (isNaN(_translation.x) || isNaN(_translation.y) || isNaN(_translation.z)) {
|
||||
if (isVec3NaN(_translation)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue