Skip to content

Commit 924e13b

Browse files
committed
Merged pull request "Fix the calculation of jointStride and weightStride of GLTF-Importer": #21
2 parents 98446af + 121d0f9 commit 924e13b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/engine/GltfImporter.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ bool GltfImporter::Load(
804804

805805
if (joint_indices->component_type == cgltf_component_type_r_8u)
806806
{
807+
if (!jointStride) jointStride = sizeof(uint8_t) * 4;
808+
807809
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
808810
{
809811
*jointDst = dm::vector<uint16_t, 4>(jointSrc[0], jointSrc[1], jointSrc[2], jointSrc[3]);
@@ -815,6 +817,9 @@ bool GltfImporter::Load(
815817
else
816818
{
817819
assert(joint_indices->component_type == cgltf_component_type_r_16u);
820+
821+
if (!jointStride) jointStride = sizeof(uint16_t) * 4;
822+
818823
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
819824
{
820825
const uint16_t* jointSrcUshort = (const uint16_t*)jointSrc;
@@ -837,6 +842,8 @@ bool GltfImporter::Load(
837842

838843
if (joint_weights->component_type == cgltf_component_type_r_8u)
839844
{
845+
if (!weightStride) weightStride = sizeof(uint8_t) * 4;
846+
840847
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
841848
{
842849
*weightDst = dm::float4(
@@ -851,6 +858,8 @@ bool GltfImporter::Load(
851858
}
852859
else if (joint_weights->component_type == cgltf_component_type_r_16u)
853860
{
861+
if (!weightStride) weightStride = sizeof(uint16_t) * 4;
862+
854863
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
855864
{
856865
const uint16_t* weightSrcUshort = (const uint16_t*)weightSrc;
@@ -867,6 +876,9 @@ bool GltfImporter::Load(
867876
else
868877
{
869878
assert(joint_weights->component_type == cgltf_component_type_r_32f);
879+
880+
if (!weightStride) weightStride = sizeof(float) * 4;
881+
870882
for (size_t v_idx = 0; v_idx < joint_indices->count; v_idx++)
871883
{
872884
*weightDst = (const float*)weightSrc;

0 commit comments

Comments
 (0)