Depsgraph: Add utility functions to go from evaluated to original datablock

This commit is contained in:
2018-04-20 11:01:43 +02:00
parent bf63fee23e
commit 3b100c5a2a
2 changed files with 23 additions and 0 deletions

View File

@@ -85,6 +85,13 @@ struct Object *DEG_get_evaluated_object(const struct Depsgraph *depsgraph,
struct ID *DEG_get_evaluated_id(const struct Depsgraph *depsgraph,
struct ID *id);
/* Get original version of object for given evaluated one. */
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);
/* ************************ DEG iterators ********************* */
enum {

View File

@@ -166,3 +166,19 @@ ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
return id_node->id_cow;
}
Object *DEG_get_original_object(Object *object)
{
return (Object *)DEG_get_original_id(&object->id);
}
ID *DEG_get_original_id(ID *id)
{
if (id == NULL) {
return NULL;
}
if (id->orig_id == NULL) {
return id;
}
BLI_assert((id->tag & LIB_TAG_COPY_ON_WRITE) != 0);
return (ID *)id->orig_id;
}