diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake index b6cf7f760..bde986920 100644 --- a/cmake/compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -16,6 +16,11 @@ macro(fastgltf_compiler_flags TARGET) # https://github.com/simdjson/simdjson/blob/master/doc/basics.md#performance-tips target_compile_options(${TARGET} PRIVATE $<$:-DNDEBUG>) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # For the conversion of ARM Neon vectors (say int16x8_t to int8x16_t) + target_compile_options(${TARGET} PRIVATE -flax-vector-conversions) + endif() endif() endif() endmacro() diff --git a/include/fastgltf/types.hpp b/include/fastgltf/types.hpp index e6030aebc..ada90d7b4 100644 --- a/include/fastgltf/types.hpp +++ b/include/fastgltf/types.hpp @@ -1336,6 +1336,12 @@ namespace fastgltf { FASTGLTF_STD_PMR_NS::string name; }; + struct TRS { + std::array translation = {{ 0.f, 0.f, 0.f }}; + std::array rotation = {{ 0.f, 0.f, 0.f, 1.f }}; + std::array scale = {{ 1.f, 1.f, 1.f }}; + }; + struct Node { Optional meshIndex; Optional skinIndex; @@ -1349,11 +1355,6 @@ namespace fastgltf { FASTGLTF_FG_PMR_NS::MaybeSmallVector children; FASTGLTF_FG_PMR_NS::MaybeSmallVector weights; - struct TRS { - std::array translation = {{ 0.f, 0.f, 0.f }}; - std::array rotation = {{ 0.f, 0.f, 0.f, 1.f }}; - std::array scale = {{ 1.f, 1.f, 1.f }}; - }; using TransformMatrix = std::array; /** diff --git a/src/fastgltf.cpp b/src/fastgltf.cpp index fbf5681a1..bf9298ee9 100644 --- a/src/fastgltf.cpp +++ b/src/fastgltf.cpp @@ -998,7 +998,7 @@ fg::Error fg::validate(const fastgltf::Asset& asset) { if (node.meshIndex.has_value() && asset.meshes.size() <= node.meshIndex.value()) return Error::InvalidGltf; - if (const auto* pTRS = std::get_if(&node.transform)) { + if (const auto* pTRS = std::get_if(&node.transform)) { for (const auto& x : pTRS->rotation) if (x > 1.0 || x < -1.0) return Error::InvalidGltf; @@ -2897,14 +2897,14 @@ fg::Error fg::Parser::parseNodes(simdjson::dom::array& nodes, Asset& asset) { } if (hasBit(options, Options::DecomposeNodeMatrices)) { - Node::TRS trs = {}; + TRS trs = {}; decomposeTransformMatrix(transformMatrix, trs.scale, trs.rotation, trs.translation); node.transform = trs; } else { node.transform = transformMatrix; } } else if (error == NO_SUCH_FIELD) { - Node::TRS trs = {}; + TRS trs = {}; // There's no matrix, let's see if there's scale, rotation, or rotation fields. if (auto error = nodeObject["scale"].get_array().get(array); error == SUCCESS) { diff --git a/tests/basic_test.cpp b/tests/basic_test.cpp index eff6f45b1..0c57ac5b9 100644 --- a/tests/basic_test.cpp +++ b/tests/basic_test.cpp @@ -153,7 +153,7 @@ TEST_CASE("Loading some basic glTF", "[gltf-loader]") { REQUIRE(cube->nodes.size() == 1); REQUIRE(cube->nodes.front().name == "Cube"); - REQUIRE(std::holds_alternative(cube->nodes.front().transform)); + REQUIRE(std::holds_alternative(cube->nodes.front().transform)); REQUIRE(cube->accessors.size() == 5); REQUIRE(cube->accessors[0].type == fastgltf::AccessorType::Scalar); @@ -384,10 +384,10 @@ TEST_CASE("Test TRS parsing and optional decomposition", "[gltf-loader]") { REQUIRE(assetWithMatrix->nodes.size() == 2); REQUIRE(assetDecomposed->nodes.size() == 2); REQUIRE(std::holds_alternative(assetWithMatrix->nodes.back().transform)); - REQUIRE(std::holds_alternative(assetDecomposed->nodes.back().transform)); + REQUIRE(std::holds_alternative(assetDecomposed->nodes.back().transform)); // Get the TRS components from the first node and use them as the test data for decomposing. - const auto* pDefaultTRS = std::get_if(&assetWithMatrix->nodes.front().transform); + const auto* pDefaultTRS = std::get_if(&assetWithMatrix->nodes.front().transform); REQUIRE(pDefaultTRS != nullptr); auto translation = glm::make_vec3(pDefaultTRS->translation.data()); auto rotation = glm::make_quat(pDefaultTRS->rotation.data()); @@ -401,7 +401,7 @@ TEST_CASE("Test TRS parsing and optional decomposition", "[gltf-loader]") { REQUIRE(glm::make_mat4x4(pMatrix->data()) == transform); // Check if the decomposed components equal the original components. - const auto* pDecomposedTRS = std::get_if(&assetDecomposed->nodes.back().transform); + const auto* pDecomposedTRS = std::get_if(&assetDecomposed->nodes.back().transform); REQUIRE(glm::make_vec3(pDecomposedTRS->translation.data()) == translation); REQUIRE(glm::make_quat(pDecomposedTRS->rotation.data()) == rotation); REQUIRE(glm::make_vec3(pDecomposedTRS->scale.data()) == scale);