From 121d0f92ce3942c0deee658c933f695e60e84163 Mon Sep 17 00:00:00 2001 From: HanetakaChou Date: Mon, 4 Nov 2024 13:58:48 +0100 Subject: [PATCH] Fix the calculation of jointStride and weightStride of GLTF-Importer in the same way as how we calculate the indexStride. --- src/engine/GltfImporter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/engine/GltfImporter.cpp b/src/engine/GltfImporter.cpp index 58784cf..4df49ac 100644 --- a/src/engine/GltfImporter.cpp +++ b/src/engine/GltfImporter.cpp @@ -802,6 +802,9 @@ bool GltfImporter::Load( if (joint_indices->component_type == cgltf_component_type_r_8u) { + + if (!jointStride) jointStride = sizeof(uint8_t) * 4; + for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++) { *jointDst = dm::vector(jointSrc[0], jointSrc[1], jointSrc[2], jointSrc[3]); @@ -813,6 +816,9 @@ bool GltfImporter::Load( else { assert(joint_indices->component_type == cgltf_component_type_r_16u); + + if (!jointStride) jointStride = sizeof(uint16_t) * 4; + for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++) { const uint16_t* jointSrcUshort = (const uint16_t*)jointSrc; @@ -833,6 +839,9 @@ bool GltfImporter::Load( if (joint_weights->component_type == cgltf_component_type_r_8u) { + + if (!weightStride) weightStride = sizeof(uint8_t) * 4; + for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++) { *weightDst = dm::float4( @@ -847,6 +856,8 @@ bool GltfImporter::Load( } else if (joint_weights->component_type == cgltf_component_type_r_16u) { + if (!weightStride) weightStride = sizeof(uint16_t) * 4; + for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++) { const uint16_t* weightSrcUshort = (const uint16_t*)weightSrc; @@ -863,6 +874,9 @@ bool GltfImporter::Load( else { assert(joint_weights->component_type == cgltf_component_type_r_32f); + + if (!weightStride) weightStride = sizeof(float) * 4; + for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++) { *weightDst = (const float*)weightSrc;