From 7aef4dab4c26f4d8f6c76f9bffaad20958a52f27 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 7 Jun 2017 11:02:23 -0700 Subject: [PATCH] Variable renaming pass --- interface/src/Application.cpp | 4 +- ...rototypeSelfie.cpp => SecondaryCamera.cpp} | 26 +++++------ .../{PrototypeSelfie.h => SecondaryCamera.h} | 20 ++++----- .../src/model-networking/TextureCache.cpp | 44 +++++++++---------- .../src/model-networking/TextureCache.h | 18 ++++---- scripts/system/spectatorCamera.js | 8 ++-- 6 files changed, 59 insertions(+), 61 deletions(-) rename interface/src/{PrototypeSelfie.cpp => SecondaryCamera.cpp} (77%) rename interface/src/{PrototypeSelfie.h => SecondaryCamera.h} (63%) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1e831d39a6..f116b5fd6d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -114,7 +114,7 @@ #include #include #include -#include +#include #include #include #include @@ -1874,7 +1874,7 @@ void Application::initializeGL() { } _renderEngine->addJob("MainFrame", cullFunctor, isDeferred); - _renderEngine->addJob("SelfieFrame", cullFunctor); + _renderEngine->addJob("SecondaryCameraFrame", cullFunctor); /* _renderEngine->addJob("RenderShadowTask", cullFunctor); diff --git a/interface/src/PrototypeSelfie.cpp b/interface/src/SecondaryCamera.cpp similarity index 77% rename from interface/src/PrototypeSelfie.cpp rename to interface/src/SecondaryCamera.cpp index 6b719a12de..c6f7526256 100644 --- a/interface/src/PrototypeSelfie.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -1,5 +1,5 @@ -#include "PrototypeSelfie.h" +#include "SecondaryCamera.h" #include @@ -20,21 +20,21 @@ void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render using RenderArgsPointer = std::shared_ptr; -void SelfieRenderTaskConfig::resetSize(int width, int height) { // Carefully adjust the framebuffer / texture. +void SecondaryCameraRenderTaskConfig::resetSize(int width, int height) { // Carefully adjust the framebuffer / texture. bool wasEnabled = isEnabled(); setEnabled(false); auto textureCache = DependencyManager::get(); - textureCache->resetSelfieFramebuffer(width, height); + textureCache->resetSecondaryCameraFramebuffer(width, height); setEnabled(wasEnabled); } -class BeginSelfieFrame { // Changes renderContext for our framebuffer and and view. +class BeginSecondaryCameraFrame { // Changes renderContext for our framebuffer and and view. glm::vec3 _position{}; glm::quat _orientation{}; public: - using Config = BeginSelfieFrameConfig; - using JobModel = render::Job::ModelO; - BeginSelfieFrame() { + using Config = BeginSecondaryCameraFrameConfig; + using JobModel = render::Job::ModelO; + BeginSecondaryCameraFrame() { _cachedArgsPointer = std::make_shared(_cachedArgs); } @@ -48,7 +48,7 @@ public: void run(const render::RenderContextPointer& renderContext, RenderArgsPointer& cachedArgs) { auto args = renderContext->args; auto textureCache = DependencyManager::get(); - auto destFramebuffer = textureCache->getSelfieFramebuffer(); + auto destFramebuffer = textureCache->getSecondaryCameraFramebuffer(); // Caching/restoring the old values doesn't seem to be needed. Is it because we happen to be last in the pipeline (which would be a bug waiting to happen)? _cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer; _cachedArgsPointer->_viewport = args->_viewport; @@ -76,9 +76,9 @@ protected: RenderArgsPointer _cachedArgsPointer; }; -class EndSelfieFrame { // Restores renderContext. +class EndSecondaryCameraFrame { // Restores renderContext. public: - using JobModel = render::Job::ModelI; + using JobModel = render::Job::ModelI; void run(const render::RenderContextPointer& renderContext, const RenderArgsPointer& cachedArgs) { auto args = renderContext->args; @@ -93,10 +93,10 @@ public: } }; -void SelfieRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor) { - const auto cachedArg = task.addJob("BeginSelfie"); +void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor) { + const auto cachedArg = task.addJob("BeginSecondaryCamera"); const auto items = task.addJob("FetchCullSort", cullFunctor); assert(items.canCast()); task.addJob("RenderDeferredTask", items); - task.addJob("EndSelfie", cachedArg); + task.addJob("EndSecondaryCamera", cachedArg); } \ No newline at end of file diff --git a/interface/src/PrototypeSelfie.h b/interface/src/SecondaryCamera.h similarity index 63% rename from interface/src/PrototypeSelfie.h rename to interface/src/SecondaryCamera.h index 7bb9bbe861..f68a65dd12 100644 --- a/interface/src/PrototypeSelfie.h +++ b/interface/src/SecondaryCamera.h @@ -1,6 +1,6 @@ #pragma once -#ifndef hifi_PrototypeSelfie_h -#define hifi_PrototypeSelfie_h +#ifndef hifi_SecondaryCamera_h +#define hifi_SecondaryCamera_h #include #include @@ -18,33 +18,33 @@ public: void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred = true); }; -class BeginSelfieFrameConfig : public render::Task::Config { // Exposes view frustum position/orientation to javascript. +class BeginSecondaryCameraFrameConfig : public render::Task::Config { // Exposes view frustum position/orientation to javascript. Q_OBJECT Q_PROPERTY(glm::vec3 position MEMBER position NOTIFY dirty) // of viewpoint to render from Q_PROPERTY(glm::quat orientation MEMBER orientation NOTIFY dirty) // of viewpoint to render from public: glm::vec3 position{}; glm::quat orientation{}; - BeginSelfieFrameConfig() : render::Task::Config(false) {} + BeginSecondaryCameraFrameConfig() : render::Task::Config(false) {} signals: void dirty(); }; -class SelfieRenderTaskConfig : public render::Task::Config { +class SecondaryCameraRenderTaskConfig : public render::Task::Config { Q_OBJECT public: - SelfieRenderTaskConfig() : render::Task::Config(false) {} + SecondaryCameraRenderTaskConfig() : render::Task::Config(false) {} signals: void dirty(); public slots: void resetSize(int width, int height); }; -class SelfieRenderTask { +class SecondaryCameraRenderTask { public: - using Config = SelfieRenderTaskConfig; - using JobModel = render::Task::Model; - SelfieRenderTask() {} + using Config = SecondaryCameraRenderTaskConfig; + using JobModel = render::Task::Model; + SecondaryCameraRenderTask() {} void configure(const Config& config) {} void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor); }; diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 0a291a79ec..f64b917520 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -50,7 +50,7 @@ Q_LOGGING_CATEGORY(trace_resource_parse_image_ktx, "trace.resource.parse.image.k const std::string TextureCache::KTX_DIRNAME { "ktx_cache" }; const std::string TextureCache::KTX_EXT { "ktx" }; -const std::string TextureCache::SELFIE_FRAME_URL { "http://selfieFrame" }; +const std::string TextureCache::SECONDARY_CAMERA_FRAME_URL { "http://secondaryCameraFrame" }; static const float SKYBOX_LOAD_PRIORITY { 10.0f }; // Make sure skybox loads first static const float HIGH_MIPS_LOAD_PRIORITY { 9.0f }; // Make sure high mips loads after skybox but before models @@ -182,9 +182,9 @@ ScriptableResource* TextureCache::prefetch(const QUrl& url, int type, int maxNum } NetworkTexturePointer TextureCache::getTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels) { - if (url == QUrl(SELFIE_FRAME_URL.c_str())) { + if (url == QUrl(SECONDARY_CAMERA_FRAME_URL.c_str())) { - return getSelfieNetworkTexture(); + return getSecondaryCameraNetworkTexture(); } TextureExtra extra = { type, content, maxNumPixels }; return ResourceCache::getResource(url, QUrl(), &extra).staticCast(); @@ -885,31 +885,31 @@ void ImageReader::read() { } -NetworkTexturePointer TextureCache::getSelfieNetworkTexture() { - if (!_selfieNetworkTexture) { - _selfieNetworkTexture.reset(new NetworkTexture(QUrl(SELFIE_FRAME_URL.c_str()))); - auto texture = getSelfieTexture(); - _selfieNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight()); +NetworkTexturePointer TextureCache::getSecondaryCameraNetworkTexture() { + if (!_secondaryCameraNetworkTexture) { + _secondaryCameraNetworkTexture.reset(new NetworkTexture(QUrl(SECONDARY_CAMERA_FRAME_URL.c_str()))); + auto texture = getSecondaryCameraTexture(); + _secondaryCameraNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight()); } - return _selfieNetworkTexture; + return _secondaryCameraNetworkTexture; } -const gpu::TexturePointer& TextureCache::getSelfieTexture() { - if (!_selfieTexture) { - getSelfieFramebuffer(); +const gpu::TexturePointer& TextureCache::getSecondaryCameraTexture() { + if (!_secondaryCameraTexture) { + getSecondaryCameraFramebuffer(); } - return _selfieTexture; + return _secondaryCameraTexture; } -const gpu::FramebufferPointer& TextureCache::getSelfieFramebuffer() { - if (!_selfieFramebuffer) { - resetSelfieFramebuffer(2048, 1024); +const gpu::FramebufferPointer& TextureCache::getSecondaryCameraFramebuffer() { + if (!_secondaryCameraFramebuffer) { + resetSecondaryCameraFramebuffer(2048, 1024); } - return _selfieFramebuffer; + return _secondaryCameraFramebuffer; } -void TextureCache::resetSelfieFramebuffer(int width, int height) { - _selfieFramebuffer.reset(gpu::Framebuffer::create("selfie", gpu::Element::COLOR_SRGBA_32, 2048, 1024)); - _selfieTexture = _selfieFramebuffer->getRenderBuffer(0); - _selfieNetworkTexture.reset(); -} \ No newline at end of file +void TextureCache::resetSecondaryCameraFramebuffer(int width, int height) { + _secondaryCameraFramebuffer.reset(gpu::Framebuffer::create("secondaryCamera", gpu::Element::COLOR_SRGBA_32, 2048, 1024)); + _secondaryCameraTexture = _secondaryCameraFramebuffer->getRenderBuffer(0); + _secondaryCameraNetworkTexture.reset(); +} diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index 698d37f38d..498a5ffb8f 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -170,11 +170,11 @@ public: gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture); - /// Selfie rendering targets. - NetworkTexturePointer getSelfieNetworkTexture(); - const gpu::TexturePointer& getSelfieTexture(); - const gpu::FramebufferPointer& getSelfieFramebuffer(); - void resetSelfieFramebuffer(int width, int height); + /// SecondaryCamera rendering targets. + NetworkTexturePointer getSecondaryCameraNetworkTexture(); + const gpu::TexturePointer& getSecondaryCameraTexture(); + const gpu::FramebufferPointer& getSecondaryCameraFramebuffer(); + void resetSecondaryCameraFramebuffer(int width, int height); protected: // Overload ResourceCache::prefetch to allow specifying texture type for loads @@ -193,7 +193,7 @@ private: static const std::string KTX_DIRNAME; static const std::string KTX_EXT; - static const std::string SELFIE_FRAME_URL; + static const std::string SECONDARY_CAMERA_FRAME_URL; KTXCache _ktxCache; // Map from image hashes to texture weak pointers @@ -207,9 +207,9 @@ private: gpu::TexturePointer _blackTexture; - gpu::FramebufferPointer _selfieFramebuffer; - gpu::TexturePointer _selfieTexture; - NetworkTexturePointer _selfieNetworkTexture; + gpu::FramebufferPointer _secondaryCameraFramebuffer; + gpu::TexturePointer _secondaryCameraTexture; + NetworkTexturePointer _secondaryCameraNetworkTexture; }; #endif // hifi_TextureCache_h diff --git a/scripts/system/spectatorCamera.js b/scripts/system/spectatorCamera.js index 44419d73ff..04aa2b8186 100644 --- a/scripts/system/spectatorCamera.js +++ b/scripts/system/spectatorCamera.js @@ -54,8 +54,8 @@ // The update function for the spectator camera. Modifies the camera's position // and orientation. // - var spectatorFrameRenderConfig = Render.getConfig("SelfieFrame"); - var beginSpectatorFrameRenderConfig = Render.getConfig("BeginSelfie"); + var spectatorFrameRenderConfig = Render.getConfig("SecondaryCameraFrame"); + var beginSpectatorFrameRenderConfig = Render.getConfig("BeginSecondaryCamera"); var viewFinderOverlay = false; var camera = false; var cameraIsDynamic = false; @@ -105,8 +105,7 @@ }, true); // Put an image3d overlay on the near face, as a viewFinder. viewFinderOverlay = Overlays.addOverlay("image3d", { - url: "http://selfieFrame", - //url: "http://1.bp.blogspot.com/-1GABEq__054/T03B00j_OII/AAAAAAAAAa8/jo55LcvEPHI/s1600/Winning.jpg", + url: "http://secondaryCameraFrame", parentID: camera, alpha: 1, position: inFrontOf(-0.25, cameraPosition, cameraRotation), @@ -141,7 +140,6 @@ } if (camera) { Entities.deleteEntity(camera); - print("ZACH FOX GOODBYE"); } if (viewFinderOverlay) { Overlays.deleteOverlay(viewFinderOverlay);