mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 09:33:45 +02:00
use isNaN rather than a self-comparison
This commit is contained in:
parent
451464cb47
commit
6b15beb88a
3 changed files with 10 additions and 23 deletions
|
@ -480,7 +480,7 @@ AACube& AACube::operator += (const glm::vec3& point) {
|
|||
}
|
||||
|
||||
bool AACube::containsNaN() const {
|
||||
if ( _corner.x != _corner.x || _corner.y != _corner.y || _corner.z != _corner.z) {
|
||||
if (isNaN(_corner.x) || isNaN(_corner.y) || isNaN(_corner.z)) {
|
||||
return true;
|
||||
}
|
||||
if (_scale != _scale) {
|
||||
|
|
|
@ -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 (position.x != position.x || position.y != position.y || position.z != position.z) {
|
||||
if (isNaN(position.x) || isNaN(position.y) || isNaN(position.z)) {
|
||||
success = false;
|
||||
return;
|
||||
}
|
||||
|
@ -364,10 +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 (orientation.x != orientation.x ||
|
||||
orientation.y != orientation.y ||
|
||||
orientation.z != orientation.z ||
|
||||
orientation.w != orientation.w) {
|
||||
if (isNaN(orientation.x) || isNaN(orientation.y) || isNaN(orientation.z) || isNaN(orientation.w)) {
|
||||
success = false;
|
||||
return;
|
||||
}
|
||||
|
@ -451,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 (scale.x != scale.x || scale.y != scale.y || scale.z != scale.z) {
|
||||
if (isNaN(scale.x) || isNaN(scale.y) || isNaN(scale.z)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalScale -- scale contains NaN";
|
||||
return;
|
||||
}
|
||||
|
@ -492,7 +489,7 @@ glm::vec3 SpatiallyNestable::getLocalPosition() const {
|
|||
|
||||
void SpatiallyNestable::setLocalPosition(const glm::vec3& position) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (position.x != position.x || position.y != position.y || position.z != position.z) {
|
||||
if (isNaN(position.x) || isNaN(position.y) || isNaN(position.z)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalPosition -- position contains NaN";
|
||||
return;
|
||||
}
|
||||
|
@ -512,10 +509,7 @@ glm::quat SpatiallyNestable::getLocalOrientation() const {
|
|||
|
||||
void SpatiallyNestable::setLocalOrientation(const glm::quat& orientation) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (orientation.x != orientation.x ||
|
||||
orientation.y != orientation.y ||
|
||||
orientation.z != orientation.z ||
|
||||
orientation.w != orientation.w) {
|
||||
if (isNaN(orientation.x) || isNaN(orientation.y) || isNaN(orientation.z) || isNaN(orientation.w)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalOrientation -- orientation contains NaN";
|
||||
return;
|
||||
}
|
||||
|
@ -536,7 +530,7 @@ glm::vec3 SpatiallyNestable::getLocalScale() const {
|
|||
|
||||
void SpatiallyNestable::setLocalScale(const glm::vec3& scale) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (scale.x != scale.x || scale.y != scale.y || scale.z != scale.z) {
|
||||
if (isNaN(scale.x) || isNaN(scale.y) || isNaN(scale.z)) {
|
||||
qDebug() << "SpatiallyNestable::setLocalScale -- scale contains NaN";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -152,20 +152,13 @@ QJsonObject Transform::toJson(const Transform& transform) {
|
|||
}
|
||||
|
||||
bool Transform::containsNaN() const {
|
||||
if (_rotation.x != _rotation.x ||
|
||||
_rotation.y != _rotation.y ||
|
||||
_rotation.z != _rotation.z ||
|
||||
_rotation.w != _rotation.w) {
|
||||
if (isNaN(_rotation.x) || isNaN(_rotation.y) || isNaN(_rotation.z) || isNaN(_rotation.w)) {
|
||||
return true;
|
||||
}
|
||||
if (_scale.x != _scale.x ||
|
||||
_scale.y != _scale.y ||
|
||||
_scale.z != _scale.z) {
|
||||
if (isNaN(_scale.x) || isNaN(_scale.y) || isNaN(_scale.z)) {
|
||||
return true;
|
||||
}
|
||||
if (_translation.x != _translation.x ||
|
||||
_translation.y != _translation.y ||
|
||||
_translation.z != _translation.z) {
|
||||
if (isNaN(_translation.x) || isNaN(_translation.y) || isNaN(_translation.z)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue