mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 21:29:33 +02:00
move isNaN() to shared utils
This commit is contained in:
parent
dfd6411a4f
commit
a37921c1d5
3 changed files with 29 additions and 5 deletions
|
@ -424,10 +424,6 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNaN(float f) {
|
|
||||||
return f != f;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const {
|
bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const {
|
||||||
|
|
||||||
// Compute distance between the two positions
|
// Compute distance between the two positions
|
||||||
|
@ -449,7 +445,7 @@ bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const
|
||||||
float angleEyeOffsetOrientation = compareTo._eyeOffsetOrientation == _eyeOffsetOrientation
|
float angleEyeOffsetOrientation = compareTo._eyeOffsetOrientation == _eyeOffsetOrientation
|
||||||
? 0.0f : glm::degrees(glm::angle(dQEyeOffsetOrientation));
|
? 0.0f : glm::degrees(glm::angle(dQEyeOffsetOrientation));
|
||||||
if (isNaN(angleEyeOffsetOrientation)) {
|
if (isNaN(angleEyeOffsetOrientation)) {
|
||||||
angleOrientation = 0.0f;
|
angleEyeOffsetOrientation = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result =
|
bool result =
|
||||||
|
|
|
@ -661,3 +661,22 @@ glm::vec3 safeEulerAngles(const glm::quat& q) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isNaN(float f) {
|
||||||
|
return f != f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) {
|
||||||
|
// Compute the angular distance between the two orientations
|
||||||
|
float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB)));
|
||||||
|
if (isNaN(angleOrientation)) {
|
||||||
|
angleOrientation = 0.0f;
|
||||||
|
}
|
||||||
|
return (angleOrientation <= similarEnough);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) {
|
||||||
|
// Compute the distance between the two points
|
||||||
|
float positionDistance = glm::distance(positionA, positionB);
|
||||||
|
return (positionDistance <= similarEnough);
|
||||||
|
}
|
||||||
|
|
|
@ -168,4 +168,13 @@ int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm
|
||||||
/// \return vec3 with euler angles in radians
|
/// \return vec3 with euler angles in radians
|
||||||
glm::vec3 safeEulerAngles(const glm::quat& q);
|
glm::vec3 safeEulerAngles(const glm::quat& q);
|
||||||
|
|
||||||
|
/// \return bool are two orientations similar to each other
|
||||||
|
const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction
|
||||||
|
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB,
|
||||||
|
float similarEnough = ORIENTATION_SIMILAR_ENOUGH);
|
||||||
|
const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter
|
||||||
|
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH);
|
||||||
|
|
||||||
|
bool isNaN(float f);
|
||||||
|
|
||||||
#endif /* defined(__hifi__SharedUtil__) */
|
#endif /* defined(__hifi__SharedUtil__) */
|
||||||
|
|
Loading…
Reference in a new issue