Showing the changes to interface/src/Application.cpp (1 of 52 files). Show all
Unified · Split
| @@ -524,10 +524,22 @@ void Application::paintGL() { · 523 unmodified lines | |||
| 524 | 524 | ||
| 525 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 525 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 526 | _myCamera.setTightness(0.0f); | 526 | _myCamera.setTightness(0.0f); |
| 527 | float headHeight = _myAvatar->getHead()->calculateAverageEyePosition().y - _myAvatar->getPosition().y; | 527 | glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition(); |
| 528 | float headHeight = eyePosition.y - _myAvatar->getPosition().y; | ||
| 528 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); | 529 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); |
| 529 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); | 530 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); |
| 530 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); | 531 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); |
| 532 | |||
| 533 | // if the head would intersect the near clip plane, we must push the camera out | ||
| 534 | glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * | ||
| 535 | (eyePosition - _myCamera.getTargetPosition()); | ||
| 536 | const float PUSHBACK_RADIUS = 0.2f; | ||
| 537 | float pushback = relativePosition.z + _myCamera.getNearClip() + | ||
| 538 | _myAvatar->getScale() * PUSHBACK_RADIUS - _myCamera.getDistance(); | ||
| 539 | if (pushback > 0.0f) { | ||
| 540 | _myCamera.setTargetPosition(_myCamera.getTargetPosition() + | ||
| 541 | _myCamera.getTargetRotation() * glm::vec3(0.0f, 0.0f, pushback)); | ||
| 542 | } | ||
| 531 | } | 543 | } |
| 532 | 544 | ||
| 533 | // Update camera position | 545 | // Update camera position |
| @@ -2232,8 +2244,7 @@ void Application::updateShadowMap() { · 1698 unmodified lines | |||
| 2232 | glRotatef(glm::degrees(glm::angle(inverseRotation)), axis.x, axis.y, axis.z); | 2244 | glRotatef(glm::degrees(glm::angle(inverseRotation)), axis.x, axis.y, axis.z); |
| 2233 | 2245 | ||
| 2234 | // store view matrix without translation, which we'll use for precision-sensitive objects | 2246 | // store view matrix without translation, which we'll use for precision-sensitive objects |
| 2235 | glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix); | 2247 | updateUntranslatedViewMatrix(); |
| 2236 | _viewMatrixTranslation = glm::vec3(); | ||
| 2237 | 2248 | ||
| 2238 | _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE); | 2249 | _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE); |
| 2239 | _particles.render(); | 2250 | _particles.render(); |
| @@ -2318,8 +2329,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 78 unmodified lines | |||
| 2318 | glRotatef(-glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); | 2329 | glRotatef(-glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); |
| 2319 | 2330 | ||
| 2320 | // store view matrix without translation, which we'll use for precision-sensitive objects | 2331 | // store view matrix without translation, which we'll use for precision-sensitive objects |
| 2321 | glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix); | 2332 | updateUntranslatedViewMatrix(-whichCamera.getPosition()); |
| 2322 | _viewMatrixTranslation = -whichCamera.getPosition(); | ||
| 2323 | 2333 | ||
| 2324 | glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z); | 2334 | glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z); |
| 2325 | 2335 | ||
| @@ -2450,6 +2460,11 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 124 unmodified lines | |||
| 2450 | } | 2460 | } |
| 2451 | } | 2461 | } |
| 2452 | 2462 | ||
| 2463 | void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) { | ||
| 2464 | glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix); | ||
| 2465 | _viewMatrixTranslation = viewMatrixTranslation; | ||
| 2466 | } | ||
| 2467 | |||
| 2453 | void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { | 2468 | void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { |
| 2454 | glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix); | 2469 | glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix); |
| 2455 | glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y, | 2470 | glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y, |
| @@ -3248,9 +3263,12 @@ void Application::toggleRunningScriptsWidget() · 792 unmodified lines | |||
| 3248 | 3263 | ||
| 3249 | void Application::uploadFST(bool isHead) { | 3264 | void Application::uploadFST(bool isHead) { |
| 3250 | ModelUploader* uploader = new ModelUploader(isHead); | 3265 | ModelUploader* uploader = new ModelUploader(isHead); |
| 3251 | if (uploader->zip()) { | 3266 | QThread* thread = new QThread(); |
| 3252 | uploader->send(); | 3267 | thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit())); |
| 3253 | } | 3268 | thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater())); |
| 3269 | uploader->connect(thread, SIGNAL(started()), SLOT(send())); | ||
| 3270 | |||
| 3271 | thread->start(); | ||
| 3254 | } | 3272 | } |
| 3255 | 3273 | ||
| 3256 | void Application::uploadHead() { | 3274 | void Application::uploadHead() { |
| @@ -3277,6 +3295,7 @@ void Application::loadScript(const QString& scriptName) { · 20 unmodified lines | |||
| 3277 | // we can use the same ones from the application. | 3295 | // we can use the same ones from the application. |
| 3278 | scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender); | 3296 | scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender); |
| 3279 | scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree()); | 3297 | scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree()); |
| 3298 | scriptEngine->getVoxelsScriptingInterface()->setUndoStack(&_undoStack); | ||
| 3280 | scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); | 3299 | scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); |
| 3281 | scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); | 3300 | scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); |
| 3282 | 3301 | ||