diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-08-16 20:59:04 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-08-16 20:59:22 +0300 |
commit | ccf31810d666c85b4c82fef090bfd08cd2402726 (patch) | |
tree | 8e0fc0cbe50c7c6e7b20269cec67bb004477c6b0 | |
parent | a3b3871ca17309e67f65d616c280783681e5b4c2 (diff) |
Cleanup: use a structure for Alembic import parameters
Also renammed some parameters and sprinkled a dash of documentation.
-rw-r--r-- | source/blender/editors/io/io_alembic.c | 20 | ||||
-rw-r--r-- | source/blender/io/alembic/ABC_alembic.h | 30 | ||||
-rw-r--r-- | source/blender/io/alembic/intern/alembic_capi.cc | 22 |
3 files changed, 41 insertions, 31 deletions
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 0068586730f..9b427938279 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -651,16 +651,16 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op) ED_object_mode_set(C, OB_MODE_OBJECT); } - bool ok = ABC_import(C, - filename, - scale, - is_sequence, - set_frame_range, - sequence_len, - offset, - validate_meshes, - always_add_cache_reader, - as_background_job); + struct AlembicImportParams params; + params.global_scale = scale; + params.sequence_len = sequence_len; + params.sequence_offset = offset; + params.is_sequence = is_sequence; + params.set_frame_range = set_frame_range; + params.validate_meshes = validate_meshes; + params.always_add_cache_reader = always_add_cache_reader; + + bool ok = ABC_import(C, filename, ¶ms, as_background_job); return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } diff --git a/source/blender/io/alembic/ABC_alembic.h b/source/blender/io/alembic/ABC_alembic.h index ded3258ff18..05025861857 100644 --- a/source/blender/io/alembic/ABC_alembic.h +++ b/source/blender/io/alembic/ABC_alembic.h @@ -60,6 +60,28 @@ struct AlembicExportParams { float global_scale; }; +struct AlembicImportParams { + /* Multiplier for the cached data scale. Mostly useful if the data is stored in a different unit + * as what Blender expects (e.g. centimeters instead of meters). */ + float global_scale; + + /* Number of consecutive files to expect if the cached animation is split in a sequence. */ + int sequence_len; + /* Start frame of the sequence, offset from 0. */ + int sequence_offset; + /* True if the cache is split in multiple files. */ + bool is_sequence; + + /* True if the importer should set the current scene's start and end frame based on the start and + * end frames of the cached animation. */ + bool set_frame_range; + /* True if imported meshes should be validated. Error messages are sent to the console. */ + bool validate_meshes; + /* True if a cache reader should be added regardless of whether there is animated data in the + * cached file. */ + bool always_add_cache_reader; +}; + /* The ABC_export and ABC_import functions both take a as_background_job * parameter, and return a boolean. * @@ -78,13 +100,7 @@ bool ABC_export(struct Scene *scene, bool ABC_import(struct bContext *C, const char *filepath, - float scale, - bool is_sequence, - bool set_frame_range, - int sequence_len, - int offset, - bool validate_meshes, - bool always_add_cache_reader, + const struct AlembicImportParams *params, bool as_background_job); struct CacheArchiveHandle *ABC_create_handle(struct Main *bmain, diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index 27df23b38c6..86622719f6e 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -672,13 +672,7 @@ static void import_freejob(void *user_data) bool ABC_import(bContext *C, const char *filepath, - float scale, - bool is_sequence, - bool set_frame_range, - int sequence_len, - int offset, - bool validate_meshes, - bool always_add_cache_reader, + const AlembicImportParams *params, bool as_background_job) { /* Using new here since MEM_* functions do not call constructor to properly initialize data. */ @@ -691,13 +685,13 @@ bool ABC_import(bContext *C, job->import_ok = false; BLI_strncpy(job->filename, filepath, 1024); - job->settings.scale = scale; - job->settings.is_sequence = is_sequence; - job->settings.set_frame_range = set_frame_range; - job->settings.sequence_len = sequence_len; - job->settings.sequence_offset = offset; - job->settings.validate_meshes = validate_meshes; - job->settings.always_add_cache_reader = always_add_cache_reader; + job->settings.scale = params->global_scale; + job->settings.is_sequence = params->is_sequence; + job->settings.set_frame_range = params->set_frame_range; + job->settings.sequence_len = params->sequence_len; + job->settings.sequence_offset = params->sequence_offset; + job->settings.validate_meshes = params->validate_meshes; + job->settings.always_add_cache_reader = params->always_add_cache_reader; job->error_code = ABC_NO_ERROR; job->was_cancelled = false; job->archive = nullptr; |