Fix call to atan2 when params are 0

This commit is contained in:
Ryan Huffman 2015-06-26 17:23:06 -07:00
parent abe8cfe90f
commit 760a5bfa37

View file

@ -709,7 +709,8 @@ Transform Avatar::calculateDisplayNameTransform(const ViewFrustum& frustum, floa
// Compute orientation
glm::vec3 dPosition = frustum.getPosition() - getPosition();
float yawRotation = glm::atan(dPosition.x, dPosition.z);
// If x and z are 0, atan(x, z) is undefined, so default to 0 degrees
float yawRotation = dPosition.x == 0.0f && dPosition.z == 0.0f ? 0.0f : glm::atan(dPosition.x, dPosition.z);
glm::quat orientation = glm::quat(glm::vec3(0.0f, yawRotation, 0.0f));
// Set transform (The order IS important)