Skip to content

Commit 377d0e0

Browse files
committed
--set flag when a drawable is built using fallback material
--this could indicate that the source asset lacks a material, or else that no materials were loaded by design (i.e. for depth sensor).
1 parent 41ccd93 commit 377d0e0

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/esp/gfx/Drawable.h

+23
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ class Drawable : public Magnum::SceneGraph::Drawable3D {
157157
setMaterialValuesInternal(material, true);
158158
}
159159

160+
/**
161+
* @brief Whether this drawable has a specified material or was assigned the
162+
* default fallback material, meaning the material for the object was either
163+
* not loaded or is otherwise missing.
164+
*/
165+
bool getUsesFallbackMaterial() const { return usingFallbackMaterial_; }
166+
160167
private:
161168
/**
162169
* Set or change this drawable's @ref Magnum::Trade::MaterialData values from passed material.
@@ -171,6 +178,15 @@ class Drawable : public Magnum::SceneGraph::Drawable3D {
171178
CORRADE_UNUSED bool reset) {}
172179

173180
protected:
181+
/**
182+
* @brief Whether this drawable has a specified material or was assigned the
183+
* default fallback material, meaning the material for the object was either
184+
* not loaded or is otherwise missing.
185+
*/
186+
void setUsesFallbackMaterial(bool _usingFallbackMaterial) {
187+
usingFallbackMaterial_ = _usingFallbackMaterial;
188+
}
189+
174190
/**
175191
* @brief resize the jointTransformArray_
176192
*/
@@ -253,6 +269,13 @@ class Drawable : public Magnum::SceneGraph::Drawable3D {
253269

254270
Corrade::Containers::Array<Magnum::Matrix4> jointTransformations_;
255271

272+
/**
273+
* @brief Whether or not this drawable is being rendered using the default
274+
* fallback material, which implies either that materials were not loaded, or
275+
* else no material existed for the source asset to load.
276+
*/
277+
bool usingFallbackMaterial_ = false;
278+
256279
bool glMeshExists() const { return mesh_ != nullptr; }
257280

258281
private:

src/esp/gfx/GenericDrawable.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ void GenericDrawable::setMaterialValuesInternal(
120120
if (meshAttributeFlags_ & Drawable::Flag::HasVertexColor) {
121121
flags_ |= Mn::Shaders::PhongGL::Flag::VertexColor;
122122
}
123+
124+
// Set whether this drawable is being rendered using a fallback material; This
125+
// would infer that either materials were not loaded or no materials were
126+
// found for the source asset
127+
setUsesFallbackMaterial(materialData->attribute<bool>("isFallbackMaterial"));
128+
123129
// If not reset then make sure the same shader is used
124130
if (!reset) {
125131
flags_ = oldFlags;

src/esp/gfx/PbrDrawable.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ void PbrDrawable::setMaterialValuesInternal(
332332
if (meshAttributeFlags_ & Drawable::Flag::HasVertexColor) {
333333
flags_ |= PbrShader::Flag::VertexColor;
334334
}
335+
// Set whether this drawable is being rendered using a fallback material; This
336+
// would infer that either materials were not loaded or no materials were
337+
// found for the source asset
338+
setUsesFallbackMaterial(materialData->attribute<bool>("isFallbackMaterial"));
335339

336340
// Skin support
337341
(skinData_ != nullptr) ? flags_ |= PbrShader::Flag::SkinnedMesh

0 commit comments

Comments
 (0)