[Bf-blender-cvs] [597cafb873] render-layers: Fix context operator test
Dalai Felinto
noreply at git.blender.org
Wed Jan 18 11:59:43 CET 2017
Commit: 597cafb873867ba599e8a496fc8ebd5fdbe0e0be
Author: Dalai Felinto
Date: Wed Jan 18 11:56:28 2017 +0100
Branches: render-layers
https://developer.blender.org/rB597cafb873867ba599e8a496fc8ebd5fdbe0e0be
Fix context operator test
We needed a fallback for the cases where the layer was specified but not a scene_collection
===================================================================
M source/blender/blenkernel/intern/context.c
===================================================================
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 9beeeac628..592adfc578 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -912,12 +912,27 @@ SceneLayer *CTX_data_scene_layer(const bContext *C)
}
}
+/**
+ * This is tricky. Sometimes the user overrides the render_layer
+ * but not the scene_collection. In this case what to do?
+ *
+ * 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)
{
+ SceneLayer *sl = CTX_data_scene_layer(C);
SceneCollection *sc;
if (ctx_data_pointer_verify(C, "scene_collection", (void *)&sc)) {
- return sc;
+ if (BKE_scene_layer_has_collection(sl, sc)) {
+ return sc;
+ }
+ else {
+ /* fallback */
+ LayerCollection *lc = BKE_layer_collection_active(sl);
+ return lc->scene_collection;
+ }
}
else {
return C->data.scene_collection;
More information about the Bf-blender-cvs
mailing list