Tiny refactor
This commit is contained in:
@@ -2476,7 +2476,7 @@ ufbxi_inflate_block_fast(ufbxi_deflate_context *dc, ufbxi_trees *trees)
|
||||
// -16 - -21: Litlen Huffman: Overfull / Underfull / Repeat 16/17/18 overflow / Bad length code
|
||||
// -22 - -27: Distance Huffman: Overfull / Underfull / Repeat 16/17/18 overflow / Bad length code
|
||||
// -28: Cancelled
|
||||
// -29: Invalid ufbx_inflate_input.internal_fast_bits value
|
||||
// -29: Invalid ufbx_inflate_engine.input.internal_fast_bits value
|
||||
ufbxi_extern_c ptrdiff_t ufbx_inflate(void *dst, size_t dst_size, const ufbx_inflate_input *input, ufbx_inflate_retain *retain)
|
||||
{
|
||||
ufbxi_inflate_retain_imp *ret_imp = (ufbxi_inflate_retain_imp*)retain;
|
||||
@@ -7779,24 +7779,24 @@ ufbxi_nodiscard ufbxi_noinline static int ufbxi_binary_parse_node(ufbxi_context
|
||||
|
||||
// Inflate the data from the user-provided IO buffer / read callbacks
|
||||
ufbx_inflate_input input;
|
||||
input.total_size = encoded_size;
|
||||
input.data = uc->data;
|
||||
input.data_size = uc->data_size;
|
||||
input.no_header = false;
|
||||
input.no_checksum = false;
|
||||
input.internal_fast_bits = 0;
|
||||
engine.input.total_size = encoded_size;
|
||||
engine.input.data = uc->data;
|
||||
engine.input.data_size = uc->data_size;
|
||||
engine.input.no_header = false;
|
||||
engine.input.no_checksum = false;
|
||||
engine.input.internal_fast_bits = 0;
|
||||
|
||||
if (uc->opts.progress_cb.fn) {
|
||||
input.progress_cb = uc->opts.progress_cb;
|
||||
input.progress_size_before = arr_begin;
|
||||
input.progress_size_after = uc->progress_bytes_total - arr_end;
|
||||
input.progress_interval_hint = uc->progress_interval;
|
||||
engine.input.progress_cb = uc->opts.progress_cb;
|
||||
engine.input.progress_size_before = arr_begin;
|
||||
engine.input.progress_size_after = uc->progress_bytes_total - arr_end;
|
||||
engine.input.progress_interval_hint = uc->progress_interval;
|
||||
} else {
|
||||
input.progress_cb.fn = NULL;
|
||||
input.progress_cb.user = NULL;
|
||||
input.progress_size_before = 0;
|
||||
input.progress_size_after = 0;
|
||||
input.progress_interval_hint = 0;
|
||||
engine.input.progress_cb.fn = NULL;
|
||||
engine.input.progress_cb.user = NULL;
|
||||
engine.input.progress_size_before = 0;
|
||||
engine.input.progress_size_after = 0;
|
||||
engine.input.progress_interval_hint = 0;
|
||||
}
|
||||
|
||||
// If the encoded array is larger than the data we have currently buffered
|
||||
@@ -7807,19 +7807,19 @@ ufbxi_nodiscard ufbxi_noinline static int ufbxi_binary_parse_node(ufbxi_context
|
||||
// usual (given that we clear the `uc->data/_size` buffer below).
|
||||
// NOTE: We _cannot_ share `read_buffer` if we plan to read later from it
|
||||
// as `ufbx_inflate()` overwrites parts of it with zeroes.
|
||||
if (encoded_size > input.data_size) {
|
||||
input.buffer = uc->read_buffer;
|
||||
input.buffer_size = uc->read_buffer_size;
|
||||
input.read_fn = uc->read_fn;
|
||||
input.read_user = uc->read_user;
|
||||
uc->data_offset += encoded_size - input.data_size;
|
||||
uc->data += input.data_size;
|
||||
if (encoded_size > engine.input.data_size) {
|
||||
engine.input.buffer = uc->read_buffer;
|
||||
engine.input.buffer_size = uc->read_buffer_size;
|
||||
engine.input.read_fn = uc->read_fn;
|
||||
engine.input.read_user = uc->read_user;
|
||||
uc->data_offset += encoded_size - engine.input.data_size;
|
||||
uc->data += engine.input.data_size;
|
||||
uc->data_size = 0;
|
||||
} else {
|
||||
input.buffer = NULL;
|
||||
input.buffer_size = 0;
|
||||
input.read_fn = NULL;
|
||||
input.read_user = 0;
|
||||
engine.input.buffer = NULL;
|
||||
engine.input.buffer_size = 0;
|
||||
engine.input.read_fn = NULL;
|
||||
engine.input.read_user = 0;
|
||||
uc->data += encoded_size;
|
||||
uc->data_size -= encoded_size;
|
||||
ufbxi_check(ufbxi_resume_progress(uc));
|
||||
@@ -17347,7 +17347,7 @@ ufbxi_nodiscard ufbxi_noinline static int ufbxi_finalize_shader_texture(ufbxi_co
|
||||
ufbx_string name = prop->name;
|
||||
if (!ufbxi_remove_prefix_str(&name, shader->prop_prefix)) continue;
|
||||
|
||||
// Check if this property is a modifier to an existing input.
|
||||
// Check if this property is a modifier to an existing engine.input.
|
||||
ufbx_string base_name = name;
|
||||
if (ufbxi_remove_suffix_c(&base_name, "_map") || ufbxi_remove_suffix_c(&base_name, ".shader")) {
|
||||
ufbx_shader_texture_input *base = ufbx_find_shader_texture_input_len(shader, base_name.data, base_name.length);
|
||||
@@ -24251,14 +24251,14 @@ static ufbxi_noinline int ufbxi_subdivide_attrib(ufbxi_subdivide_context *sc, uf
|
||||
ufbx_assert(attrib->value_reals >= 1 && attrib->value_reals <= 4);
|
||||
|
||||
ufbxi_subdivide_layer_input input;
|
||||
input.sum_fn = ufbxi_real_sum_fns[attrib->value_reals - 1];
|
||||
input.sum_user = NULL;
|
||||
input.values = attrib->values.data;
|
||||
input.indices = attrib->indices.data;
|
||||
input.stride = attrib->value_reals * sizeof(ufbx_real);
|
||||
input.boundary = boundary;
|
||||
input.check_split_data = check_split_data;
|
||||
input.ignore_indices = false;
|
||||
engine.input.sum_fn = ufbxi_real_sum_fns[attrib->value_reals - 1];
|
||||
engine.input.sum_user = NULL;
|
||||
engine.input.values = attrib->values.data;
|
||||
engine.input.indices = attrib->indices.data;
|
||||
engine.input.stride = attrib->value_reals * sizeof(ufbx_real);
|
||||
engine.input.boundary = boundary;
|
||||
engine.input.check_split_data = check_split_data;
|
||||
engine.input.ignore_indices = false;
|
||||
|
||||
ufbxi_subdivide_layer_output output;
|
||||
ufbxi_check_err(&sc->error, ufbxi_subdivide_layer(sc, &output, &input));
|
||||
@@ -24334,14 +24334,14 @@ static ufbxi_noinline int ufbxi_subdivide_weights(ufbxi_subdivide_context *sc, u
|
||||
ufbxi_check_err(&sc->error, src);
|
||||
|
||||
ufbxi_subdivide_layer_input input;
|
||||
input.sum_fn = ufbxi_subdivide_sum_vertex_weights;
|
||||
input.sum_user = sc;
|
||||
input.values = src;
|
||||
input.indices = sc->src_mesh.vertex_indices.data;
|
||||
input.stride = sizeof(ufbxi_subdivision_vertex_weights);
|
||||
input.boundary = sc->opts.boundary;
|
||||
input.check_split_data = false;
|
||||
input.ignore_indices = true;
|
||||
engine.input.sum_fn = ufbxi_subdivide_sum_vertex_weights;
|
||||
engine.input.sum_user = sc;
|
||||
engine.input.values = src;
|
||||
engine.input.indices = sc->src_mesh.vertex_indices.data;
|
||||
engine.input.stride = sizeof(ufbxi_subdivision_vertex_weights);
|
||||
engine.input.boundary = sc->opts.boundary;
|
||||
engine.input.check_split_data = false;
|
||||
engine.input.ignore_indices = true;
|
||||
|
||||
sc->total_weights = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user