From 967fc62da7b8ea75d31a53e1b6deb01da8c77d30 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 22 Jun 2015 13:46:03 -0700 Subject: [PATCH] Working on syncing with master --- interface/src/Application.h | 15 +- interface/src/Menu.h | 1 - interface/src/avatar/SkeletonModel.cpp | 2 - .../src/ui/ApplicationOverlayCompositor.cpp | 209 ------------------ .../src/ui/ApplicationOverlayCompositor.h | 37 ---- .../src/ui/overlays/LocalModelsOverlay.cpp | 7 +- 6 files changed, 7 insertions(+), 264 deletions(-) delete mode 100644 interface/src/ui/ApplicationOverlayCompositor.cpp delete mode 100644 interface/src/ui/ApplicationOverlayCompositor.h diff --git a/interface/src/Application.h b/interface/src/Application.h index 7f8e1a17cc..04404deb64 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -137,7 +137,6 @@ class Application; typedef bool (Application::* AcceptURLMethod)(const QString &); - class Application : public QApplication, public AbstractViewStateInterface, AbstractScriptingServicesInterface, PluginContainer { Q_OBJECT @@ -251,8 +250,6 @@ public: Overlays& getOverlays() { return _overlays; } float getFps() const { return _fps; } - //const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; } - //void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; } virtual const Transform& getViewTransform() const { return _viewTransform; } virtual Transform& getViewTransform() { return _viewTransform; } @@ -281,7 +278,7 @@ public: QImage renderAvatarBillboard(RenderArgs* renderArgs); - void displaySide(RenderArgs* renderArgs, const Camera& camera, bool selfAvatarOnly = false, bool billboard = false); + void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false); void getModelViewMatrix(glm::dmat4* modelViewMatrix); void getProjectionMatrix(glm::dmat4* projectionMatrix); @@ -453,12 +450,8 @@ private slots: void connectedToDomain(const QString& hostname); -#if 0 - friend class HMDToolsDialog; - void setFullscreen(bool fullscreen); -#endif - void cameraMenuChanged(); + void rotationModeChanged(); void closeMirrorView(); void restoreMirrorView(); @@ -571,10 +564,6 @@ private: Transform _viewTransform; glm::mat4 _projectionMatrix; -/* - glm::mat4 _untranslatedViewMatrix; - glm::vec3 _viewMatrixTranslation; -*/ float _scaleMirror; float _rotateMirror; diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 6fb9d6e93c..2960579b7f 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -200,7 +200,6 @@ namespace MenuOption { const QString CenterPlayerInView = "Center Player In View"; const QString GlowWhenSpeaking = "Glow When Speaking"; const QString NamesAboveHeads = "Names Above Heads"; - const QString GoToUser = "Go To User"; const QString IncreaseAvatarSize = "Increase Avatar Size"; const QString KeyboardMotorControl = "Enable Keyboard Motor Control"; const QString LeapMotionOnHMD = "Leap Motion on HMD"; diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index e1046cd33e..2aa08d36f3 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -771,7 +771,6 @@ void SkeletonModel::resetShapePositionsToDefaultPose() { void SkeletonModel::renderBoundingCollisionShapes(float alpha) { const int BALL_SUBDIVISIONS = 10; -#if 0 if (_shapes.isEmpty()) { // the bounding shape has not been propery computed // so no need to render it @@ -802,7 +801,6 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) { Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha)); glPopMatrix(); -#endif } bool SkeletonModel::hasSkeleton() { diff --git a/interface/src/ui/ApplicationOverlayCompositor.cpp b/interface/src/ui/ApplicationOverlayCompositor.cpp deleted file mode 100644 index d3fb32936d..0000000000 --- a/interface/src/ui/ApplicationOverlayCompositor.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include "ApplicationOverlayCompositor.h" - -#include -#include -#include -#include -#include - -#define DEFAULT_HMD_UI_ANGULAR_SIZE 72.0f - -ApplicationOverlayCompositor::ApplicationOverlayCompositor() { - using namespace oglplus; - - auto currentContext = QOpenGLContext::currentContext(); - Q_ASSERT(currentContext); - _canvas.create(currentContext); - _canvas.makeCurrent(); - Q_ASSERT(0 == glGetError()); - currentContext = QOpenGLContext::currentContext(); - Q_ASSERT(currentContext); - - Context::ClearColor(0, 0, 0, 1); - Q_ASSERT(0 == glGetError()); - Context::BlendFunc(BlendFunction::SrcAlpha, BlendFunction::OneMinusSrcAlpha); - Q_ASSERT(0 == glGetError()); - Context::Disable(Capability::Blend); - Q_ASSERT(0 == glGetError()); - Context::Disable(Capability::DepthTest); - Q_ASSERT(0 == glGetError()); - Context::Disable(Capability::CullFace); - Q_ASSERT(0 == glGetError()); - - _program = loadDefaultShader(); - _plane = loadPlane(_program); - - _program = loadDefaultShader(); - _plane = loadPlane(_program); - _hmdUiSurface = loadSphereSection(_program, glm::radians(DEFAULT_HMD_UI_ANGULAR_SIZE)); - - _crosshairTexture = DependencyManager::get()-> - getImageTexture(PathUtils::resourcesPath() + "images/sixense-reticle.png"); -} - - -GLuint ApplicationOverlayCompositor::composite(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize) { - using namespace oglplus; - _canvas.makeCurrent(); - if (!_fbo || sceneSize != _fbo->size) { - _fbo = BasicFramebufferWrapperPtr(new BasicFramebufferWrapper()); - _fbo->Init(sceneSize); - } - _fbo->Bound(Framebuffer::Target::Draw, [&] { - Context::Clear().ColorBuffer(); - if (plugin->isHmd()) { - compositeHmd(plugin, sceneTexture, sceneSize, overlayTexture, overlaySize); - } else if (plugin->isStereo()) { - compositeStereo(plugin, sceneTexture, sceneSize, overlayTexture, overlaySize); - } else { - composite2D(plugin, sceneTexture, sceneSize, overlayTexture, overlaySize); - } - }); - GLuint result = GetName(_fbo->color); - _canvas.doneCurrent(); - return result; -} - -void ApplicationOverlayCompositor::composite2D(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize) { - using namespace oglplus; - const uvec2 size = toGlm(plugin->getDeviceSize()); - - Q_ASSERT(0 == glGetError()); - - Context::Viewport(size.x, size.y); - _program->Bind(); - Mat4Uniform(*_program, "ModelView").Set(mat4()); - Mat4Uniform(*_program, "Projection").Set(mat4()); - glBindTexture(GL_TEXTURE_2D, sceneTexture); - _plane->Use(); - _plane->Draw(); - Context::Enable(Capability::Blend); - glBindTexture(GL_TEXTURE_2D, overlayTexture); - _plane->Draw(); - Context::Disable(Capability::Blend); - glBindTexture(GL_TEXTURE_2D, 0); - - // FIXME add the cursor - - Q_ASSERT(0 == glGetError()); -} - - -template -void sbs_for_each_eye(const uvec2& size, F f) { - QRect r(QPoint(0, 0), QSize(size.x / 2, size.y)); - for_each_eye([&](Eye eye) { - oglplus::Context::Viewport(r.x(), r.y(), r.width(), r.height()); - f(eye); - }, [&] { - r.moveLeft(r.width()); - }); -} - -void ApplicationOverlayCompositor::compositeStereo(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize) { - using namespace oglplus; - - Q_ASSERT(0 == glGetError()); - const uvec2 size = sceneSize; - - Context::Viewport(size.x, size.y); - - _program->Bind(); - - Mat4Uniform(*_program, "ModelView").Set(mat4()); - Mat4Uniform(*_program, "Projection").Set(mat4()); - - glBindTexture(GL_TEXTURE_2D, sceneTexture); - - _plane->Use(); - _plane->Draw(); - - // FIXME the - const float screenAspect = aspect(size); - const GLfloat distance = 1.0f; - const GLfloat halfQuadHeight = distance * tan(DEFAULT_FIELD_OF_VIEW_DEGREES); - const GLfloat halfQuadWidth = halfQuadHeight * screenAspect; - const GLfloat quadWidth = halfQuadWidth * 2.0f; - const GLfloat quadHeight = halfQuadHeight * 2.0f; - - vec3 quadSize(quadWidth, quadHeight, 1.0f); - quadSize = vec3(1.0f) / quadSize; - - using namespace oglplus; - Context::Enable(Capability::Blend); - glBindTexture(GL_TEXTURE_2D, overlayTexture); - - mat4 pr = glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), screenAspect, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP); - Mat4Uniform(*_program, "Projection").Set(pr); - - // Position the camera relative to the overlay texture - MatrixStack mv; - mv.translate(vec3(0, 0, -distance)).scale(vec3(0.7f, 0.7f / screenAspect, 1.0f)); // .scale(vec3(quadWidth, quadHeight, 1.0)); - sbs_for_each_eye(size, [&](Eye eye) { - mv.withPush([&] { - // translate - mv.top() = plugin->getModelview(eye, mv.top()); - Mat4Uniform(*_program, "ModelView").Set(mv.top()); - _plane->Draw(); - }); - }); - - glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); - glm::vec2 canvasSize = plugin->getCanvasSize(); - glm::vec2 mouse = vec2(0); // toGlm(_window->mapFromGlobal(QCursor::pos())); - mouse /= canvasSize; - mouse *= 2.0f; - mouse -= 1.0f; - mouse.y *= -1.0f; - sbs_for_each_eye(size, [&](Eye eye) { - mv.withPush([&] { - // translate - mv.top() = plugin->getModelview(eye, mv.top()); - mv.translate(mouse); - //mv.scale(0.05f); - mv.scale(vec3(0.025f, 0.05f, 1.0f)); - Mat4Uniform(*_program, "ModelView").Set(mv.top()); - _plane->Draw(); - }); - }); - Context::Disable(Capability::Blend); - -} - -void ApplicationOverlayCompositor::compositeHmd(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize) { - using namespace oglplus; - auto size = sceneSize; - - Context::Viewport(size.x, size.y); - - glClearColor(0, 0, 0, 0); - Context::Clear().ColorBuffer(); - - _program->Bind(); - Mat4Uniform(*_program, "Projection").Set(mat4()); - Mat4Uniform(*_program, "ModelView").Set(mat4()); - glBindTexture(GL_TEXTURE_2D, sceneTexture); - _plane->Use(); - _plane->Draw(); - - - Context::Enable(Capability::Blend); - glBindTexture(GL_TEXTURE_2D, overlayTexture); - for_each_eye([&](Eye eye) { - Context::Viewport(eye == Left ? 0 : size.x / 2, 0, size.x / 2, size.y); - glm::mat4 m = plugin->getProjection(eye, glm::mat4()); - Mat4Uniform(*_program, "Projection").Set(m); - Mat4Uniform(*_program, "ModelView").Set(glm::scale(glm::inverse(plugin->getModelview(eye, mat4())), vec3(1))); - _hmdUiSurface->Use(); - _hmdUiSurface->Draw(); - }); - Context::Disable(Capability::Blend); -} diff --git a/interface/src/ui/ApplicationOverlayCompositor.h b/interface/src/ui/ApplicationOverlayCompositor.h deleted file mode 100644 index 2110e4fd08..0000000000 --- a/interface/src/ui/ApplicationOverlayCompositor.h +++ /dev/null @@ -1,37 +0,0 @@ - -#pragma once - -#include -#include -#include -#include - -class ApplicationOverlayCompositor { -public: - ApplicationOverlayCompositor(); - GLuint composite(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize); - -private: - OffscreenGlCanvas _canvas; - BasicFramebufferWrapperPtr _fbo; - ProgramPtr _program; - ShapeWrapperPtr _plane; - ShapeWrapperPtr _hmdUiSurface; - gpu::TexturePointer _crosshairTexture; - - void composite2D(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize); - - void compositeStereo(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize); - - void compositeHmd(DisplayPlugin* plugin, - GLuint sceneTexture, const glm::uvec2& sceneSize, - GLuint overlayTexture, const glm::uvec2& overlaySize); -}; - -using CompositorPtr = std::shared_ptr; diff --git a/interface/src/ui/overlays/LocalModelsOverlay.cpp b/interface/src/ui/overlays/LocalModelsOverlay.cpp index 076f8c14a7..7d91fc521d 100644 --- a/interface/src/ui/overlays/LocalModelsOverlay.cpp +++ b/interface/src/ui/overlays/LocalModelsOverlay.cpp @@ -38,9 +38,9 @@ void LocalModelsOverlay::render(RenderArgs* args) { if (_visible) { float glowLevel = getGlowLevel(); - QSharedPointer glower; + Glower* glower = NULL; if (glowLevel > 0.0f) { - glower = QSharedPointer(new Glower(glowLevel)); + glower = new Glower(glowLevel); } glPushMatrix(); { @@ -52,6 +52,9 @@ void LocalModelsOverlay::render(RenderArgs* args) { Application::getInstance()->setViewMatrixTranslation(oldTranslation); #endif } glPopMatrix(); + if (glower) { + delete glower; + } } }