forked from bartvdbraak/blender
Depsgraph: Add queries whether ID is original/evaluated
This commit is contained in:
parent
f51521148f
commit
b679887bd5
@ -100,6 +100,19 @@ struct Object *DEG_get_original_object(struct Object *object);
|
||||
/* Get original version of given evaluated ID datablock. */
|
||||
struct ID *DEG_get_original_id(struct ID *id);
|
||||
|
||||
/* Check whether given ID is an original,
|
||||
*
|
||||
* Original IDs are considered all the IDs which are not covered by copy-on-write system and are
|
||||
* not out-of-main localized datablocks. */
|
||||
bool DEG_is_original_id(struct ID *id);
|
||||
bool DEG_is_original_object(struct Object *object);
|
||||
|
||||
/* Opposite of the above.
|
||||
*
|
||||
* If the datablock is not original it must be evaluated, and vice versa. */
|
||||
bool DEG_is_evaluated_id(struct ID *id);
|
||||
bool DEG_is_evaluated_object(struct Object *object);
|
||||
|
||||
/* ************************ DEG object iterators ********************* */
|
||||
|
||||
enum {
|
||||
|
@ -263,3 +263,43 @@ ID *DEG_get_original_id(ID *id)
|
||||
BLI_assert((id->tag & LIB_TAG_COPIED_ON_WRITE) != 0);
|
||||
return (ID *)id->orig_id;
|
||||
}
|
||||
|
||||
bool DEG_is_original_id(ID *id)
|
||||
{
|
||||
/* Some explanation of the logic.
|
||||
*
|
||||
* What we want here is to be able to tell whether given ID is a result of dependency graph
|
||||
* evaluation or not.
|
||||
*
|
||||
* All the datablocks which are created by copy-on-write mechanism will have will be tagged with
|
||||
* LIB_TAG_COPIED_ON_WRITE tag. Those datablocks can not be original.
|
||||
*
|
||||
* Modifier stack evaluation might create special datablocks which have all the modifiers
|
||||
* applied, and those will be tagged with LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT. Such datablocks
|
||||
* can not be original as well.
|
||||
*
|
||||
* Localization is usually happening from evaluated datablock, or will have some special pointer
|
||||
* magic which will make them to act as evaluated.
|
||||
*
|
||||
* NOTE: We conder ID evaluated if ANY of those flags is set. We do NOT require ALL of them. */
|
||||
if (id->tag &
|
||||
(LIB_TAG_COPIED_ON_WRITE | LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT | LIB_TAG_LOCALIZED)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DEG_is_original_object(Object *object)
|
||||
{
|
||||
return DEG_is_original_id(&object->id);
|
||||
}
|
||||
|
||||
bool DEG_is_evaluated_id(ID *id)
|
||||
{
|
||||
return !DEG_is_original_id(id);
|
||||
}
|
||||
|
||||
bool DEG_is_evaluated_object(Object *object)
|
||||
{
|
||||
return !DEG_is_original_object(object);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user