|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
|
* cgltf - a single-file glTF 2.0 parser written in C99.
|
|
|
*
|
|
|
- * Version: 1.12
|
|
|
+ * Version: 1.13
|
|
|
*
|
|
|
* Website: https://github.com/jkuhlmann/cgltf
|
|
|
*
|
|
@@ -80,19 +80,16 @@
|
|
|
* `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t
|
|
|
* and only works with single-component data types.
|
|
|
*
|
|
|
- * `cgltf_result cgltf_copy_extras_json(const cgltf_data*, const cgltf_extras*,
|
|
|
- * char* dest, cgltf_size* dest_size)` allows users to retrieve the "extras" data that
|
|
|
- * can be attached to many glTF objects (which can be arbitrary JSON data). The
|
|
|
- * `cgltf_extras` struct stores the offsets of the start and end of the extras JSON data
|
|
|
- * as it appears in the complete glTF JSON data. This function copies the extras data
|
|
|
- * into the provided buffer. If `dest` is NULL, the length of the data is written into
|
|
|
- * `dest_size`. You can then parse this data using your own JSON parser
|
|
|
+ * `cgltf_copy_extras_json` allows users to retrieve the "extras" data that can be attached to many
|
|
|
+ * glTF objects (which can be arbitrary JSON data). This is a legacy function, consider using
|
|
|
+ * cgltf_extras::data directly instead. You can parse this data using your own JSON parser
|
|
|
* or, if you've included the cgltf implementation using the integrated JSMN JSON parser.
|
|
|
*/
|
|
|
#ifndef CGLTF_H_INCLUDED__
|
|
|
#define CGLTF_H_INCLUDED__
|
|
|
|
|
|
#include <stddef.h>
|
|
|
+#include <stdint.h> /* For uint8_t, uint32_t */
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
@@ -256,8 +253,10 @@ typedef enum cgltf_data_free_method {
|
|
|
} cgltf_data_free_method;
|
|
|
|
|
|
typedef struct cgltf_extras {
|
|
|
- cgltf_size start_offset;
|
|
|
- cgltf_size end_offset;
|
|
|
+ cgltf_size start_offset; /* this field is deprecated and will be removed in the future; use data instead */
|
|
|
+ cgltf_size end_offset; /* this field is deprecated and will be removed in the future; use data instead */
|
|
|
+
|
|
|
+ char* data;
|
|
|
} cgltf_extras;
|
|
|
|
|
|
typedef struct cgltf_extension {
|
|
@@ -432,8 +431,6 @@ typedef struct cgltf_pbr_metallic_roughness
|
|
|
cgltf_float base_color_factor[4];
|
|
|
cgltf_float metallic_factor;
|
|
|
cgltf_float roughness_factor;
|
|
|
-
|
|
|
- cgltf_extras extras;
|
|
|
} cgltf_pbr_metallic_roughness;
|
|
|
|
|
|
typedef struct cgltf_pbr_specular_glossiness
|
|
@@ -833,6 +830,8 @@ void cgltf_free(cgltf_data* data);
|
|
|
void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix);
|
|
|
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);
|
|
|
+
|
|
|
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);
|
|
@@ -841,6 +840,7 @@ cgltf_size cgltf_num_components(cgltf_type type);
|
|
|
|
|
|
cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count);
|
|
|
|
|
|
+/* this function is deprecated and will be removed in the future; use cgltf_extras::data instead */
|
|
|
cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
@@ -863,7 +863,6 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras*
|
|
|
|
|
|
#ifdef CGLTF_IMPLEMENTATION
|
|
|
|
|
|
-#include <stdint.h> /* For uint8_t, uint32_t */
|
|
|
#include <string.h> /* For strncpy */
|
|
|
#include <stdio.h> /* For fopen */
|
|
|
#include <limits.h> /* For UINT_MAX etc */
|
|
@@ -905,15 +904,15 @@ enum jsmnerr {
|
|
|
};
|
|
|
typedef struct {
|
|
|
jsmntype_t type;
|
|
|
- int start;
|
|
|
- int end;
|
|
|
+ ptrdiff_t start;
|
|
|
+ ptrdiff_t end;
|
|
|
int size;
|
|
|
#ifdef JSMN_PARENT_LINKS
|
|
|
int parent;
|
|
|
#endif
|
|
|
} jsmntok_t;
|
|
|
typedef struct {
|
|
|
- unsigned int pos; /* offset in the JSON string */
|
|
|
+ size_t pos; /* offset in the JSON string */
|
|
|
unsigned int toknext; /* next token to allocate */
|
|
|
int toksuper; /* superior token node, e.g parent object or array */
|
|
|
} jsmn_parser;
|
|
@@ -924,12 +923,15 @@ static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t
|
|
|
*/
|
|
|
|
|
|
|
|
|
+#ifndef CGLTF_CONSTS
|
|
|
static const cgltf_size GlbHeaderSize = 12;
|
|
|
static const cgltf_size GlbChunkHeaderSize = 8;
|
|
|
static const uint32_t GlbVersion = 2;
|
|
|
static const uint32_t GlbMagic = 0x46546C67;
|
|
|
static const uint32_t GlbMagicJsonChunk = 0x4E4F534A;
|
|
|
static const uint32_t GlbMagicBinChunk = 0x004E4942;
|
|
|
+#define CGLTF_CONSTS
|
|
|
+#endif
|
|
|
|
|
|
#ifndef CGLTF_MALLOC
|
|
|
#define CGLTF_MALLOC(size) malloc(size)
|
|
@@ -1745,7 +1747,12 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras*
|
|
|
return cgltf_result_success;
|
|
|
}
|
|
|
|
|
|
-void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
|
|
|
+static void cgltf_free_extras(cgltf_data* data, cgltf_extras* extras)
|
|
|
+{
|
|
|
+ data->memory.free_func(data->memory.user_data, extras->data);
|
|
|
+}
|
|
|
+
|
|
|
+static void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
|
|
|
{
|
|
|
for (cgltf_size i = 0; i < extensions_count; ++i)
|
|
|
{
|
|
@@ -1755,6 +1762,12 @@ void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_
|
|
|
data->memory.free_func(data->memory.user_data, extensions);
|
|
|
}
|
|
|
|
|
|
+static void cgltf_free_texture_view(cgltf_data* data, cgltf_texture_view* view)
|
|
|
+{
|
|
|
+ cgltf_free_extensions(data, view->extensions, view->extensions_count);
|
|
|
+ cgltf_free_extras(data, &view->extras);
|
|
|
+}
|
|
|
+
|
|
|
void cgltf_free(cgltf_data* data)
|
|
|
{
|
|
|
if (!data)
|
|
@@ -1770,6 +1783,7 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->asset.min_version);
|
|
|
|
|
|
cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->asset.extras);
|
|
|
|
|
|
for (cgltf_size i = 0; i < data->accessors_count; ++i)
|
|
|
{
|
|
@@ -1780,8 +1794,12 @@ void cgltf_free(cgltf_data* data)
|
|
|
cgltf_free_extensions(data, data->accessors[i].sparse.extensions, data->accessors[i].sparse.extensions_count);
|
|
|
cgltf_free_extensions(data, data->accessors[i].sparse.indices_extensions, data->accessors[i].sparse.indices_extensions_count);
|
|
|
cgltf_free_extensions(data, data->accessors[i].sparse.values_extensions, data->accessors[i].sparse.values_extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->accessors[i].sparse.extras);
|
|
|
+ cgltf_free_extras(data, &data->accessors[i].sparse.indices_extras);
|
|
|
+ cgltf_free_extras(data, &data->accessors[i].sparse.values_extras);
|
|
|
}
|
|
|
cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->accessors[i].extras);
|
|
|
}
|
|
|
data->memory.free_func(data->memory.user_data, data->accessors);
|
|
|
|
|
@@ -1791,6 +1809,7 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->buffer_views[i].data);
|
|
|
|
|
|
cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->buffer_views[i].extras);
|
|
|
}
|
|
|
data->memory.free_func(data->memory.user_data, data->buffer_views);
|
|
|
|
|
@@ -1810,8 +1829,8 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->buffers[i].uri);
|
|
|
|
|
|
cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->buffers[i].extras);
|
|
|
}
|
|
|
-
|
|
|
data->memory.free_func(data->memory.user_data, data->buffers);
|
|
|
|
|
|
for (cgltf_size i = 0; i < data->meshes_count; ++i)
|
|
@@ -1849,9 +1868,15 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes);
|
|
|
}
|
|
|
|
|
|
+ for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
|
|
|
+ {
|
|
|
+ cgltf_free_extras(data, &data->meshes[i].primitives[j].mappings[k].extras);
|
|
|
+ }
|
|
|
+
|
|
|
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].mappings);
|
|
|
|
|
|
cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->meshes[i].primitives[j].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives);
|
|
@@ -1863,6 +1888,7 @@ void cgltf_free(cgltf_data* data)
|
|
|
}
|
|
|
|
|
|
cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->meshes[i].extras);
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->meshes[i].target_names);
|
|
|
}
|
|
@@ -1875,49 +1901,50 @@ void cgltf_free(cgltf_data* data)
|
|
|
|
|
|
if(data->materials[i].has_pbr_metallic_roughness)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].pbr_metallic_roughness.metallic_roughness_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].pbr_metallic_roughness.base_color_texture);
|
|
|
}
|
|
|
if(data->materials[i].has_pbr_specular_glossiness)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].pbr_specular_glossiness.diffuse_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].pbr_specular_glossiness.specular_glossiness_texture);
|
|
|
}
|
|
|
if(data->materials[i].has_clearcoat)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_texture.extensions, data->materials[i].clearcoat.clearcoat_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_normal_texture.extensions, data->materials[i].clearcoat.clearcoat_normal_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].clearcoat.clearcoat_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].clearcoat.clearcoat_roughness_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].clearcoat.clearcoat_normal_texture);
|
|
|
}
|
|
|
if(data->materials[i].has_specular)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].specular.specular_texture.extensions, data->materials[i].specular.specular_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].specular.specular_color_texture.extensions, data->materials[i].specular.specular_color_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].specular.specular_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].specular.specular_color_texture);
|
|
|
}
|
|
|
if(data->materials[i].has_transmission)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].transmission.transmission_texture.extensions, data->materials[i].transmission.transmission_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].transmission.transmission_texture);
|
|
|
}
|
|
|
if (data->materials[i].has_volume)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].volume.thickness_texture.extensions, data->materials[i].volume.thickness_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].volume.thickness_texture);
|
|
|
}
|
|
|
if(data->materials[i].has_sheen)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].sheen.sheen_color_texture.extensions, data->materials[i].sheen.sheen_color_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].sheen.sheen_roughness_texture.extensions, data->materials[i].sheen.sheen_roughness_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].sheen.sheen_color_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].sheen.sheen_roughness_texture);
|
|
|
}
|
|
|
if(data->materials[i].has_iridescence)
|
|
|
{
|
|
|
- cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_texture.extensions, data->materials[i].iridescence.iridescence_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_thickness_texture.extensions, data->materials[i].iridescence.iridescence_thickness_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].iridescence.iridescence_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].iridescence.iridescence_thickness_texture);
|
|
|
}
|
|
|
|
|
|
- cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, data->materials[i].normal_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].occlusion_texture.extensions, data->materials[i].occlusion_texture.extensions_count);
|
|
|
- cgltf_free_extensions(data, data->materials[i].emissive_texture.extensions, data->materials[i].emissive_texture.extensions_count);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].normal_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].occlusion_texture);
|
|
|
+ cgltf_free_texture_view(data, &data->materials[i].emissive_texture);
|
|
|
|
|
|
cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->materials[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->materials);
|
|
@@ -1929,6 +1956,7 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->images[i].mime_type);
|
|
|
|
|
|
cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->images[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->images);
|
|
@@ -1936,7 +1964,9 @@ void cgltf_free(cgltf_data* data)
|
|
|
for (cgltf_size i = 0; i < data->textures_count; ++i)
|
|
|
{
|
|
|
data->memory.free_func(data->memory.user_data, data->textures[i].name);
|
|
|
+
|
|
|
cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->textures[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->textures);
|
|
@@ -1944,7 +1974,9 @@ void cgltf_free(cgltf_data* data)
|
|
|
for (cgltf_size i = 0; i < data->samplers_count; ++i)
|
|
|
{
|
|
|
data->memory.free_func(data->memory.user_data, data->samplers[i].name);
|
|
|
+
|
|
|
cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->samplers[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->samplers);
|
|
@@ -1955,6 +1987,7 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->skins[i].joints);
|
|
|
|
|
|
cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->skins[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->skins);
|
|
@@ -1962,7 +1995,18 @@ void cgltf_free(cgltf_data* data)
|
|
|
for (cgltf_size i = 0; i < data->cameras_count; ++i)
|
|
|
{
|
|
|
data->memory.free_func(data->memory.user_data, data->cameras[i].name);
|
|
|
+
|
|
|
+ if (data->cameras[i].type == cgltf_camera_type_perspective)
|
|
|
+ {
|
|
|
+ cgltf_free_extras(data, &data->cameras[i].data.perspective.extras);
|
|
|
+ }
|
|
|
+ else if (data->cameras[i].type == cgltf_camera_type_orthographic)
|
|
|
+ {
|
|
|
+ cgltf_free_extras(data, &data->cameras[i].data.orthographic.extras);
|
|
|
+ }
|
|
|
+
|
|
|
cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->cameras[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->cameras);
|
|
@@ -1970,6 +2014,8 @@ void cgltf_free(cgltf_data* data)
|
|
|
for (cgltf_size i = 0; i < data->lights_count; ++i)
|
|
|
{
|
|
|
data->memory.free_func(data->memory.user_data, data->lights[i].name);
|
|
|
+
|
|
|
+ cgltf_free_extras(data, &data->lights[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->lights);
|
|
@@ -1979,7 +2025,19 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->nodes[i].name);
|
|
|
data->memory.free_func(data->memory.user_data, data->nodes[i].children);
|
|
|
data->memory.free_func(data->memory.user_data, data->nodes[i].weights);
|
|
|
+
|
|
|
+ if (data->nodes[i].has_mesh_gpu_instancing)
|
|
|
+ {
|
|
|
+ for (cgltf_size j = 0; j < data->nodes[i].mesh_gpu_instancing.attributes_count; ++j)
|
|
|
+ {
|
|
|
+ data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes[j].name);
|
|
|
+ }
|
|
|
+
|
|
|
+ data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes);
|
|
|
+ }
|
|
|
+
|
|
|
cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->nodes[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->nodes);
|
|
@@ -1990,6 +2048,7 @@ void cgltf_free(cgltf_data* data)
|
|
|
data->memory.free_func(data->memory.user_data, data->scenes[i].nodes);
|
|
|
|
|
|
cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->scenes[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->scenes);
|
|
@@ -2000,16 +2059,19 @@ void cgltf_free(cgltf_data* data)
|
|
|
for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
|
|
|
{
|
|
|
cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->animations[i].samplers[j].extras);
|
|
|
}
|
|
|
data->memory.free_func(data->memory.user_data, data->animations[i].samplers);
|
|
|
|
|
|
for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
|
|
|
{
|
|
|
cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->animations[i].channels[j].extras);
|
|
|
}
|
|
|
data->memory.free_func(data->memory.user_data, data->animations[i].channels);
|
|
|
|
|
|
cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->animations[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->animations);
|
|
@@ -2017,11 +2079,14 @@ void cgltf_free(cgltf_data* data)
|
|
|
for (cgltf_size i = 0; i < data->variants_count; ++i)
|
|
|
{
|
|
|
data->memory.free_func(data->memory.user_data, data->variants[i].name);
|
|
|
+
|
|
|
+ cgltf_free_extras(data, &data->variants[i].extras);
|
|
|
}
|
|
|
|
|
|
data->memory.free_func(data->memory.user_data, data->variants);
|
|
|
|
|
|
cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count);
|
|
|
+ cgltf_free_extras(data, &data->extras);
|
|
|
|
|
|
for (cgltf_size i = 0; i < data->extensions_used_count; ++i)
|
|
|
{
|
|
@@ -2440,7 +2505,7 @@ static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, co
|
|
|
{
|
|
|
CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING);
|
|
|
size_t const str_len = strlen(str);
|
|
|
- size_t const name_length = tok->end - tok->start;
|
|
|
+ size_t const name_length = (size_t)(tok->end - tok->start);
|
|
|
return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128;
|
|
|
}
|
|
|
|
|
@@ -2448,7 +2513,7 @@ static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk)
|
|
|
{
|
|
|
CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
|
|
|
char tmp[128];
|
|
|
- int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
|
|
|
+ int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
|
|
|
strncpy(tmp, (const char*)json_chunk + tok->start, size);
|
|
|
tmp[size] = 0;
|
|
|
return CGLTF_ATOI(tmp);
|
|
@@ -2458,7 +2523,7 @@ static cgltf_size cgltf_json_to_size(jsmntok_t const* tok, const uint8_t* json_c
|
|
|
{
|
|
|
CGLTF_CHECK_TOKTYPE_RETTYPE(*tok, JSMN_PRIMITIVE, cgltf_size);
|
|
|
char tmp[128];
|
|
|
- int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
|
|
|
+ int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
|
|
|
strncpy(tmp, (const char*)json_chunk + tok->start, size);
|
|
|
tmp[size] = 0;
|
|
|
return (cgltf_size)CGLTF_ATOLL(tmp);
|
|
@@ -2468,7 +2533,7 @@ static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json
|
|
|
{
|
|
|
CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
|
|
|
char tmp[128];
|
|
|
- int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
|
|
|
+ int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
|
|
|
strncpy(tmp, (const char*)json_chunk + tok->start, size);
|
|
|
tmp[size] = 0;
|
|
|
return (cgltf_float)CGLTF_ATOF(tmp);
|
|
@@ -2476,7 +2541,7 @@ static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json
|
|
|
|
|
|
static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk)
|
|
|
{
|
|
|
- int size = tok->end - tok->start;
|
|
|
+ int size = (int)(tok->end - tok->start);
|
|
|
return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0;
|
|
|
}
|
|
|
|
|
@@ -2542,7 +2607,7 @@ static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* toke
|
|
|
{
|
|
|
return CGLTF_ERROR_JSON;
|
|
|
}
|
|
|
- int size = tokens[i].end - tokens[i].start;
|
|
|
+ int size = (int)(tokens[i].end - tokens[i].start);
|
|
|
char* result = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
|
|
|
if (!result)
|
|
|
{
|
|
@@ -2683,11 +2748,27 @@ static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t con
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
-static int cgltf_parse_json_extras(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
|
|
|
+static int cgltf_parse_json_extras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
|
|
|
{
|
|
|
- (void)json_chunk;
|
|
|
+ if (out_extras->data)
|
|
|
+ {
|
|
|
+ return CGLTF_ERROR_JSON;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* fill deprecated fields for now, this will be removed in the future */
|
|
|
out_extras->start_offset = tokens[i].start;
|
|
|
out_extras->end_offset = tokens[i].end;
|
|
|
+
|
|
|
+ size_t start = tokens[i].start;
|
|
|
+ size_t size = tokens[i].end - start;
|
|
|
+ out_extras->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
|
|
|
+ if (!out_extras->data)
|
|
|
+ {
|
|
|
+ return CGLTF_ERROR_NOMEM;
|
|
|
+ }
|
|
|
+ strncpy(out_extras->data, (const char*)json_chunk + start, size);
|
|
|
+ out_extras->data[size] = '\0';
|
|
|
+
|
|
|
i = cgltf_skip_json(tokens, i);
|
|
|
return i;
|
|
|
}
|
|
@@ -2842,7 +2923,7 @@ static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmnto
|
|
|
|
|
|
int material = -1;
|
|
|
int variants_tok = -1;
|
|
|
- cgltf_extras extras = {0, 0};
|
|
|
+ int extras_tok = -1;
|
|
|
|
|
|
for (int k = 0; k < obj_size; ++k)
|
|
|
{
|
|
@@ -2863,7 +2944,8 @@ static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmnto
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &extras);
|
|
|
+ extras_tok = i + 1;
|
|
|
+ i = cgltf_skip_json(tokens, extras_tok);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2891,7 +2973,13 @@ static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmnto
|
|
|
|
|
|
out_mappings[*offset].material = CGLTF_PTRINDEX(cgltf_material, material);
|
|
|
out_mappings[*offset].variant = variant;
|
|
|
- out_mappings[*offset].extras = extras;
|
|
|
+
|
|
|
+ if (extras_tok >= 0)
|
|
|
+ {
|
|
|
+ int e = cgltf_parse_json_extras(options, tokens, extras_tok, json_chunk, &out_mappings[*offset].extras);
|
|
|
+ if (e < 0)
|
|
|
+ return e;
|
|
|
+ }
|
|
|
|
|
|
(*offset)++;
|
|
|
}
|
|
@@ -3006,7 +3094,7 @@ static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* t
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_prim->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_prim->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -3253,7 +3341,7 @@ static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t co
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->indices_extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sparse->indices_extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -3296,7 +3384,7 @@ static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t co
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->values_extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sparse->values_extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -3315,7 +3403,7 @@ static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t co
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sparse->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -3438,7 +3526,7 @@ static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* to
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_accessor->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_accessor->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -3544,7 +3632,7 @@ static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture_view->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_texture_view->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -3640,10 +3728,6 @@ static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmnt
|
|
|
i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
|
|
|
&out_pbr->metallic_roughness_texture);
|
|
|
}
|
|
|
- else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
- {
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_pbr->extras);
|
|
|
- }
|
|
|
else
|
|
|
{
|
|
|
i = cgltf_skip_json(tokens, i+1);
|
|
@@ -4076,7 +4160,7 @@ static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* token
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_image->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_image->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -4145,7 +4229,7 @@ static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tok
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -4194,7 +4278,7 @@ static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tok
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_texture->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -4357,7 +4441,7 @@ static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* to
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_material->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_material->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -4710,7 +4794,7 @@ static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const*
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer_view->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer_view->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -4813,7 +4897,7 @@ static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* toke
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -4897,7 +4981,7 @@ static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_skin->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_skin->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -4951,19 +5035,6 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
|
|
|
{
|
|
|
i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name);
|
|
|
}
|
|
|
- else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
|
|
|
- {
|
|
|
- ++i;
|
|
|
- if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0)
|
|
|
- {
|
|
|
- out_camera->type = cgltf_camera_type_perspective;
|
|
|
- }
|
|
|
- else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0)
|
|
|
- {
|
|
|
- out_camera->type = cgltf_camera_type_orthographic;
|
|
|
- }
|
|
|
- ++i;
|
|
|
- }
|
|
|
else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0)
|
|
|
{
|
|
|
++i;
|
|
@@ -4973,6 +5044,11 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
|
|
|
int data_size = tokens[i].size;
|
|
|
++i;
|
|
|
|
|
|
+ if (out_camera->type != cgltf_camera_type_invalid)
|
|
|
+ {
|
|
|
+ return CGLTF_ERROR_JSON;
|
|
|
+ }
|
|
|
+
|
|
|
out_camera->type = cgltf_camera_type_perspective;
|
|
|
|
|
|
for (int k = 0; k < data_size; ++k)
|
|
@@ -5007,7 +5083,7 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -5029,6 +5105,11 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
|
|
|
int data_size = tokens[i].size;
|
|
|
++i;
|
|
|
|
|
|
+ if (out_camera->type != cgltf_camera_type_invalid)
|
|
|
+ {
|
|
|
+ return CGLTF_ERROR_JSON;
|
|
|
+ }
|
|
|
+
|
|
|
out_camera->type = cgltf_camera_type_orthographic;
|
|
|
|
|
|
for (int k = 0; k < data_size; ++k)
|
|
@@ -5061,7 +5142,7 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -5076,7 +5157,7 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -5209,7 +5290,7 @@ static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* token
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_light->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_light->extras);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -5335,7 +5416,7 @@ static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_node->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_node->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -5473,7 +5554,7 @@ static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* token
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_scene->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_scene->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -5555,7 +5636,7 @@ static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -5635,7 +5716,7 @@ static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_channel->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_channel->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -5717,7 +5798,7 @@ static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* t
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_animation->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_animation->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -5773,7 +5854,7 @@ static int cgltf_parse_json_variant(cgltf_options* options, jsmntok_t const* tok
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_variant->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_variant->extras);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -5837,7 +5918,7 @@ static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* token
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_asset->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_asset->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -5993,7 +6074,7 @@ static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0)
|
|
|
{
|
|
|
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_data->extras);
|
|
|
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_data->extras);
|
|
|
}
|
|
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
|
|
|
{
|
|
@@ -6420,7 +6501,7 @@ static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
|
|
|
* Fills token type and boundaries.
|
|
|
*/
|
|
|
static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
|
|
|
- int start, int end) {
|
|
|
+ ptrdiff_t start, ptrdiff_t end) {
|
|
|
token->type = type;
|
|
|
token->start = start;
|
|
|
token->end = end;
|
|
@@ -6433,7 +6514,7 @@ static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
|
|
|
static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
|
|
|
size_t len, jsmntok_t *tokens, size_t num_tokens) {
|
|
|
jsmntok_t *token;
|
|
|
- int start;
|
|
|
+ ptrdiff_t start;
|
|
|
|
|
|
start = parser->pos;
|
|
|
|
|
@@ -6483,7 +6564,7 @@ static int jsmn_parse_string(jsmn_parser *parser, const char *js,
|
|
|
size_t len, jsmntok_t *tokens, size_t num_tokens) {
|
|
|
jsmntok_t *token;
|
|
|
|
|
|
- int start = parser->pos;
|
|
|
+ ptrdiff_t start = parser->pos;
|
|
|
|
|
|
parser->pos++;
|
|
|
|