diff options
author | Bastien Montagne <bastien@blender.org> | 2020-11-13 16:20:10 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-11-13 16:21:27 +0300 |
commit | 50ccf346f0b8bbf91811a88ba5f31a85dcab8467 (patch) | |
tree | ea685efe5f1c1a850988f600ea8c9452e87c0f6b /source/blender/editors | |
parent | 7e210e68ba9f79642cde6ebe07691a7f3169bb9e (diff) |
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/physics/physics_pointcache.c | 40 |
1 files changed, 37 insertions, 3 deletions
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; |