Browse Source

Trade: port away from deprecated MaterialData::tryAttribute().

pull/610/head
Vladimír Vondruš 4 years ago
parent
commit
b75cb7c584
  1. 2
      doc/snippets/MagnumTrade.cpp
  2. 16
      src/Magnum/Trade/FlatMaterialData.cpp
  3. 30
      src/Magnum/Trade/PbrClearCoatMaterialData.cpp
  4. 44
      src/Magnum/Trade/PbrMetallicRoughnessMaterialData.cpp
  5. 44
      src/Magnum/Trade/PbrSpecularGlossinessMaterialData.cpp
  6. 28
      src/Magnum/Trade/PhongMaterialData.cpp
  7. 138
      src/Magnum/Trade/Test/MaterialDataTest.cpp

2
doc/snippets/MagnumTrade.cpp

@ -446,7 +446,7 @@ Float roughness = data.attribute<Float>(Trade::MaterialAttribute::Roughness);
Color4 color = data.attributeOr(Trade::MaterialAttribute::BaseColor, Color4 color = data.attributeOr(Trade::MaterialAttribute::BaseColor,
0x3bd267ff_srgbaf); 0x3bd267ff_srgbaf);
if(Containers::Optional<UnsignedInt> texture = if(Containers::Optional<UnsignedInt> texture =
data.tryAttribute<UnsignedInt>(Trade::MaterialAttribute::BaseColorTexture)) data.findAttribute<UnsignedInt>(Trade::MaterialAttribute::BaseColorTexture))
{ {
// ... // ...
} }

16
src/Magnum/Trade/FlatMaterialData.cpp

