mirror of https://github.com/bkaradzic/bgfx
Updated cgltf.
This commit is contained in:
parent
cd3a1ea7f8
commit
35b0fdd60b
|
@ -65,7 +65,8 @@
|
|||
*
|
||||
* `cgltf_num_components` is a tiny utility that tells you the dimensionality of
|
||||
* a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate
|
||||
* the necessary amount of memory.
|
||||
* the necessary amount of memory. `cgltf_component_size` and `cgltf_calc_size` exist for
|
||||
* similar purposes.
|
||||
*
|
||||
* `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to
|
||||
* floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element
|
||||
|
@ -837,6 +838,8 @@ cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size i
|
|||
cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
|
||||
|
||||
cgltf_size cgltf_num_components(cgltf_type type);
|
||||
cgltf_size cgltf_component_size(cgltf_component_type component_type);
|
||||
cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
|
||||
|
||||
cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count);
|
||||
|
||||
|
@ -904,15 +907,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;
|
||||
|
@ -1488,8 +1491,6 @@ cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data,
|
|||
return cgltf_result_success;
|
||||
}
|
||||
|
||||
static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
|
||||
|
||||
static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count)
|
||||
{
|
||||
char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset;
|
||||
|
@ -2253,8 +2254,6 @@ static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_ty
|
|||
return (cgltf_float)cgltf_component_read_integer(in, component_type);
|
||||
}
|
||||
|
||||
static cgltf_size cgltf_component_size(cgltf_component_type component_type);
|
||||
|
||||
static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size)
|
||||
{
|
||||
cgltf_size num_components = cgltf_num_components(type);
|
||||
|
@ -2505,7 +2504,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;
|
||||
}
|
||||
|
||||
|
@ -2513,7 +2512,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);
|
||||
|
@ -2523,7 +2522,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);
|
||||
|
@ -2533,7 +2532,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);
|
||||
|
@ -2541,7 +2540,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;
|
||||
}
|
||||
|
||||
|
@ -2607,7 +2606,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)
|
||||
{
|
||||
|
@ -5965,7 +5964,7 @@ cgltf_size cgltf_num_components(cgltf_type type) {
|
|||
}
|
||||
}
|
||||
|
||||
static cgltf_size cgltf_component_size(cgltf_component_type component_type) {
|
||||
cgltf_size cgltf_component_size(cgltf_component_type component_type) {
|
||||
switch (component_type)
|
||||
{
|
||||
case cgltf_component_type_r_8:
|
||||
|
@ -5983,7 +5982,7 @@ static cgltf_size cgltf_component_size(cgltf_component_type component_type) {
|
|||
}
|
||||
}
|
||||
|
||||
static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
|
||||
cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
|
||||
{
|
||||
cgltf_size component_size = cgltf_component_size(component_type);
|
||||
if (type == cgltf_type_mat2 && component_size == 1)
|
||||
|
@ -6501,7 +6500,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;
|
||||
|
@ -6514,7 +6513,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;
|
||||
|
||||
|
@ -6564,7 +6563,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++;
|
||||
|
||||
|
|
|
@ -1123,6 +1123,7 @@ static void cgltf_write_light(cgltf_write_context* context, const cgltf_light* l
|
|||
cgltf_write_floatprop(context, "outerConeAngle", light->spot_outer_cone_angle, 3.14159265358979323846f/4.0f);
|
||||
cgltf_write_line(context, "}");
|
||||
}
|
||||
cgltf_write_extras( context, &light->extras );
|
||||
cgltf_write_line(context, "}");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue