Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -528,6 +528,16 @@ void Application::paintGL() { · 527 unmodified lines | ||
| 528 | 528 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); |
| 529 | 529 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); |
| 530 | 530 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); |
| 531 | + | |
| 532 | + // if the head would intersect the near clip plane, we must push the camera out | |
| 533 | + glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * | |
| 534 | + (_myAvatar->getHead()->getPosition() - _myCamera.getTargetPosition()); | |
| 535 | + const float HEAD_RADIUS = 0.1f; | |
| 536 | + float pushback = relativePosition.z + _myCamera.getNearClip() + HEAD_RADIUS; | |
| 537 | + if (pushback > 0.0f) { | |
| 538 | + _myCamera.setTargetPosition(_myCamera.getTargetPosition() + | |
| 539 | + _myCamera.getTargetRotation() * glm::vec3(0.0f, 0.0f, pushback)); | |
| 540 | + } | |
| 531 | 541 | } |
| 532 | 542 | |
| 533 | 543 | // Update camera position |