diff --git a/src/celmodel/modelfile.cpp b/src/celmodel/modelfile.cpp index ac1069e09a6..46db6eb85ee 100644 --- a/src/celmodel/modelfile.cpp +++ b/src/celmodel/modelfile.cpp @@ -1012,6 +1012,7 @@ AsciiModelWriter::writeVertex(const cmod::VWord* vertexData, } const VWord* data = vertexData + attr.offsetWords; + auto databytes = reinterpret_cast(data); //NOSONAR std::array fdata; switch (attr.format) @@ -1033,7 +1034,7 @@ AsciiModelWriter::writeVertex(const cmod::VWord* vertexData, fmt::print(*out, "{} {} {} {}", fdata[0], fdata[1], fdata[2], fdata[3]); break; case VertexAttributeFormat::UByte4: - fmt::print(*out, "{} {} {} {}", +data[0], +data[1], +data[2], +data[3]); + fmt::print(*out, "{} {} {} {}", +databytes[0], +databytes[1], +databytes[2], +databytes[3]); break; default: assert(0); diff --git a/test/data/huygens.3ds b/test/data/huygens.3ds deleted file mode 100644 index 4fd5d2cb056..00000000000 Binary files a/test/data/huygens.3ds and /dev/null differ diff --git a/test/data/icosphere.3ds b/test/data/icosphere.3ds new file mode 100644 index 00000000000..ec3aace82dd Binary files /dev/null and b/test/data/icosphere.3ds differ diff --git a/test/data/icosphere.3ds.license b/test/data/icosphere.3ds.license new file mode 100644 index 00000000000..25a8f3b3053 --- /dev/null +++ b/test/data/icosphere.3ds.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2024 Andrew Tribick + +SPDX-License-Identifier: CC0-1.0 \ No newline at end of file diff --git a/test/data/iss/iss.ssc b/test/data/iss/iss.ssc deleted file mode 100644 index 2704ef44d23..00000000000 --- a/test/data/iss/iss.ssc +++ /dev/null @@ -1,7 +0,0 @@ - -Modify "ISS" "Sol/Earth" -{ - Category [ "Spacecrafts" "NASA" "Space Stations" "LEO objects" ] -} - - diff --git a/test/data/iss/models/iss.cmod b/test/data/iss/models/iss.cmod deleted file mode 100644 index ef1fc059b38..00000000000 Binary files a/test/data/iss/models/iss.cmod and /dev/null differ diff --git a/test/data/testmodel.cmod b/test/data/testmodel.cmod new file mode 100644 index 00000000000..be91fecaeed Binary files /dev/null and b/test/data/testmodel.cmod differ diff --git a/test/data/testmodel.cmod.license b/test/data/testmodel.cmod.license new file mode 100644 index 00000000000..25a8f3b3053 --- /dev/null +++ b/test/data/testmodel.cmod.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2024 Andrew Tribick + +SPDX-License-Identifier: CC0-1.0 \ No newline at end of file diff --git a/test/data/testmodel.cmod.txt b/test/data/testmodel.cmod.txt new file mode 100644 index 00000000000..78cb8c076d4 --- /dev/null +++ b/test/data/testmodel.cmod.txt @@ -0,0 +1,56 @@ +#celmodel__ascii + +material +diffuse 0.0 0.25 0.75 +emissive 1.0 0.50 0.0 +opacity 0.5 +specpower 0.3 +opacity 0.25 +texture0 "abc.jpeg" +normalmap "def.png" +specularmap "ghi.jpg" +emissivemap "zyx.png" +end_material + +material +diffuse 0.5 0.25 0.625 +end_material + +mesh + +vertexdesc +position f3 +normal f3 +color0 ub4 +color1 ub4 +tangent f3 +texcoord0 f2 +texcoord1 f2 +texcoord2 f2 +texcoord3 f2 +end_vertexdesc + +vertices 3 +7.296079 11.248578 9.22705 5.2277236 -10.1726 -8.392048 45 109 146 226 71 44 179 211 -0 5.5343466 -9.530685 -0.3390279 4.252959 -7.28864 8.539534 -6.3209734 0 6.382264 -10.71377 +1.6738018 1.8557296 -11.874223 11.38663 0.19100569 0.58637905 59 93 244 125 213 24 135 182 15.036114 -1.141086 12.600051 2.1498501 2.9668765 -15.088427 -12.589463 12.911113 -6.021534 11.512148 -15.626732 +-9.80907 11.435033 9.9803095 -11.550884 -2.126639 -9.997762 55 126 178 225 249 69 173 11 -5.527182 -15.229529 -5.2998743 6.1232743 5.819463 -0.08893819 -1.8737017 13.035601 -0.87161326 10.813936 -10.861176 + +trilist 0 3 +0 1 2 + +tristrip 1 3 +1 2 0 + +trifan 0 3 +2 1 0 + +linelist 0 3 +0 2 1 + +linestrip 1 3 +1 0 2 + +points 1 3 +2 0 1 + +end_mesh \ No newline at end of file diff --git a/test/data/testmodel.cmod.txt.license b/test/data/testmodel.cmod.txt.license new file mode 100644 index 00000000000..25a8f3b3053 --- /dev/null +++ b/test/data/testmodel.cmod.txt.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2024 Andrew Tribick + +SPDX-License-Identifier: CC0-1.0 \ No newline at end of file diff --git a/test/integration/3ds_load_test.cpp b/test/integration/3ds_load_test.cpp index 6a138344a38..9297a710059 100644 --- a/test/integration/3ds_load_test.cpp +++ b/test/integration/3ds_load_test.cpp @@ -10,11 +10,11 @@ TEST_SUITE_BEGIN("3ds integration"); TEST_CASE("Load a 3DS file") { - std::unique_ptr scene = Read3DSFile("huygens.3ds"); + std::unique_ptr scene = Read3DSFile("icosphere.3ds"); REQUIRE(scene != nullptr); - REQUIRE(scene->getMaterialCount() == 4); + REQUIRE(scene->getMaterialCount() == 1); - REQUIRE(scene->getModelCount() == UINT32_C(8)); + REQUIRE(scene->getModelCount() == UINT32_C(1)); std::uint32_t meshCount = 0; std::uint32_t faceCount = 0; @@ -33,9 +33,9 @@ TEST_CASE("Load a 3DS file") } } - REQUIRE(meshCount == 8); - REQUIRE(faceCount == 6098); - REQUIRE(vertexCount == 3263); + REQUIRE(meshCount == 1); + REQUIRE(faceCount == 80); + REQUIRE(vertexCount == 63); } TEST_SUITE_END(); diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index bf3a23b6342..f2d3c498326 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -4,7 +4,7 @@ set(INTEGRATION_TEST_SOURCES test_case(integration "${INTEGRATION_TEST_SOURCES}") -file(COPY "${CMAKE_SOURCE_DIR}/test/data/huygens.3ds" +file(COPY "${CMAKE_SOURCE_DIR}/test/data/icosphere.3ds" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") -file(COPY "${CMAKE_SOURCE_DIR}/test/data/iss/models/iss.cmod" +file(COPY "${CMAKE_SOURCE_DIR}/test/data/testmodel.cmod" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/test/integration/cmod_bin_ascii_roundtrip_test.cpp b/test/integration/cmod_bin_ascii_roundtrip_test.cpp index b83e1d43413..15128bcbdb5 100644 --- a/test/integration/cmod_bin_ascii_roundtrip_test.cpp +++ b/test/integration/cmod_bin_ascii_roundtrip_test.cpp @@ -33,7 +33,7 @@ TEST_CASE("CMOD binary to ASCII roundtrip") }; cmod::SourceGetter sourceGetter = [&](ResourceHandle handle) { return paths[handle]; }; - std::ifstream f("iss.cmod", std::ios::in | std::ios::binary); + std::ifstream f("testmodel.cmod", std::ios::in | std::ios::binary); REQUIRE(f.good()); std::stringstream sourceData; sourceData << f.rdbuf();