diff --git a/src/Magnum/Trade/Implementation/sceneTools.h b/src/Magnum/Trade/Implementation/sceneTools.h index a7a67e67be..e9a8524f92 100644 --- a/src/Magnum/Trade/Implementation/sceneTools.h +++ b/src/Magnum/Trade/Implementation/sceneTools.h @@ -305,6 +305,8 @@ inline SceneData sceneConvertToSingleFunctionObjects(const SceneData& scene, Con - fields that don't actually get their object mapping touched during the process (and then all fields that share object mapping with them) */ +#warning removing implicit mapping from here will mean the null will get treated as a placeholder by copy(), not wanted +#warning it needs to restore the field instead } else fields[i] = SceneFieldData{field.name(), field.mappingType(), field.mappingData(), field.fieldType(), field.fieldData(), field.fieldArraySize(), field.flags() & ~SceneFieldFlag::ImplicitMapping}; } diff --git a/src/Magnum/Trade/Test/SceneToolsTest.cpp b/src/Magnum/Trade/Test/SceneToolsTest.cpp index ccc3d3c76a..991be39837 100644 --- a/src/Magnum/Trade/Test/SceneToolsTest.cpp +++ b/src/Magnum/Trade/Test/SceneToolsTest.cpp @@ -41,6 +41,8 @@ struct SceneToolsTest: TestSuite::Tester { void combineObjectsShared(); void combineObjectsPlaceholderFieldPlaceholder(); void combineObjectSharedFieldPlaceholder(); + void combineImplicitNullMapping(); + void combineTrivialNullParent(); void convertToSingleFunctionObjects(); void convertToSingleFunctionObjectsFieldsToCopy(); @@ -80,7 +82,10 @@ SceneToolsTest::SceneToolsTest() { addTests({&SceneToolsTest::combineAlignment, &SceneToolsTest::combineObjectsShared, &SceneToolsTest::combineObjectsPlaceholderFieldPlaceholder, - &SceneToolsTest::combineObjectSharedFieldPlaceholder}); + &SceneToolsTest::combineObjectSharedFieldPlaceholder, + + &SceneToolsTest::combineImplicitNullMapping, + &SceneToolsTest::combineTrivialNullParent}); addInstancedTests({&SceneToolsTest::convertToSingleFunctionObjects}, Containers::arraySize(ConvertToSingleFunctionObjectsData)); @@ -349,6 +354,47 @@ void SceneToolsTest::combineObjectSharedFieldPlaceholder() { CORRADE_COMPARE(scene.field(SceneField::MeshMaterial).stride()[0], 4); } +void SceneToolsTest::combineImplicitNullMapping() { + const Short parentFieldData[]{-1, 0, 0}; + const UnsignedByte meshFieldData[]{3, 5}; + + SceneData scene = Implementation::sceneCombine(SceneMappingType::UnsignedShort, 167, Containers::arrayView({ + /* If the field has any flags, it shouldn't be treated as a + placeholder */ +#warning or maybe it should be preserved? yeah + SceneFieldData{SceneField::Mesh, Containers::ArrayView{nullptr, Containers::arraySize(meshFieldData)}, Containers::arrayView(meshFieldData), SceneFieldFlag::ImplicitMapping}, + SceneFieldData{SceneField::Parent, Containers::ArrayView{nullptr, Containers::arraySize(parentFieldData)}, Containers::arrayView(parentFieldData), SceneFieldFlag::ImplicitMapping} + })); + + CORRADE_COMPARE(scene.mappingBound(), 167); + CORRADE_COMPARE(scene.fieldCount(), 2); + + CORRADE_COMPARE(scene.fieldName(0), SceneField::Mesh); + CORRADE_COMPARE(scene.fieldFlags(0), SceneFieldFlag::ImplicitMapping); + CORRADE_COMPARE(scene.fieldType(0), SceneFieldType::UnsignedByte); + CORRADE_COMPARE(scene.fieldArraySize(0), 0); + CORRADE_COMPARE_AS(scene.mapping(0), Containers::arrayView({ + 0, 1, 2 + }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(scene.field(0), + Containers::arrayView(meshFieldData), + TestSuite::Compare::Container); + + CORRADE_COMPARE(scene.fieldName(1), SceneField::Parent); + CORRADE_COMPARE(scene.fieldFlags(1), SceneFieldFlag::ImplicitMapping); + CORRADE_COMPARE(scene.fieldType(1), SceneFieldType::Short); + CORRADE_COMPARE(scene.fieldArraySize(1), 0); + CORRADE_COMPARE_AS(scene.mapping(1), Containers::arrayView({ + 0, 1 + }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(scene.field(1), + Containers::arrayView(meshFieldData), + TestSuite::Compare::Container); +} + +void SceneToolsTest::combineTrivialNullParent() { +} + void SceneToolsTest::convertToSingleFunctionObjects() { auto&& data = ConvertToSingleFunctionObjectsData[testCaseInstanceId()]; setTestCaseDescription(data.name);