From 1147adae78fe036f01de349461ae06dcc8f2f37d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 26 Aug 2016 15:16:23 +1200 Subject: [PATCH 01/23] Add columns in entity list for render performance information --- .../entities/src/EntityItemProperties.cpp | 11 +++++ scripts/system/html/css/edit-style.css | 30 ++++++++++++-- scripts/system/html/entityList.html | 40 ++++++++++++++----- scripts/system/html/js/entityList.js | 32 +++++++++++---- scripts/system/libraries/entityList.js | 8 +++- 5 files changed, 97 insertions(+), 24 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 06c91b4f32..5fdb3ba2d1 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -580,6 +580,17 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLIENT_ONLY, clientOnly); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID); + // Rendering info + if (!skipDefaults) { + QScriptValue renderInfo = engine->newObject(); + renderInfo.setProperty("verticesCount", QScriptValue(10)); + renderInfo.setProperty("texturesCount", QScriptValue(2)); + renderInfo.setProperty("texturesSize", QScriptValue(1024)); + renderInfo.setProperty("hasTransparent", QScriptValue(false)); + renderInfo.setProperty("drawCalls", QScriptValue(30)); + COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_NO_SKIP(renderInfo, renderInfo); // Gettable but not settable + } + properties.setProperty("clientOnly", convertScriptValue(engine, getClientOnly())); properties.setProperty("owningAvatarID", convertScriptValue(engine, getOwningAvatarID())); diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 8a6c7786bf..8ed044acbc 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -906,16 +906,38 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { } #col-type { - width: 16%; + width: 10%; } #col-name { - width: 34%; + width: 20%; } #col-url { - width: 34%; + width: 20%; } #col-locked, #col-visible { - width: 8%; + width: 4%; +} +#col-verticesCount { + width: 10%; +} +#col-texturesCount { + width: 10%; +} +#col-texturesSize { + width: 10%; +} +#col-hasTransparent { + width: 4%; +} +#col-drawCalls { + width: 10%; +} +#col-hasScript { + width: 4%; +} + +.verticesCount, .texturesCount, .texturesSize, .drawCalls { + text-align: right; } #entity-table thead tr, #entity-table thead tr th, diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index b19a55b5a2..16598c1ae1 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -37,19 +37,31 @@
- - - - - + + + + + + + + + + + - - - - - + + + + + + + + + + + @@ -59,12 +71,18 @@ + + + + + + - +
TypeNameFileTypeNameFileVTSTDS
URL
? ?
diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 8e5e190068..8dbef1247f 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -106,12 +106,18 @@ function loaded() { })); } - function addEntity(id, name, type, url, locked, visible) { + function addEntity(id, name, type, url, locked, visible, verticesCount, texturesCount, texturesSize, hasTransparent, + drawCalls, hasScript) { + var urlParts = url.split('/'); var filename = urlParts[urlParts.length - 1]; if (entities[id] === undefined) { - entityList.add([{ id: id, name: name, type: type, url: filename, locked: locked, visible: visible }], + entityList.add([{ + id: id, name: name, type: type, url: filename, locked: locked, visible: visible, verticesCount: verticesCount, + texturesCount: texturesCount, texturesSize: texturesSize, hasTransparent: hasTransparent, + drawCalls: drawCalls, hasScript: hasScript + }], function (items) { var currentElement = items[0].elm; var id = items[0]._values.id; @@ -264,7 +270,11 @@ function loaded() { var id = newEntities[i].id; addEntity(id, newEntities[i].name, newEntities[i].type, newEntities[i].url, newEntities[i].locked ? LOCKED_GLYPH : null, - newEntities[i].visible ? VISIBLE_GLYPH : null); + newEntities[i].visible ? VISIBLE_GLYPH : null, + newEntities[i].verticesCount, newEntities[i].texturesCount, newEntities[i].texturesSize, + newEntities[i].hasTransparent ? "T" : null, + newEntities[i].drawCalls, + newEntities[i].hasScript ? "T" : null); } updateSelectedEntities(data.selectedIDs); resize(); @@ -288,11 +298,17 @@ function loaded() { } else { // Reasonable widths if nothing is displayed var tableWidth = document.getElementById("entity-table").offsetWidth; - ths[0].width = 0.16 * tableWidth; - ths[1].width = 0.34 * tableWidth; - ths[2].width = 0.34 * tableWidth; - ths[3].width = 0.08 * tableWidth; - ths[4].width = 0.08 * tableWidth; + ths[0].width = 0.10 * tableWidth; + ths[1].width = 0.20 * tableWidth; + ths[2].width = 0.20 * tableWidth; + ths[3].width = 0.04 * tableWidth; + ths[4].width = 0.04 * tableWidth; + ths[5].width = 0.10 * tableWidth; + ths[6].width = 0.10 * tableWidth; + ths[7].width = 0.10 * tableWidth; + ths[8].width = 0.04 * tableWidth; + ths[9].width = 0.10 * tableWidth; + ths[10].width = 0.04 * tableWidth; } }; diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 448293a2ac..2eeb64e85e 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -60,7 +60,13 @@ EntityListTool = function(opts) { type: properties.type, url: properties.type == "Model" ? properties.modelURL : "", locked: properties.locked, - visible: properties.visible + visible: properties.visible, + verticesCount: properties.renderInfo.verticesCount, + texturesCount: properties.renderInfo.texturesCount, + texturesSize:properties.renderInfo.texturesSize, + hasTransparent: properties.renderInfo.hasTransparent, + drawCalls: properties.renderInfo.drawCalls, + hasScript: properties.script !== "" }); } From 6de335e1b123bfe1580544fee20324a0aa725d1f Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 26 Aug 2016 17:24:25 +1200 Subject: [PATCH 02/23] Column heading text and glyphs --- scripts/system/html/css/edit-style.css | 4 ++-- scripts/system/html/entityList.html | 16 ++++++++-------- scripts/system/html/js/entityList.js | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 8ed044acbc..6405e9ef6c 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -863,7 +863,7 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { #entity-list .glyph { font-family: HiFi-Glyphs; - font-size: 14px; + font-size: 15px; } #search-area { @@ -1124,4 +1124,4 @@ input#reset-to-natural-dimensions { margin-top:5px; font-size:16px; display:none; -} \ No newline at end of file +} diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index 16598c1ae1..db4e7b04d4 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -56,12 +56,12 @@ File - V - T - S - T - D - S + Verts + Texts + T Size + ' + Draws + Q @@ -74,9 +74,9 @@ - + - + ID diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 8dbef1247f..ba21825058 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -16,6 +16,8 @@ const ASCENDING_STRING = '▾'; const DESCENDING_STRING = '▴'; const LOCKED_GLYPH = ""; const VISIBLE_GLYPH = ""; +const TRANSPARENCY_GLYPH = "'"; +const SCRIPT_GLYPH = "Q"; const DELETE = 46; // Key code for the delete key. const MAX_ITEMS = Number.MAX_VALUE; // Used to set the max length of the list of discovered entities. @@ -272,9 +274,9 @@ function loaded() { newEntities[i].locked ? LOCKED_GLYPH : null, newEntities[i].visible ? VISIBLE_GLYPH : null, newEntities[i].verticesCount, newEntities[i].texturesCount, newEntities[i].texturesSize, - newEntities[i].hasTransparent ? "T" : null, + newEntities[i].hasTransparent ? TRANSPARENCY_GLYPH : null, newEntities[i].drawCalls, - newEntities[i].hasScript ? "T" : null); + newEntities[i].hasScript ? SCRIPT_GLYPH : null); } updateSelectedEntities(data.selectedIDs); resize(); From f55d1f7ce75e605c94e5258c51cee5b6e8f0bf53 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 26 Aug 2016 17:56:23 +1200 Subject: [PATCH 03/23] Make new columns sortable --- scripts/system/html/entityList.html | 12 ++++++------ scripts/system/html/js/entityList.js | 28 ++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index db4e7b04d4..8de77dc707 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -56,12 +56,12 @@ File - Verts - Texts - T Size - ' - Draws - Q + Verts + Texts + T Size + ' + Draws + Q diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index ba21825058..bc3d5d75bc 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -57,7 +57,25 @@ function loaded() { document.getElementById("entity-visible").onclick = function () { setSortColumn('visible'); }; - + document.getElementById("entity-verticesCount").onclick = function () { + setSortColumn('verticesCount'); + }; + document.getElementById("entity-texturesCount").onclick = function () { + setSortColumn('texturesCount'); + }; + document.getElementById("entity-texturesSize").onclick = function () { + setSortColumn('texturesSize'); + }; + document.getElementById("entity-hasTransparent").onclick = function () { + setSortColumn('hasTransparent'); + }; + document.getElementById("entity-drawCalls").onclick = function () { + setSortColumn('drawCalls'); + }; + document.getElementById("entity-hasScript").onclick = function () { + setSortColumn('hasScript'); + }; + function onRowClicked(clickEvent) { var id = this.dataset.entityId; var selection = [this.dataset.entityId]; @@ -156,7 +174,13 @@ function loaded() { type: document.querySelector('#entity-type .sort-order'), url: document.querySelector('#entity-url .sort-order'), locked: document.querySelector('#entity-locked .sort-order'), - visible: document.querySelector('#entity-visible .sort-order') + visible: document.querySelector('#entity-visible .sort-order'), + verticesCount: document.querySelector('#entity-verticesCount .sort-order'), + texturesCount: document.querySelector('#entity-texturesCount .sort-order'), + texturesSize: document.querySelector('#entity-texturesSize .sort-order'), + hasTransparent: document.querySelector('#entity-hasTransparent .sort-order'), + drawCalls: document.querySelector('#entity-drawCalls .sort-order'), + hasScript: document.querySelector('#entity-hasScript .sort-order'), } function setSortColumn(column) { if (currentSortColumn == column) { From a0691a581cb5c732c1b64edfa686476e11fc87f3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 26 Aug 2016 18:18:52 +1200 Subject: [PATCH 04/23] Fix sense of column sort order indicators --- scripts/system/html/js/entityList.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index bc3d5d75bc..35a0ed199f 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -12,8 +12,8 @@ var currentSortColumn = 'type'; var currentSortOrder = 'des'; var entityList = null; var refreshEntityListTimer = null; -const ASCENDING_STRING = '▾'; -const DESCENDING_STRING = '▴'; +const ASCENDING_STRING = '▴'; +const DESCENDING_STRING = '▾'; const LOCKED_GLYPH = ""; const VISIBLE_GLYPH = ""; const TRANSPARENCY_GLYPH = "'"; From 0d1daecf1281a0eff8dae3805064c2581e582ec9 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 27 Aug 2016 12:13:34 +1200 Subject: [PATCH 05/23] Provide count of textures for entity items --- libraries/entities/src/EntityItemProperties.cpp | 16 +++++++++++----- scripts/system/libraries/entityList.js | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 5fdb3ba2d1..a7e6ba1261 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -582,12 +582,18 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool // Rendering info if (!skipDefaults) { + /* + renderInfo.setProperty("verticesCount", QScriptValue(randIntInRange(6, 1000))); + renderInfo.setProperty("texturesCount", QScriptValue(randIntInRange(0, 10))); + renderInfo.setProperty("texturesSize", QScriptValue(randIntInRange(0, 2048))); + renderInfo.setProperty("hasTransparent", QScriptValue(randIntInRange(0, 1))); + renderInfo.setProperty("drawCalls", QScriptValue(randIntInRange(10, 5000))); + */ + QScriptValue renderInfo = engine->newObject(); - renderInfo.setProperty("verticesCount", QScriptValue(10)); - renderInfo.setProperty("texturesCount", QScriptValue(2)); - renderInfo.setProperty("texturesSize", QScriptValue(1024)); - renderInfo.setProperty("hasTransparent", QScriptValue(false)); - renderInfo.setProperty("drawCalls", QScriptValue(30)); + if (_type == EntityTypes::Model || _type == EntityTypes::PolyLine || _type == EntityTypes::ParticleEffect) { + renderInfo.setProperty("texturesCount", QScriptValue(_textureNames.count())); + } COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_NO_SKIP(renderInfo, renderInfo); // Gettable but not settable } diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 2eeb64e85e..f719ff6d31 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -62,8 +62,8 @@ EntityListTool = function(opts) { locked: properties.locked, visible: properties.visible, verticesCount: properties.renderInfo.verticesCount, - texturesCount: properties.renderInfo.texturesCount, - texturesSize:properties.renderInfo.texturesSize, + texturesCount: properties.renderInfo.texturesCount ? properties.renderInfo.texturesCount : "", + texturesSize: properties.renderInfo.texturesSize ? properties.renderInfo.texturesSize : "", hasTransparent: properties.renderInfo.hasTransparent, drawCalls: properties.renderInfo.drawCalls, hasScript: properties.script !== "" From 17d30796cc8c4aa640fa8779d910d862a8d07fb0 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 3 Sep 2016 13:07:00 +1200 Subject: [PATCH 06/23] Use count of textures actually rendered Textures specified in model may be invalid and so not actually rendered. --- libraries/entities/src/EntityItemProperties.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 0e40278824..8169c2a802 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -590,11 +590,9 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool renderInfo.setProperty("texturesSize", (int)getRenderInfoTextureSize()); // FIXME - theoretically the size of textures could be > max int renderInfo.setProperty("hasTransparent", getRenderInfoHasTransparent()); renderInfo.setProperty("drawCalls", getRenderInfoDrawCalls()); + renderInfo.setProperty("texturesCount", getRenderInfoTextureCount()); } - if (_type == EntityTypes::Model || _type == EntityTypes::PolyLine || _type == EntityTypes::ParticleEffect) { - renderInfo.setProperty("texturesCount", QScriptValue(_textureNames.count())); - } COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_NO_SKIP(renderInfo, renderInfo); // Gettable but not settable } From c44bd902c3620c65313cd23a3a304bc24456b811 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 3 Sep 2016 13:07:40 +1200 Subject: [PATCH 07/23] Display render info values only if provided --- scripts/system/libraries/entityList.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index f719ff6d31..77e5a03216 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -48,6 +48,10 @@ EntityListTool = function(opts) { webView.emitScriptEvent(JSON.stringify(data)); }; + function valueIfDefined(value) { + return value !== undefined ? value : ""; + } + that.sendUpdate = function() { var entities = []; var ids = Entities.findEntities(MyAvatar.position, searchRadius); @@ -61,11 +65,11 @@ EntityListTool = function(opts) { url: properties.type == "Model" ? properties.modelURL : "", locked: properties.locked, visible: properties.visible, - verticesCount: properties.renderInfo.verticesCount, - texturesCount: properties.renderInfo.texturesCount ? properties.renderInfo.texturesCount : "", - texturesSize: properties.renderInfo.texturesSize ? properties.renderInfo.texturesSize : "", - hasTransparent: properties.renderInfo.hasTransparent, - drawCalls: properties.renderInfo.drawCalls, + verticesCount: valueIfDefined(properties.renderInfo.verticesCount), + texturesCount: valueIfDefined(properties.renderInfo.texturesCount), + texturesSize: valueIfDefined(properties.renderInfo.texturesSize), + hasTransparent: valueIfDefined(properties.renderInfo.hasTransparent), + drawCalls: valueIfDefined(properties.renderInfo.drawCalls), hasScript: properties.script !== "" }); } From 83593087b6357647f26eab68111b44bd71e1ef77 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 7 Sep 2016 11:08:06 +1200 Subject: [PATCH 08/23] Resize table headers after filter value changed --- scripts/system/html/js/entityList.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 35a0ed199f..cb55437b96 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -35,6 +35,7 @@ function loaded() { elToggleLocked = document.getElementById("locked"); elToggleVisible = document.getElementById("visible"); elDelete = document.getElementById("delete"); + elFilter = document.getElementById("filter"); elTeleport = document.getElementById("teleport"); elRadius = document.getElementById("radius"); elFooter = document.getElementById("footer-text"); @@ -203,7 +204,7 @@ function loaded() { function refreshEntityListObject() { refreshEntityListTimer = null; entityList.sort(currentSortColumn, { order: currentSortOrder }); - entityList.search(document.getElementById("filter").value); + entityList.search(elFilter.value); } function updateSelectedEntities(selectedEntities) { @@ -339,6 +340,7 @@ function loaded() { }; window.onresize = resize; + elFilter.onchange = resize; resize(); }); From 156866f835f3c45e5d6914c21783c93b76715eea Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 7 Sep 2016 11:12:04 +1200 Subject: [PATCH 09/23] Fix "has script" entities list icon --- scripts/system/html/css/edit-style.css | 4 ++++ scripts/system/html/entityList.html | 2 +- scripts/system/html/js/entityList.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 6405e9ef6c..a0e4bf0f82 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -977,6 +977,10 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { left: 0; } +#entity-table th#entity-hasScript .glyph { + text-transform: none; +} + #entity-table thead .sort-order { display: inline-block; width: 8px; diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index 8de77dc707..fc135aba42 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -61,7 +61,7 @@ T Size ' Draws - Q + k diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index cb55437b96..c83520b74d 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -17,7 +17,7 @@ const DESCENDING_STRING = '▾'; const LOCKED_GLYPH = ""; const VISIBLE_GLYPH = ""; const TRANSPARENCY_GLYPH = "'"; -const SCRIPT_GLYPH = "Q"; +const SCRIPT_GLYPH = "k"; const DELETE = 46; // Key code for the delete key. const MAX_ITEMS = Number.MAX_VALUE; // Used to set the max length of the list of discovered entities. From dba3efd85700d0d9c2b7cd620a86a8c1c42d3ffe Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 7 Sep 2016 15:04:27 +1200 Subject: [PATCH 10/23] Add expand/collapse extra info toggle icon to entities table header --- scripts/system/html/css/edit-style.css | 33 ++++++++++++++++++++------ scripts/system/html/entityList.html | 14 +++++------ scripts/system/html/js/entityList.js | 11 +++++---- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index a0e4bf0f82..62d9c13e16 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -918,10 +918,10 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { width: 4%; } #col-verticesCount { - width: 10%; + width: 8%; } #col-texturesCount { - width: 10%; + width: 8%; } #col-texturesSize { width: 10%; @@ -930,7 +930,7 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { width: 4%; } #col-drawCalls { - width: 10%; + width: 8%; } #col-hasScript { width: 4%; @@ -960,12 +960,18 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { top: 49px; left: 0; width: 100%; + word-wrap: nowrap; + white-space: nowrap; + overflow: hidden; } -#entity-table thead th { +#entity-table th { + display: inline-block; box-sizing: border-box; - padding: 0 0 0 8px; + padding: 5px 0 0 0; vertical-align: middle; + overflow: hidden; + text-overflow: ellipsis; } #entity-table th:focus { @@ -974,7 +980,15 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { #entity-table th .glyph { position: relative; - left: 0; + left: 4px; +} +#entity-table th .glyph + .sort-order { + position: relative; + left: 4px; +} + +#entity-table th#entity-hasScript { + overflow: visible; } #entity-table th#entity-hasScript .glyph { @@ -985,10 +999,15 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { display: inline-block; width: 8px; margin: -5px 0 -3px 0; - text-align: right; vertical-align: middle; } +#entity-table th #info-toggle { + position: absolute; + left: initial; + right: 4px; +} + #entity-table td { box-sizing: border-box; } diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index fc135aba42..ed9b98333d 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -61,23 +61,23 @@ T Size ' Draws - k + kD - Type - Name -
URL
- ? - ? + + +
+ + - ID + diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index c83520b74d..1fb0d1aa85 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -315,6 +315,7 @@ function loaded() { // Take up available window space elEntityTableScroll.style.height = window.innerHeight - 207; + var SCROLLABAR_WIDTH = 21; var tds = document.querySelectorAll("#entity-table-body tr:first-child td"); var ths = document.querySelectorAll("#entity-table thead th"); if (tds.length >= ths.length) { @@ -324,18 +325,18 @@ function loaded() { } } else { // Reasonable widths if nothing is displayed - var tableWidth = document.getElementById("entity-table").offsetWidth; + var tableWidth = document.getElementById("entity-table").offsetWidth - SCROLLABAR_WIDTH; ths[0].width = 0.10 * tableWidth; ths[1].width = 0.20 * tableWidth; ths[2].width = 0.20 * tableWidth; ths[3].width = 0.04 * tableWidth; ths[4].width = 0.04 * tableWidth; - ths[5].width = 0.10 * tableWidth; - ths[6].width = 0.10 * tableWidth; + ths[5].width = 0.08 * tableWidth; + ths[6].width = 0.08 * tableWidth; ths[7].width = 0.10 * tableWidth; ths[8].width = 0.04 * tableWidth; - ths[9].width = 0.10 * tableWidth; - ths[10].width = 0.04 * tableWidth; + ths[9].width = 0.08 * tableWidth; + ths[10].width = 0.04 * tableWidth + SCROLLABAR_WIDTH; } }; From b372f82f783a5eae0147e532a45371b53c313259 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 7 Sep 2016 17:09:56 +1200 Subject: [PATCH 11/23] Ensure that the expand/collapse icon is always visible --- scripts/system/html/css/edit-style.css | 15 +++++++++++---- scripts/system/html/entityList.html | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 62d9c13e16..78fcdca535 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -909,10 +909,10 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { width: 10%; } #col-name { - width: 20%; + width: 19%; } #col-url { - width: 20%; + width: 19%; } #col-locked, #col-visible { width: 4%; @@ -933,7 +933,7 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { width: 8%; } #col-hasScript { - width: 4%; + width: 6%; } .verticesCount, .texturesCount, .texturesSize, .drawCalls { @@ -1003,9 +1003,16 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { } #entity-table th #info-toggle { + display: inline-block; position: absolute; left: initial; - right: 4px; + right: 0; + width: 11px; + background-color: #1c1c1c; +} +#entity-table th #info-toggle span { + position: relative; + left: 0; } #entity-table td { diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index ed9b98333d..f4c2cfb282 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -61,7 +61,7 @@ T Size ' Draws - kD + kD From db30e36b3bdbe0d630162d6c7f2e58be6c37509b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 7 Sep 2016 19:11:53 +1200 Subject: [PATCH 12/23] Implement expand/collapse action to show/hide table columns --- scripts/system/html/css/edit-style.css | 121 +++++++++++++++++-------- scripts/system/html/entityList.html | 10 +- scripts/system/html/js/entityList.js | 56 +++++++++--- 3 files changed, 133 insertions(+), 54 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 78fcdca535..454bb682fe 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -894,8 +894,9 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { border-left: 2px solid #575757; border-right: 2px solid #575757; background-color: #1c1c1c; -} + height: 100px; +} #entity-table { margin-top: -28px; @@ -905,41 +906,6 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { background-color: #1c1c1c; } -#col-type { - width: 10%; -} -#col-name { - width: 19%; -} -#col-url { - width: 19%; -} -#col-locked, #col-visible { - width: 4%; -} -#col-verticesCount { - width: 8%; -} -#col-texturesCount { - width: 8%; -} -#col-texturesSize { - width: 10%; -} -#col-hasTransparent { - width: 4%; -} -#col-drawCalls { - width: 8%; -} -#col-hasScript { - width: 6%; -} - -.verticesCount, .texturesCount, .texturesSize, .drawCalls { - text-align: right; -} - #entity-table thead tr, #entity-table thead tr th, #entity-table tfoot tr, #entity-table tfoot tr td { background: none; @@ -965,6 +931,10 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { overflow: hidden; } +.verticesCount, .texturesCount, .texturesSize, .drawCalls { + text-align: right; +} + #entity-table th { display: inline-block; box-sizing: border-box; @@ -1009,10 +979,11 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { right: 0; width: 11px; background-color: #1c1c1c; + z-index: 100; } #entity-table th #info-toggle span { position: relative; - left: 0; + left: -2px; } #entity-table td { @@ -1036,6 +1007,82 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { width: 100%; } + +#col-type { + width: 16%; +} +#col-name { + width: 34%; +} +#col-url { + width: 34%; +} +#col-locked, #col-visible { + width: 9%; +} +#col-verticesCount, #col-texturesCount, #col-texturesSize, #col-hasTransparent, #col-drawCalls, #col-hasScript { + width: 0; +} + +.showExtraInfo #col-type { + width: 10%; +} +.showExtraInfo #col-name { + width: 19%; +} +.showExtraInfo #col-url { + width: 19%; +} +.showExtraInfo #col-locked, .showExtraInfo #col-visible { + width: 4%; +} +.showExtraInfo #col-verticesCount { + width: 8%; +} +.showExtraInfo #col-texturesCount { + width: 8%; +} +.showExtraInfo #col-texturesSize { + width: 10%; +} +.showExtraInfo #col-hasTransparent { + width: 4%; +} +.showExtraInfo #col-drawCalls { + width: 8%; +} +.showExtraInfo #col-hasScript { + width: 6%; +} + +th#entity-verticesCount, th#entity-texturesCount, th#entity-texturesSize, th#entity-hasTransparent, th#entity-drawCalls, +th#entity-hasScript { + display: none; +} + +.verticesCount, .texturesCount, .texturesSize, .hasTransparent, .drawCalls, .hasScript { + display: none; +} + +#entity-visible { + border: none; +} + +.showExtraInfo #entity-verticesCount, .showExtraInfo #entity-texturesCount, .showExtraInfo #entity-texturesSize, +.showExtraInfo #entity-hasTransparent, .showExtraInfo #entity-drawCalls, .showExtraInfo #entity-hasScript { + display: inline-block; +} + +.showExtraInfo .verticesCount, .showExtraInfo .texturesCount, .showExtraInfo .texturesSize, .showExtraInfo .hasTransparent, +.showExtraInfo .drawCalls, .showExtraInfo .hasScript { + display: table-cell; +} + +.showExtraInfo #entity-visible { + border-right: 1px solid #575757; +} + + #no-entities { display: none; position: absolute; diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index f4c2cfb282..af2e6e69bf 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -51,7 +51,7 @@ - Type + TypeD Name File @@ -61,7 +61,7 @@ T Size ' Draws - kD + k @@ -81,9 +81,9 @@ - - - + + +
diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 1fb0d1aa85..0c3f47c711 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -38,6 +38,9 @@ function loaded() { elFilter = document.getElementById("filter"); elTeleport = document.getElementById("teleport"); elRadius = document.getElementById("radius"); + elEntityTable = document.getElementById("entity-table"); + elInfoToggle = document.getElementById("info-toggle"); + elInfoToggleGlyph = elInfoToggle.firstChild; elFooter = document.getElementById("footer-text"); elNoEntitiesMessage = document.getElementById("no-entities"); elNoEntitiesRadius = document.getElementById("no-entities-radius"); @@ -274,7 +277,7 @@ function loaded() { refreshEntities(); elNoEntitiesRadius.firstChild.nodeValue = elRadius.value; } - + if (window.EventBridge !== undefined) { EventBridge.scriptEventReceived.connect(function(data) { data = JSON.parse(data); @@ -326,22 +329,51 @@ function loaded() { } else { // Reasonable widths if nothing is displayed var tableWidth = document.getElementById("entity-table").offsetWidth - SCROLLABAR_WIDTH; - ths[0].width = 0.10 * tableWidth; - ths[1].width = 0.20 * tableWidth; - ths[2].width = 0.20 * tableWidth; - ths[3].width = 0.04 * tableWidth; - ths[4].width = 0.04 * tableWidth; - ths[5].width = 0.08 * tableWidth; - ths[6].width = 0.08 * tableWidth; - ths[7].width = 0.10 * tableWidth; - ths[8].width = 0.04 * tableWidth; - ths[9].width = 0.08 * tableWidth; - ths[10].width = 0.04 * tableWidth + SCROLLABAR_WIDTH; + if (showExtraInfo) { + ths[0].width = 0.10 * tableWidth; + ths[1].width = 0.20 * tableWidth; + ths[2].width = 0.20 * tableWidth; + ths[3].width = 0.04 * tableWidth; + ths[4].width = 0.04 * tableWidth; + ths[5].width = 0.08 * tableWidth; + ths[6].width = 0.08 * tableWidth; + ths[7].width = 0.10 * tableWidth; + ths[8].width = 0.04 * tableWidth; + ths[9].width = 0.08 * tableWidth; + ths[10].width = 0.04 * tableWidth + SCROLLABAR_WIDTH; + } else { + ths[0].width = 0.16 * tableWidth; + ths[1].width = 0.34 * tableWidth; + ths[2].width = 0.34 * tableWidth; + ths[3].width = 0.08 * tableWidth; + ths[4].width = 0.08 * tableWidth; + } } }; window.onresize = resize; elFilter.onchange = resize; + + + var showExtraInfo = false; + var COLLAPSE_EXTRA_INFO = "E"; + var EXPAND_EXTRA_INFO = "D"; + + function toggleInfo(event) { + showExtraInfo = !showExtraInfo; + if (showExtraInfo) { + elEntityTable.className = "showExtraInfo"; + elInfoToggleGlyph.innerHTML = COLLAPSE_EXTRA_INFO; + } else { + elEntityTable.className = ""; + elInfoToggleGlyph.innerHTML = EXPAND_EXTRA_INFO; + } + resize(); + event.stopPropagation(); + } + elInfoToggle.addEventListener("click", toggleInfo, true); + + resize(); }); From a4b5f5395d4f2c815cd6b26fc006dcfd804b67c7 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 8 Sep 2016 12:56:41 +1200 Subject: [PATCH 13/23] Add "in view" button --- scripts/system/html/css/edit-style.css | 16 +++++++++++++--- scripts/system/html/entityList.html | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 454bb682fe..2c153df46c 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -867,7 +867,7 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { } #search-area { - padding-right: 148px; + padding-right: 168px; padding-bottom: 24px; } @@ -875,13 +875,23 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { width: 98%; } +#inView { + position: absolute; + right: 126px; +} + #radius-and-unit { float: right; - margin-right: -148px; + margin-right: -168px; position: relative; top: -17px; } - +#radius-and-unit label { + margin-left: 2px; +} +#radius-and-unit input { + width: 120px; +} #entity-table-scroll { /* Height is set by JavaScript. */ diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index af2e6e69bf..251eb0cb24 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -29,6 +29,7 @@
Y +
From 28cfca993f1f3d0050fc33e5f4efaca75759f010 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 8 Sep 2016 14:58:48 +1200 Subject: [PATCH 14/23] Add and wire up "search in view" JavaScript API stub --- .../entities/src/EntityScriptingInterface.cpp | 8 ++++++++ .../entities/src/EntityScriptingInterface.h | 4 ++++ scripts/system/html/css/edit-style.css | 16 ++++++++------- scripts/system/html/entityList.html | 4 ++-- scripts/system/html/js/entityList.js | 20 ++++++++++++++++++- scripts/system/libraries/entityList.js | 14 ++++++++++--- 6 files changed, 53 insertions(+), 13 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 2dca21ac73..d9b8dd997a 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -550,6 +550,14 @@ QVector EntityScriptingInterface::findEntities(const glm::vec3& center, f return result; } +QVector EntityScriptingInterface::findEntitiesInView(const glm::vec3& center, float radius) const { + QVector result; + + // TODO + + return result; +} + QVector EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const { QVector result; if (_entityTree) { diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index be9b1d27e7..0b9fb5383f 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -129,6 +129,10 @@ public slots: /// finds models within the search sphere specified by the center point and radius /// this function will not find any models in script engine contexts which don't have access to models + Q_INVOKABLE QVector findEntitiesInView(const glm::vec3& center, float radius) const; + + /// finds models within the box specified by the corner and dimensions + /// this function will not find any models in script engine contexts which don't have access to models Q_INVOKABLE QVector findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const; /// If the scripting context has visible entities, this will determine a ray intersection, the results diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 2c153df46c..b402d482f0 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -366,6 +366,10 @@ input[type=button]:disabled { background: linear-gradient(#575757 20%, #252525 100%); } +input[type=button][pressed=pressed] { + color: #00b4ef; +} + input[type=checkbox] { display: none; } @@ -861,11 +865,6 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { position: relative; /* New positioning context. */ } -#entity-list .glyph { - font-family: HiFi-Glyphs; - font-size: 15px; -} - #search-area { padding-right: 168px; padding-bottom: 24px; @@ -875,7 +874,7 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { width: 98%; } -#inView { +#in-view { position: absolute; right: 126px; } @@ -904,8 +903,11 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { border-left: 2px solid #575757; border-right: 2px solid #575757; background-color: #1c1c1c; +} - height: 100px; +#entity-table-scroll .glyph { + font-family: HiFi-Glyphs; + font-size: 15px; } #entity-table { diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index 251eb0cb24..6f2f3533a2 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -29,7 +29,7 @@
Y - +
@@ -88,7 +88,7 @@
- No entities found within a 100 meter radius. Try moving to a different location and refreshing. + No entities found in view within a 100 meter radius. Try moving to a different location and refreshing.
diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 0c3f47c711..b7787b41dd 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -36,13 +36,15 @@ function loaded() { elToggleVisible = document.getElementById("visible"); elDelete = document.getElementById("delete"); elFilter = document.getElementById("filter"); - elTeleport = document.getElementById("teleport"); + elInView = document.getElementById("in-view") elRadius = document.getElementById("radius"); + elTeleport = document.getElementById("teleport"); elEntityTable = document.getElementById("entity-table"); elInfoToggle = document.getElementById("info-toggle"); elInfoToggleGlyph = elInfoToggle.firstChild; elFooter = document.getElementById("footer-text"); elNoEntitiesMessage = document.getElementById("no-entities"); + elNoEntitiesInView = document.getElementById("no-entities-in-view"); elNoEntitiesRadius = document.getElementById("no-entities-radius"); elEntityTableScroll = document.getElementById("entity-table-scroll"); @@ -271,6 +273,22 @@ function loaded() { } }, false); + var isFilterInView = false; + var FILTER_IN_VIEW_ATTRIBUTE = "pressed"; + elNoEntitiesInView.style.display = "none"; + elInView.onclick = function () { + isFilterInView = !isFilterInView; + if (isFilterInView) { + elInView.setAttribute(FILTER_IN_VIEW_ATTRIBUTE, FILTER_IN_VIEW_ATTRIBUTE); + elNoEntitiesInView.style.display = "inline"; + } else { + elInView.removeAttribute(FILTER_IN_VIEW_ATTRIBUTE); + elNoEntitiesInView.style.display = "none"; + } + EventBridge.emitWebEvent(JSON.stringify({ type: "filterInView", filterInView: isFilterInView })); + refreshEntities(); + } + elRadius.onchange = function () { elRadius.value = Math.max(elRadius.value, 0); EventBridge.emitWebEvent(JSON.stringify({ type: 'radius', radius: elRadius.value })); diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 77e5a03216..7af4cd6c68 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -9,7 +9,7 @@ EntityListTool = function(opts) { }); - + var filterInView = false; var searchRadius = 100; var visible = false; @@ -54,7 +54,14 @@ EntityListTool = function(opts) { that.sendUpdate = function() { var entities = []; - var ids = Entities.findEntities(MyAvatar.position, searchRadius); + + var ids; + if (filterInView) { + ids = Entities.findEntitiesInView(MyAvatar.position, searchRadius); + } else { + ids = Entities.findEntities(MyAvatar.position, searchRadius); + } + for (var i = 0; i < ids.length; i++) { var id = ids[i]; var properties = Entities.getEntityProperties(id); @@ -115,9 +122,10 @@ EntityListTool = function(opts) { toggleSelectedEntitiesLocked(); } else if (data.type == "toggleVisible") { toggleSelectedEntitiesVisible(); + } else if (data.type === "filterInView") { + filterInView = data.filterInView === true; } else if (data.type === "radius") { searchRadius = data.radius; - that.sendUpdate(); } }); From ce58edc4e0edca0213ce3cf5031aacc515ccabca Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 9 Sep 2016 18:56:05 +1200 Subject: [PATCH 15/23] Add frustum property to JavaScript Camera object --- interface/src/Camera.cpp | 13 +++++++++++++ interface/src/Camera.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index 227bdadb97..f930424569 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -182,3 +182,16 @@ ViewFrustum Camera::toViewFrustum() const { loadViewFrustum(result); return result; } + +QVariantMap Camera::getViewFrustum() { + ViewFrustum frustum; + loadViewFrustum(frustum); + + QVariantMap result; + result["position"].setValue(frustum.getPosition()); + result["orientation"].setValue(frustum.getOrientation()); + result["projection"].setValue(frustum.getProjection()); + result["centerRadius"].setValue(frustum.getCenterRadius()); + + return result; +} diff --git a/interface/src/Camera.h b/interface/src/Camera.h index 46cad2efc8..792dcb4a40 100644 --- a/interface/src/Camera.h +++ b/interface/src/Camera.h @@ -42,6 +42,8 @@ class Camera : public QObject { Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation) Q_PROPERTY(QString mode READ getModeString WRITE setModeString) Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity) + Q_PROPERTY(QVariantMap frustum READ getViewFrustum CONSTANT) + public: Camera(); @@ -63,6 +65,8 @@ public: const glm::mat4& getProjection() const { return _projection; } void setProjection(const glm::mat4& projection); + QVariantMap getViewFrustum(); + public slots: QString getModeString() const; void setModeString(const QString& mode); From 38c2efa22fb92f134e1554b1432c20ea70d46fce Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 9 Sep 2016 18:57:48 +1200 Subject: [PATCH 16/23] Implement Entities.findInFrustum() method --- .../entities/src/EntityScriptingInterface.cpp | 51 ++++++++++++++++--- .../entities/src/EntityScriptingInterface.h | 13 +++-- libraries/entities/src/EntityTree.cpp | 25 +++++++++ libraries/entities/src/EntityTree.h | 6 +++ libraries/entities/src/EntityTreeElement.cpp | 11 ++++ libraries/entities/src/EntityTreeElement.h | 5 ++ libraries/shared/src/QVariantGLM.cpp | 45 ++++++++++++++++ libraries/shared/src/QVariantGLM.h | 4 ++ 8 files changed, 148 insertions(+), 12 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index d9b8dd997a..bfe291f8ef 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -21,6 +21,7 @@ #include "EntityTree.h" #include "LightEntityItem.h" #include "ModelEntityItem.h" +#include "QVariantGLM.h" #include "SimulationOwner.h" #include "ZoneEntityItem.h" @@ -550,14 +551,6 @@ QVector EntityScriptingInterface::findEntities(const glm::vec3& center, f return result; } -QVector EntityScriptingInterface::findEntitiesInView(const glm::vec3& center, float radius) const { - QVector result; - - // TODO - - return result; -} - QVector EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const { QVector result; if (_entityTree) { @@ -574,6 +567,48 @@ QVector EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corn return result; } +QVector EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frustum) const { + QVector result; + + const QString POSITION_PROPERTY = "position"; + bool positionOK = frustum.contains(POSITION_PROPERTY); + glm::vec3 position = positionOK ? qMapToGlmVec3(frustum[POSITION_PROPERTY]) : glm::vec3(); + + const QString ORIENTATION_PROPERTY = "orientation"; + bool orientationOK = frustum.contains(ORIENTATION_PROPERTY); + glm::quat orientation = orientationOK ? qMapToGlmQuat(frustum[ORIENTATION_PROPERTY]) : glm::quat(); + + const QString PROJECTION_PROPERTY = "projection"; + bool projectionOK = frustum.contains(PROJECTION_PROPERTY); + glm::mat4 projection = projectionOK ? qMapToGlmMat4(frustum[PROJECTION_PROPERTY]) : glm::mat4(); + + const QString CENTER_RADIUS_PROPERTY = "centerRadius"; + bool centerRadiusOK = frustum.contains(CENTER_RADIUS_PROPERTY); + float centerRadius = centerRadiusOK ? frustum[CENTER_RADIUS_PROPERTY].toFloat() : 0.0f; + + if (positionOK && orientationOK && projectionOK && centerRadiusOK) { + ViewFrustum viewFrustum; + viewFrustum.setPosition(position); + viewFrustum.setOrientation(orientation); + viewFrustum.setProjection(projection); + viewFrustum.setCenterRadius(centerRadius); + viewFrustum.calculate(); + + if (_entityTree) { + QVector entities; + _entityTree->withReadLock([&] { + _entityTree->findEntities(viewFrustum, entities); + }); + + foreach(EntityItemPointer entity, entities) { + result << entity->getEntityItemID(); + } + } + } + + return result; +} + RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking, const QScriptValue& entityIdsToInclude, const QScriptValue& entityIdsToDiscard) { diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 0b9fb5383f..03c2f772b5 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -127,14 +127,19 @@ public slots: /// this function will not find any models in script engine contexts which don't have access to models Q_INVOKABLE QVector findEntities(const glm::vec3& center, float radius) const; - /// finds models within the search sphere specified by the center point and radius - /// this function will not find any models in script engine contexts which don't have access to models - Q_INVOKABLE QVector findEntitiesInView(const glm::vec3& center, float radius) const; - /// finds models within the box specified by the corner and dimensions /// this function will not find any models in script engine contexts which don't have access to models Q_INVOKABLE QVector findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const; + /// finds models within the frustum + /// the frustum must have the following properties: + /// - position + /// - orientation + /// - projection + /// - centerRadius + /// this function will not find any models in script engine contexts which don't have access to models + Q_INVOKABLE QVector findEntitiesInFrustum(QVariantMap frustum) const; + /// If the scripting context has visible entities, this will determine a ray intersection, the results /// may be inaccurate if the engine is unable to access the visible entities, in which case result.accurate /// will be false. diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 4cdebc364c..89f469037e 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -688,6 +688,31 @@ void EntityTree::findEntities(const AABox& box, QVector& foun foundEntities.swap(args._foundEntities); } +class FindInFrustumArgs { +public: + ViewFrustum frustum; + QVector entities; +}; + +bool EntityTree::findInFrustumOperation(OctreeElementPointer element, void* extraData) { + FindInFrustumArgs* args = static_cast(extraData); + if (element->isInView(args->frustum)) { + EntityTreeElementPointer entityTreeElement = std::static_pointer_cast(element); + entityTreeElement->getEntities(args->frustum, args->entities); + return true; + } + return false; +} + +// NOTE: assumes caller has handled locking +void EntityTree::findEntities(const ViewFrustum& frustum, QVector& foundEntities) { + FindInFrustumArgs args = { frustum, QVector() }; + // NOTE: This should use recursion, since this is a spatial operation + recurseTreeWithOperation(findInFrustumOperation, &args); + // swap the two lists of entity pointers instead of copy + foundEntities.swap(args.entities); +} + EntityItemPointer EntityTree::findEntityByID(const QUuid& id) { EntityItemID entityID(id); return findEntityByEntityItemID(entityID); diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index 7dc999aac2..917b9333a5 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -153,6 +153,11 @@ public: /// \remark Side effect: any initial contents in entities will be lost void findEntities(const AABox& box, QVector& foundEntities); + /// finds all entities within a frustum + /// \parameter frustum the query frustum + /// \param foundEntities[out] vector of EntityItemPointer + void findEntities(const ViewFrustum& frustum, QVector& foundEntities); + void addNewlyCreatedHook(NewlyCreatedEntityHook* hook); void removeNewlyCreatedHook(NewlyCreatedEntityHook* hook); @@ -276,6 +281,7 @@ protected: static bool findInSphereOperation(OctreeElementPointer element, void* extraData); static bool findInCubeOperation(OctreeElementPointer element, void* extraData); static bool findInBoxOperation(OctreeElementPointer element, void* extraData); + static bool findInFrustumOperation(OctreeElementPointer element, void* extraData); static bool sendEntitiesOperation(OctreeElementPointer element, void* extraData); void notifyNewlyCreatedEntity(const EntityItem& newEntity, const SharedNodePointer& senderNode); diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index 657e0b286b..29274d2e72 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -796,6 +796,17 @@ void EntityTreeElement::getEntities(const AABox& box, QVector }); } +void EntityTreeElement::getEntities(const ViewFrustum& frustum, QVector& foundEntities) { + forEachEntity([&](EntityItemPointer entity) { + bool success; + AABox entityBox = entity->getAABox(success); + // FIXME - See FIXMEs for similar methods above. + if (!success || frustum.boxIntersectsFrustum(entityBox) || frustum.boxIntersectsKeyhole(entityBox)) { + foundEntities.push_back(entity); + } + }); +} + EntityItemPointer EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) const { EntityItemPointer foundEntity = NULL; withReadLock([&] { diff --git a/libraries/entities/src/EntityTreeElement.h b/libraries/entities/src/EntityTreeElement.h index 4875e258da..d92dfa52dc 100644 --- a/libraries/entities/src/EntityTreeElement.h +++ b/libraries/entities/src/EntityTreeElement.h @@ -194,6 +194,11 @@ public: /// \param entities[out] vector of non-const EntityItemPointer void getEntities(const AABox& box, QVector& foundEntities); + /// finds all entities that touch a frustum + /// \param frustum the query frustum + /// \param entities[out] vector of non-const EntityItemPointer + void getEntities(const ViewFrustum& frustum, QVector& foundEntities); + EntityItemPointer getEntityWithID(uint32_t id) const; EntityItemPointer getEntityWithEntityItemID(const EntityItemID& id) const; void getEntitiesInside(const AACube& box, QVector& foundEntities); diff --git a/libraries/shared/src/QVariantGLM.cpp b/libraries/shared/src/QVariantGLM.cpp index 7a3ab92cca..b5b840c2ca 100644 --- a/libraries/shared/src/QVariantGLM.cpp +++ b/libraries/shared/src/QVariantGLM.cpp @@ -62,3 +62,48 @@ void qListtoRgbColor(const QVariant& q, rgbColor& returnValue) { returnValue[GREEN_INDEX] = qList[GREEN_INDEX].toInt(); returnValue[BLUE_INDEX] = qList[BLUE_INDEX].toInt(); } + + +glm::vec3 qMapToGlmVec3(const QVariant& q) { + QVariantMap qMap = q.toMap(); + if (qMap.contains("x") && qMap.contains("y") && qMap.contains("y")) { + return glm::vec3( + qMap["x"].toFloat(), + qMap["y"].toFloat(), + qMap["z"].toFloat() + ); + } else { + return glm::vec3(); + } +} + +glm::quat qMapToGlmQuat(const QVariant& q) { + QVariantMap qMap = q.toMap(); + if (qMap.contains("w") && qMap.contains("x") && qMap.contains("y") && qMap.contains("z")) { + return glm::quat( + qMap["w"].toFloat(), + qMap["x"].toFloat(), + qMap["y"].toFloat(), + qMap["z"].toFloat() + ); + } else { + return glm::quat(); + } +} + +glm::mat4 qMapToGlmMat4(const QVariant& q) { + QVariantMap qMap = q.toMap(); + if (qMap.contains("r0c0") && qMap.contains("r1c0") && qMap.contains("r2c0") && qMap.contains("r3c0") + && qMap.contains("r0c1") && qMap.contains("r1c1") && qMap.contains("r2c1") && qMap.contains("r3c1") + && qMap.contains("r0c2") && qMap.contains("r1c2") && qMap.contains("r2c2") && qMap.contains("r3c2") + && qMap.contains("r0c3") && qMap.contains("r1c3") && qMap.contains("r2c3") && qMap.contains("r3c3")) { + return glm::mat4( + qMap["r0c0"].toFloat(), qMap["r1c0"].toFloat(), qMap["r2c0"].toFloat(), qMap["r3c0"].toFloat(), + qMap["r0c1"].toFloat(), qMap["r1c1"].toFloat(), qMap["r2c1"].toFloat(), qMap["r3c1"].toFloat(), + qMap["r0c2"].toFloat(), qMap["r1c2"].toFloat(), qMap["r2c2"].toFloat(), qMap["r3c2"].toFloat(), + qMap["r0c3"].toFloat(), qMap["r1c3"].toFloat(), qMap["r2c3"].toFloat(), qMap["r3c3"].toFloat() + ); + } else { + return glm::mat4(); + } +} diff --git a/libraries/shared/src/QVariantGLM.h b/libraries/shared/src/QVariantGLM.h index 3a91110250..314889d5dd 100644 --- a/libraries/shared/src/QVariantGLM.h +++ b/libraries/shared/src/QVariantGLM.h @@ -27,3 +27,7 @@ QVariantMap glmToQMap(const glm::quat& glmQuat); glm::vec3 qListToGlmVec3(const QVariant& q); glm::quat qListToGlmQuat(const QVariant& q); void qListtoRgbColor(const QVariant& q, rgbColor& returnValue); + +glm::vec3 qMapToGlmVec3(const QVariant& q); +glm::quat qMapToGlmQuat(const QVariant& q); +glm::mat4 qMapToGlmMat4(const QVariant& q); From 487cb7d893c827f1318006cecc5a31550a3fb4d2 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 9 Sep 2016 18:58:38 +1200 Subject: [PATCH 17/23] Use findInFrustum in entities list and filter results per search radius --- scripts/system/libraries/entityList.js | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 7af4cd6c68..3e9d3b5648 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -57,28 +57,32 @@ EntityListTool = function(opts) { var ids; if (filterInView) { - ids = Entities.findEntitiesInView(MyAvatar.position, searchRadius); + ids = Entities.findEntitiesInFrustum(Camera.frustum); } else { ids = Entities.findEntities(MyAvatar.position, searchRadius); } + var cameraPosition = Camera.position; for (var i = 0; i < ids.length; i++) { var id = ids[i]; var properties = Entities.getEntityProperties(id); - entities.push({ - id: id, - name: properties.name, - type: properties.type, - url: properties.type == "Model" ? properties.modelURL : "", - locked: properties.locked, - visible: properties.visible, - verticesCount: valueIfDefined(properties.renderInfo.verticesCount), - texturesCount: valueIfDefined(properties.renderInfo.texturesCount), - texturesSize: valueIfDefined(properties.renderInfo.texturesSize), - hasTransparent: valueIfDefined(properties.renderInfo.hasTransparent), - drawCalls: valueIfDefined(properties.renderInfo.drawCalls), - hasScript: properties.script !== "" - }); + + if (!filterInView || Vec3.distance(properties.position, cameraPosition) <= searchRadius) { + entities.push({ + id: id, + name: properties.name, + type: properties.type, + url: properties.type == "Model" ? properties.modelURL : "", + locked: properties.locked, + visible: properties.visible, + verticesCount: valueIfDefined(properties.renderInfo.verticesCount), + texturesCount: valueIfDefined(properties.renderInfo.texturesCount), + texturesSize: valueIfDefined(properties.renderInfo.texturesSize), + hasTransparent: valueIfDefined(properties.renderInfo.hasTransparent), + drawCalls: valueIfDefined(properties.renderInfo.drawCalls), + hasScript: properties.script !== "" + }); + } } var selectedIDs = []; From 68499f49ad595f9c1ffc4e18b72a3054bebcf814 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 10 Sep 2016 10:15:13 +1200 Subject: [PATCH 18/23] Fix count of textures --- libraries/entities/src/EntityItemProperties.cpp | 2 +- libraries/render-utils/src/MeshPartPayload.cpp | 2 ++ libraries/render-utils/src/MeshPartPayload.h | 2 ++ libraries/render-utils/src/Model.cpp | 17 ++++++++++++++--- libraries/render-utils/src/Model.h | 5 +++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 8169c2a802..588c6e2977 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -769,7 +769,7 @@ void EntityItemPropertiesFromScriptValueHonorReadOnly(const QScriptValue &object QScriptValue EntityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags) { return EntityItemProperties::entityPropertyFlagsToScriptValue(engine, flags); QScriptValue result = engine->newObject(); - return result; + return result; } void EntityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags) { diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 3e891bffe2..50c0c869ff 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -77,6 +77,7 @@ void MeshPartPayload::updateMaterial(model::MaterialPointer drawMaterial) { bool MeshPartPayload::calculateMaterialSize() { bool allTextures = true; // assume we got this... _materialTextureSize = 0; + _materialTextureCount = 0; auto textureMaps = _drawMaterial->getTextureMaps(); for (auto const &textureMapItem : textureMaps) { auto textureMap = textureMapItem.second; @@ -88,6 +89,7 @@ bool MeshPartPayload::calculateMaterialSize() { //auto storedSize = texture->getStoredSize(); auto size = texture->getSize(); _materialTextureSize += size; + _materialTextureCount++; } else { allTextures = false; } diff --git a/libraries/render-utils/src/MeshPartPayload.h b/libraries/render-utils/src/MeshPartPayload.h index f7ea77beba..3ecd8da03e 100644 --- a/libraries/render-utils/src/MeshPartPayload.h +++ b/libraries/render-utils/src/MeshPartPayload.h @@ -67,10 +67,12 @@ public: size_t getVerticesCount() const { return _drawMesh ? _drawMesh->getNumVertices() : 0; } size_t getMaterialTextureSize() { return _materialTextureSize; } + int getMaterialTextureCount() { return _materialTextureCount; } bool calculateMaterialSize(); protected: size_t _materialTextureSize { 0 }; + int _materialTextureCount { 0 }; }; namespace render { diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index ebf5cb4327..8e74c3db0d 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -161,22 +161,33 @@ void Model::setOffset(const glm::vec3& offset) { _snappedToRegistrationPoint = false; } -size_t Model::getRenderInfoTextureSize() { - if (!_hasCalculatedTextureSize && isLoaded() && getGeometry()->areTexturesLoaded()) { +void Model::calculateTextureInfo() { + if (!_hasCalculatedTextureInfo && isLoaded() && getGeometry()->areTexturesLoaded()) { size_t textureSize = 0; + int textureCount = 0; bool allTexturesLoaded = true; foreach(auto renderItem, _modelMeshRenderItemsSet) { auto meshPart = renderItem.get(); bool allTexturesForThisMesh = meshPart->calculateMaterialSize(); allTexturesLoaded = allTexturesLoaded & allTexturesForThisMesh; textureSize += meshPart->getMaterialTextureSize(); + textureCount += meshPart->getMaterialTextureCount(); } _renderInfoTextureSize = textureSize; - _hasCalculatedTextureSize = allTexturesLoaded; // only do this once + _renderInfoTextureCount = textureCount; + _hasCalculatedTextureInfo = allTexturesLoaded; // only do this once } +} + +size_t Model::getRenderInfoTextureSize() { + calculateTextureInfo(); return _renderInfoTextureSize; } +int Model::getRenderInfoTextureCount() { + calculateTextureInfo(); + return _renderInfoTextureCount; +} void Model::updateRenderItems() { if (!_addedToScene) { diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 1b16892296..bd94fb706b 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -233,8 +233,8 @@ public: void setLoadingPriority(float priority) { _loadingPriority = priority; } size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; } - int getRenderInfoTextureCount() const { return _renderInfoTextureCount; } size_t getRenderInfoTextureSize(); + int getRenderInfoTextureCount(); int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; } bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; } @@ -409,13 +409,14 @@ protected: size_t _renderInfoVertexCount { 0 }; int _renderInfoTextureCount { 0 }; size_t _renderInfoTextureSize { 0 }; - bool _hasCalculatedTextureSize { false }; + bool _hasCalculatedTextureInfo { false }; int _renderInfoDrawCalls { 0 }; int _renderInfoHasTransparent { false }; private: float _loadingPriority { 0.0f }; + void calculateTextureInfo(); }; Q_DECLARE_METATYPE(ModelPointer) From a06f49f79109b5cd39c13bea705faf4dddad2291 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 10 Sep 2016 11:14:23 +1200 Subject: [PATCH 19/23] Fix footer entities count not being updated when change filter value --- scripts/system/html/js/entityList.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index b7787b41dd..7471e171fc 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -206,10 +206,23 @@ function loaded() { EventBridge.emitWebEvent(JSON.stringify({ type: 'refresh' })); } + function refreshFooter() { + if (selectedEntities.length > 1) { + elFooter.firstChild.nodeValue = selectedEntities.length + " entities selected"; + } else if (selectedEntities.length === 1) { + elFooter.firstChild.nodeValue = "1 entity selected"; + } else if (entityList.visibleItems.length === 1) { + elFooter.firstChild.nodeValue = "1 entity found"; + } else { + elFooter.firstChild.nodeValue = entityList.visibleItems.length + " entities found"; + } + } + function refreshEntityListObject() { refreshEntityListTimer = null; entityList.sort(currentSortColumn, { order: currentSortOrder }); entityList.search(elFilter.value); + refreshFooter(); } function updateSelectedEntities(selectedEntities) { @@ -227,16 +240,6 @@ function loaded() { } } - if (selectedEntities.length > 1) { - elFooter.firstChild.nodeValue = selectedEntities.length + " entities selected"; - } else if (selectedEntities.length === 1) { - elFooter.firstChild.nodeValue = "1 entity selected"; - } else if (entityList.visibleItems.length === 1) { - elFooter.firstChild.nodeValue = "1 entity found"; - } else { - elFooter.firstChild.nodeValue = entityList.visibleItems.length + " entities found"; - } - // HACK: Fixes the footer and header text sometimes not displaying after adding or deleting entities. // The problem appears to be a bug in the Qt HTML/CSS rendering (Qt 5.5). document.getElementById("radius").focus(); @@ -371,6 +374,7 @@ function loaded() { window.onresize = resize; elFilter.onchange = resize; + elFilter.onblur = refreshFooter; var showExtraInfo = false; From 44282499c5e03eb74e4daaa4c29399c630fd15ea Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 10 Sep 2016 14:37:09 +1200 Subject: [PATCH 20/23] New glyph for "has transparent" --- interface/resources/fonts/hifi-glyphs.ttf | Bin 24204 -> 24428 bytes scripts/system/html/css/edit-style.css | 17 +++++++++++++++++ scripts/system/html/entityList.html | 2 +- scripts/system/html/js/entityList.js | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/interface/resources/fonts/hifi-glyphs.ttf b/interface/resources/fonts/hifi-glyphs.ttf index 89d47670122b68a27ce80d77da0227390d817ac1..1c98f4e6f38fa3fd1516ee0b64d2dd36e6ab6d88 100644 GIT binary patch delta 647 zcmY*WPiRtc9RGaZ@2PM2N)r_-CDGU#OD5{HK}JC{56PsJxiSB|%*~bW&8CM5OFPs~ zJ5+Dbh#;t2LBx#{dY6rP@Nhw(tPZZ2>c`VnMn(WG>hMd<76H77GoD_fZ!hD}bX#xw?Ar zrgaLSmjJ$%mh)0-TWJG)M;nr*)iT~w2A~t#LW(38eug?pAhiupv%FlX{@s221(+-K zXSCx8czWedI%_)l8%7SAeEMS%2cENt_bEcMdWzCyR3Fi=i8ZMGCIn&(WM(Jaz&K@@2{uB9&#Z<-fGQHY7={^mSX+@l+$ zz=*>*0uMlbCt1hH9id<#>~ZUzWVNg1GehBk&7&!$8EZ4vZfiK2d7H~+ayd$~7Go`T zKonY9r6q`^+)fr~?p@wbIv>24RC}p0=JQUf-q}r()i<-Bd0L`t&8@i?%)(cf`ni|VEM@k@QGz}=y9)S;$Cm;W(-y;44WNnX3 delta 425 zcmY+AyGtB#6otP#Gi%la711KX2tmXIM0|jl8ElK9~A?g6;i>6SRRdOKO4m@e=tgdU@ec1}q3-k=fmD7E_(F)o!Xk}w6>D=6) zL$n$2kJ+=MHD-Dpe2dUAWX06TgVT~r;3v>vS+NCW)W``)F;H&Br)D1iDf$Mo3H-7X z!>amqr~-^F;5e>k9QGs%637IaRPor~hP@tml?L&gL~<(hKK~s=K7g^FeNLe8?BVoa zLE{CFG%`9=cIs|xcIvGJWx{weY# zdE5GL@m77R!`tc26JLNT>fP^=NVerts Texts T Size - ' + Draws k diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 7471e171fc..1b5d82fd96 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -16,7 +16,7 @@ const ASCENDING_STRING = '▴'; const DESCENDING_STRING = '▾'; const LOCKED_GLYPH = ""; const VISIBLE_GLYPH = ""; -const TRANSPARENCY_GLYPH = "'"; +const TRANSPARENCY_GLYPH = ""; const SCRIPT_GLYPH = "k"; const DELETE = 46; // Key code for the delete key. const MAX_ITEMS = Number.MAX_VALUE; // Used to set the max length of the list of discovered entities. From d61e4c5c115169ced7266def3383d76a0f74ebe3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 13 Sep 2016 10:52:19 +1200 Subject: [PATCH 21/23] Display textures size in MB --- scripts/system/html/entityList.html | 2 +- scripts/system/html/js/entityList.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index 13b00fa505..58dca4567f 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -59,7 +59,7 @@ Verts Texts - T Size + Text MB Draws k diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 1b5d82fd96..750352e6c4 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -132,6 +132,16 @@ function loaded() { })); } + const BYTES_PER_MEGABYTE = 1024 * 1024; + + function decimalMegabytes(number) { + if (number) { + return (number / BYTES_PER_MEGABYTE).toFixed(1); + } else { + return ""; + } + } + function addEntity(id, name, type, url, locked, visible, verticesCount, texturesCount, texturesSize, hasTransparent, drawCalls, hasScript) { @@ -141,7 +151,7 @@ function loaded() { if (entities[id] === undefined) { entityList.add([{ id: id, name: name, type: type, url: filename, locked: locked, visible: visible, verticesCount: verticesCount, - texturesCount: texturesCount, texturesSize: texturesSize, hasTransparent: hasTransparent, + texturesCount: texturesCount, texturesSize: decimalMegabytes(texturesSize), hasTransparent: hasTransparent, drawCalls: drawCalls, hasScript: hasScript }], function (items) { From 0cf3f6e953af0d1dc3caa8f267dbe71dbfd5c148 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 13 Sep 2016 13:03:06 +1200 Subject: [PATCH 22/23] Fix texture count and size getting stuck on 0 --- libraries/render-utils/src/Model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 8e74c3db0d..f6caa7c3d3 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -162,7 +162,7 @@ void Model::setOffset(const glm::vec3& offset) { } void Model::calculateTextureInfo() { - if (!_hasCalculatedTextureInfo && isLoaded() && getGeometry()->areTexturesLoaded()) { + if (!_hasCalculatedTextureInfo && isLoaded() && getGeometry()->areTexturesLoaded() && !_modelMeshRenderItems.isEmpty()) { size_t textureSize = 0; int textureCount = 0; bool allTexturesLoaded = true; From fa0aeb4563457e529d51fae00f60643bea33c620 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 13 Sep 2016 13:03:47 +1200 Subject: [PATCH 23/23] Display render info values only when valid provided --- scripts/system/html/js/entityList.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 750352e6c4..e9075da3eb 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -135,11 +135,11 @@ function loaded() { const BYTES_PER_MEGABYTE = 1024 * 1024; function decimalMegabytes(number) { - if (number) { - return (number / BYTES_PER_MEGABYTE).toFixed(1); - } else { - return ""; - } + return number ? (number / BYTES_PER_MEGABYTE).toFixed(1) : ""; + } + + function displayIfNonZero(number) { + return number ? number : ""; } function addEntity(id, name, type, url, locked, visible, verticesCount, texturesCount, texturesSize, hasTransparent, @@ -150,9 +150,10 @@ function loaded() { if (entities[id] === undefined) { entityList.add([{ - id: id, name: name, type: type, url: filename, locked: locked, visible: visible, verticesCount: verticesCount, - texturesCount: texturesCount, texturesSize: decimalMegabytes(texturesSize), hasTransparent: hasTransparent, - drawCalls: drawCalls, hasScript: hasScript + id: id, name: name, type: type, url: filename, locked: locked, visible: visible, + verticesCount: displayIfNonZero(verticesCount), texturesCount: displayIfNonZero(texturesCount), + texturesSize: decimalMegabytes(texturesSize), hasTransparent: hasTransparent, + drawCalls: displayIfNonZero(drawCalls), hasScript: hasScript }], function (items) { var currentElement = items[0].elm;