Browse Source

Trade: clearer asserts for "packable" textures.

In these cases there can be more than one attribute, so complaining that
just one particular attribute is not found is misleading.
pull/459/head
Vladimír Vondruš 6 years ago
parent
commit
a84721d4b7
  1. 8
      src/Magnum/Trade/PbrMetallicRoughnessMaterialData.cpp
  2. 8
      src/Magnum/Trade/PbrSpecularGlossinessMaterialData.cpp
  3. 4
      src/Magnum/Trade/PhongMaterialData.cpp
  4. 10
      src/Magnum/Trade/Test/MaterialDataTest.cpp

8
src/Magnum/Trade/PbrMetallicRoughnessMaterialData.cpp

@ -152,6 +152,10 @@ Float PbrMetallicRoughnessMaterialData::metalness() const {
}
UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTexture() const {
/* Explicit assertion because printing that MetalnessTexture isn't found
would be misleading as it can be also MetallicRoughnessTexture */
CORRADE_ASSERT(hasMetalnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::metalnessTexture(): the material doesn't have a metalness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetallicRoughnessTexture))
return *value;
return attribute<UnsignedInt>(MaterialAttribute::MetalnessTexture);
@ -186,6 +190,10 @@ Float PbrMetallicRoughnessMaterialData::roughness() const {
}
UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTexture() const {
/* Explicit assertion because printing that RoughnessTexture isn't found
would be misleading as it can be also MetallicRoughnessTexture */
CORRADE_ASSERT(hasRoughnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::roughnessTexture(): the material doesn't have a roughness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetallicRoughnessTexture))
return *value;
return attribute<UnsignedInt>(MaterialAttribute::RoughnessTexture);

8
src/Magnum/Trade/PbrSpecularGlossinessMaterialData.cpp

@ -101,6 +101,10 @@ Color4 PbrSpecularGlossinessMaterialData::specularColor() const {
}
UnsignedInt PbrSpecularGlossinessMaterialData::specularTexture() const {
/* Explicit assertion because printing that SpecularTexture isn't found
would be misleading as it can be also SpecularGlossinessTexture */
CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PbrSpecularGlossinessMaterialData::specularTexture(): the material doesn't have a specular texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture))
return *value;
return attribute<UnsignedInt>(MaterialAttribute::SpecularTexture);
@ -135,6 +139,10 @@ Float PbrSpecularGlossinessMaterialData::glossiness() const {
}
UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTexture() const {
/* Explicit assertion because printing that GlossinessTexture isn't found
would be misleading as it can be also SpecularGlossinessTexture */
CORRADE_ASSERT(hasGlossinessTexture(),
"Trade::PbrSpecularGlossinessMaterialData::glossinessTexture(): the material doesn't have a glossiness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture))
return *value;
return attribute<UnsignedInt>(MaterialAttribute::GlossinessTexture);

4
src/Magnum/Trade/PhongMaterialData.cpp

@ -204,6 +204,10 @@ Color4 PhongMaterialData::specularColor() const {
}
UnsignedInt PhongMaterialData::specularTexture() const {
/* Explicit assertion because printing that SpecularTexture isn't found
would be misleading as it can be also SpecularGlossinessTexture */
CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PhongMaterialData::specularTexture(): the material doesn't have a specular texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture))
return *value;
return attribute<UnsignedInt>(MaterialAttribute::SpecularTexture);

10
src/Magnum/Trade/Test/MaterialDataTest.cpp

@ -2782,11 +2782,11 @@ void MaterialDataTest::pbrMetallicRoughnessAccessInvalidTextures() {
"Trade::MaterialData::attribute(): attribute BaseColorTexture not found in layer 0\n"
"Trade::PbrMetallicRoughnessMaterialData::baseColorTextureMatrix(): the material doesn't have a base color texture\n"
"Trade::PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates(): the material doesn't have a base color texture\n"
"Trade::MaterialData::attribute(): attribute MetalnessTexture not found in layer 0\n"
"Trade::PbrMetallicRoughnessMaterialData::metalnessTexture(): the material doesn't have a metalness texture\n"
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureSwizzle(): the material doesn't have a metalness texture\n"
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureMatrix(): the material doesn't have a metalness texture\n"
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates(): the material doesn't have a metalness texture\n"
"Trade::MaterialData::attribute(): attribute RoughnessTexture not found in layer 0\n"
"Trade::PbrMetallicRoughnessMaterialData::roughnessTexture(): the material doesn't have a roughness texture\n"
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureSwizzle(): the material doesn't have a roughness texture\n"
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureMatrix(): the material doesn't have a roughness texture\n"
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates(): the material doesn't have a roughness texture\n"
@ -3164,11 +3164,11 @@ void MaterialDataTest::pbrSpecularGlossinessAccessInvalidTextures() {
"Trade::MaterialData::attribute(): attribute DiffuseTexture not found in layer 0\n"
"Trade::PbrSpecularGlossinessMaterialData::diffuseTextureMatrix(): the material doesn't have a diffuse texture\n"
"Trade::PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture\n"
"Trade::MaterialData::attribute(): attribute SpecularTexture not found in layer 0\n"
"Trade::PbrSpecularGlossinessMaterialData::specularTexture(): the material doesn't have a specular texture\n"
"Trade::PbrSpecularGlossinessMaterialData::specularTextureSwizzle(): the material doesn't have a specular texture\n"
"Trade::PbrSpecularGlossinessMaterialData::specularTextureMatrix(): the material doesn't have a specular texture\n"
"Trade::PbrSpecularGlossinessMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture\n"
"Trade::MaterialData::attribute(): attribute GlossinessTexture not found in layer 0\n"
"Trade::PbrSpecularGlossinessMaterialData::glossinessTexture(): the material doesn't have a glossiness texture\n"
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureSwizzle(): the material doesn't have a glossiness texture\n"
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureMatrix(): the material doesn't have a glossiness texture\n"
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates(): the material doesn't have a glossiness texture\n"
@ -3379,7 +3379,7 @@ void MaterialDataTest::phongAccessInvalidTextures() {
"Trade::MaterialData::attribute(): attribute DiffuseTexture not found in layer 0\n"
"Trade::PhongMaterialData::diffuseTextureMatrix(): the material doesn't have a diffuse texture\n"
"Trade::PhongMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture\n"
"Trade::MaterialData::attribute(): attribute SpecularTexture not found in layer 0\n"
"Trade::PhongMaterialData::specularTexture(): the material doesn't have a specular texture\n"
"Trade::PhongMaterialData::specularTextureSwizzle(): the material doesn't have a specular texture\n"
"Trade::PhongMaterialData::specularTextureMatrix(): the material doesn't have a specular texture\n"
"Trade::PhongMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture\n"

Loading…
Cancel
Save