History

Threaded rendering & entity rendering refactor

Brad Davis committed 9 years ago

Commit e817d3c1 parent eb9436b81 files · +5147 −5162Browse files

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

Unified · Split

interface/src/Application.cpp+203−147
@@ -113,7 +113,6 @@ · 112 unmodified lines
113113 #include <plugins/SteamClientPlugin.h>
114114 #include <plugins/InputConfiguration.h>
115115 #include <RecordingScriptingInterface.h>
116−#include <RenderableWebEntityItem.h>
117116 #include <UpdateSceneTask.h>
118117 #include <RenderViewTask.h>
119118 #include <SecondaryCamera.h>
@@ -139,6 +138,7 @@ · 19 unmodified lines
139138 #include <display-plugins/CompositorHelper.h>
140139 #include <trackers/EyeTracker.h>
141140 #include <avatars-renderer/ScriptAvatar.h>
141+#include <RenderableEntityItem.h>
142142
143143 #include "AudioClient.h"
144144 #include "audio/AudioScope.h"
@@ -212,6 +212,73 @@ extern "C" { · 67 unmodified lines
212212 }
213213 #endif
214214
215+enum ApplicationEvent {
216+ // Execute a lambda function
217+ Lambda = QEvent::User + 1,
218+ // Trigger the next render
219+ Render,
220+ // Trigger the next idle
221+ Idle,
222+};
223+
224+
225+class RenderEventHandler : public QObject {
226+ using Parent = QObject;
227+ Q_OBJECT
228+public:
229+ RenderEventHandler(QOpenGLContext* context) {
230+ _renderContext = new OffscreenGLCanvas();
231+ _renderContext->setObjectName("RenderContext");
232+ _renderContext->create(context);
233+ if (!_renderContext->makeCurrent()) {
234+ qFatal("Unable to make rendering context current");
235+ }
236+ _renderContext->doneCurrent();
237+
238+ // Deleting the object with automatically shutdown the thread
239+ connect(qApp, &QCoreApplication::aboutToQuit, this, &QObject::deleteLater);
240+
241+ // Transfer to a new thread
242+ moveToNewNamedThread(this, "RenderThread", [this](QThread* renderThread) {
243+ hifi::qt::addBlockingForbiddenThread("Render", renderThread);
244+ _renderContext->moveToThreadWithContext(renderThread);
245+ qApp->_lastTimeRendered.start();
246+ }, std::bind(&RenderEventHandler::initialize, this), QThread::HighestPriority);
247+ }
248+
249+private:
250+ void initialize() {
251+ PROFILE_SET_THREAD_NAME("Render");
252+ if (!_renderContext->makeCurrent()) {
253+ qFatal("Unable to make rendering context current on render thread");
254+ }
255+ }
256+
257+ void render() {
258+ if (qApp->shouldPaint()) {
259+ qApp->paintGL();
260+ }
261+ }
262+
263+ bool event(QEvent* event) override {
264+ switch ((int)event->type()) {
265+ case ApplicationEvent::Render:
266+ render();
267+ // Ensure we never back up the render events. Each render should be triggered only in response
268+ // to the NEXT render event after the last render occured
269+ QCoreApplication::removePostedEvents(this, ApplicationEvent::Render);
270+ return true;
271+
272+ default:
273+ break;
274+ }
275+ return Parent::event(event);
276+ }
277+
278+ OffscreenGLCanvas* _renderContext { nullptr };
279+};
280+
281+
215282 Q_LOGGING_CATEGORY(trace_app_input_mouse, "trace.app.input.mouse")
216283
217284 using namespace std;
@@ -427,10 +494,10 @@ class LambdaEvent : public QEvent { · 209 unmodified lines
427494 std::function<void()> _fun;
428495 public:
429496 LambdaEvent(const std::function<void()> & fun) :
430− QEvent(static_cast<QEvent::Type>(Application::Lambda)), _fun(fun) {
497+ QEvent(static_cast<QEvent::Type>(ApplicationEvent::Lambda)), _fun(fun) {
431498 }
432499 LambdaEvent(std::function<void()> && fun) :
433− QEvent(static_cast<QEvent::Type>(Application::Lambda)), _fun(fun) {
500+ QEvent(static_cast<QEvent::Type>(ApplicationEvent::Lambda)), _fun(fun) {
434501 }
435502 void call() const { _fun(); }
436503 };
@@ -1367,8 +1434,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 930 unmodified lines
13671434 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
13681435 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
13691436 [this](const EntityItemID& entityItemID, const PointerEvent& event) {
1370− auto entity = getEntities()->getTree()->findEntityByID(entityItemID);
1371− if (entity && entity->wantsKeyboardFocus()) {
1437+ if (getEntities()->wantsKeyboardFocus(entityItemID)) {
13721438 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
13731439 setKeyboardFocusEntity(entityItemID);
13741440 } else {
@@ -1692,7 +1758,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 317 unmodified lines
16921758 _defaultSkybox->setCubemap(_defaultSkyboxTexture);
16931759 }
16941760
1695− EntityItem::setEntitiesShouldFadeFunction([this]() {
1761+ EntityTreeRenderer::setEntitiesShouldFadeFunction([this]() {
16961762 SharedNodePointer entityServerNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::EntityServer);
16971763 return entityServerNode && !isPhysicsEnabled();
16981764 });
@@ -2099,6 +2165,13 @@ void Application::initializeGL() { · 400 unmodified lines
20992165 _renderEngine->load();
21002166 _renderEngine->registerScene(_main3DScene);
21012167
2168+ _offscreenContext = new OffscreenGLCanvas();
2169+ _offscreenContext->setObjectName("MainThreadContext");
2170+ _offscreenContext->create(_glWidget->qglContext());
2171+ if (!_offscreenContext->makeCurrent()) {
2172+ qFatal("Unable to make offscreen context current");
2173+ }
2174+
21022175 // The UI can't be created until the primary OpenGL
21032176 // context is created, because it needs to share
21042177 // texture resources
@@ -2122,14 +2195,15 @@ void Application::initializeGL() { · 17 unmodified lines
21222195
21232196 _idleLoopStdev.reset();
21242197
2125− _offscreenContext = new OffscreenGLCanvas();
2126− _offscreenContext->setObjectName("MainThreadContext");
2127− _offscreenContext->create(_glWidget->qglContext());
2128− _offscreenContext->makeCurrent();
2198+ _renderEventHandler = new RenderEventHandler(_glWidget->qglContext());
2199+
2200+ // Restore the primary GL content for the main thread
2201+ if (!_offscreenContext->makeCurrent()) {
2202+ qFatal("Unable to make offscreen context current");
2203+ }
21292204
21302205 // update before the first render
21312206 update(0);
2132−
21332207 }
21342208
21352209 FrameTimingsScriptingInterface _frameTimingsScriptingInterface;
@@ -2137,6 +2211,9 @@ FrameTimingsScriptingInterface _frameTimingsScriptingInterface; · 1 unmodified line
21372211 extern void setupPreferences();
21382212
21392213 void Application::initializeUi() {
2214+ // Make sure all QML surfaces share the main thread GL context
2215+ OffscreenQmlSurface::setSharedContext(_offscreenContext->getContext());
2216+
21402217 AddressBarDialog::registerType();
21412218 ErrorDialog::registerType();
21422219 LoginDialog::registerType();
@@ -2147,7 +2224,7 @@ void Application::initializeUi() { · 4 unmodified lines
21472224 qmlRegisterType<Preference>("Hifi", 1, 0, "Preference");
21482225
21492226 auto offscreenUi = DependencyManager::get<OffscreenUi>();
2150− offscreenUi->create(_glWidget->qglContext());
2227+ offscreenUi->create();
21512228
21522229 auto surfaceContext = offscreenUi->getSurfaceContext();
21532230
@@ -2292,14 +2369,12 @@ void Application::initializeUi() { · 138 unmodified lines
22922369
22932370 void Application::paintGL() {
22942371 // Some plugins process message events, allowing paintGL to be called reentrantly.
2295− if (_inPaint || _aboutToQuit || _window->isMinimized()) {
2372+ if (_aboutToQuit || _window->isMinimized()) {
22962373 return;
22972374 }
22982375
2299− _inPaint = true;
2300− Finally clearFlag([this] { _inPaint = false; });
2301−
23022376 _frameCount++;
2377+ _lastTimeRendered.start();
23032378
23042379 auto lastPaintBegin = usecTimestampNow();
23052380 PROFILE_RANGE_EX(render, __FUNCTION__, 0xff0000ff, (uint64_t)_frameCount);
@@ -2315,18 +2390,11 @@ void Application::paintGL() { · 9 unmodified lines
23152390 displayPlugin = getActiveDisplayPlugin();
23162391 }
23172392
2318− {
2319− PROFILE_RANGE(render, "/offscreenMakeCurrent");
2320− // FIXME not needed anymore?
2321− _offscreenContext->makeCurrent();
2322− }
2323−
23242393 {
23252394 PROFILE_RANGE(render, "/pluginBeginFrameRender");
23262395 // If a display plugin loses it's underlying support, it
23272396 // needs to be able to signal us to not use it
23282397 if (!displayPlugin->beginFrameRender(_frameCount)) {
2329− _inPaint = false;
23302398 updateDisplayMode();
23312399 return;
23322400 }
@@ -2394,12 +2462,6 @@ void Application::paintGL() { · 61 unmodified lines
23942462 auto myAvatar = getMyAvatar();
23952463 boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
23962464
2397− if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
2398− Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
2399− Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
2400− cameraMenuChanged();
2401− }
2402−
24032465 // The render mode is default or mirror if the camera is in mirror mode, assigned further below
24042466 renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
24052467
@@ -2707,15 +2769,6 @@ void Application::resizeGL() { · 301 unmodified lines
27072769 QMutexLocker viewLocker(&_viewMutex);
27082770 _myCamera.loadViewFrustum(_viewFrustum);
27092771 }
2710−
2711− auto offscreenUi = DependencyManager::get<OffscreenUi>();
2712− auto uiSize = displayPlugin->getRecommendedUiSize();
2713− // Bit of a hack since there's no device pixel ratio change event I can find.
2714− if (offscreenUi->size() != fromGlm(uiSize)) {
2715− qCDebug(interfaceapp) << "Device pixel ratio changed, triggering resize to " << uiSize;
2716− offscreenUi->resize(fromGlm(uiSize), true);
2717− _offscreenContext->makeCurrent();
2718− }
27192772 }
27202773
27212774 void Application::handleSandboxStatus(QNetworkReply* reply) {
@@ -2889,56 +2942,26 @@ bool Application::importFromZIP(const QString& filePath) { · 167 unmodified lines
28892942 }
28902943
28912944 void Application::onPresent(quint32 frameCount) {
2892− if (shouldPaint()) {
2893− postEvent(this, new QEvent(static_cast<QEvent::Type>(Idle)), Qt::HighEventPriority);
2894− postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority);
2945+ postEvent(this, new QEvent((QEvent::Type)ApplicationEvent::Idle), Qt::HighEventPriority);
2946+ if (_renderEventHandler && !isAboutToQuit()) {
2947+ postEvent(_renderEventHandler, new QEvent((QEvent::Type)ApplicationEvent::Render));
28952948 }
28962949 }
28972950
2898−bool _renderRequested { false };
2899−
2900−bool Application::event(QEvent* event) {
2901− if (!Menu::getInstance()) {
2902− return false;
2903− }
2904−
2905− int type = event->type();
2906− switch (type) {
2907− case Event::Lambda:
2908− static_cast<LambdaEvent*>(event)->call();
2909− return true;
2910−
2911− // Explicit idle keeps the idle running at a lower interval, but without any rendering
2912− // see (windowMinimizedChanged)
2913− case Event::Idle:
2914− idle();
2915− // Clear the event queue of pending idle calls
2916− removePostedEvents(this, Idle);
2917− return true;
2918−
2919− case Event::Paint:
2920− // NOTE: This must be updated as close to painting as possible,
2921− // or AvatarInputs will mysteriously move to the bottom-right
2922− AvatarInputs::getInstance()->update();
2923− paintGL();
2924− // Clear the event queue of pending paint calls
2925− removePostedEvents(this, Paint);
2926− return true;
2927−
2928− default:
2929− break;
2930− }
2951+static inline bool isKeyEvent(QEvent::Type type) {
2952+ return type == QEvent::KeyPress || type == QEvent::KeyRelease;
2953+}
29312954
2932− {
2933− if (!_keyboardFocusedEntity.get().isInvalidID()) {
2934− switch (event->type()) {
2935− case QEvent::KeyPress:
2936− case QEvent::KeyRelease: {
2937− //auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
2938− auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get());
2939− if (entity && entity->getEventHandler()) {
2955+bool Application::handleKeyEventForFocusedEntityOrOverlay(QEvent* event) {
2956+ if (!_keyboardFocusedEntity.get().isInvalidID()) {
2957+ switch (event->type()) {
2958+ case QEvent::KeyPress:
2959+ case QEvent::KeyRelease:
2960+ {
2961+ auto eventHandler = getEntities()->getEventHandler(_keyboardFocusedEntity.get());
2962+ if (eventHandler) {
29402963 event->setAccepted(false);
2941− QCoreApplication::sendEvent(entity->getEventHandler(), event);
2964+ QCoreApplication::sendEvent(eventHandler, event);
29422965 if (event->isAccepted()) {
29432966 _lastAcceptedKeyPress = usecTimestampNow();
29442967 return true;
@@ -2946,20 +2969,17 @@ bool Application::event(QEvent* event) { · 1 unmodified line
29462969 }
29472970 break;
29482971 }
2949− default:
2950− break;
2951− }
2972+ default:
2973+ break;
29522974 }
29532975 }
29542976
2955− {
2956− if (_keyboardFocusedOverlay.get() != UNKNOWN_OVERLAY_ID) {
2957− switch (event->type()) {
2958− case QEvent::KeyPress:
2959− case QEvent::KeyRelease: {
2977+ if (_keyboardFocusedOverlay.get() != UNKNOWN_OVERLAY_ID) {
2978+ switch (event->type()) {
2979+ case QEvent::KeyPress:
2980+ case QEvent::KeyRelease: {
29602981 // Only Web overlays can have focus.
2961− auto overlay =
2962− std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
2982+ auto overlay = std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
29632983 if (overlay && overlay->getEventHandler()) {
29642984 event->setAccepted(false);
29652985 QCoreApplication::sendEvent(overlay->getEventHandler(), event);
@@ -2968,15 +2988,52 @@ bool Application::event(QEvent* event) { · 2 unmodified lines
29682988 return true;
29692989 }
29702990 }
2971− break;
2972− }
2973− default:
2974− break;
29752991 }
2992+ break;
2993+
2994+ default:
2995+ break;
2996+ }
2997+ }
2998+
2999+ return false;
3000+}
3001+
3002+bool Application::handleFileOpenEvent(QFileOpenEvent* fileEvent) {
3003+ QUrl url = fileEvent->url();
3004+ if (!url.isEmpty()) {
3005+ QString urlString = url.toString();
3006+ if (canAcceptURL(urlString)) {
3007+ return acceptURL(urlString);
29763008 }
29773009 }
3010+ return false;
3011+}
3012+
3013+bool Application::event(QEvent* event) {
3014+ if (!Menu::getInstance()) {
3015+ return false;
3016+ }
3017+
3018+ // Allow focused Entities and Overlays to handle keyboard input
3019+ if (isKeyEvent(event->type()) && handleKeyEventForFocusedEntityOrOverlay(event)) {
3020+ return true;
3021+ }
3022+
3023+ int type = event->type();
3024+ switch (type) {
3025+ case ApplicationEvent::Lambda:
3026+ static_cast<LambdaEvent*>(event)->call();
3027+ return true;
3028+
3029+ // Explicit idle keeps the idle running at a lower interval, but without any rendering
3030+ // see (windowMinimizedChanged)
3031+ case ApplicationEvent::Idle:
3032+ idle();
3033+ // Don't process extra idle events that arrived in the event queue while we were doing this idle
3034+ QCoreApplication::removePostedEvents(this, ApplicationEvent::Idle);
3035+ return true;
29783036
2979− switch (event->type()) {
29803037 case QEvent::MouseMove:
29813038 mouseMoveEvent(static_cast<QMouseEvent*>(event));
29823039 return true;
@@ -3017,26 +3074,15 @@ bool Application::event(QEvent* event) { · 34 unmodified lines
30173074 case QEvent::Drop:
30183075 dropEvent(static_cast<QDropEvent*>(event));
30193076 return true;
3020− default:
3021− break;
3022− }
3023−
3024− // handle custom URL
3025− if (event->type() == QEvent::FileOpen) {
3026−
3027− QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
3028−
3029− QUrl url = fileEvent->url();
3030−
3031− if (!url.isEmpty()) {
3032− QString urlString = url.toString();
30333077
3034− if (canAcceptURL(urlString)) {
3035−
3036− return acceptURL(urlString);
3078+ case QEvent::FileOpen:
3079+ if (handleFileOpenEvent(static_cast<QFileOpenEvent*>(event))) {
3080+ return true;
30373081 }
3038− }
3039− return false;
3082+ break;
3083+
3084+ default:
3085+ break;
30403086 }
30413087
30423088 if (HFActionEvent::types().contains(event->type())) {
@@ -3741,11 +3787,12 @@ bool Application::acceptSnapshot(const QString& urlString) { · 698 unmodified lines
37413787
37423788 static uint32_t _renderedFrameIndex { INVALID_FRAME };
37433789
3744−bool Application::shouldPaint() {
3790+bool Application::shouldPaint() const {
37453791 if (_aboutToQuit) {
37463792 return false;
37473793 }
37483794
3795+
37493796 auto displayPlugin = getActiveDisplayPlugin();
37503797
37513798 #ifdef DEBUG_PAINT_DELAY
@@ -3763,13 +3810,12 @@ bool Application::shouldPaint() { · 11 unmodified lines
37633810 #endif
37643811
37653812 // Throttle if requested
3766− if (displayPlugin->isThrottled() && (_lastTimeUpdated.elapsed() < THROTTLED_SIM_FRAME_PERIOD_MS)) {
3813+ if (displayPlugin->isThrottled() && (_lastTimeRendered.elapsed() < THROTTLED_SIM_FRAME_PERIOD_MS)) {
37673814 return false;
37683815 }
37693816
37703817 // Sync up the _renderedFrameIndex
37713818 _renderedFrameIndex = displayPlugin->presentCount();
3772−
37733819 return true;
37743820 }
37753821
@@ -3979,7 +4025,6 @@ void setupCpuMonitorThread() { · 203 unmodified lines
39794025
39804026 #endif
39814027
3982−
39834028 void Application::idle() {
39844029 PerformanceTimer perfTimer("idle");
39854030
@@ -4010,9 +4055,17 @@ void Application::idle() { · 24 unmodified lines
40104055 });
40114056 #endif
40124057
4013−
4014−
40154058 auto displayPlugin = getActiveDisplayPlugin();
4059+ if (displayPlugin) {
4060+ auto uiSize = displayPlugin->getRecommendedUiSize();
4061+ // Bit of a hack since there's no device pixel ratio change event I can find.
4062+ if (offscreenUi->size() != fromGlm(uiSize)) {
4063+ qCDebug(interfaceapp) << "Device pixel ratio changed, triggering resize to " << uiSize;
4064+ offscreenUi->resize(fromGlm(uiSize), true);
4065+ _offscreenContext->makeCurrent();
4066+ }
4067+ }
4068+
40164069 if (displayPlugin) {
40174070 PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate());
40184071 }
@@ -4060,6 +4113,10 @@ void Application::idle() { · 41 unmodified lines
40604113 bool showWarnings = getLogger()->extraDebugging();
40614114 PerformanceWarning warn(showWarnings, "idle()");
40624115
4116+ if (!_offscreenContext->makeCurrent()) {
4117+ qFatal("Unable to make main thread context current");
4118+ }
4119+
40634120 {
40644121 PerformanceTimer perfTimer("update");
40654122 PerformanceWarning warn(showWarnings, "Application::idle()... update()");
@@ -4122,6 +4179,13 @@ void Application::idle() { · 56 unmodified lines
41224179 }
41234180
41244181 _overlayConductor.update(secondsSinceLastUpdate);
4182+
4183+ auto myAvatar = getMyAvatar();
4184+ if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
4185+ Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
4186+ Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
4187+ cameraMenuChanged();
4188+ }
41254189 }
41264190
41274191 ivec2 Application::getMouse() const {
@@ -4376,7 +4440,6 @@ void Application::init() { · 248 unmodified lines
43764440 _timerStart.start();
43774441 _lastTimeUpdated.start();
43784442
4379−
43804443 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
43814444 // when +connect_lobby in command line, join steam lobby
43824445 const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";
@@ -4425,14 +4488,7 @@ void Application::init() { · 42 unmodified lines
44254488
44264489 // Make sure any new sounds are loaded as soon as know about them.
44274490 connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) {
4428− EntityTreePointer tree = getEntities()->getTree();
4429− if (auto entity = tree->findEntityByEntityItemID(id)) {
4430− auto sound = DependencyManager::get<SoundCache>()->getSound(newURL);
4431− auto renderable = entity->getRenderableInterface();
4432− if (renderable) {
4433− renderable->setCollisionSound(sound);
4434− }
4435− }
4491+ getEntities()->setCollisionSound(id, DependencyManager::get<SoundCache>()->getSound(newURL));
44364492 }, Qt::QueuedConnection);
44374493 connect(getMyAvatar().get(), &MyAvatar::newCollisionSoundURL, this, [this](QUrl newURL) {
44384494 if (auto avatar = getMyAvatar()) {
@@ -4743,9 +4799,12 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 304 unmodified lines
47434799 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
47444800 auto properties = entityScriptingInterface->getEntityProperties(entityItemID);
47454801 if (!properties.getLocked() && properties.getVisible()) {
4746− auto entity = getEntities()->getTree()->findEntityByID(entityItemID);
4747− if (entity && entity->wantsKeyboardFocus()) {
4748− entity->setProxyWindow(_window->windowHandle());
4802+
4803+ auto entities = getEntities();
4804+ auto entityId = _keyboardFocusedEntity.get();
4805+ if (entities->wantsKeyboardFocus(entityId)) {
4806+ entities->setProxyWindow(entityId, _window->windowHandle());
4807+ auto entity = getEntities()->getEntity(entityId);
47494808 if (_keyboardMouseDevice->isActive()) {
47504809 _keyboardMouseDevice->pluginFocusOutEvent();
47514810 }
@@ -5021,7 +5080,7 @@ void Application::update(float deltaTime) { · 269 unmodified lines
50215080 PerformanceTimer perfTimer("physics");
50225081
50235082 {
5024− PROFILE_RANGE_EX(simulation_physics, "UpdateStats", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount());
5083+ PROFILE_RANGE_EX(simulation_physics, "UpdateStates", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount());
50255084
50265085 PerformanceTimer perfTimer("updateStates)");
50275086 static VectorOfMotionStates motionStates;
@@ -5090,7 +5149,7 @@ void Application::update(float deltaTime) { · 62 unmodified lines
50905149
50915150 // NOTE: the getEntities()->update() call below will wait for lock
50925151 // and will simulate entity motion (the EntityTree has been given an EntitySimulation).
5093− getEntities()->update(); // update the models...
5152+ getEntities()->update(true); // update the models...
50945153 }
50955154
50965155 myAvatar->harvestResultsFromPhysicsSimulation(deltaTime);
@@ -5103,6 +5162,9 @@ void Application::update(float deltaTime) { · 6 unmodified lines
51035162 _physicsEngine->dumpStatsIfNecessary();
51045163 }
51055164 }
5165+ } else {
5166+ // update the rendering without any simulation
5167+ getEntities()->update(false);
51065168 }
51075169
51085170 // AvatarManager update
@@ -7255,14 +7317,6 @@ void Application::updateDisplayMode() { · 2146 unmodified lines
72557317 qFatal("Attempted to switch display plugins from a non-main thread");
72567318 }
72577319
7258− // Some plugins *cough* Oculus *cough* process message events from inside their
7259− // display function, and we don't want to change the display plugin underneath
7260− // the paintGL call, so we need to guard against that
7261− // The current oculus runtime doesn't do this anymore
7262− if (_inPaint) {
7263− qFatal("Attempted to switch display plugins while in painting");
7264− }
7265−
72667320 auto menu = Menu::getInstance();
72677321 auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
72687322
@@ -7339,12 +7393,12 @@ void Application::updateDisplayMode() { · 70 unmodified lines
73397393 bool wasRepositionLocked = offscreenUi->getDesktop()->property("repositionLocked").toBool();
73407394 offscreenUi->getDesktop()->setProperty("repositionLocked", true);
73417395
7342− auto oldDisplayPlugin = _displayPlugin;
73437396 if (_displayPlugin) {
7344− disconnect(_displayPluginPresentConnection);
7397+ disconnect(_displayPlugin.get(), &DisplayPlugin::presented, this, &Application::onPresent);
73457398 _displayPlugin->deactivate();
73467399 }
73477400
7401+ auto oldDisplayPlugin = _displayPlugin;
73487402 bool active = newDisplayPlugin->activate();
73497403
73507404 if (!active) {
@@ -7382,7 +7436,7 @@ void Application::updateDisplayMode() { · 31 unmodified lines
73827436 _offscreenContext->makeCurrent();
73837437 getApplicationCompositor().setDisplayPlugin(newDisplayPlugin);
73847438 _displayPlugin = newDisplayPlugin;
7385− _displayPluginPresentConnection = connect(_displayPlugin.get(), &DisplayPlugin::presented, this, &Application::onPresent);
7439+ connect(_displayPlugin.get(), &DisplayPlugin::presented, this, &Application::onPresent);
73867440 offscreenUi->getDesktop()->setProperty("repositionLocked", wasRepositionLocked);
73877441 }
73887442
@@ -7634,3 +7688,5 @@ void Application::setAvatarOverrideUrl(const QUrl& url, bool save) { · 245 unmodified lines
76347688 _avatarOverrideUrl = url;
76357689 _saveAvatarOverrideUrl = save;
76367690 }
7691+
7692+#include "Application.moc"

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