Browse Source

Trade: use ` LayerName` instead of `$LayerName` in MaterialData.

Reason is that Assimp custom material attribute names are also prefixed
with $ and other weird characters, which could lead to them appearing
before $LayerName, causing a layer to falsely appear unnamed. A space,
instead, is before all printable characters so it's guaranteed to be
always first.

Some things you just don't realize at first. Fortunately the binary
layout isn't pinned yet for the serialization format so this change is
mostly fine.
pull/525/head
Vladimír Vondruš 5 years ago
parent
commit
aeeff73a71
  1. 2
      src/Magnum/MeshTools/sceneconverter.cpp
  2. 2
      src/Magnum/Trade/Implementation/materialAttributeProperties.hpp
  3. 8
      src/Magnum/Trade/MaterialData.cpp
  4. 17
      src/Magnum/Trade/MaterialData.h
  5. 90
      src/Magnum/Trade/Test/MaterialDataTest.cpp

2
src/Magnum/MeshTools/sceneconverter.cpp

@ -694,7 +694,7 @@ used.)")
/* Ignore layer name (which is always first) unless it's in
the base material, in which case we print it as it
wouldn't otherwise be shown anywhere */
if(i && !j && info.data.attributeName(i, j) == "$LayerName")
if(i && !j && info.data.attributeName(i, j) == " LayerName")
continue;
d << Debug::newline << indent

2
src/Magnum/Trade/Implementation/materialAttributeProperties.hpp

@ -25,7 +25,7 @@
/* See Magnum/Trade/MaterialData.cpp and Magnum/Trade/Test/MaterialDataTest.cpp */
#ifdef _c
_cnt(LayerName,"$LayerName",String,Containers::StringView)
_cnt(LayerName," LayerName",String,Containers::StringView)
_c(AlphaMask,Float)
_ct(AlphaBlend,Bool,bool)
_ct(DoubleSided,Bool,bool)

8
src/Magnum/Trade/MaterialData.cpp

