@@ -978,19 +978,20 @@ TEST_CASE("serialize-lods", "[lods]") {
978
978
{
979
979
tinygltf::Model m;
980
980
981
- m.nodes .resize (3 );
981
+ m.nodes .resize (4 );
982
982
// Add Node 1 and Node 2 as lods to Node 0
983
983
m.nodes [0 ].lods .push_back (1 );
984
984
m.nodes [0 ].lods .push_back (2 );
985
985
986
986
// Add Material 1 and Material 2 as lods to Material 0
987
- m.materials .resize (3 );
987
+ m.materials .resize (4 );
988
988
m.materials [0 ].lods .push_back (1 );
989
989
m.materials [0 ].lods .push_back (2 );
990
990
991
991
tinygltf::Scene scene;
992
- // Scene uses Node 0 as root node
992
+ // Scene uses Node 0 and 3 as root node
993
993
scene.nodes .push_back (0 );
994
+ scene.nodes .push_back (3 );
994
995
// Add scene to the model
995
996
m.scenes .push_back (scene);
996
997
@@ -1006,28 +1007,52 @@ TEST_CASE("serialize-lods", "[lods]") {
1006
1007
// Parse the serialized model
1007
1008
bool ok = ctx.LoadASCIIFromString (&m, nullptr , nullptr , os.str ().c_str (), os.str ().size (), " " );
1008
1009
REQUIRE (true == ok);
1009
-
1010
- // Make sure all three materials are there
1011
- REQUIRE (3 == m.materials .size ());
1010
+ // Make sure the model's used extensions hold MSFT_lod
1011
+ CHECK (m.extensionsUsed .size () == 1 );
1012
+ CHECK (m.extensionsUsed [0 ].compare (" MSFT_lod" ) == 0 );
1013
+ // MSFT_lod is not a required extension
1014
+ CHECK (m.extensionsRequired .size () == 0 );
1015
+
1016
+ // Make sure all four materials are there
1017
+ REQUIRE (4 == m.materials .size ());
1012
1018
// Make sure the first material has both lod materials
1013
1019
REQUIRE (2 == m.materials [0 ].lods .size ());
1014
1020
// Make sure the order is still the same after serialization and deserialization
1015
1021
CHECK (1 == m.materials [0 ].lods [0 ]);
1016
1022
CHECK (2 == m.materials [0 ].lods [1 ]);
1023
+ // Make sure the material with lods exposes the MSFT_lod extension
1024
+ CHECK (m.materials [0 ].extensions .size () == 1 );
1025
+ CHECK (m.materials [0 ].extensions .count (" MSFT_lod" ) == 1 );
1026
+ // Make sure the last material has no lod materials
1027
+ CHECK (0 == m.materials [3 ].lods .size ());
1028
+ // Make sure the material without lods does not exposes the MSFT_lod extension
1029
+ CHECK (m.materials [3 ].extensions .size () == 0 );
1030
+ CHECK (m.materials [3 ].extensions .count (" MSFT_lod" ) == 0 );
1017
1031
1018
1032
// Make sure the single scene is there
1019
1033
REQUIRE (1 == m.scenes .size ());
1020
- // Make sure all three nodes are there
1021
- REQUIRE (3 == m.nodes .size ());
1022
- // Make sure the single root node of the scene is there
1023
- REQUIRE (1 == m.scenes [0 ].nodes .size ());
1034
+ // Make sure all four nodes are there
1035
+ REQUIRE (4 == m.nodes .size ());
1036
+ // Make sure the two root nodes of the scene are there
1037
+ REQUIRE (2 == m.scenes [0 ].nodes .size ());
1024
1038
REQUIRE (0 == m.scenes [0 ].nodes [0 ]);
1025
- // Retrieve the scene root node
1026
- const tinygltf::Node& node = m.nodes [m.scenes [0 ].nodes [0 ]];
1027
- // Make sure the single root node has both lod nodes
1028
- REQUIRE (2 == node.lods .size ());
1039
+ REQUIRE (3 == m.scenes [0 ].nodes [1 ]);
1040
+ // Retrieve the node with lods
1041
+ const tinygltf::Node& nodeWithLods = m.nodes [m.scenes [0 ].nodes [0 ]];
1042
+ // Make sure the node has both lod nodes
1043
+ REQUIRE (2 == nodeWithLods.lods .size ());
1029
1044
// Make sure the order is still the same after serialization and deserialization
1030
- CHECK (1 == node.lods [0 ]);
1031
- CHECK (2 == node.lods [1 ]);
1045
+ CHECK (1 == nodeWithLods.lods [0 ]);
1046
+ CHECK (2 == nodeWithLods.lods [1 ]);
1047
+ // Make sure the node with lods exposes the MSFT_lod extension
1048
+ CHECK (nodeWithLods.extensions .size () == 1 );
1049
+ CHECK (nodeWithLods.extensions .count (" MSFT_lod" ) == 1 );
1050
+ // Retrieve the node without lods
1051
+ const tinygltf::Node& nodeWithoutLods = m.nodes [m.scenes [0 ].nodes [1 ]];
1052
+ // Make sure the node has no lod nodes
1053
+ CHECK (0 == nodeWithoutLods.lods .size ());
1054
+ // Make sure the node without lods does not exposes the MSFT_lod extension
1055
+ CHECK (nodeWithoutLods.extensions .size () == 0 );
1056
+ CHECK (nodeWithoutLods.extensions .count (" MSFT_lod" ) == 0 );
1032
1057
}
1033
1058
}
0 commit comments