From 1e46b0803c829f393ea72a5d09d0335280cca964 Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 23 Mar 2016 15:59:57 -0700 Subject: [PATCH] fixing repported issues during review --- .../src/model-networking/ModelCache.cpp | 4 +-- libraries/model/src/model/Material.cpp | 32 ++++++++----------- .../render-utils/src/MeshPartPayload.cpp | 2 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 5eb961ef98..198cf9143c 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -139,7 +139,7 @@ bool NetworkGeometry::isLoadedWithTextures() const { } if (!_isLoadedWithTextures) { - _hasTransparentTextures = true; + _hasTransparentTextures = false; for (auto&& material : _materials) { if ((material->albedoTexture && !material->albedoTexture->isLoaded()) || @@ -156,7 +156,7 @@ bool NetworkGeometry::isLoadedWithTextures() const { material->_material->setTextureMap(model::MaterialKey::ALBEDO_MAP, material->_material->getTextureMap(model::MaterialKey::ALBEDO_MAP)); const auto& usage = material->albedoTexture->getGPUTexture()->getUsage(); bool isTransparentTexture = usage.isAlpha() && !usage.isAlphaMask(); - _hasTransparentTextures = isTransparentTexture && _hasTransparentTextures; + _hasTransparentTextures |= isTransparentTexture; } } diff --git a/libraries/model/src/model/Material.cpp b/libraries/model/src/model/Material.cpp index 81bc9b40a6..0a6a4bb695 100755 --- a/libraries/model/src/model/Material.cpp +++ b/libraries/model/src/model/Material.cpp @@ -80,7 +80,6 @@ void Material::setMetallic(float metallic) { _schemaBuffer.edit()._metallic = metallic; } - void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textureMap) { if (textureMap) { _key.setMapChannel(channel, (true)); @@ -90,26 +89,21 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur _key.setOpacityMaskMap(false); _key.setTranslucentMap(false); - if (textureMap->useAlphaChannel()) { - if (textureMap->isDefined()) { - if (textureMap->getTextureView().isValid()) { - auto usage = textureMap->getTextureView()._texture->getUsage(); - if (usage.isAlpha()) { - // Texture has alpha, is not just a mask or a true transparent channel - if (usage.isAlphaMask()) { - _key.setOpacityMaskMap(true); - _key.setTranslucentMap(false); - } else { - _key.setOpacityMaskMap(false); - _key.setTranslucentMap(true); - } - } + if (textureMap->useAlphaChannel() && textureMap->isDefined() && textureMap->getTextureView().isValid()) { + auto usage = textureMap->getTextureView()._texture->getUsage(); + if (usage.isAlpha()) { + // Texture has alpha, is not just a mask or a true transparent channel + if (usage.isAlphaMask()) { + _key.setOpacityMaskMap(true); + _key.setTranslucentMap(false); + } else { + _key.setOpacityMaskMap(false); + _key.setTranslucentMap(true); } } } } - _schemaBuffer.edit()._key = (uint32)_key._flags.to_ulong(); _textureMaps[channel] = textureMap; } else { _key.setMapChannel(channel, (false)); @@ -119,9 +113,11 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur _key.setTranslucentMap(false); } - _schemaBuffer.edit()._key = (uint32)_key._flags.to_ulong(); _textureMaps.erase(channel); } + + _schemaBuffer.edit()._key = (uint32)_key._flags.to_ulong(); + } @@ -132,4 +128,4 @@ const TextureMapPointer Material::getTextureMap(MapChannel channel) const { } else { return TextureMapPointer(); } -} \ No newline at end of file +} diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index aca9774221..363def05a1 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -81,7 +81,7 @@ ItemKey MeshPartPayload::getKey() const { if (_drawMaterial) { auto matKey = _drawMaterial->getKey(); - if (matKey.isTranslucentFactor() || matKey.isTranslucentMap()) { + if (matKey.isTranslucent()) { builder.withTransparent(); } }