[Bf-blender-cvs] [b073f58a8e9] master: Fix T96930: Cloth Disk cache not being saved and being deleted on files that have been linked and library override enabled.

Bastien Montagne noreply at git.blender.org
Fri Apr 1 12:45:44 CEST 2022


Commit: b073f58a8e96ab3224c67550672a051e61a718e8
Author: Bastien Montagne
Date:   Fri Apr 1 12:41:59 2022 +0200
Branches: master
https://developer.blender.org/rBb073f58a8e96ab3224c67550672a051e61a718e8

Fix T96930: Cloth Disk cache not being saved and being deleted on files that have been linked and library override enabled.

PointCache handing is just horrible from RNA, makes dealing with
overrides a nightmare...

Ended up having to add a specific 'apply' callback for the `use_disk_cache`
property, that would explicitely NOT call the the `update` callback of
this property, to avoid having the whole disk cache nuked away...

But the whole thing remains fairly britle, to say the least.

===================================================================

M	source/blender/makesrna/intern/rna_object_force.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index ca8c1876887..ce4b1a193a3 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -49,6 +49,8 @@ static const EnumPropertyItem effector_shape_items[] = {
 
 #  include "BLI_math_base.h"
 
+#  include "RNA_access.h"
+
 /* type specific return values only used from functions */
 static const EnumPropertyItem curve_shape_items[] = {
     {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
@@ -239,6 +241,33 @@ static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene
   }
 }
 
+bool rna_Cache_use_disk_cache_override_apply(Main *UNUSED(bmain),
+                                             PointerRNA *ptr_dst,
+                                             PointerRNA *ptr_src,
+                                             PointerRNA *UNUSED(ptr_storage),
+                                             PropertyRNA *prop_dst,
+                                             PropertyRNA *prop_src,
+                                             PropertyRNA *UNUSED(prop_storage),
+                                             const int UNUSED(len_dst),
+                                             const int UNUSED(len_src),
+                                             const int UNUSED(len_storage),
+                                             PointerRNA *UNUSED(ptr_item_dst),
+                                             PointerRNA *UNUSED(ptr_item_src),
+                                             PointerRNA *UNUSED(ptr_item_storage),
+                                             IDOverrideLibraryPropertyOperation *opop)
+{
+  BLI_assert(RNA_property_type(prop_dst) == PROP_BOOLEAN);
+  BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE);
+  UNUSED_VARS_NDEBUG(opop);
+
+  RNA_property_boolean_set(ptr_dst, prop_dst, RNA_property_boolean_get(ptr_src, prop_src));
+
+  /* DO NOT call `RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);`, that would trigger
+   * the whole 'update from mem point cache' process, ending up in the complete deletion of an
+   * existing diskcache if any. */
+  return true;
+}
+
 static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
   Object *ob = NULL;
@@ -983,6 +1012,7 @@ static void rna_def_pointcache_common(StructRNA *srna)
   RNA_def_property_ui_text(
       prop, "Disk Cache", "Save cache files to disk (.blend file must be saved first)");
   RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache");
+  RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Cache_use_disk_cache_override_apply");
 
   prop = RNA_def_property(srna, "is_outdated", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_OUTDATED);



More information about the Bf-blender-cvs mailing list