Skip to content

Commit

Permalink
Merge pull request #257 from zeux/master
Browse files Browse the repository at this point in the history
Add cgltf_find_accessor helper
  • Loading branch information
jkuhlmann authored Nov 4, 2024
2 parents fa3b80f + 9e3675d commit 9bc9ea3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cgltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,8 @@ void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)

const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view);

const cgltf_accessor* cgltf_find_accessor(const cgltf_primitive* prim, cgltf_attribute_type type, cgltf_int index);

cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size);
cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size);
cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
Expand Down Expand Up @@ -2312,6 +2314,18 @@ const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view)
return result;
}

const cgltf_accessor* cgltf_find_accessor(const cgltf_primitive* prim, cgltf_attribute_type type, cgltf_int index)
{
for (cgltf_size i = 0; i < prim->attributes_count; ++i)
{
const cgltf_attribute* attr = &prim->attributes[i];
if (attr->type == type && attr->index == index)
return attr->data;
}

return NULL;
}

cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size)
{
if (accessor->is_sparse)
Expand Down

0 comments on commit 9bc9ea3

Please sign in to comment.