diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenkernel/intern/cachefile.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenkernel/intern/cachefile.c')
-rw-r--r-- | source/blender/blenkernel/intern/cachefile.c | 247 |
1 files changed, 125 insertions, 122 deletions
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index 2c9e4966fc9..4fe8cabde65 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -49,57 +49,57 @@ static SpinLock spin; void BKE_cachefiles_init(void) { - BLI_spin_init(&spin); + BLI_spin_init(&spin); } void BKE_cachefiles_exit(void) { - BLI_spin_end(&spin); + BLI_spin_end(&spin); } void *BKE_cachefile_add(Main *bmain, const char *name) { - CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0); + CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0); - BKE_cachefile_init(cache_file); + BKE_cachefile_init(cache_file); - return cache_file; + return cache_file; } void BKE_cachefile_init(CacheFile *cache_file) { - cache_file->handle = NULL; - cache_file->filepath[0] = '\0'; - cache_file->override_frame = false; - cache_file->frame = 0.0f; - cache_file->is_sequence = false; - cache_file->scale = 1.0f; - cache_file->handle_mutex = BLI_mutex_alloc(); - BLI_listbase_clear(&cache_file->object_paths); + cache_file->handle = NULL; + cache_file->filepath[0] = '\0'; + cache_file->override_frame = false; + cache_file->frame = 0.0f; + cache_file->is_sequence = false; + cache_file->scale = 1.0f; + cache_file->handle_mutex = BLI_mutex_alloc(); + BLI_listbase_clear(&cache_file->object_paths); } /** Free (or release) any data used by this cachefile (does not free the cachefile itself). */ void BKE_cachefile_free(CacheFile *cache_file) { - BKE_animdata_free((ID *)cache_file, false); + BKE_animdata_free((ID *)cache_file, false); - if (cache_file->id.tag & LIB_TAG_NO_MAIN) { - /* CoW/no-main copies reuse the existing ArchiveReader and mutex */ - return; - } + if (cache_file->id.tag & LIB_TAG_NO_MAIN) { + /* CoW/no-main copies reuse the existing ArchiveReader and mutex */ + return; + } - if (cache_file->handle) { + if (cache_file->handle) { #ifdef WITH_ALEMBIC - ABC_free_handle(cache_file->handle); + ABC_free_handle(cache_file->handle); #endif - cache_file->handle = NULL; - } - if (cache_file->handle_mutex) { - BLI_mutex_free(cache_file->handle_mutex); - cache_file->handle_mutex = NULL; - } - - BLI_freelistN(&cache_file->object_paths); + cache_file->handle = NULL; + } + if (cache_file->handle_mutex) { + BLI_mutex_free(cache_file->handle_mutex); + cache_file->handle_mutex = NULL; + } + + BLI_freelistN(&cache_file->object_paths); } /** @@ -110,158 +110,161 @@ void BKE_cachefile_free(CacheFile *cache_file) * * \param flag: Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ -void BKE_cachefile_copy_data( - Main *UNUSED(bmain), CacheFile *cache_file_dst, const CacheFile *UNUSED(cache_file_src), const int UNUSED(flag)) +void BKE_cachefile_copy_data(Main *UNUSED(bmain), + CacheFile *cache_file_dst, + const CacheFile *UNUSED(cache_file_src), + const int UNUSED(flag)) { - if (cache_file_dst->id.tag & LIB_TAG_NO_MAIN) { - /* CoW/no-main copies reuse the existing ArchiveReader and mutex */ - return; - } - - cache_file_dst->handle = NULL; - cache_file_dst->handle_mutex = NULL; - BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_dst->object_paths); + if (cache_file_dst->id.tag & LIB_TAG_NO_MAIN) { + /* CoW/no-main copies reuse the existing ArchiveReader and mutex */ + return; + } + + cache_file_dst->handle = NULL; + cache_file_dst->handle_mutex = NULL; + BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_dst->object_paths); } CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file) { - CacheFile *cache_file_copy; - BKE_id_copy(bmain, &cache_file->id, (ID **)&cache_file_copy); - return cache_file_copy; + CacheFile *cache_file_copy; + BKE_id_copy(bmain, &cache_file->id, (ID **)&cache_file_copy); + return cache_file_copy; } void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const bool lib_local) { - BKE_id_make_local_generic(bmain, &cache_file->id, true, lib_local); + BKE_id_make_local_generic(bmain, &cache_file->id, true, lib_local); } void BKE_cachefile_reload(const Main *bmain, CacheFile *cache_file) { - char filepath[FILE_MAX]; + char filepath[FILE_MAX]; - BLI_strncpy(filepath, cache_file->filepath, sizeof(filepath)); - BLI_path_abs(filepath, ID_BLEND_PATH(bmain, &cache_file->id)); + BLI_strncpy(filepath, cache_file->filepath, sizeof(filepath)); + BLI_path_abs(filepath, ID_BLEND_PATH(bmain, &cache_file->id)); #ifdef WITH_ALEMBIC - if (cache_file->handle) { - ABC_free_handle(cache_file->handle); - } + if (cache_file->handle) { + ABC_free_handle(cache_file->handle); + } - cache_file->handle = ABC_create_handle(filepath, &cache_file->object_paths); + cache_file->handle = ABC_create_handle(filepath, &cache_file->object_paths); #endif } void BKE_cachefile_ensure_handle(const Main *bmain, CacheFile *cache_file) { - BLI_spin_lock(&spin); - if (cache_file->handle_mutex == NULL) { - cache_file->handle_mutex = BLI_mutex_alloc(); - } - BLI_spin_unlock(&spin); + BLI_spin_lock(&spin); + if (cache_file->handle_mutex == NULL) { + cache_file->handle_mutex = BLI_mutex_alloc(); + } + BLI_spin_unlock(&spin); - BLI_mutex_lock(cache_file->handle_mutex); + BLI_mutex_lock(cache_file->handle_mutex); - if (cache_file->handle == NULL) { - /* Assigning to a CoW copy is a bad idea; assign to the original instead. */ - BLI_assert((cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0); - BKE_cachefile_reload(bmain, cache_file); - } + if (cache_file->handle == NULL) { + /* Assigning to a CoW copy is a bad idea; assign to the original instead. */ + BLI_assert((cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0); + BKE_cachefile_reload(bmain, cache_file); + } - BLI_mutex_unlock(cache_file->handle_mutex); + BLI_mutex_unlock(cache_file->handle_mutex); } void BKE_cachefile_update_frame( - Main *bmain, struct Depsgraph *depsgraph, Scene *scene, - const float ctime, const float fps) + Main *bmain, struct Depsgraph *depsgraph, Scene *scene, const float ctime, const float fps) { - CacheFile *cache_file; - char filename[FILE_MAX]; + CacheFile *cache_file; + char filename[FILE_MAX]; - for (cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) { - /* TODO: dependency graph should be updated to do drivers on cachefile. - * Execute drivers only, as animation has already been done. */ - BKE_animsys_evaluate_animdata(depsgraph, scene, &cache_file->id, cache_file->adt, ctime, ADT_RECALC_DRIVERS); + for (cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) { + /* TODO: dependency graph should be updated to do drivers on cachefile. + * Execute drivers only, as animation has already been done. */ + BKE_animsys_evaluate_animdata( + depsgraph, scene, &cache_file->id, cache_file->adt, ctime, ADT_RECALC_DRIVERS); - if (!cache_file->is_sequence) { - continue; - } + if (!cache_file->is_sequence) { + continue; + } - const float time = BKE_cachefile_time_offset(cache_file, ctime, fps); + const float time = BKE_cachefile_time_offset(cache_file, ctime, fps); - if (BKE_cachefile_filepath_get(bmain, cache_file, time, filename)) { - BKE_cachefile_clean(bmain, cache_file); + if (BKE_cachefile_filepath_get(bmain, cache_file, time, filename)) { + BKE_cachefile_clean(bmain, cache_file); #ifdef WITH_ALEMBIC - ABC_free_handle(cache_file->handle); - cache_file->handle = ABC_create_handle(filename, NULL); + ABC_free_handle(cache_file->handle); + cache_file->handle = ABC_create_handle(filename, NULL); #endif - } - } + } + } } -bool BKE_cachefile_filepath_get( - const Main *bmain, const CacheFile *cache_file, float frame, - char r_filepath[FILE_MAX]) +bool BKE_cachefile_filepath_get(const Main *bmain, + const CacheFile *cache_file, + float frame, + char r_filepath[FILE_MAX]) { - BLI_strncpy(r_filepath, cache_file->filepath, FILE_MAX); - BLI_path_abs(r_filepath, ID_BLEND_PATH(bmain, &cache_file->id)); + BLI_strncpy(r_filepath, cache_file->filepath, FILE_MAX); + BLI_path_abs(r_filepath, ID_BLEND_PATH(bmain, &cache_file->id)); - int fframe; - int frame_len; + int fframe; + int frame_len; - if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) { - char ext[32]; - BLI_path_frame_strip(r_filepath, ext); - BLI_path_frame(r_filepath, frame, frame_len); - BLI_path_extension_ensure(r_filepath, FILE_MAX, ext); + if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) { + char ext[32]; + BLI_path_frame_strip(r_filepath, ext); + BLI_path_frame(r_filepath, frame, frame_len); + BLI_path_extension_ensure(r_filepath, FILE_MAX, ext); - /* TODO(kevin): store sequence range? */ - return BLI_exists(r_filepath); - } + /* TODO(kevin): store sequence range? */ + return BLI_exists(r_filepath); + } - return true; + return true; } float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const float fps) { - const float time_offset = cache_file->frame_offset / fps; - const float frame = (cache_file->override_frame ? cache_file->frame : time); - return cache_file->is_sequence ? frame : frame / fps - time_offset; + const float time_offset = cache_file->frame_offset / fps; + const float frame = (cache_file->override_frame ? cache_file->frame : time); + return cache_file->is_sequence ? frame : frame / fps - time_offset; } /* TODO(kevin): replace this with some depsgraph mechanism, or something similar. */ void BKE_cachefile_clean(struct Main *bmain, CacheFile *cache_file) { - for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache); + for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { + ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache); - if (md) { - MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md; + if (md) { + MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md; - if (cache_file == mcmd->cache_file) { + if (cache_file == mcmd->cache_file) { #ifdef WITH_ALEMBIC - if (mcmd->reader != NULL) { - CacheReader_free(mcmd->reader); - } + if (mcmd->reader != NULL) { + CacheReader_free(mcmd->reader); + } #endif - mcmd->reader = NULL; - } - } + mcmd->reader = NULL; + } + } - for (bConstraint *con = ob->constraints.first; con; con = con->next) { - if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) { - continue; - } + for (bConstraint *con = ob->constraints.first; con; con = con->next) { + if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) { + continue; + } - bTransformCacheConstraint *data = con->data; + bTransformCacheConstraint *data = con->data; - if (cache_file == data->cache_file) { + if (cache_file == data->cache_file) { #ifdef WITH_ALEMBIC - if (data->reader != NULL) { - CacheReader_free(data->reader); - } + if (data->reader != NULL) { + CacheReader_free(data->reader); + } #endif - data->reader = NULL; - } - } - } + data->reader = NULL; + } + } + } } |