mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-27 06:19:51 -05:00
Prevent division by 0 error in ScreenSpaceSkybrowser (closes #3696)
This commit is contained in:
@@ -740,7 +740,7 @@ glm::vec3 ScreenSpaceRenderable::cartesianToSpherical(const glm::vec3& cartesian
|
||||
const float r = std::sqrt(
|
||||
std::pow(rotated.x, 2.f) + std::pow(rotated.y, 2.f) + std::pow(rotated.z, 2.f)
|
||||
);
|
||||
const float theta = std::acos(rotated.z / r);
|
||||
const float theta = std::acos(r != 0.f ? rotated.z / r : rotated.z);
|
||||
const float phi = std::atan2(rotated.y, rotated.x);
|
||||
return sanitizeSphericalCoordinates(glm::vec3(r, theta, phi));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user