mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Working on pushing the mirror camera back to prevent intersecting the near
clip plane. Closes #2617.
This commit is contained in:
parent
8e097be28d
commit
5776514e6a
1 changed files with 10 additions and 0 deletions
|
@ -528,6 +528,16 @@ void Application::paintGL() {
|
|||
_myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale());
|
||||
_myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0));
|
||||
_myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
|
||||
|
||||
// if the head would intersect the near clip plane, we must push the camera out
|
||||
glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *
|
||||
(_myAvatar->getHead()->getPosition() - _myCamera.getTargetPosition());
|
||||
const float HEAD_RADIUS = 0.1f;
|
||||
float pushback = relativePosition.z + _myCamera.getNearClip() + HEAD_RADIUS;
|
||||
if (pushback > 0.0f) {
|
||||
_myCamera.setTargetPosition(_myCamera.getTargetPosition() +
|
||||
_myCamera.getTargetRotation() * glm::vec3(0.0f, 0.0f, pushback));
|
||||
}
|
||||
}
|
||||
|
||||
// Update camera position
|
||||
|
|
Loading…
Reference in a new issue