History

Merge branch 'master' into offscreen

Brad Davis committed 11 years ago

Commit ce6b7e72 parents 36ca913 d72bb7156 files · +2394 −907Browse files

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

Unified · Split

interface/src/Application.cpp+27−50
@@ -35,7 +35,6 @@ · 34 unmodified lines
35#include <QMouseEvent>35#include <QMouseEvent>
36#include <QNetworkReply>36#include <QNetworkReply>
37#include <QNetworkDiskCache>37#include <QNetworkDiskCache>
38#include <QOpenGLFramebufferObject>
39#include <QObject>38#include <QObject>
40#include <QWheelEvent>39#include <QWheelEvent>
41#include <QScreen>40#include <QScreen>
@@ -841,7 +840,7 @@ void Application::paintGL() { · 799 unmodified lines
841 DependencyManager::get<GlowEffect>()->prepare();840 DependencyManager::get<GlowEffect>()->prepare();
842 841
843 // Viewport is assigned to the size of the framebuffer842 // Viewport is assigned to the size of the framebuffer
844 QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();843 QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize();
845 glViewport(0, 0, size.width(), size.height());844 glViewport(0, 0, size.width(), size.height());
846 845
847 glMatrixMode(GL_MODELVIEW);846 glMatrixMode(GL_MODELVIEW);
@@ -2731,8 +2730,9 @@ void Application::updateShadowMap() { · 1883 unmodified lines
2731 activeRenderingThread = QThread::currentThread();2730 activeRenderingThread = QThread::currentThread();
2732 2731
2733 PerformanceTimer perfTimer("shadowMap");2732 PerformanceTimer perfTimer("shadowMap");
2734 QOpenGLFramebufferObject* fbo = DependencyManager::get<TextureCache>()->getShadowFramebufferObject();2733 auto shadowFramebuffer = DependencyManager::get<TextureCache>()->getShadowFramebuffer();
2735 fbo->bind();2734 glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(shadowFramebuffer));
2735
2736 glEnable(GL_DEPTH_TEST);2736 glEnable(GL_DEPTH_TEST);
2737 glClear(GL_DEPTH_BUFFER_BIT);2737 glClear(GL_DEPTH_BUFFER_BIT);
2738 2738
@@ -2748,16 +2748,18 @@ void Application::updateShadowMap() { · 9 unmodified lines
2748 loadViewFrustum(_myCamera, _viewFrustum);2748 loadViewFrustum(_myCamera, _viewFrustum);
2749 2749
2750 int matrixCount = 1;2750 int matrixCount = 1;
2751 int targetSize = fbo->width();2751 //int targetSize = fbo->width();
2752 int sourceSize = shadowFramebuffer->getWidth();
2753 int targetSize = shadowFramebuffer->getWidth();
2752 float targetScale = 1.0f;2754 float targetScale = 1.0f;
2753 if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {2755 if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {
2754 matrixCount = CASCADED_SHADOW_MATRIX_COUNT;2756 matrixCount = CASCADED_SHADOW_MATRIX_COUNT;
2755 targetSize = fbo->width() / 2;2757 targetSize = sourceSize / 2;
2756 targetScale = 0.5f;2758 targetScale = 0.5f;
2757 }2759 }
2758 for (int i = 0; i < matrixCount; i++) {2760 for (int i = 0; i < matrixCount; i++) {
2759 const glm::vec2& coord = MAP_COORDS[i];2761 const glm::vec2& coord = MAP_COORDS[i];
2760 glViewport(coord.s * fbo->width(), coord.t * fbo->height(), targetSize, targetSize);2762 glViewport(coord.s * sourceSize, coord.t * sourceSize, targetSize, targetSize);
2761 2763
2762 // if simple shadow then since the resolution is twice as much as with cascaded, cover 2 regions with the map, not just one2764 // if simple shadow then since the resolution is twice as much as with cascaded, cover 2 regions with the map, not just one
2763 int regionIncrement = (matrixCount == 1 ? 2 : 1);2765 int regionIncrement = (matrixCount == 1 ? 2 : 1);
@@ -2880,7 +2882,7 @@ void Application::updateShadowMap() { · 116 unmodified lines
2880 glMatrixMode(GL_MODELVIEW);2882 glMatrixMode(GL_MODELVIEW);
2881 }2883 }
2882 2884
2883 fbo->release();2885 // fbo->release();
2884 2886
2885 glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());2887 glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
2886 activeRenderingThread = nullptr;2888 activeRenderingThread = nullptr;
@@ -2926,7 +2928,8 @@ PickRay Application::computePickRay(float x, float y) { · 39 unmodified lines
2926}2928}
2927 2929
2928QImage Application::renderAvatarBillboard() {2930QImage Application::renderAvatarBillboard() {
2929 DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();2931 auto primaryFramebuffer = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
2932 glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFramebuffer));
2930 2933
2931 // the "glow" here causes an alpha of one2934 // the "glow" here causes an alpha of one
2932 Glower glower;2935 Glower glower;
@@ -2939,7 +2942,7 @@ QImage Application::renderAvatarBillboard() { · 6 unmodified lines
2939 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);2942 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
2940 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());2943 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
2941 2944
2942 DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();2945 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2943 2946
2944 return image;2947 return image;
2945}2948}
@@ -3808,17 +3811,7 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 862 unmodified lines
3808 }3811 }
3809 3812
3810 // Download the FST file, to attempt to determine its model type3813 // Download the FST file, to attempt to determine its model type
3811 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();3814 QVariantHash fstMapping = FSTReader::downloadMapping(url);
3812 QNetworkRequest networkRequest = QNetworkRequest(url);
3813 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
3814 QNetworkReply* reply = networkAccessManager.get(networkRequest);
3815 qCDebug(interfaceapp) << "Downloading avatar file at " << url;
3816 QEventLoop loop;
3817 QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
3818 loop.exec();
3819 QByteArray fstContents = reply->readAll();
3820 delete reply;
3821 QVariantHash fstMapping = FSTReader::readMapping(fstContents);
3822 3815
3823 FSTReader::ModelType modelType = FSTReader::predictModelType(fstMapping);3816 FSTReader::ModelType modelType = FSTReader::predictModelType(fstMapping);
3824 3817
@@ -3829,26 +3822,27 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 4 unmodified lines
3829 QPushButton* bodyButton = NULL;3822 QPushButton* bodyButton = NULL;
3830 QPushButton* bodyAndHeadButton = NULL;3823 QPushButton* bodyAndHeadButton = NULL;
3831 3824
3825 QString modelName = fstMapping["name"].toString();
3832 QString message;3826 QString message;
3833 QString typeInfo;3827 QString typeInfo;
3834 switch (modelType) {3828 switch (modelType) {
3835 case FSTReader::HEAD_MODEL:3829 case FSTReader::HEAD_MODEL:
3836 message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for your avatar head?");3830 message = QString("Would you like to use '") + modelName + QString("' for your avatar head?");
3837 headButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);3831 headButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);
3838 break;3832 break;
3839 3833
3840 case FSTReader::BODY_ONLY_MODEL:3834 case FSTReader::BODY_ONLY_MODEL:
3841 message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for your avatar body?");3835 message = QString("Would you like to use '") + modelName + QString("' for your avatar body?");
3842 bodyButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);3836 bodyButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);
3843 break;3837 break;
3844 3838
3845 case FSTReader::HEAD_AND_BODY_MODEL:3839 case FSTReader::HEAD_AND_BODY_MODEL:
3846 message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for your avatar?");3840 message = QString("Would you like to use '") + modelName + QString("' for your avatar?");
3847 bodyAndHeadButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);3841 bodyAndHeadButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);
3848 break;3842 break;
3849 3843
3850 default:3844 default:
3851 message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for some part of your avatar head?");3845 message = QString("Would you like to use '") + modelName + QString("' for some part of your avatar head?");
3852 headButton = msgBox.addButton(tr("Use for Head"), QMessageBox::ActionRole);3846 headButton = msgBox.addButton(tr("Use for Head"), QMessageBox::ActionRole);
3853 bodyButton = msgBox.addButton(tr("Use for Body"), QMessageBox::ActionRole);3847 bodyButton = msgBox.addButton(tr("Use for Body"), QMessageBox::ActionRole);
3854 bodyAndHeadButton = msgBox.addButton(tr("Use for Body and Head"), QMessageBox::ActionRole);3848 bodyAndHeadButton = msgBox.addButton(tr("Use for Body and Head"), QMessageBox::ActionRole);
@@ -3861,34 +3855,18 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 6 unmodified lines
3861 msgBox.exec();3855 msgBox.exec();
3862 3856
3863 if (msgBox.clickedButton() == headButton) {3857 if (msgBox.clickedButton() == headButton) {
3864 qCDebug(interfaceapp) << "Chose to use for head: " << url;3858 _myAvatar->useHeadURL(url, modelName);
3865 _myAvatar->setFaceModelURL(url);3859 emit headURLChanged(url, modelName);
3866 UserActivityLogger::getInstance().changedModel("head", url);
3867 _myAvatar->sendIdentityPacket();
3868 emit faceURLChanged(url);
3869 } else if (msgBox.clickedButton() == bodyButton) {3860 } else if (msgBox.clickedButton() == bodyButton) {
3870 qCDebug(interfaceapp) << "Chose to use for body: " << url;3861 _myAvatar->useBodyURL(url, modelName);
3871 _myAvatar->setSkeletonModelURL(url);3862 emit bodyURLChanged(url, modelName);
3872 // if the head is empty, reset it to the default head.
3873 if (_myAvatar->getFaceModelURLString().isEmpty()) {
3874 _myAvatar->setFaceModelURL(DEFAULT_HEAD_MODEL_URL);
3875 emit faceURLChanged(DEFAULT_HEAD_MODEL_URL.toString());
3876 UserActivityLogger::getInstance().changedModel("head", DEFAULT_HEAD_MODEL_URL.toString());
3877 }
3878 UserActivityLogger::getInstance().changedModel("skeleton", url);
3879 _myAvatar->sendIdentityPacket();
3880 emit skeletonURLChanged(url);
3881 } else if (msgBox.clickedButton() == bodyAndHeadButton) {3863 } else if (msgBox.clickedButton() == bodyAndHeadButton) {
3882 qCDebug(interfaceapp) << "Chose to use for body + head: " << url;3864 _myAvatar->useFullAvatarURL(url, modelName);
3883 _myAvatar->setFaceModelURL(QString());3865 emit fullAvatarURLChanged(url, modelName);
3884 _myAvatar->setSkeletonModelURL(url);
3885 UserActivityLogger::getInstance().changedModel("skeleton", url);
3886 _myAvatar->sendIdentityPacket();
3887 emit faceURLChanged(QString());
3888 emit skeletonURLChanged(url);
3889 } else {3866 } else {
3890 qCDebug(interfaceapp) << "Declined to use the avatar: " << url;3867 qCDebug(interfaceapp) << "Declined to use the avatar: " << url;
3891 }3868 }
3869
3892 return true;3870 return true;
3893}3871}
3894 3872
@@ -4400,8 +4378,7 @@ void Application::checkSkeleton() { · 505 unmodified lines
4400 msgBox.setIcon(QMessageBox::Warning);4378 msgBox.setIcon(QMessageBox::Warning);
4401 msgBox.exec();4379 msgBox.exec();
4402 4380
4403 _myAvatar->setSkeletonModelURL(DEFAULT_BODY_MODEL_URL);4381 _myAvatar->useBodyURL(DEFAULT_BODY_MODEL_URL, "Default");
4404 _myAvatar->sendIdentityPacket();
4405 } else {4382 } else {
4406 _myAvatar->updateCharacterController();4383 _myAvatar->updateCharacterController();
4407 _physicsEngine.setCharacterController(_myAvatar->getCharacterController());4384 _physicsEngine.setCharacterController(_myAvatar->getCharacterController());

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