[Bf-blender-cvs] [3b100c5a2a7] blender2.8: Depsgraph: Add utility functions to go from evaluated to original datablock
Sergey Sharybin
noreply at git.blender.org
Fri Apr 20 11:02:31 CEST 2018
Commit: 3b100c5a2a78b196eb7fe6fb559c1e5ea0c47e66
Author: Sergey Sharybin
Date: Fri Apr 20 11:01:43 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB3b100c5a2a78b196eb7fe6fb559c1e5ea0c47e66
Depsgraph: Add utility functions to go from evaluated to original datablock
===================================================================
M source/blender/depsgraph/DEG_depsgraph_query.h
M source/blender/depsgraph/intern/depsgraph_query.cc
===================================================================
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 902a2ea3981..508714db218 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -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 {
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 3bffbf4d88e..63eb1f18281 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -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;
+}
More information about the Bf-blender-cvs
mailing list