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
164164
165165 const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
166166
167+bool renderCollisionHulls = false;
168+
167169 #ifdef Q_OS_WIN
168170 class MyNativeEventFilter : public QAbstractNativeEventFilter {
169171 public:
@@ -256,7 +258,8 @@ bool setupEssentials(int& argc, char** argv) { · 86 unmodified lines
256258 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
257259 #endif
258260 auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>();
259−
261+ auto sceneScriptingInterface = DependencyManager::set<SceneScriptingInterface>();
262+
260263 return true;
261264 }
262265
@@ -265,6 +268,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 2 unmodified lines
265268 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
266269 _window(new MainWindow(desktop())),
267270 _toolWindow(NULL),
271+ _friendsWindow(NULL),
268272 _datagramProcessor(),
269273 _undoStack(),
270274 _undoStackScriptingInterface(&_undoStack),
@@ -566,6 +570,9 @@ void Application::aboutToQuit() { · 295 unmodified lines
566570 }
567571
568572 void Application::cleanupBeforeQuit() {
573+
574+ _entities.clear(); // this will allow entity scripts to properly shutdown
575+
569576 _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
570577 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
571578 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
@@ -773,10 +780,6 @@ void Application::paintGL() { · 201 unmodified lines
773780 }
774781
775782 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−
780783 //When in mirror mode, use camera rotation. Otherwise, use body rotation
781784 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
782785 OculusManager::display(_myCamera.getRotation(), _myCamera.getPosition(), _myCamera);
@@ -970,9 +973,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 187 unmodified lines
970973
971974 case Qt::Key_E:
972975 case Qt::Key_PageUp:
973− if (!_myAvatar->getDriveKeys(UP)) {
974− _myAvatar->jump();
975− }
976976 _myAvatar->setDriveKeys(UP, 1.0f);
977977 break;
978978
@@ -1181,6 +1181,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 202 unmodified lines
11811181 break;
11821182 }
11831183
1184+ case Qt::Key_Comma: {
1185+ renderCollisionHulls = !renderCollisionHulls;
1186+ }
1187+
11841188 default:
11851189 event->ignore();
11861190 break;
@@ -2207,6 +2211,7 @@ void Application::update(float deltaTime) { · 1020 unmodified lines
22072211
22082212 {
22092213 PerformanceTimer perfTimer("physics");
2214+ _myAvatar->relayDriveKeysToCharacterController();
22102215 _physicsEngine.stepSimulation();
22112216 }
22122217
@@ -2259,7 +2264,7 @@ void Application::update(float deltaTime) { · 46 unmodified lines
22592264 if (queryIsDue || viewIsDifferentEnough) {
22602265 _lastQueriedTime = now;
22612266
2262− if (Menu::getInstance()->isOptionChecked(MenuOption::Entities)) {
2267+ if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
22632268 queryOctree(NodeType::EntityServer, PacketTypeEntityQuery, _entityServerJurisdictions);
22642269 }
22652270 _lastQueriedViewFrustum = _viewFrustum;
@@ -2611,7 +2616,12 @@ glm::vec3 Application::getSunDirection() { · 345 unmodified lines
26112616 return skyStage->getSunLight()->getDirection();
26122617 }
26132618
2619+// FIXME, preprocessor guard this check to occur only in DEBUG builds
2620+static QThread * activeRenderingThread = nullptr;
2621+
26142622 void Application::updateShadowMap() {
2623+ activeRenderingThread = QThread::currentThread();
2624+
26152625 PerformanceTimer perfTimer("shadowMap");
26162626 QOpenGLFramebufferObject* fbo = DependencyManager::get<TextureCache>()->getShadowFramebufferObject();
26172627 fbo->bind();
@@ -2706,6 +2716,10 @@ void Application::updateShadowMap() { · 88 unmodified lines
27062716 glLoadIdentity();
27072717 glOrtho(minima.x, maxima.x, minima.y, maxima.y, -maxima.z, -minima.z);
27082718
2719+ glm::mat4 projAgain;
2720+ glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat*)&projAgain);
2721+
2722+
27092723 glMatrixMode(GL_MODELVIEW);
27102724 glPushMatrix();
27112725 glLoadIdentity();
@@ -2761,11 +2775,12 @@ void Application::updateShadowMap() { · 49 unmodified lines
27612775 fbo->release();
27622776
27632777 glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
2778+ activeRenderingThread = nullptr;
27642779 }
27652780
27662781 const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
27672782 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 };
27692784
27702785 const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
27712786
@@ -2821,9 +2836,6 @@ QImage Application::renderAvatarBillboard() { · 49 unmodified lines
28212836 return image;
28222837 }
28232838
2824−// FIXME, preprocessor guard this check to occur only in DEBUG builds
2825−static QThread * activeRenderingThread = nullptr;
2826−
28272839 ViewFrustum* Application::getViewFrustum() {
28282840 #ifdef DEBUG
28292841 if (QThread::currentThread() == activeRenderingThread) {
@@ -2972,11 +2984,15 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 142 unmodified lines
29722984 DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
29732985
29742986 // render models...
2975− if (Menu::getInstance()->isOptionChecked(MenuOption::Entities)) {
2987+ if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
29762988 PerformanceTimer perfTimer("entities");
29772989 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
29782990 "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+ }
29802996 }
29812997
29822998 // render JS/scriptable overlays
@@ -2993,17 +3009,15 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 10 unmodified lines
29933009 DependencyManager::get<AmbientOcclusionEffect>()->render();
29943010 }
29953011 }
2996−
2997−
2998−
3012+
29993013 bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR);
3014+
30003015 {
30013016 PerformanceTimer perfTimer("avatars");
30023017 DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? RenderArgs::MIRROR_RENDER_MODE : RenderArgs::NORMAL_RENDER_MODE,
30033018 false, selfAvatarOnly);
30043019 }
30053020
3006−
30073021 {
30083022 DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());
30093023 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
@@ -3586,6 +3600,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 576 unmodified lines
35863600 scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition2D", HMDScriptingInterface::getHUDLookAtPosition2D, 0);
35873601 scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0);
35883602
3603+ scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data());
3604+
35893605 #ifdef HAVE_RTMIDI
35903606 scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
35913607 #endif
@@ -3737,22 +3753,27 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 145 unmodified lines
37373753 _myAvatar->setFaceModelURL(url);
37383754 UserActivityLogger::getInstance().changedModel("head", url);
37393755 _myAvatar->sendIdentityPacket();
3756+ emit faceURLChanged(url);
37403757 } else if (msgBox.clickedButton() == bodyButton) {
37413758 qDebug() << "Chose to use for body: " << url;
37423759 _myAvatar->setSkeletonModelURL(url);
37433760 // if the head is empty, reset it to the default head.
37443761 if (_myAvatar->getFaceModelURLString().isEmpty()) {
37453762 _myAvatar->setFaceModelURL(DEFAULT_HEAD_MODEL_URL);
3763+ emit faceURLChanged(DEFAULT_HEAD_MODEL_URL.toString());
37463764 UserActivityLogger::getInstance().changedModel("head", DEFAULT_HEAD_MODEL_URL.toString());
37473765 }
37483766 UserActivityLogger::getInstance().changedModel("skeleton", url);
37493767 _myAvatar->sendIdentityPacket();
3768+ emit skeletonURLChanged(url);
37503769 } else if (msgBox.clickedButton() == bodyAndHeadButton) {
37513770 qDebug() << "Chose to use for body + head: " << url;
37523771 _myAvatar->setFaceModelURL(QString());
37533772 _myAvatar->setSkeletonModelURL(url);
37543773 UserActivityLogger::getInstance().changedModel("skeleton", url);
37553774 _myAvatar->sendIdentityPacket();
3775+ emit faceURLChanged(QString());
3776+ emit skeletonURLChanged(url);
37563777 } else {
37573778 qDebug() << "Declined to use the avatar: " << url;
37583779 }
@@ -4274,3 +4295,21 @@ void Application::checkSkeleton() { · 515 unmodified lines
42744295 _physicsEngine.setCharacterController(_myAvatar->getCharacterController());
42754296 }
42764297 }
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+}