History

MErging with origin/orange, brinign the fix for shadows

Sam Gateau committed 11 years ago

Commit 00817ab2 parents 3f581d0 17743c672 files · +1895 −1767Browse files

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

Unified · Split

interface/src/Application.cpp+58−19
@@ -164,6 +164,8 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 163 unmodified lines
164 164
165const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";165const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
166 166
167bool renderCollisionHulls = false;
168
167#ifdef Q_OS_WIN169#ifdef Q_OS_WIN
168class MyNativeEventFilter : public QAbstractNativeEventFilter {170class MyNativeEventFilter : public QAbstractNativeEventFilter {
169public:171public:
@@ -256,7 +258,8 @@ bool setupEssentials(int& argc, char** argv) { · 86 unmodified lines
256 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();258 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
257#endif259#endif
258 auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>();260 auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>();
259 261 auto sceneScriptingInterface = DependencyManager::set<SceneScriptingInterface>();
262
260 return true;263 return true;
261}264}
262 265
@@ -265,6 +268,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 2 unmodified lines
265 _dependencyManagerIsSetup(setupEssentials(argc, argv)),268 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
266 _window(new MainWindow(desktop())),269 _window(new MainWindow(desktop())),
267 _toolWindow(NULL),270 _toolWindow(NULL),
271 _friendsWindow(NULL),
268 _datagramProcessor(),272 _datagramProcessor(),
269 _undoStack(),273 _undoStack(),
270 _undoStackScriptingInterface(&_undoStack),274 _undoStackScriptingInterface(&_undoStack),
@@ -566,6 +570,9 @@ void Application::aboutToQuit() { · 295 unmodified lines
566}570}
567 571
568void Application::cleanupBeforeQuit() {572void Application::cleanupBeforeQuit() {
573
574 _entities.clear(); // this will allow entity scripts to properly shutdown
575
569 _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit576 _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
570 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts577 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
571 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts578 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
@@ -773,10 +780,6 @@ void Application::paintGL() { · 201 unmodified lines
773 }780 }
774 781
775 if (OculusManager::isConnected()) {782 if (OculusManager::isConnected()) {
776 //Clear the color buffer to ensure that there isnt any residual color
777 //Left over from when OR was not connected.
778 glClear(GL_COLOR_BUFFER_BIT);
779
780 //When in mirror mode, use camera rotation. Otherwise, use body rotation783 //When in mirror mode, use camera rotation. Otherwise, use body rotation
781 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {784 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
782 OculusManager::display(_myCamera.getRotation(), _myCamera.getPosition(), _myCamera);785 OculusManager::display(_myCamera.getRotation(), _myCamera.getPosition(), _myCamera);
@@ -970,9 +973,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 187 unmodified lines
970 973
971 case Qt::Key_E:974 case Qt::Key_E:
972 case Qt::Key_PageUp:975 case Qt::Key_PageUp:
973 if (!_myAvatar->getDriveKeys(UP)) {
974 _myAvatar->jump();
975 }
976 _myAvatar->setDriveKeys(UP, 1.0f);976 _myAvatar->setDriveKeys(UP, 1.0f);
977 break;977 break;
978 978
@@ -1181,6 +1181,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 202 unmodified lines
1181 break;1181 break;
1182 }1182 }
1183 1183
1184 case Qt::Key_Comma: {
1185 renderCollisionHulls = !renderCollisionHulls;
1186 }
1187
1184 default:1188 default:
1185 event->ignore();1189 event->ignore();
1186 break;1190 break;
@@ -2207,6 +2211,7 @@ void Application::update(float deltaTime) { · 1020 unmodified lines
2207 2211
2208 {2212 {
2209 PerformanceTimer perfTimer("physics");2213 PerformanceTimer perfTimer("physics");
2214 _myAvatar->relayDriveKeysToCharacterController();
2210 _physicsEngine.stepSimulation();2215 _physicsEngine.stepSimulation();
2211 }2216 }
2212 2217
@@ -2259,7 +2264,7 @@ void Application::update(float deltaTime) { · 46 unmodified lines
2259 if (queryIsDue || viewIsDifferentEnough) {2264 if (queryIsDue || viewIsDifferentEnough) {
2260 _lastQueriedTime = now;2265 _lastQueriedTime = now;
2261 2266
2262 if (Menu::getInstance()->isOptionChecked(MenuOption::Entities)) {2267 if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
2263 queryOctree(NodeType::EntityServer, PacketTypeEntityQuery, _entityServerJurisdictions);2268 queryOctree(NodeType::EntityServer, PacketTypeEntityQuery, _entityServerJurisdictions);
2264 }2269 }
2265 _lastQueriedViewFrustum = _viewFrustum;2270 _lastQueriedViewFrustum = _viewFrustum;
@@ -2611,7 +2616,12 @@ glm::vec3 Application::getSunDirection() { · 345 unmodified lines
2611 return skyStage->getSunLight()->getDirection();2616 return skyStage->getSunLight()->getDirection();
2612}2617}
2613 2618
2619// FIXME, preprocessor guard this check to occur only in DEBUG builds
2620static QThread * activeRenderingThread = nullptr;
2621
2614void Application::updateShadowMap() {2622void Application::updateShadowMap() {
2623 activeRenderingThread = QThread::currentThread();
2624
2615 PerformanceTimer perfTimer("shadowMap");2625 PerformanceTimer perfTimer("shadowMap");
2616 QOpenGLFramebufferObject* fbo = DependencyManager::get<TextureCache>()->getShadowFramebufferObject();2626 QOpenGLFramebufferObject* fbo = DependencyManager::get<TextureCache>()->getShadowFramebufferObject();
2617 fbo->bind();2627 fbo->bind();
@@ -2706,6 +2716,10 @@ void Application::updateShadowMap() { · 88 unmodified lines
2706 glLoadIdentity();2716 glLoadIdentity();
2707 glOrtho(minima.x, maxima.x, minima.y, maxima.y, -maxima.z, -minima.z);2717 glOrtho(minima.x, maxima.x, minima.y, maxima.y, -maxima.z, -minima.z);
2708 2718
2719 glm::mat4 projAgain;
2720 glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat*)&projAgain);
2721
2722
2709 glMatrixMode(GL_MODELVIEW);2723 glMatrixMode(GL_MODELVIEW);
2710 glPushMatrix();2724 glPushMatrix();
2711 glLoadIdentity();2725 glLoadIdentity();
@@ -2761,11 +2775,12 @@ void Application::updateShadowMap() { · 49 unmodified lines
2761 fbo->release();2775 fbo->release();
2762 2776
2763 glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());2777 glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
2778 activeRenderingThread = nullptr;
2764}2779}
2765 2780
2766const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };2781const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
2767const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };2782const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
2768const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };2783const GLfloat WORLD_SPECULAR_COLOR[] = { 0.08f, 0.08f, 0.08f, 1.0f };
2769 2784
2770const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };2785const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
2771 2786
@@ -2821,9 +2836,6 @@ QImage Application::renderAvatarBillboard() { · 49 unmodified lines
2821 return image;2836 return image;
2822}2837}
2823 2838
2824// FIXME, preprocessor guard this check to occur only in DEBUG builds
2825static QThread * activeRenderingThread = nullptr;
2826
2827ViewFrustum* Application::getViewFrustum() {2839ViewFrustum* Application::getViewFrustum() {
2828#ifdef DEBUG2840#ifdef DEBUG
2829 if (QThread::currentThread() == activeRenderingThread) {2841 if (QThread::currentThread() == activeRenderingThread) {
@@ -2972,11 +2984,15 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 142 unmodified lines
2972 DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));2984 DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
2973 2985
2974 // render models...2986 // render models...
2975 if (Menu::getInstance()->isOptionChecked(MenuOption::Entities)) {2987 if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
2976 PerformanceTimer perfTimer("entities");2988 PerformanceTimer perfTimer("entities");
2977 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),2989 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2978 "Application::displaySide() ... entities...");2990 "Application::displaySide() ... entities...");
2979 _entities.render(RenderArgs::DEFAULT_RENDER_MODE, renderSide);2991 if (renderCollisionHulls) {
2992 _entities.render(RenderArgs::DEBUG_RENDER_MODE, renderSide);
2993 } else {
2994 _entities.render(RenderArgs::DEFAULT_RENDER_MODE, renderSide);
2995 }
2980 }2996 }
2981 2997
2982 // render JS/scriptable overlays2998 // render JS/scriptable overlays
@@ -2993,17 +3009,15 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 10 unmodified lines
2993 DependencyManager::get<AmbientOcclusionEffect>()->render();3009 DependencyManager::get<AmbientOcclusionEffect>()->render();
2994 }3010 }
2995 }3011 }
2996 3012
2997
2998
2999 bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR);3013 bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR);
3014
3000 {3015 {
3001 PerformanceTimer perfTimer("avatars");3016 PerformanceTimer perfTimer("avatars");
3002 DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? RenderArgs::MIRROR_RENDER_MODE : RenderArgs::NORMAL_RENDER_MODE,3017 DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? RenderArgs::MIRROR_RENDER_MODE : RenderArgs::NORMAL_RENDER_MODE,
3003 false, selfAvatarOnly); 3018 false, selfAvatarOnly);
3004 }3019 }
3005 3020
3006
3007 {3021 {
3008 DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());3022 DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());
3009 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();3023 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
@@ -3586,6 +3600,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 576 unmodified lines
3586 scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition2D", HMDScriptingInterface::getHUDLookAtPosition2D, 0);3600 scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition2D", HMDScriptingInterface::getHUDLookAtPosition2D, 0);
3587 scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0);3601 scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0);
3588 3602
3603 scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data());
3604
3589#ifdef HAVE_RTMIDI3605#ifdef HAVE_RTMIDI
3590 scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());3606 scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
3591#endif3607#endif
@@ -3737,22 +3753,27 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 145 unmodified lines
3737 _myAvatar->setFaceModelURL(url);3753 _myAvatar->setFaceModelURL(url);
3738 UserActivityLogger::getInstance().changedModel("head", url);3754 UserActivityLogger::getInstance().changedModel("head", url);
3739 _myAvatar->sendIdentityPacket();3755 _myAvatar->sendIdentityPacket();
3756 emit faceURLChanged(url);
3740 } else if (msgBox.clickedButton() == bodyButton) {3757 } else if (msgBox.clickedButton() == bodyButton) {
3741 qDebug() << "Chose to use for body: " << url;3758 qDebug() << "Chose to use for body: " << url;
3742 _myAvatar->setSkeletonModelURL(url);3759 _myAvatar->setSkeletonModelURL(url);
3743 // if the head is empty, reset it to the default head.3760 // if the head is empty, reset it to the default head.
3744 if (_myAvatar->getFaceModelURLString().isEmpty()) {3761 if (_myAvatar->getFaceModelURLString().isEmpty()) {
3745 _myAvatar->setFaceModelURL(DEFAULT_HEAD_MODEL_URL);3762 _myAvatar->setFaceModelURL(DEFAULT_HEAD_MODEL_URL);
3763 emit faceURLChanged(DEFAULT_HEAD_MODEL_URL.toString());
3746 UserActivityLogger::getInstance().changedModel("head", DEFAULT_HEAD_MODEL_URL.toString());3764 UserActivityLogger::getInstance().changedModel("head", DEFAULT_HEAD_MODEL_URL.toString());
3747 }3765 }
3748 UserActivityLogger::getInstance().changedModel("skeleton", url);3766 UserActivityLogger::getInstance().changedModel("skeleton", url);
3749 _myAvatar->sendIdentityPacket();3767 _myAvatar->sendIdentityPacket();
3768 emit skeletonURLChanged(url);
3750 } else if (msgBox.clickedButton() == bodyAndHeadButton) {3769 } else if (msgBox.clickedButton() == bodyAndHeadButton) {
3751 qDebug() << "Chose to use for body + head: " << url;3770 qDebug() << "Chose to use for body + head: " << url;
3752 _myAvatar->setFaceModelURL(QString());3771 _myAvatar->setFaceModelURL(QString());
3753 _myAvatar->setSkeletonModelURL(url);3772 _myAvatar->setSkeletonModelURL(url);
3754 UserActivityLogger::getInstance().changedModel("skeleton", url);3773 UserActivityLogger::getInstance().changedModel("skeleton", url);
3755 _myAvatar->sendIdentityPacket();3774 _myAvatar->sendIdentityPacket();
3775 emit faceURLChanged(QString());
3776 emit skeletonURLChanged(url);
3756 } else {3777 } else {
3757 qDebug() << "Declined to use the avatar: " << url;3778 qDebug() << "Declined to use the avatar: " << url;
3758 }3779 }
@@ -4274,3 +4295,21 @@ void Application::checkSkeleton() { · 515 unmodified lines
4274 _physicsEngine.setCharacterController(_myAvatar->getCharacterController());4295 _physicsEngine.setCharacterController(_myAvatar->getCharacterController());
4275 }4296 }
4276}4297}
4298
4299void Application::showFriendsWindow() {
4300 const QString FRIENDS_WINDOW_TITLE = "Add/Remove Friends";
4301 const QString FRIENDS_WINDOW_URL = "https://metaverse.highfidelity.com/user/friends";
4302 const int FRIENDS_WINDOW_WIDTH = 290;
4303 const int FRIENDS_WINDOW_HEIGHT = 500;
4304 if (!_friendsWindow) {
4305 _friendsWindow = new WebWindowClass(FRIENDS_WINDOW_TITLE, FRIENDS_WINDOW_URL, FRIENDS_WINDOW_WIDTH,
4306 FRIENDS_WINDOW_HEIGHT, false);
4307 connect(_friendsWindow, &WebWindowClass::closed, this, &Application::friendsWindowClosed);
4308 }
4309 _friendsWindow->setVisible(true);
4310}
4311
4312void Application::friendsWindowClosed() {
4313 delete _friendsWindow;
4314 _friendsWindow = NULL;
4315}