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.
This commit is contained in:
Bastien Montagne 2020-11-13 14:20:10 +01:00
parent 7e210e68ba
commit 50ccf346f0
Notes: blender-bot 2023-02-14 07:39:44 +01:00
Referenced by issue #82503, Add Support of PointCaches to Library Overrides
1 changed files with 37 additions and 3 deletions

View File

@ -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;