From 76589316dfef0f308355fc7a387ce6a4b20b7982 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 17 Oct 2017 10:24:05 +0200 Subject: [PATCH] Working debug script with multiple selection --- .../src/ui/overlays/ContextOverlayInterface.h | 2 +- .../utilities/render/debugOutline.js | 99 ++++++++++++++++++- .../developer/utilities/render/outline.qml | 4 +- 3 files changed, 101 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/overlays/ContextOverlayInterface.h b/interface/src/ui/overlays/ContextOverlayInterface.h index 2a96ea3d3e..28e3707f99 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.h +++ b/interface/src/ui/overlays/ContextOverlayInterface.h @@ -49,7 +49,7 @@ class ContextOverlayInterface : public QObject, public Dependency { public: enum { - MAX_HIGHLIGHT_COUNT = 4 + MAX_HIGHLIGHT_COUNT = 5 }; ContextOverlayInterface(); diff --git a/scripts/developer/utilities/render/debugOutline.js b/scripts/developer/utilities/render/debugOutline.js index e333ab5869..ac75197933 100644 --- a/scripts/developer/utilities/render/debugOutline.js +++ b/scripts/developer/utilities/render/debugOutline.js @@ -17,4 +17,101 @@ var window = new OverlayWindow({ width: 285, height: 370, }); -window.closed.connect(function() { Script.stop(); }); \ No newline at end of file +window.closed.connect(function() { Script.stop(); }); + +"use strict"; + +// Created by Sam Gondelman on 9/7/2017 +// Copyright 2017 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() { // BEGIN LOCAL_SCOPE + +var END_DIMENSIONS = { + x: 0.15, + y: 0.15, + z: 0.15 +}; +var COLOR = {red: 97, green: 247, blue: 255}; +var end = { + type: "sphere", + dimensions: END_DIMENSIONS, + color: COLOR, + ignoreRayIntersection: true, + alpha: 1.0, + visible: true +} + +var COLOR2 = {red: 247, green: 97, blue: 255}; +var end2 = { + type: "sphere", + dimensions: END_DIMENSIONS, + color: COLOR2, + ignoreRayIntersection: true, + alpha: 1.0, + visible: true +} + +var renderStates = [{name: "test", end: end}]; +var defaultRenderStates = [{name: "test", distance: 20.0, end: end2}]; + +var ray = LaserPointers.createLaserPointer({ + joint: "Mouse", + filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_AVATARS | RayPick.PICK_INVISIBLE | RayPick.PICK_NONCOLLIDABLE, + renderStates: renderStates, + defaultRenderStates: defaultRenderStates, + enabled: true +}); + +function cleanup() { + LaserPointers.removeLaserPointer(ray); +} +Script.scriptEnding.connect(cleanup); + +var prevID = 0; +var prevType = ""; +function update() { + // you have to do this repeatedly because there's a bug but I'll fix it + LaserPointers.setRenderState(ray, "test"); + + var result = LaserPointers.getPrevRayPickResult(ray); + var selectionName = "contextOverlayHighlightList" + var outlineGroupIndex = Render.getConfig("RenderMainView.OutlineEffect").group + + if (outlineGroupIndex>0) { + selectionName += outlineGroupIndex + } + + if (result.type != RayPick.INTERSECTED_NONE) { + if (result.objectID != prevID) { + if (prevID != 0) { + Selection.removeFromSelectedItemsList(selectionName, prevType, prevID) + } + + var typeName = "" + if (result.type == RayPick.INTERSECTED_ENTITY) { + typeName = "entity" + } else if (result.type == RayPick.INTERSECTED_OVERLAY) { + typeName = "overlay" + } else if (result.type == RayPick.INTERSECTED_AVATAR) { + typeName = "avatar" + } + + Selection.addToSelectedItemsList(selectionName, typeName, result.objectID) + //print("type: " + result.type + ", id: " + result.objectID); + + prevID = result.objectID; + prevType = typeName; + } + } else { + if (prevID != 0) { + Selection.removeFromSelectedItemsList(selectionName, prevType, prevID) + } + prevID = 0; + } +} +Script.update.connect(update); + +}()); // END LOCAL_SCOPE \ No newline at end of file diff --git a/scripts/developer/utilities/render/outline.qml b/scripts/developer/utilities/render/outline.qml index 1270c696d1..d62e3b8899 100644 --- a/scripts/developer/utilities/render/outline.qml +++ b/scripts/developer/utilities/render/outline.qml @@ -122,7 +122,7 @@ Item { label: "Unoccluded" integral: false config: root.drawConfig - property: "fillOpacityUnoccluded" + property: "unoccludedFillOpacity" max: 1.0 min: 0.0 width: 270 @@ -131,7 +131,7 @@ Item { label: "Occluded" integral: false config: root.drawConfig - property: "fillOpacityOccluded" + property: "occludedFillOpacity" max: 1.0 min: 0.0 width: 270