History

Made mirror view remain constant no matter what the avatar scale is set to.

barnold1953 committed 12 years ago

Commit 97c0a2f1 parent 21f03a41 file · +2 −32Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+2−32
@@ -553,9 +553,6 @@ void Application::paintGL() { · 552 unmodified lines
553 PerformanceWarning warn(showWarnings, "Application::paintGL()");553 PerformanceWarning warn(showWarnings, "Application::paintGL()");
554 554
555 glEnable(GL_LINE_SMOOTH);555 glEnable(GL_LINE_SMOOTH);
556
557 float pushback = 0.0f;
558 float pushbackFocalLength = 0.0f;
559 556
560 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {557 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
561 _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay558 _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
@@ -571,52 +568,25 @@ void Application::paintGL() { · 9 unmodified lines
571 _myCamera.setTightness(0.0f);568 _myCamera.setTightness(0.0f);
572 glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition();569 glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition();
573 float headHeight = eyePosition.y - _myAvatar->getPosition().y;570 float headHeight = eyePosition.y - _myAvatar->getPosition().y;
574 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale() * _scaleMirror);571 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
575 _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0));572 _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0));
576 _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));573 _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
577
578 // if the head would intersect the near clip plane, we must push the camera out
579 glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *
580 (eyePosition - _myCamera.getTargetPosition());
581 const float BASE_PUSHBACK_RADIUS = 0.2f;
582 float pushbackRadius = _myCamera.getNearClip() + _myAvatar->getScale() * BASE_PUSHBACK_RADIUS;
583 pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance();
584 pushbackFocalLength = _myCamera.getDistance();
585 }574 }
586 575
587 if (OculusManager::isConnected()) {576 if (OculusManager::isConnected()) {
588 // OR in third person causes nausea, so only allow it if option is checked in dev menu577 // Oculus in third person causes nausea, so only allow it if option is checked in dev menu
589 if (!Menu::getInstance()->isOptionChecked(MenuOption::AllowOculusCameraModeChange) || _myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {578 if (!Menu::getInstance()->isOptionChecked(MenuOption::AllowOculusCameraModeChange) || _myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
590 _myCamera.setDistance(0.0f);579 _myCamera.setDistance(0.0f);
591 _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());580 _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
592 _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());581 _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
593 pushback = 0.0f;
594 pushbackFocalLength = 0.0f;
595 }582 }
596 _myCamera.setUpShift(0.0f);583 _myCamera.setUpShift(0.0f);
597 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing584 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
598 }585 }
599
600 // handle pushback, if any
601 if (pushbackFocalLength > 0.0f) {
602 const float PUSHBACK_DECAY = 0.5f;
603 _cameraPushback = qMax(pushback, _cameraPushback * PUSHBACK_DECAY);
604 if (_cameraPushback > EPSILON) {
605 _myCamera.setTargetPosition(_myCamera.getTargetPosition() +
606 _myCamera.getTargetRotation() * glm::vec3(0.0f, 0.0f, _cameraPushback));
607 float enlargement = pushbackFocalLength / (pushbackFocalLength + _cameraPushback);
608 _myCamera.setFieldOfView(glm::degrees(2.0f * atanf(enlargement * tanf(
609 glm::radians(Menu::getInstance()->getFieldOfView() * 0.5f)))));
610 } else {
611 _myCamera.setFieldOfView(Menu::getInstance()->getFieldOfView());
612 }
613 updateProjectionMatrix(_myCamera, true);
614 }
615 586
616 // Update camera position587 // Update camera position
617 _myCamera.update( 1.f/_fps );588 _myCamera.update( 1.f/_fps );
618 589
619
620 // Note: whichCamera is used to pick between the normal camera myCamera for our590 // Note: whichCamera is used to pick between the normal camera myCamera for our
621 // main camera, vs, an alternate camera. The alternate camera we support right now591 // main camera, vs, an alternate camera. The alternate camera we support right now
622 // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism592 // is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t