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