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:
authorDalai Felinto <dfelinto@gmail.com>2017-01-30 20:07:14 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-01-30 20:21:07 +0300
commitf51c34185ed424a5e3ea0a2fa2f34f8ec9d678b2 (patch)
tree11b3ce948a1c732be17e3b47cebff7b75c7af1b0
parent3da834e83ce9d7056c033148dab04885a6d3b1b7 (diff)
bpy.context.layer_collection
-rw-r--r--source/blender/blenkernel/BKE_context.h2
-rw-r--r--source/blender/blenkernel/intern/context.c29
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_context.c12
4 files changed, 39 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 3f131050694..2fd11746fb0 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -40,6 +40,7 @@ extern "C" {
struct ARegion;
struct bScreen;
struct CacheFile;
+struct LayerCollection;
struct ListBase;
struct Main;
struct Object;
@@ -243,6 +244,7 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBas
struct Main *CTX_data_main(const bContext *C);
struct Scene *CTX_data_scene(const bContext *C);
+struct LayerCollection *CTX_data_layer_collection(const bContext *C);
struct SceneCollection *CTX_data_scene_collection(const bContext *C);
struct SceneLayer *CTX_data_scene_layer(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 85fa57f788b..f079ec8f7bd 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -928,20 +928,39 @@ SceneLayer *CTX_data_scene_layer(const bContext *C)
* If the scene_collection is linked to the SceneLayer we use it.
* Otherwise we fallback to the active one of the SceneLayer.
*/
-SceneCollection *CTX_data_scene_collection(const bContext *C)
+LayerCollection *CTX_data_layer_collection(const bContext *C)
{
SceneLayer *sl = CTX_data_scene_layer(C);
- SceneCollection *sc;
+ LayerCollection *lc;
+
+ if (ctx_data_pointer_verify(C, "layer_collection", (void *)&lc)) {
+ if (BKE_scene_layer_has_collection(sl, lc->scene_collection)) {
+ return lc;
+ }
+ }
+
+ /* fallback */
+ return BKE_layer_collection_active(sl);
+}
+SceneCollection *CTX_data_scene_collection(const bContext *C)
+{
+ SceneCollection *sc;
if (ctx_data_pointer_verify(C, "scene_collection", (void *)&sc)) {
- if (BKE_scene_layer_has_collection(sl, sc)) {
+ if (BKE_scene_layer_has_collection(CTX_data_scene_layer(C), sc)) {
return sc;
}
}
+ else {
+ LayerCollection *lc = CTX_data_layer_collection(C);
+ if (lc) {
+ return lc->scene_collection;
+ }
+ }
/* fallback */
- LayerCollection *lc = BKE_layer_collection_active(sl);
- return lc->scene_collection;
+ Scene *scene = CTX_data_scene(C);
+ return BKE_collection_master(scene);
}
int CTX_data_mode_enum(const bContext *C)
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 48e20e72528..c07287abd16 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -317,6 +317,7 @@ extern StructRNA RNA_LaplacianSmoothModifier;
extern StructRNA RNA_Lattice;
extern StructRNA RNA_LatticeModifier;
extern StructRNA RNA_LatticePoint;
+extern StructRNA RNA_LayerCollection;
extern StructRNA RNA_Library;
extern StructRNA RNA_LimitDistanceConstraint;
extern StructRNA RNA_LimitLocationConstraint;
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index 9270cda0d2b..27e88f592ab 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -120,6 +120,13 @@ static PointerRNA rna_Context_scene_collection_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_SceneCollection, CTX_data_scene_collection(C));
}
+static PointerRNA rna_Context_layer_collection_get(PointerRNA *ptr)
+{
+ bContext *C = (bContext *)ptr->data;
+ ptr->id.data = CTX_data_scene(C);
+ return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, CTX_data_layer_collection(C));
+}
+
static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
@@ -226,6 +233,11 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "SceneCollection");
RNA_def_property_pointer_funcs(prop, "rna_Context_scene_collection_get", NULL, NULL, NULL);
+ prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "LayerCollection");
+ RNA_def_property_pointer_funcs(prop, "rna_Context_layer_collection_get", NULL, NULL, NULL);
+
prop = RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "ToolSettings");