[Bf-blender-cvs] [cdd182d09d3] temp-lineart-contained: LibOverride: Adjust PointCache operators to properly handle overrides.
Bastien Montagne
noreply at git.blender.org
Sat Dec 19 06:18:53 CET 2020
Commit: cdd182d09d3a984518e554b3bd7ed243efd21eb0
Author: Bastien Montagne
Date: Fri Nov 13 14:20:10 2020 +0100
Branches: temp-lineart-contained
https://developer.blender.org/rBcdd182d09d3a984518e554b3bd7ed243efd21eb0
LibOverride: Adjust PointCache operators to properly handle overrides.
LibOverrides only support a small sub-set of PointCache features for now
(one cannot add new caches, baking in memory is not supported...).
Part of first step of T82503: support disk cache in liboverrides.
===================================================================
M source/blender/editors/physics/physics_pointcache.c
===================================================================
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index 4934a3d10cd..e827a3fbb2d 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -57,7 +57,41 @@ static bool ptcache_bake_all_poll(bContext *C)
static bool ptcache_poll(bContext *C)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- return (ptr.data && ptr.owner_id);
+
+ ID *id = ptr.owner_id;
+ PointCache *point_cache = ptr.data;
+
+ if (id == NULL || point_cache == NULL) {
+ return false;
+ }
+
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && (point_cache->flag & PTCACHE_DISK_CACHE) == false) {
+ return false;
+ }
+
+ if (ID_IS_LINKED(id) && (point_cache->flag & PTCACHE_DISK_CACHE) == false) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool ptcache_add_remove_poll(bContext *C)
+{
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
+
+ ID *id = ptr.owner_id;
+ PointCache *point_cache = ptr.data;
+
+ if (id == NULL || point_cache == NULL) {
+ return false;
+ }
+
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(id) || ID_IS_LINKED(id)) {
+ return false;
+ }
+
+ return true;
}
typedef struct PointCacheJob {
@@ -417,7 +451,7 @@ void PTCACHE_OT_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = ptcache_add_new_exec;
- ot->poll = ptcache_poll;
+ ot->poll = ptcache_add_remove_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -431,7 +465,7 @@ void PTCACHE_OT_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = ptcache_remove_exec;
- ot->poll = ptcache_poll;
+ ot->poll = ptcache_add_remove_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
More information about the Bf-blender-cvs
mailing list