diff --git a/interface/src/workload/GameWorkloadRenderer.cpp b/interface/src/workload/GameWorkloadRenderer.cpp index 09235d71ea..bb6aa35257 100644 --- a/interface/src/workload/GameWorkloadRenderer.cpp +++ b/interface/src/workload/GameWorkloadRenderer.cpp @@ -20,7 +20,7 @@ void GameSpaceToRender::configure(const Config& config) { - _showAllWorkspace = config.showAllWorkspace; + _showAllProxies = config.showAllProxies; } void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext, Outputs& outputs) { @@ -33,8 +33,9 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext, return; } - auto visible = _showAllWorkspace; + auto visible = _showAllProxies; render::Transaction transaction; + auto scene = gameWorkloadContext->_scene; // Nothing really needed, early exit if (!visible) { @@ -42,6 +43,7 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext, transaction.updateItem(_spaceRenderItemID, [](GameWorkloadRenderItem& item) { item.setVisible(false); }); + scene->enqueueTransaction(transaction); } return; } @@ -50,7 +52,6 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext, space->copyProxyValues(proxies.data(), (uint32_t)proxies.size()); - auto scene = gameWorkloadContext->_scene; // Valid space, let's display its content if (!render::Item::isValidID(_spaceRenderItemID)) { @@ -71,11 +72,7 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext, namespace render { template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload) { - auto key = ItemKey::Builder::opaqueShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1); - if (!payload->isVisible()) { - key.withInvisible(); - } - return key; + return payload->getKey(); } template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload) { if (payload) { @@ -97,6 +94,21 @@ namespace render { } +GameWorkloadRenderItem::GameWorkloadRenderItem() : _key(render::ItemKey::Builder::opaqueShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1)) { +} + +render::ItemKey GameWorkloadRenderItem::getKey() const { + return _key; +} + +void GameWorkloadRenderItem::setVisible(bool isVisible) { + if (isVisible) { + _key = render::ItemKey::Builder(_key).withVisible(); + } else { + _key = render::ItemKey::Builder(_key).withInvisible(); + } +} + void GameWorkloadRenderItem::setAllProxies(const std::vector& proxies) { _myOwnProxies = proxies; static const uint32_t sizeOfProxy = sizeof(workload::Space::Proxy); diff --git a/interface/src/workload/GameWorkloadRenderer.h b/interface/src/workload/GameWorkloadRenderer.h index dd568eadec..dc0fb9f3a1 100644 --- a/interface/src/workload/GameWorkloadRenderer.h +++ b/interface/src/workload/GameWorkloadRenderer.h @@ -14,10 +14,10 @@ class GameSpaceToRenderConfig : public workload::Job::Config { Q_OBJECT - Q_PROPERTY(bool showAllWorkspace MEMBER showAllWorkspace NOTIFY dirty) + Q_PROPERTY(bool showAllProxies MEMBER showAllProxies NOTIFY dirty) public: - bool showAllWorkspace{ false }; + bool showAllProxies{ false }; signals: void dirty(); @@ -37,7 +37,7 @@ public: protected: render::ItemID _spaceRenderItemID{ render::Item::INVALID_ITEM_ID }; - bool _showAllWorkspace{ false }; + bool _showAllProxies{ false }; }; @@ -46,18 +46,19 @@ public: using Payload = render::Payload; using Pointer = Payload::DataPointer; - GameWorkloadRenderItem() {} + GameWorkloadRenderItem(); ~GameWorkloadRenderItem() {} void render(RenderArgs* args); render::Item::Bound& editBound() { _needUpdate = true; return _bound; } const render::Item::Bound& getBound() { return _bound; } - void setVisible(bool visible) { _isVisible = visible; } - bool isVisible() const { return _isVisible; } + void setVisible(bool visible); void setAllProxies(const std::vector& proxies); + render::ItemKey getKey() const; + protected: render::Item::Bound _bound; @@ -68,6 +69,7 @@ protected: gpu::PipelinePointer _drawAllProxiesPipeline; const gpu::PipelinePointer getPipeline(); + render::ItemKey _key; bool _needUpdate{ true }; bool _isVisible{ true }; }; diff --git a/libraries/render/src/render/Item.h b/libraries/render/src/render/Item.h index e4dcc7ee03..b8a3fbf0f8 100644 --- a/libraries/render/src/render/Item.h +++ b/libraries/render/src/render/Item.h @@ -122,6 +122,7 @@ public: Builder& withDynamic() { _flags.set(DYNAMIC); return (*this); } Builder& withDeformed() { _flags.set(DEFORMED); return (*this); } Builder& withInvisible() { _flags.set(INVISIBLE); return (*this); } + Builder& withVisible() { _flags.reset(INVISIBLE); return (*this); } Builder& withShadowCaster() { _flags.set(SHADOW_CASTER); return (*this); } Builder& withLayered() { _flags.set(LAYERED); return (*this); } Builder& withMetaCullGroup() { _flags.set(META_CULL_GROUP); return (*this); } diff --git a/scripts/developer/utilities/workload/workload.js b/scripts/developer/utilities/workload/workload.js new file mode 100644 index 0000000000..10ca43821f --- /dev/null +++ b/scripts/developer/utilities/workload/workload.js @@ -0,0 +1,83 @@ +"use strict"; + +// +// Workload.js +// tablet-workload-engine app +// +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +(function() { + var TABLET_BUTTON_NAME = "Workload"; + var QMLAPP_URL = Script.resolvePath("./workload.qml"); + var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg"); + var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg"); + + + var onAppScreen = false; + + function onClicked() { + if (onAppScreen) { + tablet.gotoHomeScreen(); + } else { + tablet.loadQMLSource(QMLAPP_URL); + } + } + + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + var button = tablet.addButton({ + text: TABLET_BUTTON_NAME, + icon: ICON_URL, + activeIcon: ACTIVE_ICON_URL + }); + + var hasEventBridge = false; + + function wireEventBridge(on) { + if (!tablet) { + print("Warning in wireEventBridge(): 'tablet' undefined!"); + return; + } + if (on) { + if (!hasEventBridge) { + tablet.fromQml.connect(fromQml); + hasEventBridge = true; + } + } else { + if (hasEventBridge) { + tablet.fromQml.disconnect(fromQml); + hasEventBridge = false; + } + } + } + + function onScreenChanged(type, url) { + if (url === QMLAPP_URL) { + onAppScreen = true; + } else { + onAppScreen = false; + } + + button.editProperties({isActive: onAppScreen}); + wireEventBridge(onAppScreen); + } + + function fromQml(message) { + } + + button.clicked.connect(onClicked); + tablet.screenChanged.connect(onScreenChanged); + + Script.scriptEnding.connect(function () { + if (onAppScreen) { + tablet.gotoHomeScreen(); + } + button.clicked.disconnect(onClicked); + tablet.screenChanged.disconnect(onScreenChanged); + tablet.removeButton(button); + }); + +}()); \ No newline at end of file diff --git a/scripts/developer/utilities/workload/workload.qml b/scripts/developer/utilities/workload/workload.qml new file mode 100644 index 0000000000..e514e9b28a --- /dev/null +++ b/scripts/developer/utilities/workload/workload.qml @@ -0,0 +1,40 @@ +// +// workload.qml +// +// Created by Sam Gateau on 3/1/2018 +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.3 + +import "qrc:///qml/styles-uit" +import "qrc:///qml/controls-uit" as HifiControls +import "../render/configSlider" + +Rectangle { + HifiConstants { id: hifi;} + id: workload; + anchors.margins: hifi.dimensions.contentMargin.x + + color: hifi.colors.baseGray; + property var spaceToRender: Workload.getConfig("SpaceToRender") + + Column { + spacing: 5 + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: hifi.dimensions.contentMargin.x + //padding: hifi.dimensions.contentMargin.x + + HifiControls.CheckBox { + boxSize: 20 + text: "Show All Proxies" + checked: workload.spaceToRender["showAllProxies"] + onCheckedChanged: { workload.spaceToRender["showAllProxies"] = checked } + } + } +}