@ -63,7 +63,7 @@ Color4 FlatMaterialData::color() const {
return attributeOr(MaterialAttribute::DiffuseColor, 0xffffffff_srgbaf); return attributeOr(MaterialAttribute::DiffuseColor, 0xffffffff_srgbaf);
/* If there's no texture, return whatever is present */ /* If there's no texture, return whatever is present */
if(Containers::Optional<Color4> value = tryAttribute<Color4>(MaterialAttribute::BaseColor)) if(Containers::Optional<Color4> value = findAttribute<Color4>(MaterialAttribute::BaseColor))
return *value; return *value;
return attributeOr(MaterialAttribute::DiffuseColor, 0xffffffff_srgbaf); return attributeOr(MaterialAttribute::DiffuseColor, 0xffffffff_srgbaf);
} }
@ -73,20 +73,20 @@ UnsignedInt FlatMaterialData::texture() const {
would be misleading as it can be also BaseColorTexture */ would be misleading as it can be also BaseColorTexture */
CORRADE_ASSERT(hasTexture(), CORRADE_ASSERT(hasTexture(),
"Trade::FlatMaterialData::texture(): the material doesn't have a texture", {}); "Trade::FlatMaterialData::texture(): the material doesn't have a texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::BaseColorTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::BaseColorTexture))
return *value; return *value;
return attribute<UnsignedInt>(MaterialAttribute::DiffuseTexture); return attribute<UnsignedInt>(MaterialAttribute::DiffuseTexture);
} }
Matrix3 FlatMaterialData::textureMatrix() const { Matrix3 FlatMaterialData::textureMatrix() const {
if(hasAttribute(MaterialAttribute::BaseColorTexture)) { if(hasAttribute(MaterialAttribute::BaseColorTexture)) {
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::BaseColorTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::BaseColorTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
if(hasAttribute(MaterialAttribute::DiffuseTexture)) { if(hasAttribute(MaterialAttribute::DiffuseTexture)) {
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::DiffuseTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::DiffuseTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -96,13 +96,13 @@ Matrix3 FlatMaterialData::textureMatrix() const {
UnsignedInt FlatMaterialData::textureCoordinates() const { UnsignedInt FlatMaterialData::textureCoordinates() const {
if(hasAttribute(MaterialAttribute::BaseColorTexture)) { if(hasAttribute(MaterialAttribute::BaseColorTexture)) {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
if(hasAttribute(MaterialAttribute::DiffuseTexture)) { if(hasAttribute(MaterialAttribute::DiffuseTexture)) {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -112,13 +112,13 @@ UnsignedInt FlatMaterialData::textureCoordinates() const {
UnsignedInt FlatMaterialData::textureLayer() const { UnsignedInt FlatMaterialData::textureLayer() const {
if(hasAttribute(MaterialAttribute::BaseColorTexture)) { if(hasAttribute(MaterialAttribute::BaseColorTexture)) {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
if(hasAttribute(MaterialAttribute::DiffuseTexture)) { if(hasAttribute(MaterialAttribute::DiffuseTexture)) {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }

30
src/Magnum/Trade/PbrClearCoatMaterialData.cpp

@ -142,9 +142,9 @@ MaterialTextureSwizzle PbrClearCoatMaterialData::roughnessTextureSwizzle() const
Matrix3 PbrClearCoatMaterialData::roughnessTextureMatrix() const { Matrix3 PbrClearCoatMaterialData::roughnessTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::RoughnessTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::RoughnessTexture),
"Trade::PbrClearCoatMaterialData::roughnessTextureMatrix(): the layer doesn't have a roughness texture", {}); "Trade::PbrClearCoatMaterialData::roughnessTextureMatrix(): the layer doesn't have a roughness texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::RoughnessTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::RoughnessTextureMatrix))
return *value; return *value;
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::TextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::TextureMatrix))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(0, MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -152,9 +152,9 @@ Matrix3 PbrClearCoatMaterialData::roughnessTextureMatrix() const {
UnsignedInt PbrClearCoatMaterialData::roughnessTextureCoordinates() const { UnsignedInt PbrClearCoatMaterialData::roughnessTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::RoughnessTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::RoughnessTexture),
"Trade::PbrClearCoatMaterialData::roughnessTextureCoordinates(): the layer doesn't have a roughness texture", {}); "Trade::PbrClearCoatMaterialData::roughnessTextureCoordinates(): the layer doesn't have a roughness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureCoordinates))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::TextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::TextureCoordinates))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureCoordinates, 0u); return attributeOr(0, MaterialAttribute::TextureCoordinates, 0u);
} }
@ -162,9 +162,9 @@ UnsignedInt PbrClearCoatMaterialData::roughnessTextureCoordinates() const {
UnsignedInt PbrClearCoatMaterialData::roughnessTextureLayer() const { UnsignedInt PbrClearCoatMaterialData::roughnessTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::RoughnessTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::RoughnessTexture),
"Trade::PbrClearCoatMaterialData::roughnessTextureLayer(): the layer doesn't have a roughness texture", {}); "Trade::PbrClearCoatMaterialData::roughnessTextureLayer(): the layer doesn't have a roughness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureLayer))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::TextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::TextureLayer))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureLayer, 0u); return attributeOr(0, MaterialAttribute::TextureLayer, 0u);
} }
@ -188,9 +188,9 @@ MaterialTextureSwizzle PbrClearCoatMaterialData::normalTextureSwizzle() const {
Matrix3 PbrClearCoatMaterialData::normalTextureMatrix() const { Matrix3 PbrClearCoatMaterialData::normalTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrClearCoatMaterialData::normalTextureMatrix(): the layer doesn't have a normal texture", {}); "Trade::PbrClearCoatMaterialData::normalTextureMatrix(): the layer doesn't have a normal texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix))
return *value; return *value;
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::TextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::TextureMatrix))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(0, MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -198,9 +198,9 @@ Matrix3 PbrClearCoatMaterialData::normalTextureMatrix() const {
UnsignedInt PbrClearCoatMaterialData::normalTextureCoordinates() const { UnsignedInt PbrClearCoatMaterialData::normalTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrClearCoatMaterialData::normalTextureCoordinates(): the layer doesn't have a normal texture", {}); "Trade::PbrClearCoatMaterialData::normalTextureCoordinates(): the layer doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::TextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::TextureCoordinates))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureCoordinates, 0u); return attributeOr(0, MaterialAttribute::TextureCoordinates, 0u);
} }
@ -208,9 +208,9 @@ UnsignedInt PbrClearCoatMaterialData::normalTextureCoordinates() const {
UnsignedInt PbrClearCoatMaterialData::normalTextureLayer() const { UnsignedInt PbrClearCoatMaterialData::normalTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrClearCoatMaterialData::normalTextureLayer(): the layer doesn't have a normal texture", {}); "Trade::PbrClearCoatMaterialData::normalTextureLayer(): the layer doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::TextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::TextureLayer))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureLayer, 0u); return attributeOr(0, MaterialAttribute::TextureLayer, 0u);
} }
@ -224,7 +224,7 @@ Matrix3 PbrClearCoatMaterialData::commonTextureMatrix() const {
return roughnessTextureMatrix(); return roughnessTextureMatrix();
if(hasAttribute(MaterialAttribute::NormalTexture)) if(hasAttribute(MaterialAttribute::NormalTexture))
return normalTextureMatrix(); return normalTextureMatrix();
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::TextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::TextureMatrix))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(0, MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -238,7 +238,7 @@ UnsignedInt PbrClearCoatMaterialData::commonTextureCoordinates() const {
return roughnessTextureCoordinates(); return roughnessTextureCoordinates();
if(hasAttribute(MaterialAttribute::NormalTexture)) if(hasAttribute(MaterialAttribute::NormalTexture))
return normalTextureCoordinates(); return normalTextureCoordinates();
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::TextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::TextureCoordinates))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureCoordinates, 0u); return attributeOr(0, MaterialAttribute::TextureCoordinates, 0u);
} }
@ -252,7 +252,7 @@ UnsignedInt PbrClearCoatMaterialData::commonTextureLayer() const {
return roughnessTextureLayer(); return roughnessTextureLayer();
if(hasAttribute(MaterialAttribute::NormalTexture)) if(hasAttribute(MaterialAttribute::NormalTexture))
return normalTextureLayer(); return normalTextureLayer();
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::TextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::TextureLayer))
return *value; return *value;
return attributeOr(0, MaterialAttribute::TextureLayer, 0u); return attributeOr(0, MaterialAttribute::TextureLayer, 0u);
} }

44
src/Magnum/Trade/PbrMetallicRoughnessMaterialData.cpp

@ -251,7 +251,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTexture() const {
Matrix3 PbrMetallicRoughnessMaterialData::baseColorTextureMatrix() const { Matrix3 PbrMetallicRoughnessMaterialData::baseColorTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture),
"Trade::PbrMetallicRoughnessMaterialData::baseColorTextureMatrix(): the material doesn't have a base color texture", {}); "Trade::PbrMetallicRoughnessMaterialData::baseColorTextureMatrix(): the material doesn't have a base color texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::BaseColorTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::BaseColorTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -259,7 +259,7 @@ Matrix3 PbrMetallicRoughnessMaterialData::baseColorTextureMatrix() const {
UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates() const { UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture),
"Trade::PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates(): the material doesn't have a base color texture", {}); "Trade::PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates(): the material doesn't have a base color texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -267,7 +267,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates() cons
UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTextureLayer() const { UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture),
"Trade::PbrMetallicRoughnessMaterialData::baseColorTextureLayer(): the material doesn't have a base color texture", {}); "Trade::PbrMetallicRoughnessMaterialData::baseColorTextureLayer(): the material doesn't have a base color texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -277,9 +277,9 @@ Float PbrMetallicRoughnessMaterialData::metalness() const {
} }
UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTexture() const { UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTexture() const {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NoneRoughnessMetallicTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NoneRoughnessMetallicTexture))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetalnessTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::MetalnessTexture))
return *value; return *value;
/* Explicit assertion because printing that MetalnessTexture isn't found /* Explicit assertion because printing that MetalnessTexture isn't found
@ -298,7 +298,7 @@ MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::metalnessTextureSwizzle
Matrix3 PbrMetallicRoughnessMaterialData::metalnessTextureMatrix() const { Matrix3 PbrMetallicRoughnessMaterialData::metalnessTextureMatrix() const {
CORRADE_ASSERT(hasMetalnessTexture(), CORRADE_ASSERT(hasMetalnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureMatrix(): the material doesn't have a metalness texture", {}); "Trade::PbrMetallicRoughnessMaterialData::metalnessTextureMatrix(): the material doesn't have a metalness texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::MetalnessTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::MetalnessTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -306,7 +306,7 @@ Matrix3 PbrMetallicRoughnessMaterialData::metalnessTextureMatrix() const {
UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates() const { UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates() const {
CORRADE_ASSERT(hasMetalnessTexture(), CORRADE_ASSERT(hasMetalnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates(): the material doesn't have a metalness texture", {}); "Trade::PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates(): the material doesn't have a metalness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetalnessTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::MetalnessTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -314,7 +314,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates() cons
UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTextureLayer() const { UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTextureLayer() const {
CORRADE_ASSERT(hasMetalnessTexture(), CORRADE_ASSERT(hasMetalnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureLayer(): the material doesn't have a metalness texture", {}); "Trade::PbrMetallicRoughnessMaterialData::metalnessTextureLayer(): the material doesn't have a metalness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetalnessTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::MetalnessTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -324,9 +324,9 @@ Float PbrMetallicRoughnessMaterialData::roughness() const {
} }
UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTexture() const { UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTexture() const {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NoneRoughnessMetallicTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NoneRoughnessMetallicTexture))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::RoughnessTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::RoughnessTexture))
return *value; return *value;
/* Explicit assertion because printing that RoughnessTexture isn't found /* Explicit assertion because printing that RoughnessTexture isn't found
@ -345,7 +345,7 @@ MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::roughnessTextureSwizzle
Matrix3 PbrMetallicRoughnessMaterialData::roughnessTextureMatrix() const { Matrix3 PbrMetallicRoughnessMaterialData::roughnessTextureMatrix() const {
CORRADE_ASSERT(hasRoughnessTexture(), CORRADE_ASSERT(hasRoughnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureMatrix(): the material doesn't have a roughness texture", {}); "Trade::PbrMetallicRoughnessMaterialData::roughnessTextureMatrix(): the material doesn't have a roughness texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::RoughnessTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::RoughnessTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -353,7 +353,7 @@ Matrix3 PbrMetallicRoughnessMaterialData::roughnessTextureMatrix() const {
UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates() const { UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates() const {
CORRADE_ASSERT(hasRoughnessTexture(), CORRADE_ASSERT(hasRoughnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates(): the material doesn't have a roughness texture", {}); "Trade::PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates(): the material doesn't have a roughness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -361,7 +361,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates() cons
UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTextureLayer() const { UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTextureLayer() const {
CORRADE_ASSERT(hasRoughnessTexture(), CORRADE_ASSERT(hasRoughnessTexture(),
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureLayer(): the material doesn't have a roughness texture", {}); "Trade::PbrMetallicRoughnessMaterialData::roughnessTextureLayer(): the material doesn't have a roughness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -385,7 +385,7 @@ MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::normalTextureSwizzle()
Matrix3 PbrMetallicRoughnessMaterialData::normalTextureMatrix() const { Matrix3 PbrMetallicRoughnessMaterialData::normalTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrMetallicRoughnessMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {}); "Trade::PbrMetallicRoughnessMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -393,7 +393,7 @@ Matrix3 PbrMetallicRoughnessMaterialData::normalTextureMatrix() const {
UnsignedInt PbrMetallicRoughnessMaterialData::normalTextureCoordinates() const { UnsignedInt PbrMetallicRoughnessMaterialData::normalTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrMetallicRoughnessMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {}); "Trade::PbrMetallicRoughnessMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -401,7 +401,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::normalTextureCoordinates() const {
UnsignedInt PbrMetallicRoughnessMaterialData::normalTextureLayer() const { UnsignedInt PbrMetallicRoughnessMaterialData::normalTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrMetallicRoughnessMaterialData::normalTextureLayer(): the material doesn't have a normal texture", {}); "Trade::PbrMetallicRoughnessMaterialData::normalTextureLayer(): the material doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -425,7 +425,7 @@ MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::occlusionTextureSwizzle
Matrix3 PbrMetallicRoughnessMaterialData::occlusionTextureMatrix() const { Matrix3 PbrMetallicRoughnessMaterialData::occlusionTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture),
"Trade::PbrMetallicRoughnessMaterialData::occlusionTextureMatrix(): the material doesn't have an occlusion texture", {}); "Trade::PbrMetallicRoughnessMaterialData::occlusionTextureMatrix(): the material doesn't have an occlusion texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::OcclusionTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::OcclusionTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -433,7 +433,7 @@ Matrix3 PbrMetallicRoughnessMaterialData::occlusionTextureMatrix() const {
UnsignedInt PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates() const { UnsignedInt PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture),
"Trade::PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates(): the material doesn't have an occlusion texture", {}); "Trade::PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates(): the material doesn't have an occlusion texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -441,7 +441,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates() cons
UnsignedInt PbrMetallicRoughnessMaterialData::occlusionTextureLayer() const { UnsignedInt PbrMetallicRoughnessMaterialData::occlusionTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture),
"Trade::PbrMetallicRoughnessMaterialData::occlusionTextureLayer(): the material doesn't have an occlusion texture", {}); "Trade::PbrMetallicRoughnessMaterialData::occlusionTextureLayer(): the material doesn't have an occlusion texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -457,7 +457,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTexture() const {
Matrix3 PbrMetallicRoughnessMaterialData::emissiveTextureMatrix() const { Matrix3 PbrMetallicRoughnessMaterialData::emissiveTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture),
"Trade::PbrMetallicRoughnessMaterialData::emissiveTextureMatrix(): the material doesn't have an emissive texture", {}); "Trade::PbrMetallicRoughnessMaterialData::emissiveTextureMatrix(): the material doesn't have an emissive texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::EmissiveTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::EmissiveTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -465,7 +465,7 @@ Matrix3 PbrMetallicRoughnessMaterialData::emissiveTextureMatrix() const {
UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates() const { UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture),
"Trade::PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture", {}); "Trade::PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -473,7 +473,7 @@ UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates() const
UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTextureLayer() const { UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture),
"Trade::PbrMetallicRoughnessMaterialData::emissiveTextureLayer(): the material doesn't have an emissive texture", {}); "Trade::PbrMetallicRoughnessMaterialData::emissiveTextureLayer(): the material doesn't have an emissive texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }

44
src/Magnum/Trade/PbrSpecularGlossinessMaterialData.cpp

@ -176,7 +176,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTexture() const {
Matrix3 PbrSpecularGlossinessMaterialData::diffuseTextureMatrix() const { Matrix3 PbrSpecularGlossinessMaterialData::diffuseTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture),
"Trade::PbrSpecularGlossinessMaterialData::diffuseTextureMatrix(): the material doesn't have a diffuse texture", {}); "Trade::PbrSpecularGlossinessMaterialData::diffuseTextureMatrix(): the material doesn't have a diffuse texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::DiffuseTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::DiffuseTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -184,7 +184,7 @@ Matrix3 PbrSpecularGlossinessMaterialData::diffuseTextureMatrix() const {
UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates() const { UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture),
"Trade::PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture", {}); "Trade::PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -192,7 +192,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates() const
UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTextureLayer() const { UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture),
"Trade::PbrSpecularGlossinessMaterialData::diffuseTextureLayer(): the material doesn't have a diffuse texture", {}); "Trade::PbrSpecularGlossinessMaterialData::diffuseTextureLayer(): the material doesn't have a diffuse texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -202,9 +202,9 @@ Color4 PbrSpecularGlossinessMaterialData::specularColor() const {
} }
UnsignedInt PbrSpecularGlossinessMaterialData::specularTexture() const { UnsignedInt PbrSpecularGlossinessMaterialData::specularTexture() const {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::SpecularTexture))
return *value; return *value;
/* Explicit assertion because printing that SpecularTexture isn't found /* Explicit assertion because printing that SpecularTexture isn't found
@ -223,7 +223,7 @@ MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::specularTextureSwizzle
Matrix3 PbrSpecularGlossinessMaterialData::specularTextureMatrix() const { Matrix3 PbrSpecularGlossinessMaterialData::specularTextureMatrix() const {
CORRADE_ASSERT(hasSpecularTexture(), CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PbrSpecularGlossinessMaterialData::specularTextureMatrix(): the material doesn't have a specular texture", {}); "Trade::PbrSpecularGlossinessMaterialData::specularTextureMatrix(): the material doesn't have a specular texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::SpecularTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::SpecularTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -231,7 +231,7 @@ Matrix3 PbrSpecularGlossinessMaterialData::specularTextureMatrix() const {
UnsignedInt PbrSpecularGlossinessMaterialData::specularTextureCoordinates() const { UnsignedInt PbrSpecularGlossinessMaterialData::specularTextureCoordinates() const {
CORRADE_ASSERT(hasSpecularTexture(), CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PbrSpecularGlossinessMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture", {}); "Trade::PbrSpecularGlossinessMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -239,7 +239,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::specularTextureCoordinates() cons
UnsignedInt PbrSpecularGlossinessMaterialData::specularTextureLayer() const { UnsignedInt PbrSpecularGlossinessMaterialData::specularTextureLayer() const {
CORRADE_ASSERT(hasSpecularTexture(), CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PbrSpecularGlossinessMaterialData::specularTextureLayer(): the material doesn't have a specular texture", {}); "Trade::PbrSpecularGlossinessMaterialData::specularTextureLayer(): the material doesn't have a specular texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -249,9 +249,9 @@ Float PbrSpecularGlossinessMaterialData::glossiness() const {
} }
UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTexture() const { UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTexture() const {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::GlossinessTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::GlossinessTexture))
return *value; return *value;
/* Explicit assertion because printing that GlossinessTexture isn't found /* Explicit assertion because printing that GlossinessTexture isn't found
@ -270,7 +270,7 @@ MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::glossinessTextureSwizz
Matrix3 PbrSpecularGlossinessMaterialData::glossinessTextureMatrix() const { Matrix3 PbrSpecularGlossinessMaterialData::glossinessTextureMatrix() const {
CORRADE_ASSERT(hasGlossinessTexture(), CORRADE_ASSERT(hasGlossinessTexture(),
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureMatrix(): the material doesn't have a glossiness texture", {}); "Trade::PbrSpecularGlossinessMaterialData::glossinessTextureMatrix(): the material doesn't have a glossiness texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::GlossinessTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::GlossinessTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -278,7 +278,7 @@ Matrix3 PbrSpecularGlossinessMaterialData::glossinessTextureMatrix() const {
UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates() const { UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates() const {
CORRADE_ASSERT(hasGlossinessTexture(), CORRADE_ASSERT(hasGlossinessTexture(),
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates(): the material doesn't have a glossiness texture", {}); "Trade::PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates(): the material doesn't have a glossiness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::GlossinessTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::GlossinessTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -286,7 +286,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates() co
UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTextureLayer() const { UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTextureLayer() const {
CORRADE_ASSERT(hasGlossinessTexture(), CORRADE_ASSERT(hasGlossinessTexture(),
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureLayer(): the material doesn't have a glossiness texture", {}); "Trade::PbrSpecularGlossinessMaterialData::glossinessTextureLayer(): the material doesn't have a glossiness texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::GlossinessTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::GlossinessTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -310,7 +310,7 @@ MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::normalTextureSwizzle()
Matrix3 PbrSpecularGlossinessMaterialData::normalTextureMatrix() const { Matrix3 PbrSpecularGlossinessMaterialData::normalTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrSpecularGlossinessMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {}); "Trade::PbrSpecularGlossinessMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -318,7 +318,7 @@ Matrix3 PbrSpecularGlossinessMaterialData::normalTextureMatrix() const {
UnsignedInt PbrSpecularGlossinessMaterialData::normalTextureCoordinates() const { UnsignedInt PbrSpecularGlossinessMaterialData::normalTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrSpecularGlossinessMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {}); "Trade::PbrSpecularGlossinessMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -326,7 +326,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::normalTextureCoordinates() const
UnsignedInt PbrSpecularGlossinessMaterialData::normalTextureLayer() const { UnsignedInt PbrSpecularGlossinessMaterialData::normalTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PbrSpecularGlossinessMaterialData::normalTextureLayer(): the material doesn't have a normal texture", {}); "Trade::PbrSpecularGlossinessMaterialData::normalTextureLayer(): the material doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -350,7 +350,7 @@ MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::occlusionTextureSwizzl
Matrix3 PbrSpecularGlossinessMaterialData::occlusionTextureMatrix() const { Matrix3 PbrSpecularGlossinessMaterialData::occlusionTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture),
"Trade::PbrSpecularGlossinessMaterialData::occlusionTextureMatrix(): the material doesn't have an occlusion texture", {}); "Trade::PbrSpecularGlossinessMaterialData::occlusionTextureMatrix(): the material doesn't have an occlusion texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::OcclusionTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::OcclusionTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -358,7 +358,7 @@ Matrix3 PbrSpecularGlossinessMaterialData::occlusionTextureMatrix() const {
UnsignedInt PbrSpecularGlossinessMaterialData::occlusionTextureCoordinates() const { UnsignedInt PbrSpecularGlossinessMaterialData::occlusionTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture),
"Trade::PbrSpecularGlossinessMaterialData::occlusionTextureCoordinates(): the material doesn't have an occlusion texture", {}); "Trade::PbrSpecularGlossinessMaterialData::occlusionTextureCoordinates(): the material doesn't have an occlusion texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -366,7 +366,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::occlusionTextureCoordinates() con
UnsignedInt PbrSpecularGlossinessMaterialData::occlusionTextureLayer() const { UnsignedInt PbrSpecularGlossinessMaterialData::occlusionTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture),
"Trade::PbrSpecularGlossinessMaterialData::occlusionTextureLayer(): the material doesn't have an occlusion texture", {}); "Trade::PbrSpecularGlossinessMaterialData::occlusionTextureLayer(): the material doesn't have an occlusion texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -382,7 +382,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTexture() const {
Matrix3 PbrSpecularGlossinessMaterialData::emissiveTextureMatrix() const { Matrix3 PbrSpecularGlossinessMaterialData::emissiveTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture),
"Trade::PbrSpecularGlossinessMaterialData::emissiveTextureMatrix(): the material doesn't have an emissive texture", {}); "Trade::PbrSpecularGlossinessMaterialData::emissiveTextureMatrix(): the material doesn't have an emissive texture", {});
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::EmissiveTextureMatrix)) if(Containers::Optional<Matrix3> value = findAttribute<Matrix3>(MaterialAttribute::EmissiveTextureMatrix))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -390,7 +390,7 @@ Matrix3 PbrSpecularGlossinessMaterialData::emissiveTextureMatrix() const {
UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTextureCoordinates() const { UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture),
"Trade::PbrSpecularGlossinessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture", {}); "Trade::PbrSpecularGlossinessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureCoordinates)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureCoordinates))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -398,7 +398,7 @@ UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTextureCoordinates() cons
UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTextureLayer() const { UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture),
"Trade::PbrSpecularGlossinessMaterialData::emissiveTextureLayer(): the material doesn't have an emissive texture", {}); "Trade::PbrSpecularGlossinessMaterialData::emissiveTextureLayer(): the material doesn't have an emissive texture", {});
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureLayer)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureLayer))
return *value; return *value;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }

28
src/Magnum/Trade/PhongMaterialData.cpp

@ -239,7 +239,7 @@ UnsignedInt PhongMaterialData::ambientTexture() const {
Matrix3 PhongMaterialData::ambientTextureMatrix() const { Matrix3 PhongMaterialData::ambientTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::AmbientTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::AmbientTexture),
"Trade::PhongMaterialData::ambientTextureMatrix(): the material doesn't have an ambient texture", {}); "Trade::PhongMaterialData::ambientTextureMatrix(): the material doesn't have an ambient texture", {});
if(Containers::Optional<Matrix3> set = tryAttribute<Matrix3>(MaterialAttribute::AmbientTextureMatrix)) if(Containers::Optional<Matrix3> set = findAttribute<Matrix3>(MaterialAttribute::AmbientTextureMatrix))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -247,7 +247,7 @@ Matrix3 PhongMaterialData::ambientTextureMatrix() const {
UnsignedInt PhongMaterialData::ambientTextureCoordinates() const { UnsignedInt PhongMaterialData::ambientTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::AmbientTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::AmbientTexture),
"Trade::PhongMaterialData::ambientTextureCoordinates(): the material doesn't have an ambient texture", {}); "Trade::PhongMaterialData::ambientTextureCoordinates(): the material doesn't have an ambient texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::AmbientTextureCoordinates)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::AmbientTextureCoordinates))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -255,7 +255,7 @@ UnsignedInt PhongMaterialData::ambientTextureCoordinates() const {
UnsignedInt PhongMaterialData::ambientTextureLayer() const { UnsignedInt PhongMaterialData::ambientTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::AmbientTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::AmbientTexture),
"Trade::PhongMaterialData::ambientTextureLayer(): the material doesn't have an ambient texture", {}); "Trade::PhongMaterialData::ambientTextureLayer(): the material doesn't have an ambient texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::AmbientTextureLayer)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::AmbientTextureLayer))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -271,7 +271,7 @@ UnsignedInt PhongMaterialData::diffuseTexture() const {
Matrix3 PhongMaterialData::diffuseTextureMatrix() const { Matrix3 PhongMaterialData::diffuseTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture),
"Trade::PhongMaterialData::diffuseTextureMatrix(): the material doesn't have a diffuse texture", {}); "Trade::PhongMaterialData::diffuseTextureMatrix(): the material doesn't have a diffuse texture", {});
if(Containers::Optional<Matrix3> set = tryAttribute<Matrix3>(MaterialAttribute::DiffuseTextureMatrix)) if(Containers::Optional<Matrix3> set = findAttribute<Matrix3>(MaterialAttribute::DiffuseTextureMatrix))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -279,7 +279,7 @@ Matrix3 PhongMaterialData::diffuseTextureMatrix() const {
UnsignedInt PhongMaterialData::diffuseTextureCoordinates() const { UnsignedInt PhongMaterialData::diffuseTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture),
"Trade::PhongMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture", {}); "Trade::PhongMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureCoordinates)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureCoordinates))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -287,7 +287,7 @@ UnsignedInt PhongMaterialData::diffuseTextureCoordinates() const {
UnsignedInt PhongMaterialData::diffuseTextureLayer() const { UnsignedInt PhongMaterialData::diffuseTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture),
"Trade::PhongMaterialData::diffuseTextureLayer(): the material doesn't have a diffuse texture", {}); "Trade::PhongMaterialData::diffuseTextureLayer(): the material doesn't have a diffuse texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureLayer)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureLayer))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -297,9 +297,9 @@ Color4 PhongMaterialData::specularColor() const {
} }
UnsignedInt PhongMaterialData::specularTexture() const { UnsignedInt PhongMaterialData::specularTexture() const {
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture))
return *value; return *value;
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTexture)) if(Containers::Optional<UnsignedInt> value = findAttribute<UnsignedInt>(MaterialAttribute::SpecularTexture))
return *value; return *value;
/* Explicit assertion because printing that SpecularTexture isn't found /* Explicit assertion because printing that SpecularTexture isn't found
@ -318,7 +318,7 @@ MaterialTextureSwizzle PhongMaterialData::specularTextureSwizzle() const {
Matrix3 PhongMaterialData::specularTextureMatrix() const { Matrix3 PhongMaterialData::specularTextureMatrix() const {
CORRADE_ASSERT(hasSpecularTexture(), CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PhongMaterialData::specularTextureMatrix(): the material doesn't have a specular texture", {}); "Trade::PhongMaterialData::specularTextureMatrix(): the material doesn't have a specular texture", {});
if(Containers::Optional<Matrix3> set = tryAttribute<Matrix3>(MaterialAttribute::SpecularTextureMatrix)) if(Containers::Optional<Matrix3> set = findAttribute<Matrix3>(MaterialAttribute::SpecularTextureMatrix))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -326,7 +326,7 @@ Matrix3 PhongMaterialData::specularTextureMatrix() const {
UnsignedInt PhongMaterialData::specularTextureCoordinates() const { UnsignedInt PhongMaterialData::specularTextureCoordinates() const {
CORRADE_ASSERT(hasSpecularTexture(), CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PhongMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture", {}); "Trade::PhongMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureCoordinates)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureCoordinates))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -334,7 +334,7 @@ UnsignedInt PhongMaterialData::specularTextureCoordinates() const {
UnsignedInt PhongMaterialData::specularTextureLayer() const { UnsignedInt PhongMaterialData::specularTextureLayer() const {
CORRADE_ASSERT(hasSpecularTexture(), CORRADE_ASSERT(hasSpecularTexture(),
"Trade::PhongMaterialData::specularTextureLayer(): the material doesn't have a specular texture", {}); "Trade::PhongMaterialData::specularTextureLayer(): the material doesn't have a specular texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureLayer)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureLayer))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }
@ -358,7 +358,7 @@ MaterialTextureSwizzle PhongMaterialData::normalTextureSwizzle() const {
Matrix3 PhongMaterialData::normalTextureMatrix() const { Matrix3 PhongMaterialData::normalTextureMatrix() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PhongMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {}); "Trade::PhongMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {});
if(Containers::Optional<Matrix3> set = tryAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix)) if(Containers::Optional<Matrix3> set = findAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{});
} }
@ -366,7 +366,7 @@ Matrix3 PhongMaterialData::normalTextureMatrix() const {
UnsignedInt PhongMaterialData::normalTextureCoordinates() const { UnsignedInt PhongMaterialData::normalTextureCoordinates() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PhongMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {}); "Trade::PhongMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); return attributeOr(MaterialAttribute::TextureCoordinates, 0u);
} }
@ -374,7 +374,7 @@ UnsignedInt PhongMaterialData::normalTextureCoordinates() const {
UnsignedInt PhongMaterialData::normalTextureLayer() const { UnsignedInt PhongMaterialData::normalTextureLayer() const {
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture),
"Trade::PhongMaterialData::normalTextureLayer(): the material doesn't have a normal texture", {}); "Trade::PhongMaterialData::normalTextureLayer(): the material doesn't have a normal texture", {});
if(Containers::Optional<UnsignedInt> set = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer)) if(Containers::Optional<UnsignedInt> set = findAttribute<UnsignedInt>(MaterialAttribute::NormalTextureLayer))
return *set; return *set;
return attributeOr(MaterialAttribute::TextureLayer, 0u); return attributeOr(MaterialAttribute::TextureLayer, 0u);
} }

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

@ -1940,20 +1940,20 @@ void MaterialDataTest::accessOptional() {
}}; }};
/* This exists */ /* This exists */
CORRADE_VERIFY(data.tryAttribute("SpecularTexture")); CORRADE_VERIFY(data.findAttribute("SpecularTexture"));
CORRADE_VERIFY(data.tryAttribute(MaterialAttribute::SpecularTexture)); CORRADE_VERIFY(data.findAttribute(MaterialAttribute::SpecularTexture));
CORRADE_COMPARE(*static_cast<const Int*>(data.tryAttribute("SpecularTexture")), 3); CORRADE_COMPARE(*static_cast<const Int*>(data.findAttribute("SpecularTexture")), 3);
CORRADE_COMPARE(*static_cast<const Int*>(data.tryAttribute(MaterialAttribute::SpecularTexture)), 3); CORRADE_COMPARE(*static_cast<const Int*>(data.findAttribute(MaterialAttribute::SpecularTexture)), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>("SpecularTexture"), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>("SpecularTexture"), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTexture), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>(MaterialAttribute::SpecularTexture), 3);
CORRADE_COMPARE(data.attributeOr("SpecularTexture", 5u), 3); CORRADE_COMPARE(data.attributeOr("SpecularTexture", 5u), 3);
CORRADE_COMPARE(data.attributeOr(MaterialAttribute::SpecularTexture, 5u), 3); CORRADE_COMPARE(data.attributeOr(MaterialAttribute::SpecularTexture, 5u), 3);
/* This doesn't */ /* This doesn't */
CORRADE_VERIFY(!data.tryAttribute("DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute("DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute(MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute(MaterialAttribute::DiffuseTexture));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>("DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>("DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>(MaterialAttribute::DiffuseTexture));
CORRADE_COMPARE(data.attributeOr("DiffuseTexture", 5u), 5); CORRADE_COMPARE(data.attributeOr("DiffuseTexture", 5u), 5);
CORRADE_COMPARE(data.attributeOr(MaterialAttribute::DiffuseTexture, 5u), 5); CORRADE_COMPARE(data.attributeOr(MaterialAttribute::DiffuseTexture, 5u), 5);
} }
@ -2030,8 +2030,8 @@ void MaterialDataTest::accessWrongType() {
data.mutableAttribute<Color3>(0); data.mutableAttribute<Color3>(0);
data.mutableAttribute<Color3>(MaterialAttribute::DiffuseColor); data.mutableAttribute<Color3>(MaterialAttribute::DiffuseColor);
data.mutableAttribute<Color3>("DiffuseColor"); data.mutableAttribute<Color3>("DiffuseColor");
data.tryAttribute<Color3>(MaterialAttribute::DiffuseColor); data.findAttribute<Color3>(MaterialAttribute::DiffuseColor);
data.tryAttribute<Color3>("DiffuseColor"); data.findAttribute<Color3>("DiffuseColor");
data.attributeOr(MaterialAttribute::DiffuseColor, Color3{1.0f}); data.attributeOr(MaterialAttribute::DiffuseColor, Color3{1.0f});
data.attributeOr("DiffuseColor", Color3{1.0f}); data.attributeOr("DiffuseColor", Color3{1.0f});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
@ -2041,7 +2041,7 @@ void MaterialDataTest::accessWrongType() {
"Trade::MaterialData::mutableAttribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n" "Trade::MaterialData::mutableAttribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n"
"Trade::MaterialData::mutableAttribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n" "Trade::MaterialData::mutableAttribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n"
"Trade::MaterialData::mutableAttribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n" "Trade::MaterialData::mutableAttribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n"
/* tryAttribute() and attributeOr() delegate to attribute() so the /* findAttribute() and attributeOr() delegate to attribute() so the
assert is the same */ assert is the same */
"Trade::MaterialData::attribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n" "Trade::MaterialData::attribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n"
"Trade::MaterialData::attribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n" "Trade::MaterialData::attribute(): DiffuseColor is Trade::MaterialAttributeType::Vector4 but requested a type equivalent to Trade::MaterialAttributeType::Vector3\n"
@ -2098,8 +2098,8 @@ void MaterialDataTest::accessWrongTypeString() {
data.mutableAttribute<Containers::MutableStringView>(0); data.mutableAttribute<Containers::MutableStringView>(0);
data.mutableAttribute<Containers::MutableStringView>(MaterialAttribute::Shininess); data.mutableAttribute<Containers::MutableStringView>(MaterialAttribute::Shininess);
data.mutableAttribute<Containers::MutableStringView>("Shininess"); data.mutableAttribute<Containers::MutableStringView>("Shininess");
data.tryAttribute<Containers::StringView>(MaterialAttribute::Shininess); data.findAttribute<Containers::StringView>(MaterialAttribute::Shininess);
data.tryAttribute<Containers::StringView>("Shininess"); data.findAttribute<Containers::StringView>("Shininess");
data.attributeOr(MaterialAttribute::Shininess, Containers::StringView{}); data.attributeOr(MaterialAttribute::Shininess, Containers::StringView{});
data.attributeOr("Shininess", Containers::StringView{}); data.attributeOr("Shininess", Containers::StringView{});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
@ -2109,7 +2109,7 @@ void MaterialDataTest::accessWrongTypeString() {
"Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n" "Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n"
"Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n" "Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n"
"Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n" "Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n"
/* tryAttribute() and attributeOr() delegate to attribute() so the /* findAttribute() and attributeOr() delegate to attribute() so the
assert is the same */ assert is the same */
"Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n" "Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n"
"Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n" "Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a string\n"
@ -2132,8 +2132,8 @@ void MaterialDataTest::accessWrongTypeBuffer() {
data.mutableAttribute<Containers::ArrayView<void>>(0); data.mutableAttribute<Containers::ArrayView<void>>(0);
data.mutableAttribute<Containers::ArrayView<void>>(MaterialAttribute::Shininess); data.mutableAttribute<Containers::ArrayView<void>>(MaterialAttribute::Shininess);
data.mutableAttribute<Containers::ArrayView<void>>("Shininess"); data.mutableAttribute<Containers::ArrayView<void>>("Shininess");
data.tryAttribute<Containers::ArrayView<const void>>(MaterialAttribute::Shininess); data.findAttribute<Containers::ArrayView<const void>>(MaterialAttribute::Shininess);
data.tryAttribute<Containers::ArrayView<const void>>("Shininess"); data.findAttribute<Containers::ArrayView<const void>>("Shininess");
data.attributeOr(MaterialAttribute::Shininess, Containers::ArrayView<const void>{}); data.attributeOr(MaterialAttribute::Shininess, Containers::ArrayView<const void>{});
data.attributeOr("Shininess", Containers::ArrayView<const void>{}); data.attributeOr("Shininess", Containers::ArrayView<const void>{});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
@ -2143,7 +2143,7 @@ void MaterialDataTest::accessWrongTypeBuffer() {
"Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n" "Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n"
"Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n" "Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n"
"Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n" "Trade::MaterialData::mutableAttribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n"
/* tryAttribute() and attributeOr() delegate to attribute() so the /* findAttribute() and attributeOr() delegate to attribute() so the
assert is the same */ assert is the same */
"Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n" "Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n"
"Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n" "Trade::MaterialData::attribute(): Shininess of Trade::MaterialAttributeType::Float can't be retrieved as a buffer\n"
@ -2500,20 +2500,20 @@ void MaterialDataTest::accessLayerIndexOptional() {
}, {1, 3}}; }, {1, 3}};
/* This exists */ /* This exists */
CORRADE_VERIFY(data.tryAttribute(1, "SpecularTexture")); CORRADE_VERIFY(data.findAttribute(1, "SpecularTexture"));
CORRADE_VERIFY(data.tryAttribute(1, MaterialAttribute::SpecularTexture)); CORRADE_VERIFY(data.findAttribute(1, MaterialAttribute::SpecularTexture));
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute(1, "SpecularTexture")), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute(1, "SpecularTexture")), 3);
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute(1, MaterialAttribute::SpecularTexture)), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute(1, MaterialAttribute::SpecularTexture)), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>(1, "SpecularTexture"), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>(1, "SpecularTexture"), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>(1, MaterialAttribute::SpecularTexture), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>(1, MaterialAttribute::SpecularTexture), 3);
CORRADE_COMPARE(data.attributeOr(1, "SpecularTexture", 5u), 3); CORRADE_COMPARE(data.attributeOr(1, "SpecularTexture", 5u), 3);
CORRADE_COMPARE(data.attributeOr(1, MaterialAttribute::SpecularTexture, 5u), 3); CORRADE_COMPARE(data.attributeOr(1, MaterialAttribute::SpecularTexture, 5u), 3);
/* This doesn't */ /* This doesn't */
CORRADE_VERIFY(!data.tryAttribute(1, "DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute(1, "DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute(1, MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute(1, MaterialAttribute::DiffuseTexture));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>(1, "DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>(1, "DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>(1, MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>(1, MaterialAttribute::DiffuseTexture));
CORRADE_COMPARE(data.attributeOr(1, "DiffuseTexture", 5u), 5); CORRADE_COMPARE(data.attributeOr(1, "DiffuseTexture", 5u), 5);
CORRADE_COMPARE(data.attributeOr(1, MaterialAttribute::DiffuseTexture, 5u), 5); CORRADE_COMPARE(data.attributeOr(1, MaterialAttribute::DiffuseTexture, 5u), 5);
} }
@ -2527,20 +2527,20 @@ void MaterialDataTest::accessLayerNameOptional() {
}, {1, 4}}; }, {1, 4}};
/* This exists */ /* This exists */
CORRADE_VERIFY(data.tryAttribute(MaterialLayer::ClearCoat, "SpecularTexture")); CORRADE_VERIFY(data.findAttribute(MaterialLayer::ClearCoat, "SpecularTexture"));
CORRADE_VERIFY(data.tryAttribute(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture)); CORRADE_VERIFY(data.findAttribute(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture));
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute(MaterialLayer::ClearCoat, "SpecularTexture")), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute(MaterialLayer::ClearCoat, "SpecularTexture")), 3);
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture)), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture)), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>(MaterialLayer::ClearCoat, "SpecularTexture"), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>(MaterialLayer::ClearCoat, "SpecularTexture"), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture), 3);
CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, "SpecularTexture", 5u), 3); CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, "SpecularTexture", 5u), 3);
CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture, 5u), 3); CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, MaterialAttribute::SpecularTexture, 5u), 3);
/* This doesn't */ /* This doesn't */
CORRADE_VERIFY(!data.tryAttribute(MaterialLayer::ClearCoat, "DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute(MaterialLayer::ClearCoat, "DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute(MaterialLayer::ClearCoat, MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute(MaterialLayer::ClearCoat, MaterialAttribute::DiffuseTexture));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>(MaterialLayer::ClearCoat, "DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>(MaterialLayer::ClearCoat, "DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>(MaterialLayer::ClearCoat, MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>(MaterialLayer::ClearCoat, MaterialAttribute::DiffuseTexture));
CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, "DiffuseTexture", 5u), 5); CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, "DiffuseTexture", 5u), 5);
CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, MaterialAttribute::DiffuseTexture, 5u), 5); CORRADE_COMPARE(data.attributeOr(MaterialLayer::ClearCoat, MaterialAttribute::DiffuseTexture, 5u), 5);
} }
@ -2554,20 +2554,20 @@ void MaterialDataTest::accessLayerStringOptional() {
}, {1, 4}}; }, {1, 4}};
/* This exists */ /* This exists */
CORRADE_VERIFY(data.tryAttribute("ClearCoat", "SpecularTexture")); CORRADE_VERIFY(data.findAttribute("ClearCoat", "SpecularTexture"));
CORRADE_VERIFY(data.tryAttribute("ClearCoat", MaterialAttribute::SpecularTexture)); CORRADE_VERIFY(data.findAttribute("ClearCoat", MaterialAttribute::SpecularTexture));
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute("ClearCoat", "SpecularTexture")), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute("ClearCoat", "SpecularTexture")), 3);
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute("ClearCoat", MaterialAttribute::SpecularTexture)), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute("ClearCoat", MaterialAttribute::SpecularTexture)), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>("ClearCoat", "SpecularTexture"), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>("ClearCoat", "SpecularTexture"), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>("ClearCoat", MaterialAttribute::SpecularTexture), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>("ClearCoat", MaterialAttribute::SpecularTexture), 3);
CORRADE_COMPARE(data.attributeOr("ClearCoat", "SpecularTexture", 5u), 3); CORRADE_COMPARE(data.attributeOr("ClearCoat", "SpecularTexture", 5u), 3);
CORRADE_COMPARE(data.attributeOr("ClearCoat", MaterialAttribute::SpecularTexture, 5u), 3); CORRADE_COMPARE(data.attributeOr("ClearCoat", MaterialAttribute::SpecularTexture, 5u), 3);
/* This doesn't */ /* This doesn't */
CORRADE_VERIFY(!data.tryAttribute("ClearCoat", "DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute("ClearCoat", "DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute("ClearCoat", MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute("ClearCoat", MaterialAttribute::DiffuseTexture));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>("ClearCoat", "DiffuseTexture")); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>("ClearCoat", "DiffuseTexture"));
CORRADE_VERIFY(!data.tryAttribute<UnsignedInt>("ClearCoat", MaterialAttribute::DiffuseTexture)); CORRADE_VERIFY(!data.findAttribute<UnsignedInt>("ClearCoat", MaterialAttribute::DiffuseTexture));
CORRADE_COMPARE(data.attributeOr("ClearCoat", "DiffuseTexture", 5u), 5); CORRADE_COMPARE(data.attributeOr("ClearCoat", "DiffuseTexture", 5u), 5);
CORRADE_COMPARE(data.attributeOr("ClearCoat", MaterialAttribute::DiffuseTexture, 5u), 5); CORRADE_COMPARE(data.attributeOr("ClearCoat", MaterialAttribute::DiffuseTexture, 5u), 5);
} }
@ -2615,10 +2615,10 @@ void MaterialDataTest::accessLayerOutOfBounds() {
data.mutableAttribute<Int>(2, "AlphaMask"); data.mutableAttribute<Int>(2, "AlphaMask");
data.mutableAttribute<Int>(2, MaterialAttribute::AlphaMask); data.mutableAttribute<Int>(2, MaterialAttribute::AlphaMask);
data.mutableAttribute<Containers::MutableStringView>(2, 0); data.mutableAttribute<Containers::MutableStringView>(2, 0);
data.tryAttribute(2, "AlphaMask"); data.findAttribute(2, "AlphaMask");
data.tryAttribute(2, MaterialAttribute::AlphaMask); data.findAttribute(2, MaterialAttribute::AlphaMask);
data.tryAttribute<bool>(2, "AlphaMask"); data.findAttribute<bool>(2, "AlphaMask");
data.tryAttribute<bool>(2, MaterialAttribute::AlphaMask); data.findAttribute<bool>(2, MaterialAttribute::AlphaMask);
data.attributeOr(2, "AlphaMask", false); data.attributeOr(2, "AlphaMask", false);
data.attributeOr(2, MaterialAttribute::AlphaMask, false); data.attributeOr(2, MaterialAttribute::AlphaMask, false);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
@ -2708,10 +2708,10 @@ void MaterialDataTest::accessLayerNotFound() {
data.mutableAttribute<Int>("ClearCoat", "AlphaMask"); data.mutableAttribute<Int>("ClearCoat", "AlphaMask");
data.mutableAttribute<Int>("ClearCoat", MaterialAttribute::AlphaMask); data.mutableAttribute<Int>("ClearCoat", MaterialAttribute::AlphaMask);
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", 0); data.mutableAttribute<Containers::MutableStringView>("ClearCoat", 0);
data.tryAttribute("ClearCoat", "AlphaMask"); data.findAttribute("ClearCoat", "AlphaMask");
data.tryAttribute("ClearCoat", MaterialAttribute::AlphaMask); data.findAttribute("ClearCoat", MaterialAttribute::AlphaMask);
data.tryAttribute<bool>("ClearCoat", "AlphaMask"); data.findAttribute<bool>("ClearCoat", "AlphaMask");
data.tryAttribute<bool>("ClearCoat", MaterialAttribute::AlphaMask); data.findAttribute<bool>("ClearCoat", MaterialAttribute::AlphaMask);
data.attributeOr("ClearCoat", "AlphaMask", false); data.attributeOr("ClearCoat", "AlphaMask", false);
data.attributeOr("ClearCoat", MaterialAttribute::AlphaMask, false); data.attributeOr("ClearCoat", MaterialAttribute::AlphaMask, false);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
@ -2796,10 +2796,10 @@ void MaterialDataTest::accessInvalidLayerName() {
data.mutableAttribute<Int>(MaterialLayer(0xfefe), "AlphaMask"); data.mutableAttribute<Int>(MaterialLayer(0xfefe), "AlphaMask");
data.mutableAttribute<Int>(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask); data.mutableAttribute<Int>(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask);
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer(0xfefe), 0); data.mutableAttribute<Containers::MutableStringView>(MaterialLayer(0xfefe), 0);
data.tryAttribute(MaterialLayer(0xfefe), "AlphaMask"); data.findAttribute(MaterialLayer(0xfefe), "AlphaMask");
data.tryAttribute(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask); data.findAttribute(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask);
data.tryAttribute<bool>(MaterialLayer(0xfefe), "AlphaMask"); data.findAttribute<bool>(MaterialLayer(0xfefe), "AlphaMask");
data.tryAttribute<bool>(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask); data.findAttribute<bool>(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask);
data.attributeOr(MaterialLayer(0xfefe), "AlphaMask", false); data.attributeOr(MaterialLayer(0xfefe), "AlphaMask", false);
data.attributeOr(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask, false); data.attributeOr(MaterialLayer(0xfefe), MaterialAttribute::AlphaMask, false);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
@ -2988,10 +2988,10 @@ void MaterialDataTest::accessInvalidAttributeName() {
data.mutableAttribute("Layer", MaterialAttribute(0xfefe)); data.mutableAttribute("Layer", MaterialAttribute(0xfefe));
data.mutableAttribute<Int>(0, MaterialAttribute(0x0)); data.mutableAttribute<Int>(0, MaterialAttribute(0x0));
data.mutableAttribute<Int>("Layer", MaterialAttribute(0xfefe)); data.mutableAttribute<Int>("Layer", MaterialAttribute(0xfefe));
data.tryAttribute(0, MaterialAttribute(0x0)); data.findAttribute(0, MaterialAttribute(0x0));
data.tryAttribute("Layer", MaterialAttribute(0xfefe)); data.findAttribute("Layer", MaterialAttribute(0xfefe));
data.tryAttribute<Int>(0, MaterialAttribute(0x0)); data.findAttribute<Int>(0, MaterialAttribute(0x0));
data.tryAttribute<Int>("Layer", MaterialAttribute(0xfefe)); data.findAttribute<Int>("Layer", MaterialAttribute(0xfefe));
data.attributeOr(0, MaterialAttribute(0x0), 42); data.attributeOr(0, MaterialAttribute(0x0), 42);
data.attributeOr("Layer", MaterialAttribute(0xfefe), 42); data.attributeOr("Layer", MaterialAttribute(0xfefe), 42);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
@ -3220,11 +3220,11 @@ void MaterialDataTest::templateLayerAccess() {
CORRADE_COMPARE(data.mutableAttribute<UnsignedInt>(MaterialAttribute::LayerFactorTexture), 3); CORRADE_COMPARE(data.mutableAttribute<UnsignedInt>(MaterialAttribute::LayerFactorTexture), 3);
CORRADE_COMPARE(data.mutableAttribute<UnsignedInt>("LayerFactorTexture"), 3); CORRADE_COMPARE(data.mutableAttribute<UnsignedInt>("LayerFactorTexture"), 3);
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute(MaterialAttribute::LayerFactorTexture)), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute(MaterialAttribute::LayerFactorTexture)), 3);
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.tryAttribute("LayerFactorTexture")), 3); CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.findAttribute("LayerFactorTexture")), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>(MaterialAttribute::LayerFactorTexture), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>(MaterialAttribute::LayerFactorTexture), 3);
CORRADE_COMPARE(data.tryAttribute<UnsignedInt>("LayerFactorTexture"), 3); CORRADE_COMPARE(data.findAttribute<UnsignedInt>("LayerFactorTexture"), 3);
CORRADE_COMPARE(data.attributeOr(MaterialAttribute::LayerFactorTexture, 5u), 3); CORRADE_COMPARE(data.attributeOr(MaterialAttribute::LayerFactorTexture, 5u), 3);
CORRADE_COMPARE(data.attributeOr("LayerFactorTexture", 5u), 3); CORRADE_COMPARE(data.attributeOr("LayerFactorTexture", 5u), 3);

Loading…
Cancel
Save