Skip to content

Change cgltf_accessor_unpack_indices to work with int vectors#267

Merged
jkuhlmann merged 1 commit intojkuhlmann:masterfrom
fda0:better_cgltf_accessor_unpack_indices
Mar 13, 2025
Merged

Change cgltf_accessor_unpack_indices to work with int vectors#267
jkuhlmann merged 1 commit intojkuhlmann:masterfrom
fda0:better_cgltf_accessor_unpack_indices

Conversation

@fda0
Copy link
Contributor

@fda0 fda0 commented Mar 10, 2025

This PR introduces 3 improvements to the
cgltf_accessor_unpack_indices function:

  1. Query cgltf_num_components and use it to load int vectors properly - this is useful for loading vec4 uint8_t joint indices.
  2. Add support for uint8_t in slow path (for loop) in cases where data wasn't tightly packed (previously the function wouldn't do anything).
  3. Return 0 on failure instead of failing silently and leaving memory uninitialized.

This PR introduces 3 improvements to the
`cgltf_accessor_unpack_indices` function:
1. Query `cgltf_num_components` and use it to load int vectors
   properly - this is useful for loading vec4 uint8_t joint indices.
2. Add support for uint8_t in slow path (for loop) in cases where
   data wasn't tightly packed (previously the function wouldn't do
   anything).
3. Return 0 on failure instead of failing silently and leaving memory
   uninitialized.
@fda0
Copy link
Contributor Author

fda0 commented Mar 10, 2025

This brings this function closer to cgltf_accessor_unpack_floats and I think that ideally in the future both functions would be compressed into one. Perhaps both functions could call a common implementation.

@jkuhlmann jkuhlmann merged commit 08470a2 into jkuhlmann:master Mar 13, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants