mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
proper corner case check for Quat::lookAtSimple()
This commit is contained in:
parent
cd5826e2ce
commit
b7c6922545
1 changed files with 10 additions and 9 deletions
|
@ -37,7 +37,8 @@ glm::quat Quat::lookAt(const glm::vec3& eye, const glm::vec3& center, const glm:
|
||||||
glm::quat Quat::lookAtSimple(const glm::vec3& eye, const glm::vec3& center) {
|
glm::quat Quat::lookAtSimple(const glm::vec3& eye, const glm::vec3& center) {
|
||||||
auto dir = glm::normalize(center - eye);
|
auto dir = glm::normalize(center - eye);
|
||||||
// if the direction is nearly aligned with the Y axis, then use the X axis for 'up'
|
// if the direction is nearly aligned with the Y axis, then use the X axis for 'up'
|
||||||
if (dir.x < 0.001f && dir.z < 0.001f) {
|
const float MAX_ABS_Y_COMPONENT = 0.9999991f;
|
||||||
|
if (fabsf(dir.y) > MAX_ABS_Y_COMPONENT) {
|
||||||
return lookAt(eye, center, Vectors::UNIT_X);
|
return lookAt(eye, center, Vectors::UNIT_X);
|
||||||
}
|
}
|
||||||
return lookAt(eye, center, Vectors::UNIT_Y);
|
return lookAt(eye, center, Vectors::UNIT_Y);
|
||||||
|
|
Loading…
Reference in a new issue