Prevent division by 0 error in ScreenSpaceSkybrowser (closes #3696)

This commit is contained in:
Alexander Bock
2025-06-09 11:22:33 +02:00
parent 72c40f531f
commit d5c586f46f
+1 -1
View File
@@ -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));
}