Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <mont29>2021-11-29 16:20:58 +0300
committerBastien Montagne <bastien@blender.org>2021-11-29 16:22:38 +0300
commite5e8db73df86ee04260c5f2bd2c61dfa8eb7943f (patch)
tree46a5840efb51a363f17e64b93d5132679a5dbec4 /source/blender/blenkernel/intern/object.cc
parent6ae34bb0714859d9ef0b7fa2aceb16b4531df48f (diff)
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`, and move each ID-specific part of the `foreach_path` looper into their own IDTypeInfo struct, using a new `foreach_path` callback. Additionally, following improvements/cleanups are included: * Attempt to get better, more consistent namings. ** In particular, move from `path_visitor` to more standard `foreach_path`. * Update and extend documentation. ** API doc was moved to header, according to recent discussions on this topic. * Remove `BKE_bpath_relocate_visitor` from API, this is specific callback that belongs in `lib_id.c` user code. NOTE: This commit is expected to be 100% non-behavioral-change. This implies that several potential further changes were only noted as comments (like using a more generic solution for `lib_id_library_local_paths`, addressing inconsistencies like path of packed libraries always being skipped, regardless of the `BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value, etc.). NOTE: basic unittests were added to master already in rBdcc500e5a265093bc9cc. Reviewed By: brecht Differential Revision: https://developer.blender.org/D13381
Diffstat (limited to 'source/blender/blenkernel/intern/object.cc')
-rw-r--r--source/blender/blenkernel/intern/object.cc62
1 files changed, 62 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc
index e3b9e4109ed..efb8cdd9c9d 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -83,6 +83,7 @@
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_asset.h"
+#include "BKE_bpath.h"
#include "BKE_camera.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
@@ -548,6 +549,66 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void object_foreach_path_pointcache(ListBase *ptcache_list, BPathForeachPathData *bpath_data)
+{
+ for (PointCache *cache = (PointCache *)ptcache_list->first; cache != nullptr;
+ cache = cache->next) {
+ if (cache->flag & PTCACHE_DISK_CACHE) {
+ BKE_bpath_foreach_path_fixed_process(bpath_data, cache->path);
+ }
+ }
+}
+
+static void object_foreach_path(ID *id, BPathForeachPathData *bpath_data)
+{
+ Object *ob = reinterpret_cast<Object *>(id);
+
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
+ /* TODO: Move that to #ModifierTypeInfo. */
+ switch (md->type) {
+ case eModifierType_Fluidsim: {
+ FluidsimModifierData *fluidmd = reinterpret_cast<FluidsimModifierData *>(md);
+ if (fluidmd->fss) {
+ BKE_bpath_foreach_path_fixed_process(bpath_data, fluidmd->fss->surfdataPath);
+ }
+ break;
+ }
+ case eModifierType_Fluid: {
+ FluidModifierData *fmd = reinterpret_cast<FluidModifierData *>(md);
+ if (fmd->type & MOD_FLUID_TYPE_DOMAIN && fmd->domain) {
+ BKE_bpath_foreach_path_fixed_process(bpath_data, fmd->domain->cache_directory);
+ }
+ break;
+ }
+ case eModifierType_Cloth: {
+ ClothModifierData *clmd = reinterpret_cast<ClothModifierData *>(md);
+ object_foreach_path_pointcache(&clmd->ptcaches, bpath_data);
+ break;
+ }
+ case eModifierType_Ocean: {
+ OceanModifierData *omd = reinterpret_cast<OceanModifierData *>(md);
+ BKE_bpath_foreach_path_fixed_process(bpath_data, omd->cachepath);
+ break;
+ }
+ case eModifierType_MeshCache: {
+ MeshCacheModifierData *mcmd = reinterpret_cast<MeshCacheModifierData *>(md);
+ BKE_bpath_foreach_path_fixed_process(bpath_data, mcmd->filepath);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ if (ob->soft != nullptr) {
+ object_foreach_path_pointcache(&ob->soft->shared->ptcaches, bpath_data);
+ }
+
+ LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
+ object_foreach_path_pointcache(&psys->ptcaches, bpath_data);
+ }
+}
+
static void write_fmaps(BlendWriter *writer, ListBase *fbase)
{
LISTBASE_FOREACH (bFaceMap *, fmap, fbase) {
@@ -1266,6 +1327,7 @@ IDTypeInfo IDType_ID_OB = {
/* make_local */ object_make_local,
/* foreach_id */ object_foreach_id,
/* foreach_cache */ nullptr,
+ /* foreach_path */ object_foreach_path,
/* owner_get */ nullptr,
/* blend_write */ object_blend_write,