@ -314,7 +314,7 @@ Containers::StringView MaterialData::attributeString(const MaterialAttribute nam
UnsignedInt MaterialData::layerFor(const Containers::StringView layer) const {
for(std::size_t i = 1; i < _layerOffsets.size(); ++i) {
if(_layerOffsets[i] > _layerOffsets[i - 1] &&
_data[_layerOffsets[i - 1]].name() == "$LayerName"_s &&
_data[_layerOffsets[i - 1]].name() == " LayerName"_s &&
_data[_layerOffsets[i - 1]].value<Containers::StringView>() == layer)
return i;
}
@ -348,7 +348,7 @@ Containers::StringView MaterialData::layerName(const UnsignedInt layer) const {
CORRADE_ASSERT(layer < layerCount(),
"Trade::MaterialData::layerName(): index" << layer << "out of range for" << layerCount() << "layers", {});
/* Deliberately ignore this attribute in the base material */
if(layer && _layerOffsets[layer] > _layerOffsets[layer - 1] && _data[_layerOffsets[layer - 1]].name() == "$LayerName")
if(layer && _layerOffsets[layer] > _layerOffsets[layer - 1] && _data[_layerOffsets[layer - 1]].name() == " LayerName")
return _data[_layerOffsets[layer - 1]].value<Containers::StringView>();
return {};
}
@ -953,9 +953,9 @@ Debug& operator<<(Debug& debug, const MaterialAttribute value) {
if(UnsignedInt(value) - 1 >= Containers::arraySize(AttributeMap))
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
/* LayerName is prefixed with $, drop that */
/* LayerName is prefixed with a single space, drop that */
Containers::StringView string = AttributeMap[UnsignedInt(value) - 1].name;
if(string[0] == '$') string = string.suffix(1);
if(string[0] == ' ') string = string.suffix(1);
return debug << "::" << Debug::nospace << string;
}

17
src/Magnum/Trade/MaterialData.h

@ -93,7 +93,7 @@ MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, MaterialLayer value);
Convenience aliases to actual attribute name strings. In most cases the alias
is in the same form and capitalization --- so for example
@ref MaterialAttribute::DoubleSided is an alias for @cpp "DoubleSided" @ce, the
only exception is @ref MaterialAttribute::LayerName which is @cpp "$LayerName" @ce.
only exception is @ref MaterialAttribute::LayerName which is @cpp " LayerName" @ce (with a space at the front).
When this enum si used in
@ref MaterialAttributeData constructors, the data are additionally checked for
@ -108,9 +108,9 @@ enum class MaterialAttribute: UnsignedInt {
* Layer name, @ref MaterialAttributeType::String.
*
* Unlike other attributes where string name matches the enum name, in this
* case the corresponding string is @cpp "$LayerName" @ce, done in order to
* have the layer name attribute appear first in each layer and thus
* simplify layer implementation.
* case the corresponding string is @cpp " LayerName" @ce (with a space at
* the front), done in order to have the layer name attribute appear first
* in each layer and thus simplify layer implementation.
* @see @ref MaterialData::layerName()
*/
LayerName = 1,
@ -1591,10 +1591,11 @@ already sorted by name.
@subsection Trade-MaterialData-populating-custom Custom material attributes
While attribute names beginning with uppercase letters are reserved for builtin
Magnum attributes, anything beginning with a lowercase letter or a non-letter
can be a custom attribute. For greater flexibility, custom attributes can be
also strings or pointers, allowing you to store arbitrary properties or direct
While attribute names beginning with uppercase letters and whitespace are
reserved for builtin Magnum attributes, anything beginning with a lowercase
letter or a printable non-letter character can be a custom attribute. For
greater flexibility, custom attributes can be also strings or pointers,
allowing you to store arbitrary properties such as image filenames or direct
texture pointers instead of IDs:
@snippet MagnumTrade.cpp MaterialData-populating-custom

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

@ -603,7 +603,7 @@ void MaterialDataTest::constructAttributeNameStringValue() {
byte isn't read by accident*/
MaterialAttributeData attribute{MaterialAttribute::LayerName, "a value\0that's long but still fits!!"_s.except(1)};
CORRADE_COMPARE(attribute.name(), "$LayerName");
CORRADE_COMPARE(attribute.name(), " LayerName");
CORRADE_COMPARE(attribute.name().flags(), Containers::StringViewFlag::NullTerminated);
CORRADE_COMPARE(attribute.name()[attribute.name().size()], '\0');
CORRADE_COMPARE(attribute.type(), MaterialAttributeType::String);
@ -616,7 +616,7 @@ void MaterialDataTest::constructAttributeNameStringValue() {
/* Type-erased variant */
const Containers::StringView value = "a value\0that's long but still fits!!"_s.except(1);
MaterialAttributeData typeErased{MaterialAttribute::LayerName, MaterialAttributeType::String, &value};
CORRADE_COMPARE(typeErased.name(), "$LayerName");
CORRADE_COMPARE(typeErased.name(), " LayerName");
CORRADE_COMPARE(typeErased.name().flags(), Containers::StringViewFlag::NullTerminated);
CORRADE_COMPARE(typeErased.name()[typeErased.name().size()], '\0');
CORRADE_COMPARE(typeErased.type(), MaterialAttributeType::String);
@ -648,7 +648,7 @@ void MaterialDataTest::constructAttributeTextureSwizzle() {
void MaterialDataTest::constructAttributeLayer() {
MaterialAttributeData attribute{MaterialLayer::ClearCoat};
CORRADE_COMPARE(attribute.name(), "$LayerName");
CORRADE_COMPARE(attribute.name(), " LayerName");
CORRADE_COMPARE(attribute.type(), MaterialAttributeType::String);
CORRADE_COMPARE(attribute.value<Containers::StringView>(), "ClearCoat");
}
@ -755,7 +755,7 @@ void MaterialDataTest::constructAttributeTooLargeNameString() {
Error redirectError{&out};
MaterialAttributeData{MaterialAttribute::LayerName, "This is a problem, got a huge, yuuge value to store"};
CORRADE_COMPARE(out.str(),
"Trade::MaterialAttributeData: name $LayerName and value This is a problem, got a huge, yuuge value to store too long, expected at most 60 bytes in total but got 61\n");
"Trade::MaterialAttributeData: name LayerName and value This is a problem, got a huge, yuuge value to store too long, expected at most 60 bytes in total but got 61\n");
}
void MaterialDataTest::constructAttributeWrongAccessType() {
@ -1026,7 +1026,7 @@ void MaterialDataTest::constructLayers() {
CORRADE_COMPARE(data.attributeName(0, 0), "DiffuseTextureCoordinates");
CORRADE_COMPARE(data.attributeName(0, 1), "DoubleSided");
CORRADE_COMPARE(data.attributeName(1, 0), "$LayerName");
CORRADE_COMPARE(data.attributeName(1, 0), " LayerName");
CORRADE_COMPARE(data.attributeName(1, 1), "AlphaBlend");
CORRADE_COMPARE(data.attributeName(1, 2), "highlightColor");
@ -1093,37 +1093,37 @@ void MaterialDataTest::constructLayers() {
CORRADE_VERIFY(data.hasAttribute(0, "DoubleSided"));
CORRADE_VERIFY(!data.hasAttribute(0, "highlightColor"));
CORRADE_VERIFY(data.hasAttribute(1, "highlightColor"));
CORRADE_VERIFY(data.hasAttribute(1, "$LayerName"));
CORRADE_VERIFY(!data.hasAttribute(2, "$LayerName"));
CORRADE_VERIFY(data.hasAttribute(1, " LayerName"));
CORRADE_VERIFY(!data.hasAttribute(2, " LayerName"));
CORRADE_VERIFY(!data.hasAttribute(2, "NormalTexture"));
CORRADE_VERIFY(data.hasAttribute(3, "NormalTexture"));
CORRADE_COMPARE(data.attributeId(0, "DoubleSided"), 1);
CORRADE_COMPARE(data.attributeId(1, "highlightColor"), 2);
CORRADE_COMPARE(data.attributeId(1, "$LayerName"), 0);
CORRADE_COMPARE(data.attributeId(1, " LayerName"), 0);
CORRADE_COMPARE(data.attributeId(3, "NormalTexture"), 0);
CORRADE_COMPARE(data.attributeType(0, "DoubleSided"), MaterialAttributeType::Bool);
CORRADE_COMPARE(data.attributeType(1, "highlightColor"), MaterialAttributeType::Vector4);
CORRADE_COMPARE(data.attributeType(1, "$LayerName"), MaterialAttributeType::String);
CORRADE_COMPARE(data.attributeType(1, " LayerName"), MaterialAttributeType::String);
CORRADE_COMPARE(data.attributeType(3, "NormalTexture"), MaterialAttributeType::UnsignedInt);
CORRADE_COMPARE(data.attribute<bool>(0, "DoubleSided"), true);
CORRADE_COMPARE(data.attribute<Color4>(1, "highlightColor"), 0x335566ff_rgbaf);
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, "$LayerName"), "ClearCoat");
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, " LayerName"), "ClearCoat");
CORRADE_COMPARE(data.attribute<UnsignedInt>(3, "NormalTexture"), 3);
CORRADE_COMPARE(data.mutableAttribute<bool>(0, "DoubleSided"), true);
CORRADE_COMPARE(data.mutableAttribute<Color4>(1, "highlightColor"), 0x335566ff_rgbaf);
CORRADE_COMPARE(data.mutableAttribute<Containers::MutableStringView>(1, "$LayerName"), "ClearCoat"_s);
CORRADE_COMPARE(data.mutableAttribute<Containers::MutableStringView>(1, " LayerName"), "ClearCoat"_s);
CORRADE_COMPARE(data.mutableAttribute<UnsignedInt>(3, "NormalTexture"), 3);
CORRADE_COMPARE(*static_cast<const bool*>(data.attribute(0, "DoubleSided")), true);
CORRADE_COMPARE(*static_cast<const Color4*>(data.attribute(1, "highlightColor")), 0x335566ff_rgbaf);
CORRADE_COMPARE(static_cast<const char*>(data.attribute(1, "$LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(static_cast<const char*>(data.attribute(1, " LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(*static_cast<const UnsignedInt*>(data.attribute(3, "NormalTexture")), 3);
CORRADE_COMPARE(*static_cast<bool*>(data.mutableAttribute(0, "DoubleSided")), true);
CORRADE_COMPARE(*static_cast<Color4*>(data.mutableAttribute(1, "highlightColor")), 0x335566ff_rgbaf);
CORRADE_COMPARE(static_cast<char*>(data.mutableAttribute(1, "$LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(static_cast<char*>(data.mutableAttribute(1, " LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(*static_cast<UnsignedInt*>(data.mutableAttribute(3, "NormalTexture")), 3);
/* Access by layer name and attribute ID */
@ -1165,23 +1165,23 @@ void MaterialDataTest::constructLayers() {
/* Access by layer name and attribute string */
CORRADE_VERIFY(data.hasAttribute(MaterialLayer::ClearCoat, "highlightColor"));
CORRADE_VERIFY(data.hasAttribute(MaterialLayer::ClearCoat, "$LayerName"));
CORRADE_VERIFY(data.hasAttribute(MaterialLayer::ClearCoat, " LayerName"));
CORRADE_COMPARE(data.attributeId(MaterialLayer::ClearCoat, "highlightColor"), 2);
CORRADE_COMPARE(data.attributeId(MaterialLayer::ClearCoat, "$LayerName"), 0);
CORRADE_COMPARE(data.attributeId(MaterialLayer::ClearCoat, " LayerName"), 0);
CORRADE_COMPARE(data.attributeType(MaterialLayer::ClearCoat, "highlightColor"), MaterialAttributeType::Vector4);
CORRADE_COMPARE(data.attributeType(MaterialLayer::ClearCoat, "$LayerName"), MaterialAttributeType::String);
CORRADE_COMPARE(data.attributeType(MaterialLayer::ClearCoat, " LayerName"), MaterialAttributeType::String);
CORRADE_COMPARE(data.attribute<Color4>(MaterialLayer::ClearCoat, "highlightColor"), 0x335566ff_rgbaf);
CORRADE_COMPARE(data.attribute<Containers::StringView>(MaterialLayer::ClearCoat, "$LayerName"), "ClearCoat");
CORRADE_COMPARE(data.attribute<Containers::StringView>(MaterialLayer::ClearCoat, " LayerName"), "ClearCoat");
CORRADE_COMPARE(data.mutableAttribute<Color4>(MaterialLayer::ClearCoat, "highlightColor"), 0x335566ff_rgbaf);
CORRADE_COMPARE(data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, "$LayerName"), "ClearCoat"_s);
CORRADE_COMPARE(data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, " LayerName"), "ClearCoat"_s);
CORRADE_COMPARE(*static_cast<const Color4*>(data.attribute(MaterialLayer::ClearCoat, "highlightColor")), 0x335566ff_rgbaf);
CORRADE_COMPARE(static_cast<const char*>(data.attribute(MaterialLayer::ClearCoat, "$LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(static_cast<const char*>(data.attribute(MaterialLayer::ClearCoat, " LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(*static_cast<Color4*>(data.mutableAttribute(MaterialLayer::ClearCoat, "highlightColor")), 0x335566ff_rgbaf);
CORRADE_COMPARE(static_cast<char*>(data.mutableAttribute(MaterialLayer::ClearCoat, "$LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(static_cast<char*>(data.mutableAttribute(MaterialLayer::ClearCoat, " LayerName")), "ClearCoat"_s);
/* Access by layer string and attribute ID */
CORRADE_COMPARE(data.attributeName("ClearCoat", 1), "AlphaBlend");
@ -1222,23 +1222,23 @@ void MaterialDataTest::constructLayers() {
/* Access by layer string and attribute string */
CORRADE_VERIFY(data.hasAttribute("ClearCoat", "highlightColor"));
CORRADE_VERIFY(data.hasAttribute("ClearCoat", "$LayerName"));
CORRADE_VERIFY(data.hasAttribute("ClearCoat", " LayerName"));
CORRADE_COMPARE(data.attributeId("ClearCoat", "highlightColor"), 2);
CORRADE_COMPARE(data.attributeId("ClearCoat", "$LayerName"), 0);
CORRADE_COMPARE(data.attributeId("ClearCoat", " LayerName"), 0);
CORRADE_COMPARE(data.attributeType("ClearCoat", "highlightColor"), MaterialAttributeType::Vector4);
CORRADE_COMPARE(data.attributeType("ClearCoat", "$LayerName"), MaterialAttributeType::String);
CORRADE_COMPARE(data.attributeType("ClearCoat", " LayerName"), MaterialAttributeType::String);
CORRADE_COMPARE(data.attribute<Color4>("ClearCoat", "highlightColor"), 0x335566ff_rgbaf);
CORRADE_COMPARE(data.attribute<Containers::StringView>("ClearCoat", "$LayerName"), "ClearCoat");
CORRADE_COMPARE(data.attribute<Containers::StringView>("ClearCoat", " LayerName"), "ClearCoat");
CORRADE_COMPARE(data.mutableAttribute<Color4>("ClearCoat", "highlightColor"), 0x335566ff_rgbaf);
CORRADE_COMPARE(data.mutableAttribute<Containers::MutableStringView>("ClearCoat", "$LayerName"), "ClearCoat"_s);
CORRADE_COMPARE(data.mutableAttribute<Containers::MutableStringView>("ClearCoat", " LayerName"), "ClearCoat"_s);
CORRADE_COMPARE(*static_cast<const Color4*>(data.attribute("ClearCoat", "highlightColor")), 0x335566ff_rgbaf);
CORRADE_COMPARE(static_cast<const char*>(data.attribute("ClearCoat", "$LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(static_cast<const char*>(data.attribute("ClearCoat", " LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(*static_cast<Color4*>(data.mutableAttribute("ClearCoat", "highlightColor")), 0x335566ff_rgbaf);
CORRADE_COMPARE(static_cast<char*>(data.mutableAttribute("ClearCoat", "$LayerName")), "ClearCoat"_s);
CORRADE_COMPARE(static_cast<char*>(data.mutableAttribute("ClearCoat", " LayerName")), "ClearCoat"_s);
}
void MaterialDataTest::constructLayersNotMonotonic() {
@ -1314,7 +1314,7 @@ void MaterialDataTest::constructNonOwnedLayers() {
{"DiffuseCoordinateSet"_s, 5u},
{"DoubleSided"_s, true},
{"$LayerName"_s, "ClearCoat"_s},
{" LayerName"_s, "ClearCoat"_s},
{"AlphaBlend"_s, true},
{"highlightColor"_s, Vector4{0.2f, 0.6f, 0.4f, 1.0f}},
@ -1361,7 +1361,7 @@ void MaterialDataTest::constructNonOwnedLayers() {
CORRADE_COMPARE(data.attributeName(0, 0), "DiffuseCoordinateSet");
CORRADE_COMPARE(data.attributeName(0, 1), "DoubleSided");
CORRADE_COMPARE(data.attributeName(1, 0), "$LayerName");
CORRADE_COMPARE(data.attributeName(1, 0), " LayerName");
CORRADE_COMPARE(data.attributeName(1, 1), "AlphaBlend");
CORRADE_COMPARE(data.attributeName(1, 2), "highlightColor");
@ -1687,10 +1687,10 @@ void MaterialDataTest::accessMutable() {
++*static_cast<char*>(data.mutableAttribute(0));
++*static_cast<char*>(data.mutableAttribute(MaterialAttribute::LayerName));
++*static_cast<char*>(data.mutableAttribute("$LayerName"));
++*static_cast<char*>(data.mutableAttribute(" LayerName"));
++data.mutableAttribute<Containers::MutableStringView>(0)[0];
++data.mutableAttribute<Containers::MutableStringView>(MaterialAttribute::LayerName)[0];
++data.mutableAttribute<Containers::MutableStringView>("$LayerName")[0];
++data.mutableAttribute<Containers::MutableStringView>(" LayerName")[0];
CORRADE_COMPARE(data.attribute<Containers::StringView>(MaterialAttribute::LayerName), "gye"_s);
}
@ -2108,10 +2108,10 @@ void MaterialDataTest::accessLayerIndexMutable() {
CORRADE_COMPARE(data.attribute<Float>(1, MaterialAttribute::Roughness), 64.0f);
++*static_cast<char*>(data.mutableAttribute(1, 0));
++*static_cast<char*>(data.mutableAttribute(1, "$LayerName"));
++*static_cast<char*>(data.mutableAttribute(1, " LayerName"));
++*static_cast<char*>(data.mutableAttribute(1, MaterialAttribute::LayerName));
++data.mutableAttribute<Containers::MutableStringView>(1, 0)[0];
++data.mutableAttribute<Containers::MutableStringView>(1, "$LayerName")[0];
++data.mutableAttribute<Containers::MutableStringView>(1, " LayerName")[0];
++data.mutableAttribute<Containers::MutableStringView>(1, MaterialAttribute::LayerName)[0];
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, MaterialAttribute::LayerName), "IlearCoat"_s);
}
@ -2138,7 +2138,7 @@ void MaterialDataTest::accessLayerNameMutable() {
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "DlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
*static_cast<char*>(data.mutableAttribute(MaterialLayer::ClearCoat, "$LayerName")) = 'E';
*static_cast<char*>(data.mutableAttribute(MaterialLayer::ClearCoat, " LayerName")) = 'E';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "ElearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
@ -2150,11 +2150,11 @@ void MaterialDataTest::accessLayerNameMutable() {
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "GlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, "$LayerName")[0] = 'H';
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, " LayerName")[0] = 'H';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "HlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, "$LayerName")[0] = 'I';
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, " LayerName")[0] = 'I';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "IlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
}
@ -2182,7 +2182,7 @@ void MaterialDataTest::accessLayerStringMutable() {
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "DlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
*static_cast<char*>(data.mutableAttribute("ClearCoat", "$LayerName")) = 'E';
*static_cast<char*>(data.mutableAttribute("ClearCoat", " LayerName")) = 'E';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "ElearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
@ -2194,11 +2194,11 @@ void MaterialDataTest::accessLayerStringMutable() {
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "GlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", "$LayerName")[0] = 'H';
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", " LayerName")[0] = 'H';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "HlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", "$LayerName")[0] = 'I';
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", " LayerName")[0] = 'I';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "IlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
}
@ -2745,7 +2745,7 @@ void MaterialDataTest::accessMutableNotAllowed() {
data.mutableAttribute<Float>(1, "Roughness");
data.mutableAttribute<Float>(1, MaterialAttribute::Roughness);
data.mutableAttribute<Containers::MutableStringView>(1, 0);
data.mutableAttribute<Containers::MutableStringView>(1, "$LayerName");
data.mutableAttribute<Containers::MutableStringView>(1, " LayerName");
data.mutableAttribute<Containers::MutableStringView>(1, MaterialAttribute::LayerName);
data.mutableAttribute("ClearCoat", 1);
@ -2755,7 +2755,7 @@ void MaterialDataTest::accessMutableNotAllowed() {
data.mutableAttribute<Float>("ClearCoat", "Roughness");
data.mutableAttribute<Float>("ClearCoat", MaterialAttribute::Roughness);
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", 0);
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", "$LayerName");
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", " LayerName");
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", MaterialAttribute::LayerName);
data.mutableAttribute(MaterialLayer::ClearCoat, 1);
@ -2765,7 +2765,7 @@ void MaterialDataTest::accessMutableNotAllowed() {
data.mutableAttribute<Float>(MaterialLayer::ClearCoat, "Roughness");
data.mutableAttribute<Float>(MaterialLayer::ClearCoat, MaterialAttribute::Roughness);
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, 0);
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, "$LayerName");
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, " LayerName");
data.mutableAttribute<Containers::MutableStringView>(MaterialLayer::ClearCoat, MaterialAttribute::LayerName);
CORRADE_COMPARE(out.str(),
"Trade::MaterialData::mutableAttribute(): attribute data not mutable\n"
@ -2925,7 +2925,7 @@ void MaterialDataTest::templateLayerAccessMutable() {
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "DlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
*static_cast<char*>(data.mutableAttribute("ClearCoat", "$LayerName")) = 'E';
*static_cast<char*>(data.mutableAttribute("ClearCoat", " LayerName")) = 'E';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "ElearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
@ -2937,11 +2937,11 @@ void MaterialDataTest::templateLayerAccessMutable() {
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "GlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", "$LayerName")[0] = 'H';
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", " LayerName")[0] = 'H';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "HlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
} {
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", "$LayerName")[0] = 'I';
data.mutableAttribute<Containers::MutableStringView>("ClearCoat", " LayerName")[0] = 'I';
CORRADE_COMPARE(data.attribute<Containers::StringView>(1, 0), "IlearCoat");
*static_cast<char*>(data.mutableAttribute(1, 0)) = 'C';
}

Loading…
Cancel
Save