From fa7621896a8c317d41ed79f9e062c37f5ef6d5b4 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 20 May 2019 11:58:01 -0700 Subject: [PATCH 1/3] Add debug icon which shows on render items with transitions --- interface/src/Menu.cpp | 6 ++ interface/src/Menu.h | 1 + libraries/render/src/render/DrawStatus.cpp | 89 +++++++++++++++------- libraries/render/src/render/DrawStatus.h | 3 + 4 files changed, 70 insertions(+), 29 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 9341b2316c..524831a13e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -522,6 +522,12 @@ Menu::Menu() { addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ComputeBlendshapes, 0, true, DependencyManager::get().data(), SLOT(setComputeBlendshapes(bool))); + { + auto drawStatusConfig = qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DrawStatus"); + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::HighlightTransitions, 0, false, + drawStatusConfig, SLOT(setShowFade(bool))); + } + // Developer > Assets >>> // Menu item is not currently needed but code should be kept in case it proves useful again at some stage. //#define WANT_ASSET_MIGRATION diff --git a/interface/src/Menu.h b/interface/src/Menu.h index eeede178c7..7c462e4e74 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -228,6 +228,7 @@ namespace MenuOption { const QString NotificationSoundsTablet = "play_notification_sounds_tablet"; const QString ForceCoarsePicking = "Force Coarse Picking"; const QString ComputeBlendshapes = "Compute Blendshapes"; + const QString HighlightTransitions = "Highlight Transitions"; } #endif // hifi_Menu_h diff --git a/libraries/render/src/render/DrawStatus.cpp b/libraries/render/src/render/DrawStatus.cpp index 76ed5aa663..8ea79c74b1 100644 --- a/libraries/render/src/render/DrawStatus.cpp +++ b/libraries/render/src/render/DrawStatus.cpp @@ -26,7 +26,7 @@ using namespace render; void DrawStatusConfig::dirtyHelper() { - _isEnabled = showNetwork || showDisplay; + _isEnabled = showNetwork || showDisplay || showFade; emit dirty(); } @@ -79,6 +79,7 @@ const gpu::TexturePointer DrawStatus::getStatusIconMap() const { void DrawStatus::configure(const Config& config) { _showDisplay = config.showDisplay; _showNetwork = config.showNetwork; + _showFade = config.showFade; } void DrawStatus::run(const RenderContextPointer& renderContext, const Input& input) { @@ -96,40 +97,70 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const Input& inp int nbItems = 0; render::ItemBounds itemBounds; std::vector> itemStatus; - { - for (size_t i = 0; i < inItems.size(); ++i) { - const auto& item = inItems[i]; - if (!item.bound.isInvalid()) { - if (!item.bound.isNull()) { - itemBounds.emplace_back(render::ItemBound(item.id, item.bound)); - } else { - itemBounds.emplace_back(item.id, AABox(item.bound.getCorner(), 0.1f)); - } - auto& itemScene = scene->getItem(item.id); + for (size_t i = 0; i < inItems.size(); ++i) { + const auto& item = inItems[i]; + if (!item.bound.isInvalid()) { + if (!item.bound.isNull()) { + itemBounds.emplace_back(render::ItemBound(item.id, item.bound)); + } else { + itemBounds.emplace_back(item.id, AABox(item.bound.getCorner(), 0.1f)); + } - auto itemStatusPointer = itemScene.getStatus(); - if (itemStatusPointer) { - itemStatus.push_back(std::pair()); - // Query the current status values, this is where the statusGetter lambda get called - auto&& currentStatusValues = itemStatusPointer->getCurrentValues(); - int valueNum = 0; - for (int vec4Num = 0; vec4Num < NUM_STATUS_VEC4_PER_ITEM; vec4Num++) { - auto& value = (vec4Num ? itemStatus[nbItems].first : itemStatus[nbItems].second); - value = glm::ivec4(Item::Status::Value::INVALID.getPackedData()); - for (int component = 0; component < VEC4_LENGTH; component++) { - valueNum = vec4Num * VEC4_LENGTH + component; - if (valueNum < (int)currentStatusValues.size()) { - value[component] = currentStatusValues[valueNum].getPackedData(); + auto& itemScene = scene->getItem(item.id); + + if (_showNetwork || _showFade) { + const static auto invalid = glm::ivec4(Item::Status::Value::INVALID.getPackedData()); + itemStatus.emplace_back(invalid, invalid); + int vec4Num = 0; + int vec4Component = 0; + + if (_showNetwork) { + auto itemStatusPointer = itemScene.getStatus(); + if (itemStatusPointer) { + // Query the current status values, this is where the statusGetter lambda get called + auto&& currentStatusValues = itemStatusPointer->getCurrentValues(); + for (const auto& statusValue : currentStatusValues) { + if (vec4Num == NUM_STATUS_VEC4_PER_ITEM) { + // Ran out of space + break; + } + + auto& value = (vec4Num == 0 ? itemStatus[nbItems].first : itemStatus[nbItems].second); + value[vec4Component] = statusValue.getPackedData(); + + ++vec4Component; + if (vec4Component == VEC4_LENGTH) { + vec4Component = 0; + ++vec4Num; } } } - } else { - auto invalid = glm::ivec4(Item::Status::Value::INVALID.getPackedData()); - itemStatus.emplace_back(invalid, invalid); } - nbItems++; + + if (_showFade && vec4Num != NUM_STATUS_VEC4_PER_ITEM) { + auto& value = (vec4Num == 0 ? itemStatus[nbItems].first : itemStatus[nbItems].second); + + Item::Status::Value status; + status.setColor(Item::Status::Value::CYAN); + status.setIcon(3); // RenderItemStatusIcon::SIMULATION_OWNER (RenderableModelEntityItem.cpp) + if (itemScene.getTransitionId() != INVALID_INDEX) { + // We have a transition. Show this icon. + status.setScale(1.0f); + } else { + status.setScale(0.0f); + } + value[vec4Component] = status.getPackedData(); + + ++vec4Component; + if (vec4Component == VEC4_LENGTH) { + vec4Component = 0; + ++vec4Num; + } + } } + + nbItems++; } } @@ -169,7 +200,7 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const Input& inp batch.setPipeline(getDrawItemStatusPipeline()); - if (_showNetwork) { + if (_showNetwork || _showFade) { if (!_instanceBuffer) { _instanceBuffer = std::make_shared(); } diff --git a/libraries/render/src/render/DrawStatus.h b/libraries/render/src/render/DrawStatus.h index 2959ca59c5..6e0783f000 100644 --- a/libraries/render/src/render/DrawStatus.h +++ b/libraries/render/src/render/DrawStatus.h @@ -27,10 +27,12 @@ namespace render { bool showDisplay{ false }; bool showNetwork{ false }; + bool showFade{ false }; public slots: void setShowDisplay(bool enabled) { showDisplay = enabled; dirtyHelper(); } void setShowNetwork(bool enabled) { showNetwork = enabled; dirtyHelper(); } + void setShowFade(bool enabled) { showFade = enabled; dirtyHelper(); } signals: void dirty(); @@ -57,6 +59,7 @@ namespace render { protected: bool _showDisplay; // initialized by Config bool _showNetwork; // initialized by Config + bool _showFade; // initialized by Config gpu::Stream::FormatPointer _drawItemFormat; gpu::PipelinePointer _drawItemBoundsPipeline; From 5aff4d9f69c7dfc5fcc1fde2f8191ed89ab96b8f Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 20 May 2019 11:58:55 -0700 Subject: [PATCH 2/3] Update comment on render item status --- libraries/entities-renderer/src/RenderableEntityItem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index fb6fbad2ac..659bdb215f 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -32,8 +32,8 @@ using namespace render; using namespace render::entities; -// These or the icon "name" used by the render item status value, they correspond to the atlas texture used by the DrawItemStatus -// job in the current rendering pipeline defined as of now (11/2015) in render-utils/RenderDeferredTask.cpp. +// These or the icon "name" used by the render item status value, they correspond to the atlas texture used by the DrawStatus +// job in the current rendering pipeline defined as of now (2019/05) in render-utils/RenderDeferredTask.cpp. enum class RenderItemStatusIcon { ACTIVE_IN_BULLET = 0, PACKET_SENT = 1, From 03a8e77ade43c6172b41c36f868f997adaba1eb1 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 20 May 2019 12:07:41 -0700 Subject: [PATCH 3/3] Move RenderItemStatusIcon to Item.h --- .../src/RenderableEntityItem.cpp | 39 +++++++------------ libraries/render/src/render/DrawStatus.cpp | 2 +- libraries/render/src/render/Item.h | 11 ++++++ 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index 659bdb215f..01d31856e0 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -32,19 +32,6 @@ using namespace render; using namespace render::entities; -// These or the icon "name" used by the render item status value, they correspond to the atlas texture used by the DrawStatus -// job in the current rendering pipeline defined as of now (2019/05) in render-utils/RenderDeferredTask.cpp. -enum class RenderItemStatusIcon { - ACTIVE_IN_BULLET = 0, - PACKET_SENT = 1, - PACKET_RECEIVED = 2, - SIMULATION_OWNER = 3, - HAS_ACTIONS = 4, - OTHER_SIMULATION_OWNER = 5, - ENTITY_HOST_TYPE = 6, - NONE = 255 -}; - void EntityRenderer::initEntityRenderers() { REGISTER_ENTITY_TYPE_WITH_FACTORY(Model, RenderableModelEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(PolyVox, RenderablePolyVoxEntityItem::factory) @@ -67,7 +54,7 @@ void EntityRenderer::makeStatusGetters(const EntityItemPointer& entity, Item::St return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ? render::Item::Status::Value::GREEN : render::Item::Status::Value::RED), - (unsigned char)RenderItemStatusIcon::PACKET_RECEIVED); + (unsigned char)render::Item::Status::Icon::PACKET_RECEIVED); }); statusGetters.push_back([entity] () -> render::Item::Status::Value { @@ -79,17 +66,17 @@ void EntityRenderer::makeStatusGetters(const EntityItemPointer& entity, Item::St return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ? render::Item::Status::Value::MAGENTA : render::Item::Status::Value::CYAN), - (unsigned char)RenderItemStatusIcon::PACKET_SENT); + (unsigned char)render::Item::Status::Icon::PACKET_SENT); }); statusGetters.push_back([entity] () -> render::Item::Status::Value { ObjectMotionState* motionState = static_cast(entity->getPhysicsInfo()); if (motionState && motionState->isActive()) { return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE, - (unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET); + (unsigned char)render::Item::Status::Icon::ACTIVE_IN_BULLET); } return render::Item::Status::Value(0.0f, render::Item::Status::Value::BLUE, - (unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET); + (unsigned char)render::Item::Status::Icon::ACTIVE_IN_BULLET); }); statusGetters.push_back([entity, myNodeID] () -> render::Item::Status::Value { @@ -98,39 +85,39 @@ void EntityRenderer::makeStatusGetters(const EntityItemPointer& entity, Item::St if (weOwnSimulation) { return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE, - (unsigned char)RenderItemStatusIcon::SIMULATION_OWNER); + (unsigned char)render::Item::Status::Icon::SIMULATION_OWNER); } else if (otherOwnSimulation) { return render::Item::Status::Value(1.0f, render::Item::Status::Value::RED, - (unsigned char)RenderItemStatusIcon::OTHER_SIMULATION_OWNER); + (unsigned char)render::Item::Status::Icon::OTHER_SIMULATION_OWNER); } return render::Item::Status::Value(0.0f, render::Item::Status::Value::BLUE, - (unsigned char)RenderItemStatusIcon::SIMULATION_OWNER); + (unsigned char)render::Item::Status::Icon::SIMULATION_OWNER); }); statusGetters.push_back([entity] () -> render::Item::Status::Value { if (entity->hasActions()) { return render::Item::Status::Value(1.0f, render::Item::Status::Value::GREEN, - (unsigned char)RenderItemStatusIcon::HAS_ACTIONS); + (unsigned char)render::Item::Status::Icon::HAS_ACTIONS); } return render::Item::Status::Value(0.0f, render::Item::Status::Value::GREEN, - (unsigned char)RenderItemStatusIcon::HAS_ACTIONS); + (unsigned char)render::Item::Status::Icon::HAS_ACTIONS); }); statusGetters.push_back([entity, myNodeID] () -> render::Item::Status::Value { if (entity->isAvatarEntity()) { if (entity->getOwningAvatarID() == myNodeID) { return render::Item::Status::Value(1.0f, render::Item::Status::Value::GREEN, - (unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE); + (unsigned char)render::Item::Status::Icon::ENTITY_HOST_TYPE); } else { return render::Item::Status::Value(1.0f, render::Item::Status::Value::RED, - (unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE); + (unsigned char)render::Item::Status::Icon::ENTITY_HOST_TYPE); } } else if (entity->isLocalEntity()) { return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE, - (unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE); + (unsigned char)render::Item::Status::Icon::ENTITY_HOST_TYPE); } return render::Item::Status::Value(0.0f, render::Item::Status::Value::GREEN, - (unsigned char)RenderItemStatusIcon::ENTITY_HOST_TYPE); + (unsigned char)render::Item::Status::Icon::ENTITY_HOST_TYPE); }); } diff --git a/libraries/render/src/render/DrawStatus.cpp b/libraries/render/src/render/DrawStatus.cpp index 8ea79c74b1..0484c0c125 100644 --- a/libraries/render/src/render/DrawStatus.cpp +++ b/libraries/render/src/render/DrawStatus.cpp @@ -143,7 +143,7 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const Input& inp Item::Status::Value status; status.setColor(Item::Status::Value::CYAN); - status.setIcon(3); // RenderItemStatusIcon::SIMULATION_OWNER (RenderableModelEntityItem.cpp) + status.setIcon((unsigned char)Item::Status::Icon::SIMULATION_OWNER); if (itemScene.getTransitionId() != INVALID_INDEX) { // We have a transition. Show this icon. status.setScale(1.0f); diff --git a/libraries/render/src/render/Item.h b/libraries/render/src/render/Item.h index 79557e3e44..d5d3e6942a 100644 --- a/libraries/render/src/render/Item.h +++ b/libraries/render/src/render/Item.h @@ -354,6 +354,17 @@ public: // This is Used for monitoring and dynamically adjust the quality class Status { public: + + enum class Icon { + ACTIVE_IN_BULLET = 0, + PACKET_SENT = 1, + PACKET_RECEIVED = 2, + SIMULATION_OWNER = 3, + HAS_ACTIONS = 4, + OTHER_SIMULATION_OWNER = 5, + ENTITY_HOST_TYPE = 6, + NONE = 255 + }; // Status::Value class is the data used to represent the transient information of a status as a square icon // The "icon" is a square displayed in the 3D scene over the render::Item AABB center.