Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-10-02 15:13:25 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-10-02 15:14:50 +0300
commitc71577d19542c629555631da65954c992c9c3f20 (patch)
treef472cdaf29ecd95cad7491c9cc6ae8b25131ac62 /source
parent038c7a7f1e0c4723f65d352751499c7d1da716e7 (diff)
RNA ID: add accessors to original ID, and a boolean stating whether it is evaluated or original data-block.
Since RNA depagraph API mostly returns evaluated data, it is mandatory to have access to original datablocks now...
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 0a294bfaab9..cc1c1bffff2 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -105,6 +105,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = {
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "WM_api.h"
@@ -167,6 +168,20 @@ static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info))
return PROP_EDITABLE;
}
+static int rna_ID_is_evaluated_get(PointerRNA *ptr)
+{
+ ID *id = (ID *)ptr->data;
+
+ return (DEG_get_original_id(id) != id);
+}
+
+static PointerRNA rna_ID_original_get(PointerRNA *ptr)
+{
+ ID *id = (ID *)ptr->data;
+
+ return rna_pointer_inherit_refine(ptr, &RNA_ID, DEG_get_original_id(id));
+}
+
short RNA_type_to_ID_code(const StructRNA *type)
{
const StructRNA *base_type = RNA_struct_base_child_of(type, &RNA_ID);
@@ -1137,6 +1152,19 @@ static void rna_def_ID(BlenderRNA *brna)
RNA_def_property_update(prop, NC_ID | NA_RENAME, NULL);
RNA_def_struct_name_property(srna, prop);
+ prop = RNA_def_property(srna, "is_evaluated", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Is Evaluated",
+ "Whether this ID is runtime-only, evaluated data-block, or actual data from .blend file");
+ RNA_def_property_boolean_funcs(prop, "rna_ID_is_evaluated_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "original", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_ui_text(prop, "Original ID",
+ "Actual data-block from .blend file (Main database) that generated that evaluated one");
+ RNA_def_property_pointer_funcs(prop, "rna_ID_original_get", NULL, NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP);
+
prop = RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "us");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);