Skip to content

Commit fd4b3ad

Browse files
committed
extern: Update cgltf to 1.15
This incorporates all custom patches our version had and syncs to the officially released version again.
1 parent 7044538 commit fd4b3ad

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

extern/cgltf.h

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* cgltf - a single-file glTF 2.0 parser written in C99.
33
*
4-
* Version: 1.14
4+
* Version: 1.15
55
*
66
* Website: https://github.com/jkuhlmann/cgltf
77
*
@@ -376,13 +376,29 @@ typedef struct cgltf_image
376376
cgltf_extension* extensions;
377377
} cgltf_image;
378378

379+
typedef enum cgltf_filter_type {
380+
cgltf_filter_type_undefined = 0,
381+
cgltf_filter_type_nearest = 9728,
382+
cgltf_filter_type_linear = 9729,
383+
cgltf_filter_type_nearest_mipmap_nearest = 9984,
384+
cgltf_filter_type_linear_mipmap_nearest = 9985,
385+
cgltf_filter_type_nearest_mipmap_linear = 9986,
386+
cgltf_filter_type_linear_mipmap_linear = 9987
387+
} cgltf_filter_type;
388+
389+
typedef enum cgltf_wrap_mode {
390+
cgltf_wrap_mode_clamp_to_edge = 33071,
391+
cgltf_wrap_mode_mirrored_repeat = 33648,
392+
cgltf_wrap_mode_repeat = 10497
393+
} cgltf_wrap_mode;
394+
379395
typedef struct cgltf_sampler
380396
{
381397
char* name;
382-
cgltf_int mag_filter;
383-
cgltf_int min_filter;
384-
cgltf_int wrap_s;
385-
cgltf_int wrap_t;
398+
cgltf_filter_type mag_filter;
399+
cgltf_filter_type min_filter;
400+
cgltf_wrap_mode wrap_s;
401+
cgltf_wrap_mode wrap_t;
386402
cgltf_extras extras;
387403
cgltf_size extensions_count;
388404
cgltf_extension* extensions;
@@ -854,6 +870,8 @@ void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)
854870

855871
const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view);
856872

873+
const cgltf_accessor* cgltf_find_accessor(const cgltf_primitive* prim, cgltf_attribute_type type, cgltf_int index);
874+
857875
cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size);
858876
cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size);
859877
cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
@@ -2322,6 +2340,18 @@ const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view)
23222340
return result;
23232341
}
23242342

2343+
const cgltf_accessor* cgltf_find_accessor(const cgltf_primitive* prim, cgltf_attribute_type type, cgltf_int index)
2344+
{
2345+
for (cgltf_size i = 0; i < prim->attributes_count; ++i)
2346+
{
2347+
const cgltf_attribute* attr = &prim->attributes[i];
2348+
if (attr->type == type && attr->index == index)
2349+
return attr->data;
2350+
}
2351+
2352+
return NULL;
2353+
}
2354+
23252355
cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size)
23262356
{
23272357
if (accessor->is_sparse)
@@ -4296,6 +4326,7 @@ static int cgltf_parse_json_diffuse_transmission(cgltf_options* options, jsmntok
42964326

42974327
// Defaults
42984328
cgltf_fill_float_array(out_diff_transmission->diffuse_transmission_color_factor, 3, 1.0f);
4329+
out_diff_transmission->diffuse_transmission_factor = 0.f;
42994330

43004331
for (int j = 0; j < size; ++j)
43014332
{
@@ -4461,8 +4492,8 @@ static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tok
44614492
(void)options;
44624493
CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
44634494

4464-
out_sampler->wrap_s = 10497;
4465-
out_sampler->wrap_t = 10497;
4495+
out_sampler->wrap_s = cgltf_wrap_mode_repeat;
4496+
out_sampler->wrap_t = cgltf_wrap_mode_repeat;
44664497

44674498
int size = tokens[i].size;
44684499
++i;
@@ -4479,28 +4510,28 @@ static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tok
44794510
{
44804511
++i;
44814512
out_sampler->mag_filter
4482-
= cgltf_json_to_int(tokens + i, json_chunk);
4513+
= (cgltf_filter_type)cgltf_json_to_int(tokens + i, json_chunk);
44834514
++i;
44844515
}
44854516
else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0)
44864517
{
44874518
++i;
44884519
out_sampler->min_filter
4489-
= cgltf_json_to_int(tokens + i, json_chunk);
4520+
= (cgltf_filter_type)cgltf_json_to_int(tokens + i, json_chunk);
44904521
++i;
44914522
}
44924523
else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0)
44934524
{
44944525
++i;
44954526
out_sampler->wrap_s
4496-
= cgltf_json_to_int(tokens + i, json_chunk);
4527+
= (cgltf_wrap_mode)cgltf_json_to_int(tokens + i, json_chunk);
44974528
++i;
44984529
}
44994530
else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0)
45004531
{
45014532
++i;
45024533
out_sampler->wrap_t
4503-
= cgltf_json_to_int(tokens + i, json_chunk);
4534+
= (cgltf_wrap_mode)cgltf_json_to_int(tokens + i, json_chunk);
45044535
++i;
45054536
}
45064537
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)

0 commit comments

Comments
 (0)