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:
authorJeroen Bakker <j.bakker@atmind.nl>2022-09-25 19:50:12 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2022-09-25 19:50:12 +0300
commit32b93a560e7888ec05fc554ee6d75552bf5dd4f0 (patch)
tree7d52ad44a69a742885bc19719b6a6cb2bb4f6980
parent0419ee871ff960f62e28a2a9fed764f66c616d71 (diff)
[WIP] Potential fix for T101272.temp-T101272
Not working yet, it seems to call the correct function, but the viewlayer doesn't contain the collection. Pushed to continue tomorrow.
-rw-r--r--source/blender/makesrna/intern/rna_layer.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index ae0366bebad..9deda08a75a 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -369,6 +369,41 @@ static bool rna_LayerCollection_has_selected_objects(LayerCollection *lc,
return false;
}
+static bool rna_LayerCollection_children_lookupint(struct PointerRNA *ptr,
+ int key,
+ struct PointerRNA *r_ptr)
+{
+ Scene *scene = (Scene *)ptr->owner_id;
+ LayerCollection *lc = (LayerCollection *)ptr->data;
+ ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
+ BKE_view_layer_synced_ensure(scene, view_layer);
+
+ LayerCollection *child = BLI_findlink(&lc->layer_collections, key);
+ if (!child) {
+ return false;
+ }
+ RNA_pointer_create(ptr->owner_id, &RNA_LayerCollection, child, r_ptr);
+ return true;
+}
+
+static bool rna_LayerCollection_children_lookupstring(struct PointerRNA *ptr,
+ const char *key,
+ struct PointerRNA *r_ptr)
+{
+ Scene *scene = (Scene *)ptr->owner_id;
+ LayerCollection *lc = (LayerCollection *)ptr->data;
+ ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc);
+ BKE_view_layer_synced_ensure(scene, view_layer);
+
+ LISTBASE_FOREACH (LayerCollection *, child, &lc->layer_collections) {
+ if (STREQ(child->collection->id.name, key)) {
+ RNA_pointer_create(ptr->owner_id, &RNA_LayerCollection, child, r_ptr);
+ return true;
+ }
+ }
+ return false;
+}
+
#else
static void rna_def_layer_collection(BlenderRNA *brna)
@@ -399,6 +434,15 @@ static void rna_def_layer_collection(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL);
RNA_def_property_struct_type(prop, "LayerCollection");
RNA_def_property_ui_text(prop, "Children", "Child layer collections");
+ RNA_def_property_collection_funcs(prop,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "rna_LayerCollection_children_lookupint",
+ "rna_LayerCollection_children_lookupstring",
+ NULL);
/* Restriction flags. */
prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE);