Skip to content

Commit 121d0f9

Browse files
committed
Fix the calculation of jointStride and weightStride of GLTF-Importer in the same way as how we calculate the indexStride.
1 parent 7ddcc0a commit 121d0f9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/engine/GltfImporter.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,9 @@ bool GltfImporter::Load(
802802

803803
if (joint_indices->component_type == cgltf_component_type_r_8u)
804804
{
805+
806+
if (!jointStride) jointStride = sizeof(uint8_t) * 4;
807+
805808
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
806809
{
807810
*jointDst = dm::vector<uint16_t, 4>(jointSrc[0], jointSrc[1], jointSrc[2], jointSrc[3]);
@@ -813,6 +816,9 @@ bool GltfImporter::Load(
813816
else
814817
{
815818
assert(joint_indices->component_type == cgltf_component_type_r_16u);
819+
820+
if (!jointStride) jointStride = sizeof(uint16_t) * 4;
821+
816822
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
817823
{
818824
const uint16_t* jointSrcUshort = (const uint16_t*)jointSrc;
@@ -833,6 +839,9 @@ bool GltfImporter::Load(
833839

834840
if (joint_weights->component_type == cgltf_component_type_r_8u)
835841
{
842+
843+
if (!weightStride) weightStride = sizeof(uint8_t) * 4;
844+
836845
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
837846
{
838847
*weightDst = dm::float4(
@@ -847,6 +856,8 @@ bool GltfImporter::Load(
847856
}
848857
else if (joint_weights->component_type == cgltf_component_type_r_16u)
849858
{
859+
if (!weightStride) weightStride = sizeof(uint16_t) * 4;
860+
850861
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
851862
{
852863
const uint16_t* weightSrcUshort = (const uint16_t*)weightSrc;
@@ -863,6 +874,9 @@ bool GltfImporter::Load(
863874
else
864875
{
865876
assert(joint_weights->component_type == cgltf_component_type_r_32f);
877+
878+
if (!weightStride) weightStride = sizeof(float) * 4;
879+
866880
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
867881
{
868882
*weightDst = (const float*)weightSrc;

0 commit comments

Comments
 (0)