History

Merged with master

Olivier Prat committed 9 years ago

Commit fa58cf22 parents 6611b28 9ff454172 files · +2549 −1257Browse files

Showing the changes to scripts/developer (8 of 72 files). Show all

Unified · Split

8 files
  1. scripts/developer/debugging/debugWindow.js +11 −0
  2. scripts/developer/utilities/render/debugHighlight.js +160 −0
  3. scripts/developer/utilities/render/debugOutline.js +0 −20
  4. scripts/developer/utilities/render/highlight.qml +177 −0
  5. scripts/developer/utilities/render/highlightPage/HighlightPage.qml +116 −0
  6. scripts/developer/utilities/render/highlightPage/qmldir +1 −0
  7. scripts/developer/utilities/render/outline.qml +0 −119
  8. scripts/developer/utilities/render/statsGPU.qml +14 −0
scripts/developer/debugging/debugWindow.js+11−0
@@ -10,13 +10,24 @@ · 9 unmodified lines
1010
1111 (function() { // BEGIN LOCAL_SCOPE
1212
13+//check if script already running.
14+var scriptData = ScriptDiscoveryService.getRunning();
15+var scripts = scriptData.filter(function (datum) { return datum.name === 'debugWindow.js'; });
16+if (scripts.length >= 2) {
17+ //2nd instance of the script is too much
18+ ScriptDiscoveryService.stopScript(scripts[1].url);
19+ return;
20+}
21+
1322 // Set up the qml ui
1423 var qml = Script.resolvePath('debugWindow.qml');
24+
1525 var window = new OverlayWindow({
1626 title: 'Debug Window',
1727 source: qml,
1828 width: 400, height: 900,
1929 });
30+
2031 window.setPosition(25, 50);
2132 window.closed.connect(function() { Script.stop(); });
2233
scripts/developer/utilities/render/debugHighlight.js+160−0
@@ -0,0 +1,160 @@
1+//
2+// debugHighlight.js
3+// developer/utilities/render
4+//
5+// Olivier Prat, created on 08/08/2017.
6+// Copyright 2017 High Fidelity, Inc.
7+//
8+// Distributed under the Apache License, Version 2.0.
9+// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10+//
11+
12+// Set up the qml ui
13+var qml = Script.resolvePath('highlight.qml');
14+var window = new OverlayWindow({
15+ title: 'Highlight',
16+ source: qml,
17+ width: 400,
18+ height: 400,
19+});
20+window.closed.connect(function() { Script.stop(); });
21+
22+"use strict";
23+
24+// Created by Sam Gondelman on 9/7/2017
25+// Copyright 2017 High Fidelity, Inc.
26+//
27+// Distributed under the Apache License, Version 2.0.
28+// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
29+
30+(function() { // BEGIN LOCAL_SCOPE
31+
32+var END_DIMENSIONS = {
33+ x: 0.15,
34+ y: 0.15,
35+ z: 0.15
36+};
37+var COLOR = {red: 97, green: 247, blue: 255};
38+var end = {
39+ type: "sphere",
40+ dimensions: END_DIMENSIONS,
41+ color: COLOR,
42+ ignoreRayIntersection: true,
43+ alpha: 1.0,
44+ visible: true
45+}
46+
47+var COLOR2 = {red: 247, green: 97, blue: 255};
48+var end2 = {
49+ type: "sphere",
50+ dimensions: END_DIMENSIONS,
51+ color: COLOR2,
52+ ignoreRayIntersection: true,
53+ alpha: 1.0,
54+ visible: true
55+}
56+
57+var highlightGroupIndex = 0
58+var isSelectionAddEnabled = false
59+var isSelectionEnabled = false
60+var renderStates = [{name: "test", end: end}];
61+var defaultRenderStates = [{name: "test", distance: 20.0, end: end2}];
62+var time = 0
63+
64+var ray = LaserPointers.createLaserPointer({
65+ joint: "Mouse",
66+ filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_AVATARS | RayPick.PICK_INVISIBLE | RayPick.PICK_NONCOLLIDABLE,
67+ renderStates: renderStates,
68+ defaultRenderStates: defaultRenderStates,
69+ enabled: false
70+});
71+
72+function getSelectionName() {
73+ var selectionName = "contextOverlayHighlightList"
74+
75+ if (highlightGroupIndex>0) {
76+ selectionName += highlightGroupIndex
77+ }
78+ return selectionName
79+}
80+
81+function fromQml(message) {
82+ tokens = message.split(' ')
83+ print("Received '"+message+"' from hightlight.qml")
84+ if (tokens[0]=="highlight") {
85+ highlightGroupIndex = parseInt(tokens[1])
86+ print("Switching to highlight group "+highlightGroupIndex)
87+ } else if (tokens[0]=="pick") {
88+ isSelectionEnabled = tokens[1]=='true'
89+ print("Ray picking set to "+isSelectionEnabled.toString())
90+ if (isSelectionEnabled) {
91+ LaserPointers.enableLaserPointer(ray)
92+ } else {
93+ LaserPointers.disableLaserPointer(ray)
94+ }
95+ time = 0
96+ } else if (tokens[0]=="add") {
97+ isSelectionAddEnabled = tokens[1]=='true'
98+ print("Add to selection set to "+isSelectionAddEnabled.toString())
99+ if (!isSelectionAddEnabled) {
100+ Selection.clearSelectedItemsList(getSelectionName())
101+ }
102+ }
103+}
104+
105+window.fromQml.connect(fromQml);
106+
107+function cleanup() {
108+ LaserPointers.removeLaserPointer(ray);
109+}
110+Script.scriptEnding.connect(cleanup);
111+
112+var prevID = 0
113+var prevType = ""
114+var selectedID = 0
115+var selectedType = ""
116+function update(deltaTime) {
117+
118+ // you have to do this repeatedly because there's a bug but I'll fix it
119+ LaserPointers.setRenderState(ray, "test");
120+
121+ var result = LaserPointers.getPrevRayPickResult(ray);
122+ var selectionName = getSelectionName()
123+
124+ if (isSelectionEnabled && result.type != RayPick.INTERSECTED_NONE) {
125+ time += deltaTime
126+ if (result.objectID != prevID) {
127+ var typeName = ""
128+ if (result.type == RayPick.INTERSECTED_ENTITY) {
129+ typeName = "entity"
130+ } else if (result.type == RayPick.INTERSECTED_OVERLAY) {
131+ typeName = "overlay"
132+ } else if (result.type == RayPick.INTERSECTED_AVATAR) {
133+ typeName = "avatar"
134+ }
135+
136+ prevID = result.objectID;
137+ prevType = typeName;
138+ time = 0
139+ } else if (time>1.0 && prevID!=selectedID) {
140+ if (prevID != 0 && !isSelectionAddEnabled) {
141+ Selection.removeFromSelectedItemsList(selectionName, selectedType, selectedID)
142+ }
143+ selectedID = prevID
144+ selectedType = prevType
145+ Selection.addToSelectedItemsList(selectionName, selectedType, selectedID)
146+ print("HIGHLIGHT " + highlightGroupIndex + " picked type: " + result.type + ", id: " + result.objectID);
147+ }
148+ } else {
149+ if (prevID != 0 && !isSelectionAddEnabled) {
150+ Selection.removeFromSelectedItemsList(selectionName, prevType, prevID)
151+ }
152+ prevID = 0
153+ selectedID = 0
154+ time = 0
155+ }
156+}
157+
158+Script.update.connect(update);
159+
160+}()); // END LOCAL_SCOPE
scripts/developer/utilities/render/debugOutline.js+0−20
@@ -1,20 +0,0 @@
1−//
2−// debugOutline.js
3−// developer/utilities/render
4−//
5−// Olivier Prat, created on 08/08/2017.
6−// Copyright 2017 High Fidelity, Inc.
7−//
8−// Distributed under the Apache License, Version 2.0.
9−// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10−//
11−
12−// Set up the qml ui
13−var qml = Script.resolvePath('outline.qml');
14−var window = new OverlayWindow({
15− title: 'Outline',
16− source: qml,
17− width: 285,
18− height: 370,
19−});
20−window.closed.connect(function() { Script.stop(); });
scripts/developer/utilities/render/highlight.qml+177−0
@@ -0,0 +1,177 @@
1+//
2+// highlight.qml
3+// developer/utilities/render
4+//
5+// Olivier Prat, created on 08/08/2017.
6+// Copyright 2017 High Fidelity, Inc.
7+//
8+// Distributed under the Apache License, Version 2.0.
9+// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
10+//
11+import QtQuick 2.7
12+import QtQuick.Controls 1.4
13+import QtQuick.Layouts 1.3
14+
15+import "qrc:///qml/styles-uit"
16+import "qrc:///qml/controls-uit" as HifiControls
17+import "configSlider"
18+
19+Rectangle {
20+ id: root
21+ HifiConstants { id: hifi;}
22+ color: hifi.colors.baseGray;
23+ anchors.margins: hifi.dimensions.contentMargin.x
24+
25+ property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug")
26+ property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup")
27+
28+ signal sendToScript(var message);
29+
30+ Column {
31+ id: col
32+ spacing: 10
33+ anchors.left: parent.left
34+ anchors.right: parent.right
35+ anchors.margins: hifi.dimensions.contentMargin.x
36+
37+ Row {
38+ spacing: 10
39+ anchors.left: parent.left
40+ anchors.right: parent.right
41+
42+ HifiControls.CheckBox {
43+ id: debug
44+ text: "View Mask"
45+ checked: root.debugConfig["viewMask"]
46+ onCheckedChanged: {
47+ root.debugConfig["viewMask"] = checked;
48+ }
49+ }
50+ HifiControls.CheckBox {
51+ text: "Hover select"
52+ checked: false
53+ onCheckedChanged: {
54+ sendToScript("pick "+checked.toString())
55+ }
56+ }
57+ HifiControls.CheckBox {
58+ text: "Add to selection"
59+ checked: false
60+ onCheckedChanged: {
61+ sendToScript("add "+checked.toString())
62+ }
63+ }
64+ }
65+
66+ HifiControls.ComboBox {
67+ id: box
68+ width: 350
69+ z: 999
70+ editable: true
71+ colorScheme: hifi.colorSchemes.dark
72+ model: [
73+ "contextOverlayHighlightList",
74+ "highlightList1",
75+ "highlightList2",
76+ "highlightList3",
77+ "highlightList4"]
78+ label: ""
79+
80+ Timer {
81+ id: postpone
82+ interval: 100; running: false; repeat: false
83+ onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets }
84+ }
85+ onCurrentIndexChanged: {
86+ root.highlightConfig["selectionName"] = model[currentIndex];
87+ sendToScript("highlight "+currentIndex)
88+ // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component
89+ // by setting the loader source to Null and then recreate it 100ms later
90+ paramWidgetLoader.sourceComponent = undefined;
91+ postpone.interval = 100
92+ postpone.start()
93+ }
94+ }
95+
96+ Loader {
97+ id: paramWidgetLoader
98+ sourceComponent: paramWidgets
99+ width: 350
100+ }
101+
102+ Component {
103+ id: paramWidgets
104+
105+ Column {
106+ spacing: 10
107+ anchors.margins: hifi.dimensions.contentMargin.x
108+
109+ HifiControls.Label {
110+ text: "Outline"
111+ }
112+ Column {
113+ spacing: 10
114+ anchors.left: parent.left
115+ anchors.right: parent.right
116+ HifiControls.CheckBox {
117+ text: "Smooth"
118+ checked: root.highlightConfig["isOutlineSmooth"]
119+ onCheckedChanged: {
120+ root.highlightConfig["isOutlineSmooth"] = checked;
121+ }
122+ }
123+ Repeater {
124+ model: ["Width:outlineWidth:5.0:0.0",
125+ "Intensity:outlineIntensity:1.0:0.0"
126+ ]
127+ ConfigSlider {
128+ label: qsTr(modelData.split(":")[0])
129+ integral: false
130+ config: root.highlightConfig
131+ property: modelData.split(":")[1]
132+ max: modelData.split(":")[2]
133+ min: modelData.split(":")[3]
134+ }
135+ }
136+ }
137+
138+ Separator {}
139+ HifiControls.Label {
140+ text: "Color"
141+ }
142+ Repeater {
143+ model: ["Red:colorR:1.0:0.0",
144+ "Green:colorG:1.0:0.0",
145+ "Blue:colorB:1.0:0.0"
146+ ]
147+ ConfigSlider {
148+ label: qsTr(modelData.split(":")[0])
149+ integral: false
150+ config: root.highlightConfig
151+ property: modelData.split(":")[1]
152+ max: modelData.split(":")[2]
153+ min: modelData.split(":")[3]
154+ }
155+ }
156+
157+ Separator {}
158+ HifiControls.Label {
159+ text: "Fill Opacity"
160+ }
161+ Repeater {
162+ model: ["Unoccluded:unoccludedFillOpacity:1.0:0.0",
163+ "Occluded:occludedFillOpacity:1.0:0.0"
164+ ]
165+ ConfigSlider {
166+ label: qsTr(modelData.split(":")[0])
167+ integral: false
168+ config: root.highlightConfig
169+ property: modelData.split(":")[1]
170+ max: modelData.split(":")[2]
171+ min: modelData.split(":")[3]
172+ }
173+ }
174+ }
175+ }
176+ }
177+}
scripts/developer/utilities/render/highlightPage/HighlightPage.qml+116−0
@@ -0,0 +1,116 @@
1+//
2+// highlightPage.qml
3+// developer/utilities/render
4+//
5+// Olivier Prat, created on 08/08/2017.
6+// Copyright 2017 High Fidelity, Inc.
7+//
8+// Distributed under the Apache License, Version 2.0.
9+// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
10+//
11+import QtQuick 2.7
12+import QtQuick.Controls 1.4
13+import QtQuick.Layouts 1.3
14+import "../configSlider"
15+import "qrc:///qml/styles-uit"
16+import "qrc:///qml/controls-uit" as HifiControls
17+
18+Rectangle {
19+ id: root
20+ property var highlightIndex: 0
21+ property var drawConfig: Render.getConfig("RenderMainView.HighlightEffect"+highlightIndex)
22+
23+ HifiConstants { id: hifi;}
24+ anchors.margins: hifi.dimensions.contentMargin.x
25+
26+ Column {
27+ spacing: 5
28+ anchors.left: parent.left
29+ anchors.right: parent.right
30+ anchors.margins: hifi.dimensions.contentMargin.x
31+
32+ HifiControls.CheckBox {
33+ id: glow
34+ text: "Glow"
35+ checked: root.drawConfig["glow"]
36+ onCheckedChanged: {
37+ root.drawConfig["glow"] = checked;
38+ }
39+ }
40+ Repeater {
41+ model: ["Width:width:5.0:0.0",
42+ "Intensity:intensity:1.0:0.0"
43+ ]
44+ ConfigSlider {
45+ label: qsTr(modelData.split(":")[0])
46+ integral: false
47+ config: root.drawConfig
48+ property: modelData.split(":")[1]
49+ max: modelData.split(":")[2]
50+ min: modelData.split(":")[3]
51+
52+ anchors.left: parent.left
53+ anchors.right: parent.right
54+ }
55+ }
56+
57+ GroupBox {
58+ title: "Color"
59+ anchors.left: parent.left
60+ anchors.right: parent.right
61+ Column {
62+ spacing: 10
63+ anchors.left: parent.left
64+ anchors.right: parent.right
65+ anchors.margins: hifi.dimensions.contentMargin.x
66+
67+ Repeater {
68+ model: ["Red:colorR:1.0:0.0",
69+ "Green:colorG:1.0:0.0",
70+ "Blue:colorB:1.0:0.0"
71+ ]
72+ ConfigSlider {
73+ label: qsTr(modelData.split(":")[0])
74+ integral: false
75+ config: root.drawConfig
76+ property: modelData.split(":")[1]
77+ max: modelData.split(":")[2]
78+ min: modelData.split(":")[3]
79+
80+ anchors.left: parent.left
81+ anchors.right: parent.right
82+ }
83+ }
84+ }
85+ }
86+
87+ GroupBox {
88+ title: "Fill Opacity"
89+ anchors.left: parent.left
90+ anchors.right: parent.right
91+ Column {
92+ spacing: 10
93+ anchors.left: parent.left
94+ anchors.right: parent.right
95+ anchors.margins: hifi.dimensions.contentMargin.x
96+
97+ Repeater {
98+ model: ["Unoccluded:unoccludedFillOpacity:1.0:0.0",
99+ "Occluded:occludedFillOpacity:1.0:0.0"
100+ ]
101+ ConfigSlider {
102+ label: qsTr(modelData.split(":")[0])
103+ integral: false
104+ config: root.drawConfig
105+ property: modelData.split(":")[1]
106+ max: modelData.split(":")[2]
107+ min: modelData.split(":")[3]
108+
109+ anchors.left: parent.left
110+ anchors.right: parent.right
111+ }
112+ }
113+ }
114+ }
115+ }
116+}
scripts/developer/utilities/render/highlightPage/qmldir+1−0
@@ -0,0 +1 @@
1+HighlightPage 1.0 HighlightPage.qml
scripts/developer/utilities/render/outline.qml+0−119
@@ -1,119 +0,0 @@
1−//
2−// outline.qml
3−// developer/utilities/render
4−//
5−// Olivier Prat, created on 08/08/2017.
6−// Copyright 2017 High Fidelity, Inc.
7−//
8−// Distributed under the Apache License, Version 2.0.
9−// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
10−//
11−import QtQuick 2.5
12−import QtQuick.Controls 1.4
13−import "configSlider"
14−
15−Item {
16− id: root
17− property var debugConfig: Render.getConfig("RenderMainView.OutlineDebug")
18− property var drawConfig: Render.getConfig("RenderMainView.OutlineEffect")
19−
20− Column {
21− spacing: 8
22−
23− CheckBox {
24− text: "View Outlined Depth"
25− checked: root.debugConfig["viewOutlinedDepth"]
26− onCheckedChanged: {
27− root.debugConfig["viewOutlinedDepth"] = checked;
28− }
29− }
30− CheckBox {
31− text: "Glow"
32− checked: root.drawConfig["glow"]
33− onCheckedChanged: {
34− root.drawConfig["glow"] = checked;
35− }
36− }
37− ConfigSlider {
38− label: "Width"
39− integral: false
40− config: root.drawConfig
41− property: "width"
42− max: 15.0
43− min: 0.0
44− width: 280
45− }
46− ConfigSlider {
47− label: "Intensity"
48− integral: false
49− config: root.drawConfig
50− property: "intensity"
51− max: 1.0
52− min: 0.0
53− width: 280
54− }
55−
56− GroupBox {
57− title: "Color"
58− width: 280
59− Column {
60− spacing: 8
61−
62− ConfigSlider {
63− label: "Red"
64− integral: false
65− config: root.drawConfig
66− property: "colorR"
67− max: 1.0
68− min: 0.0
69− width: 270
70− }
71− ConfigSlider {
72− label: "Green"
73− integral: false
74− config: root.drawConfig
75− property: "colorG"
76− max: 1.0
77− min: 0.0
78− width: 270
79− }
80− ConfigSlider {
81− label: "Blue"
82− integral: false
83− config: root.drawConfig
84− property: "colorB"
85− max: 1.0
86− min: 0.0
87− width: 270
88− }
89− }
90− }
91−
92− GroupBox {
93− title: "Fill Opacity"
94− width: 280
95− Column {
96− spacing: 8
97−
98− ConfigSlider {
99− label: "Unoccluded"
100− integral: false
101− config: root.drawConfig
102− property: "fillOpacityUnoccluded"
103− max: 1.0
104− min: 0.0
105− width: 270
106− }
107− ConfigSlider {
108− label: "Occluded"
109− integral: false
110− config: root.drawConfig
111− property: "fillOpacityOccluded"
112− max: 1.0
113− min: 0.0
114− width: 270
115− }
116− }
117− }
118− }
119−}
scripts/developer/utilities/render/statsGPU.qml+14−0
@@ -65,6 +65,13 @@ Item { · 64 unmodified lines
6565 label: "tone and post",
6666 color: "#FF0000"
6767 }
68+ ,
69+ {
70+ object: Render.getConfig("RenderMainView.OutlineRangeTimer"),
71+ prop: "gpuRunTime",
72+ label: "outline",
73+ color: "#FFFF00"
74+ }
6875 ]
6976 }
7077 PlotPerf {
@@ -105,6 +112,13 @@ Item { · 34 unmodified lines
105112 label: "tone and post",
106113 color: "#FF0000"
107114 }
115+ ,
116+ {
117+ object: Render.getConfig("RenderMainView.OutlineRangeTimer"),
118+ prop: "batchRunTime",
119+ label: "outline",
120+ color: "#FFFF00"
121+ }
108122 ]
109123 }
110124 }