Skip to content

Commit

Permalink
Merged pull request "Fix the calculation of jointStride and weightStr…
Browse files Browse the repository at this point in the history
…ide of GLTF-Importer": #21
  • Loading branch information
apanteleev committed Nov 7, 2024
2 parents 98446af + 121d0f9 commit 924e13b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/engine/GltfImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ 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<uint16_t, 4>(jointSrc[0], jointSrc[1], jointSrc[2], jointSrc[3]);
Expand All @@ -815,6 +817,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;
Expand All @@ -837,6 +842,8 @@ 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(
Expand All @@ -851,6 +858,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;
Expand All @@ -867,6 +876,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;
Expand Down

0 comments on commit 924e13b

Please sign in to comment.