Skip to content

Commit

Permalink
Merge pull request #252 from zeux/inst
Browse files Browse the repository at this point in the history
Improve EXT_mesh_gpu_instancing validation
  • Loading branch information
jkuhlmann authored Jun 3, 2024
2 parents 52c2381 + c42251a commit 3efa245
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cgltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,20 @@ cgltf_result cgltf_validate(cgltf_data* data)
{
if (data->nodes[i].weights && data->nodes[i].mesh)
{
CGLTF_ASSERT_IF (data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
CGLTF_ASSERT_IF(data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
}

if (data->nodes[i].has_mesh_gpu_instancing)
{
CGLTF_ASSERT_IF(data->nodes[i].mesh == NULL, cgltf_result_invalid_gltf);
CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes_count == 0, cgltf_result_invalid_gltf);

cgltf_accessor* first = data->nodes[i].mesh_gpu_instancing.attributes[0].data;

for (cgltf_size k = 0; k < data->nodes[i].mesh_gpu_instancing.attributes_count; ++k)
{
CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
}
}
}

Expand Down

0 comments on commit 3efa245

Please sign in to comment.