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
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-06-30 12:55:11 +0300
committerBastien Montagne <bastien@blender.org>2020-06-30 13:19:11 +0300
commit24c4d3f1f727c84509c6f2f8db6ba915b2699b94 (patch)
tree16d47793a3a1993a9ee8c50921a402bd5b79d608 /source/blender/makesrna/intern/rna_access_compare_override.c
parent7556530bac39189915d8936fa7158e2bfbcaf342 (diff)
LibOverride: Add necessary bits in RNA to deal with embedded IDs paths.
Note that this code is rather rough and slightly hacky, a proper solution needs to be designed at some point probably, but for now this should work fine. As usual, master collections and root node trees remain TODO for now.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access_compare_override.c')
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c74
1 files changed, 62 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index f7ce296bbc4..8cd8f80b7c8 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -24,6 +24,7 @@
#include "DNA_ID.h"
#include "DNA_constraint_types.h"
+#include "DNA_key_types.h"
#include "DNA_modifier_types.h"
#include "BLI_listbase.h"
@@ -1076,18 +1077,70 @@ void RNA_struct_override_apply(Main *bmain,
#endif
}
-IDOverrideLibraryProperty *RNA_property_override_property_find(PointerRNA *ptr, PropertyRNA *prop)
+static char *rna_property_override_property_real_id_owner(PointerRNA *ptr,
+ PropertyRNA *prop,
+ ID **r_id)
{
ID *id = ptr->owner_id;
+ ID *owner_id = id;
+ const char *rna_path_prefix = NULL;
- if (!id || !id->override_library) {
+ *r_id = NULL;
+
+ if (id == NULL) {
+ return NULL;
+ }
+
+ if (id->flag & (LIB_EMBEDDED_DATA | LIB_EMBEDDED_DATA_LIB_OVERRIDE)) {
+ /* XXX this is very bad band-aid code, but for now it will do.
+ * We should at least use a #define for those prop names.
+ * Ideally RNA as a whole should be aware of those PITA of embedded IDs, and have a way to
+ * retrieve their owner IDs and generate paths from those.
+ */
+
+ switch (GS(id->name)) {
+ case ID_KE:
+ owner_id = ((Key *)id)->from;
+ rna_path_prefix = "shape_keys.";
+ break;
+ case ID_GR:
+ /* Master collection, TODO. */
+ break;
+ case ID_NT:
+ /* Root node trees, TODO. */
+ break;
+ default:
+ BLI_assert(0);
+ }
+ }
+
+ if (!ID_IS_OVERRIDE_LIBRARY_REAL(owner_id)) {
return NULL;
}
char *rna_path = RNA_path_from_ID_to_property(ptr, prop);
if (rna_path) {
- IDOverrideLibraryProperty *op = BKE_lib_override_library_property_find(id->override_library,
- rna_path);
+ char *rna_path_full = rna_path;
+ if (rna_path_prefix != NULL) {
+ rna_path_full = BLI_sprintfN("%s%s", rna_path_prefix, rna_path);
+ MEM_freeN(rna_path);
+ }
+
+ *r_id = owner_id;
+ return rna_path_full;
+ }
+ return NULL;
+}
+
+IDOverrideLibraryProperty *RNA_property_override_property_find(PointerRNA *ptr,
+ PropertyRNA *prop,
+ ID **r_owner_id)
+{
+ char *rna_path;
+
+ if ((rna_path = rna_property_override_property_real_id_owner(ptr, prop, r_owner_id)) != NULL) {
+ IDOverrideLibraryProperty *op = BKE_lib_override_library_property_find(
+ (*r_owner_id)->override_library, rna_path);
MEM_freeN(rna_path);
return op;
}
@@ -1098,14 +1151,10 @@ IDOverrideLibraryProperty *RNA_property_override_property_get(PointerRNA *ptr,
PropertyRNA *prop,
bool *r_created)
{
- ID *id = ptr->owner_id;
+ ID *id;
+ char *rna_path;
- if (!id || !id->override_library) {
- return NULL;
- }
-
- char *rna_path = RNA_path_from_ID_to_property(ptr, prop);
- if (rna_path) {
+ if ((rna_path = rna_property_override_property_real_id_owner(ptr, prop, &id)) != NULL) {
IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
id->override_library, rna_path, r_created);
MEM_freeN(rna_path);
@@ -1117,7 +1166,8 @@ IDOverrideLibraryProperty *RNA_property_override_property_get(PointerRNA *ptr,
IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_find(
PointerRNA *ptr, PropertyRNA *prop, const int index, const bool strict, bool *r_strict)
{
- IDOverrideLibraryProperty *op = RNA_property_override_property_find(ptr, prop);
+ ID *owner_id;
+ IDOverrideLibraryProperty *op = RNA_property_override_property_find(ptr, prop, &owner_id);
if (!op) {
return NULL;