diff --git a/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp b/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp index eae0561343..c8dc701989 100644 --- a/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp @@ -11,6 +11,9 @@ #include "RenderPipelines.h" #include "GeometryCache.h" +#include "EntitiesRendererLogging.h" + + using namespace render; using namespace render::entities; @@ -195,7 +198,10 @@ void MaterialEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo auto material = getMaterial(); bool newTexturesLoaded = material ? !material->isMissingTexture() : false; if (!_texturesLoaded && newTexturesLoaded) { - material->checkResetOpacityMap(); + bool changed = material->checkResetOpacityMap(); + if (changed) { + qCWarning(entitiesrenderer) << "opacity change detected for material " << material->getName().c_str(); + } } _texturesLoaded = newTexturesLoaded; } diff --git a/libraries/graphics/src/graphics/Material.cpp b/libraries/graphics/src/graphics/Material.cpp index 7524414947..aeb37fc8d2 100755 --- a/libraries/graphics/src/graphics/Material.cpp +++ b/libraries/graphics/src/graphics/Material.cpp @@ -14,6 +14,8 @@ #include +#include "GraphicsLogging.h" + using namespace graphics; using namespace gpu; @@ -162,7 +164,8 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur } -void Material::resetOpacityMap() const { +bool Material::resetOpacityMap() const { + auto previous = _key.getAlphaMapMode(); // Clear the previous flags _key.setOpacityMaskMap(false); _key.setTranslucentMap(false); @@ -186,6 +189,12 @@ void Material::resetOpacityMap() const { } } } + auto newious = _key.getAlphaMapMode(); + if (previous != newious) { + qCWarning(graphicsLog) << "opacity change detected for material " << _name.c_str(); + return true; + } + return false; } const TextureMapPointer Material::getTextureMap(MapChannel channel) const { diff --git a/libraries/graphics/src/graphics/Material.h b/libraries/graphics/src/graphics/Material.h index adfe53a962..dd97aa1216 100755 --- a/libraries/graphics/src/graphics/Material.h +++ b/libraries/graphics/src/graphics/Material.h @@ -358,7 +358,8 @@ public: // Albedo maps cannot have opacity detected until they are loaded // This method allows const changing of the key/schemaBuffer without touching the map - void resetOpacityMap() const; + // return true if the opacity changed, flase otherwise + bool resetOpacityMap() const; // conversion from legacy material properties to PBR equivalent static float shininessToRoughness(float shininess) { return 1.0f - shininess / 100.0f; } diff --git a/libraries/material-networking/src/material-networking/MaterialCache.cpp b/libraries/material-networking/src/material-networking/MaterialCache.cpp index 087e1ca049..41ea04135b 100644 --- a/libraries/material-networking/src/material-networking/MaterialCache.cpp +++ b/libraries/material-networking/src/material-networking/MaterialCache.cpp @@ -748,13 +748,14 @@ bool NetworkMaterial::isMissingTexture() { return false; } -void NetworkMaterial::checkResetOpacityMap() { +bool NetworkMaterial::checkResetOpacityMap() { // If material textures are loaded, check the material translucency // FIXME: This should not be done here. The opacity map should already be reset in Material::setTextureMap. // However, currently that code can be called before the albedo map is defined, so resetOpacityMap will fail. // Geometry::areTexturesLoaded() is called repeatedly until it returns true, so we do the check here for now const auto& albedoTexture = _textures[NetworkMaterial::MapChannel::ALBEDO_MAP]; if (albedoTexture.texture) { - resetOpacityMap(); + return resetOpacityMap(); } + return false; } diff --git a/libraries/material-networking/src/material-networking/MaterialCache.h b/libraries/material-networking/src/material-networking/MaterialCache.h index 18aa5e5994..aa103adb1e 100644 --- a/libraries/material-networking/src/material-networking/MaterialCache.h +++ b/libraries/material-networking/src/material-networking/MaterialCache.h @@ -34,7 +34,7 @@ public: void setLightMap(const QUrl& url); bool isMissingTexture(); - void checkResetOpacityMap(); + bool checkResetOpacityMap(); class Texture { public: diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 1ed1c65358..1fcfcfcc70 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -472,7 +472,10 @@ bool Geometry::areTexturesLoaded() const { return false; } - material->checkResetOpacityMap(); + bool changed = material->checkResetOpacityMap(); + if (changed) { + qCWarning(modelnetworking) << "Material list: opacity change detected for material " << material->getName().c_str(); + } } for (auto& materialMapping : _materialMapping) { @@ -483,7 +486,10 @@ bool Geometry::areTexturesLoaded() const { return false; } - materialPair.second->checkResetOpacityMap(); + bool changed = materialPair.second->checkResetOpacityMap(); + if (changed) { + qCWarning(modelnetworking) << "Mapping list: opacity change detected for material " << materialPair.first.c_str(); + } } } } diff --git a/scripts/developer/utilities/cache/cash.qml b/scripts/developer/utilities/cache/cash.qml index e143a82e62..159ce95c5f 100644 --- a/scripts/developer/utilities/cache/cash.qml +++ b/scripts/developer/utilities/cache/cash.qml @@ -109,21 +109,6 @@ Rectangle { } width:column.width } - - Prop.PropScalar { - label: "Texture Loading" - object: TextureCache - property: "numLoading" - integral: true - readOnly: true - } - Prop.PropScalar { - label: "Model Loading" - object: ModelCache - property: "numLoading" - integral: true - readOnly: true - } } } } diff --git a/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml b/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml index 733472cb9e..7d14a07e13 100644 --- a/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml +++ b/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml @@ -63,14 +63,13 @@ Item { } - /* Timer { + Timer { interval: 2000; running: true; repeat: true onTriggered: pullFreshValues() - }*/ + } function pullFreshValues() { if (needFreshList) { - //console.log("Updating " + cacheResourceName + "cache list") updateItemList(fetchItemsList()) needFreshList = false } @@ -127,7 +126,9 @@ Item { var item = itemList[i] currentItemsList.push(item) resourceItemsModel.append(packItemEntry(item, currentItemsList.length -1)) - } + } + // At the end of it, force an update + visualModel.forceUpdate() } function updateItemList(newItemList) { @@ -148,6 +149,7 @@ Item { anchors.left: parent.left anchors.right: parent.right height: totalCount.height + id: headerTop Prop.PropButton { id: refreshButton @@ -158,30 +160,46 @@ Item { onPressed: { pullFreshValues() } } - Item { + GridLayout { anchors.left: refreshButton.right anchors.right: parent.right - Prop.PropScalar { - id: totalCount - anchors.left: parent.left - anchors.right: parent.horizontalCenter - label: "Count" - object: root.cache - property: "numTotal" - integral: true - readOnly: true - onSourceValueVarChanged: { updateItemListFromCache() } + id: headerCountLane + columns: 3 + + Item { + Layout.fillWidth: true + Prop.PropScalar { + id: itemCount + label: "Count" + object: root.cache + property: "numTotal" + integral: true + readOnly: true + } } - Prop.PropScalar { - id: cachedCount - anchors.left: parent.horizontalCenter - anchors.right: parent.right - label: "Cached" - object: root.cache - property: "numCached" - integral: true - readOnly: true - onSourceValueVarChanged: { updateItemListFromCache() } + Item { + Layout.fillWidth: true + Prop.PropScalar { + id: totalCount + label: "Count" + object: root.cache + property: "numTotal" + integral: true + readOnly: true + onSourceValueVarChanged: { updateItemListFromCache() } + } + } + Item { + Layout.fillWidth: true + Prop.PropScalar { + id: cachedCount + label: "Cached" + object: root.cache + property: "numCached" + integral: true + readOnly: true + onSourceValueVarChanged: { updateItemListFromCache() } + } } } } @@ -331,7 +349,7 @@ Item { //console.log("refreshFilter! token = " + textFilter + " field = " + filterField) acceptItem = acceptItemArray[(textFilter.length != 0) * + (1 + filterField)] } - + delegate: resouceItemDelegate } diff --git a/scripts/developer/utilities/cache/cash/SortFilterModel.qml b/scripts/developer/utilities/cache/cash/SortFilterModel.qml index a4a9c3f6a3..08ad8d1dbd 100644 --- a/scripts/developer/utilities/cache/cash/SortFilterModel.qml +++ b/scripts/developer/utilities/cache/cash/SortFilterModel.qml @@ -6,96 +6,71 @@ DelegateModel { property var lessThan: function(left, right) { return true; } property var acceptItem: function(item) { return true; } -/* - function insertPosition(lessThan, item) { - var lower = 0 - var upper = items.count - while (lower < upper) { - var middle = Math.floor(lower + (upper - lower) / 2) - var result = lessThan(item.model, items.get(middle).model); - if (result) { - upper = middle - } else { - lower = middle + 1 - } - } - return lower - } - function sort(lessThan) { - while (unsortedItems.count > 0) { - var item = unsortedItems.get(0) - - var index = insertPosition(lessThan, item) - - item.groups = "items" - items.move(item.itemsIndex, index) + function insertPosition(lessThanFunctor, item) { + var lower = 0 + var upper = visibleItems.count + while (lower < upper) { + var middle = Math.floor(lower + (upper - lower) / 2) + var result = lessThanFunctor(item.model, visibleItems.get(middle).model); + if (result) { + upper = middle + } else { + lower = middle + 1 } } -*/ - function insertPosition(lessThanFunctor, item) { - var lower = 0 - var upper = visibleItems.count - while (lower < upper) { - var middle = Math.floor(lower + (upper - lower) / 2) - var result = lessThanFunctor(item.model, visibleItems.get(middle).model); - if (result) { - upper = middle - } else { - lower = middle + 1 - } - } - return lower - } + return lower + } - function sort(lessThanFunctor, acceptItemFunctor) { - while (unsortedItems.count > 0) { - var item = unsortedItems.get(0) - - if (acceptItemFunctor(item.model)) { - var index = insertPosition(lessThanFunctor, item) + function sortAndFilter(lessThanFunctor, acceptItemFunctor) { + while (unsortedItems.count > 0) { + var item = unsortedItems.get(0) + + if (acceptItemFunctor(item.model)) { + var index = insertPosition(lessThanFunctor, item) - item.groups = ["items","visible"] - visibleItems.move(item.visibleIndex, index) - } else { - item.groups = ["items"] - } + item.groups = ["items","visible"] + visibleItems.move(item.visibleIndex, index) + } else { + item.groups = ["items"] } } + } + // Private bool to track when items changed and view is dirty + property bool itemsDirty: true function update() { + console.log("SortFilterMode: update and sort and filter items !!" + items.count); if (items.count > 0) { items.setGroups(0, items.count, ["items","unsorted"]); } - sort(lessThan, acceptItem) - /* - // Step 1: Filter items - var visible = []; - for (var i = 0; i < items.count; ++i) { - var item = items.get(i); - if (filterAcceptsItem(item.model)) { - visible.push(item); - } - } - - // Step 2: Sort the list of visible items - visible.sort(function(a, b) { - return lessThan(a.model, b.model) ? -1 : 1; - }); - - // Step 3: Add all items to the visible group: - for (i = 0; i < visible.length; ++i) { - item = visible[i]; - item.inVisible = true; - if (item.visibleIndex !== i) { - visibleItems.move(item.visibleIndex, i, 1); - } - } - */ + sortAndFilter(lessThan, acceptItem) + itemsDirty = false; + itemsUpdated() } - items.onChanged: update() + signal itemsUpdated() + + function updateOnItemsChanged() { + itemsDirty = true; + if (isAutoUpdateOnChanged) { + update() + } + } + + property bool isAutoUpdateOnChanged: false + function setAutoUpdateOnChanged(enabled) { + isAutoUpdateOnChanged = enabled + if (enabled) { + update() + } + } + + function forceUpdate() { + update(); + } + items.onChanged: updateOnItemsChanged() onLessThanChanged: update() onAcceptItemChanged: update() diff --git a/scripts/developer/utilities/lib/prop/PropItem.qml b/scripts/developer/utilities/lib/prop/PropItem.qml index fe2364b59a..24e2ecaa9a 100644 --- a/scripts/developer/utilities/lib/prop/PropItem.qml +++ b/scripts/developer/utilities/lib/prop/PropItem.qml @@ -33,11 +33,11 @@ Item { // PropItem is stretching horizontally accross its parent // Fixed height + height: global.lineHeight anchors.left: parent.left anchors.right: parent.right - height: global.lineHeight - anchors.leftMargin: global.horizontalMargin - anchors.rightMargin: global.horizontalMargin + // anchors.leftMargin: global.horizontalMargin + // anchors.rightMargin: global.horizontalMargin // LabelControl And SplitterControl are on the left side of the PropItem property bool showLabel: true