mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
Merge pull request #13269 from wayne-chen/BillboardableWarning-case-14709
Billboardable::pointTransformAtCamera div by zero asan warning
This commit is contained in:
commit
aa630e02cf
1 changed files with 10 additions and 6 deletions
|
@ -41,12 +41,16 @@ bool Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offse
|
||||||
glm::vec3 cameraPos = qApp->getCamera().getPosition();
|
glm::vec3 cameraPos = qApp->getCamera().getPosition();
|
||||||
// use the referencial from the avatar, y isn't always up
|
// use the referencial from the avatar, y isn't always up
|
||||||
glm::vec3 avatarUP = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldOrientation()*Vectors::UP;
|
glm::vec3 avatarUP = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldOrientation()*Vectors::UP;
|
||||||
|
// check to see if glm::lookAt will work / using glm::lookAt variable name
|
||||||
glm::quat rotation(conjugate(toQuat(glm::lookAt(cameraPos, billboardPos, avatarUP))));
|
glm::highp_vec3 s(glm::cross(billboardPos - cameraPos, avatarUP));
|
||||||
|
|
||||||
transform.setRotation(rotation);
|
// make sure s is not NaN for any component
|
||||||
transform.postRotate(offsetRotation);
|
if(glm::length2(s) > 0.0f) {
|
||||||
return true;
|
glm::quat rotation(conjugate(toQuat(glm::lookAt(cameraPos, billboardPos, avatarUP))));
|
||||||
|
transform.setRotation(rotation);
|
||||||
|
transform.postRotate(offsetRotation);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue