diff --git a/src/esp/gfx/Drawable.h b/src/esp/gfx/Drawable.h index 92d57741d9..296e092fcd 100644 --- a/src/esp/gfx/Drawable.h +++ b/src/esp/gfx/Drawable.h @@ -157,6 +157,13 @@ class Drawable : public Magnum::SceneGraph::Drawable3D { setMaterialValuesInternal(material, true); } + /** + * @brief Whether this drawable has a specified material or was assigned the + * default fallback material, meaning the material for the object was either + * not loaded or is otherwise missing. + */ + bool getUsesFallbackMaterial() const { return usingFallbackMaterial_; } + private: /** * Set or change this drawable's @ref Magnum::Trade::MaterialData values from passed material. @@ -171,6 +178,15 @@ class Drawable : public Magnum::SceneGraph::Drawable3D { CORRADE_UNUSED bool reset) {} protected: + /** + * @brief Whether this drawable has a specified material or was assigned the + * default fallback material, meaning the material for the object was either + * not loaded or is otherwise missing. + */ + void setUsesFallbackMaterial(bool _usingFallbackMaterial) { + usingFallbackMaterial_ = _usingFallbackMaterial; + } + /** * @brief resize the jointTransformArray_ */ @@ -253,6 +269,13 @@ class Drawable : public Magnum::SceneGraph::Drawable3D { Corrade::Containers::Array jointTransformations_; + /** + * @brief Whether or not this drawable is being rendered using the default + * fallback material, which implies either that materials were not loaded, or + * else no material existed for the source asset to load. + */ + bool usingFallbackMaterial_ = false; + bool glMeshExists() const { return mesh_ != nullptr; } private: diff --git a/src/esp/gfx/GenericDrawable.cpp b/src/esp/gfx/GenericDrawable.cpp index d3429bdb61..8f553b303c 100644 --- a/src/esp/gfx/GenericDrawable.cpp +++ b/src/esp/gfx/GenericDrawable.cpp @@ -120,6 +120,12 @@ void GenericDrawable::setMaterialValuesInternal( if (meshAttributeFlags_ & Drawable::Flag::HasVertexColor) { flags_ |= Mn::Shaders::PhongGL::Flag::VertexColor; } + + // Set whether this drawable is being rendered using a fallback material; This + // would infer that either materials were not loaded or no materials were + // found for the source asset + setUsesFallbackMaterial(materialData->attribute("isFallbackMaterial")); + // If not reset then make sure the same shader is used if (!reset) { flags_ = oldFlags; diff --git a/src/esp/gfx/PbrDrawable.cpp b/src/esp/gfx/PbrDrawable.cpp index b2798f8734..d98ca439ce 100644 --- a/src/esp/gfx/PbrDrawable.cpp +++ b/src/esp/gfx/PbrDrawable.cpp @@ -332,6 +332,10 @@ void PbrDrawable::setMaterialValuesInternal( if (meshAttributeFlags_ & Drawable::Flag::HasVertexColor) { flags_ |= PbrShader::Flag::VertexColor; } + // Set whether this drawable is being rendered using a fallback material; This + // would infer that either materials were not loaded or no materials were + // found for the source asset + setUsesFallbackMaterial(materialData->attribute("isFallbackMaterial")); // If not reset then make sure the same shader is used if (!reset) {