1
1
/**
2
2
* cgltf - a single-file glTF 2.0 parser written in C99.
3
3
*
4
- * Version: 1.14
4
+ * Version: 1.15
5
5
*
6
6
* Website: https://github.com/jkuhlmann/cgltf
7
7
*
@@ -376,13 +376,29 @@ typedef struct cgltf_image
376
376
cgltf_extension * extensions ;
377
377
} cgltf_image ;
378
378
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
+
379
395
typedef struct cgltf_sampler
380
396
{
381
397
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 ;
386
402
cgltf_extras extras ;
387
403
cgltf_size extensions_count ;
388
404
cgltf_extension * extensions ;
@@ -854,6 +870,8 @@ void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)
854
870
855
871
const uint8_t * cgltf_buffer_view_data (const cgltf_buffer_view * view );
856
872
873
+ const cgltf_accessor * cgltf_find_accessor (const cgltf_primitive * prim , cgltf_attribute_type type , cgltf_int index );
874
+
857
875
cgltf_bool cgltf_accessor_read_float (const cgltf_accessor * accessor , cgltf_size index , cgltf_float * out , cgltf_size element_size );
858
876
cgltf_bool cgltf_accessor_read_uint (const cgltf_accessor * accessor , cgltf_size index , cgltf_uint * out , cgltf_size element_size );
859
877
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)
2322
2340
return result ;
2323
2341
}
2324
2342
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
+
2325
2355
cgltf_bool cgltf_accessor_read_float (const cgltf_accessor * accessor , cgltf_size index , cgltf_float * out , cgltf_size element_size )
2326
2356
{
2327
2357
if (accessor -> is_sparse )
@@ -4296,6 +4326,7 @@ static int cgltf_parse_json_diffuse_transmission(cgltf_options* options, jsmntok
4296
4326
4297
4327
// Defaults
4298
4328
cgltf_fill_float_array (out_diff_transmission -> diffuse_transmission_color_factor , 3 , 1.0f );
4329
+ out_diff_transmission -> diffuse_transmission_factor = 0.f ;
4299
4330
4300
4331
for (int j = 0 ; j < size ; ++ j )
4301
4332
{
@@ -4461,8 +4492,8 @@ static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tok
4461
4492
(void )options ;
4462
4493
CGLTF_CHECK_TOKTYPE (tokens [i ], JSMN_OBJECT );
4463
4494
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 ;
4466
4497
4467
4498
int size = tokens [i ].size ;
4468
4499
++ i ;
@@ -4479,28 +4510,28 @@ static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tok
4479
4510
{
4480
4511
++ i ;
4481
4512
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 );
4483
4514
++ i ;
4484
4515
}
4485
4516
else if (cgltf_json_strcmp (tokens + i , json_chunk , "minFilter" ) == 0 )
4486
4517
{
4487
4518
++ i ;
4488
4519
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 );
4490
4521
++ i ;
4491
4522
}
4492
4523
else if (cgltf_json_strcmp (tokens + i , json_chunk , "wrapS" ) == 0 )
4493
4524
{
4494
4525
++ i ;
4495
4526
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 );
4497
4528
++ i ;
4498
4529
}
4499
4530
else if (cgltf_json_strcmp (tokens + i , json_chunk , "wrapT" ) == 0 )
4500
4531
{
4501
4532
++ i ;
4502
4533
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 );
4504
4535
++ i ;
4505
4536
}
4506
4537
else if (cgltf_json_strcmp (tokens + i , json_chunk , "extras" ) == 0 )
0 commit comments