Layers: Separate between scene render layer (F12) and context render layer (everything else)

For now they are the same. However with workspaces they will be
different, and should be treated differently.
This commit is contained in:
Dalai Felinto
2017-02-15 18:37:59 +01:00
parent 883ef2c9ce
commit a428daada0
9 changed files with 24 additions and 81 deletions

View File

@@ -3146,74 +3146,6 @@ class VIEW3D_PT_viewport_debug(Panel):
col.row(align=True).prop(view, "debug_background", expand=True)
class VIEW3D_PT_collections_editor(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Collections"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.space_data
def draw(self, context):
layout = self.layout
layer = context.render_layer
active_collection = context.layer_collection
col = layout.column()
box = col.box()
index = -1
for collection in layer.collections:
index = self._draw_layer_collection(box, index, active_collection, collection, True, True)
row = layout.row(align=True)
row.operator("collections.collection_new", text="", icon='NEW')
row.operator("collections.override_new", text="", icon='LINK_AREA')
row.operator("collections.collection_link", text="", icon='LINKED')
row.operator("collections.collection_unlink", text="", icon='UNLINKED')
row.operator("collections.delete", text="", icon='X')
def _draw_layer_collection(self, box, index, active_collection, collection, is_active, is_draw, depth=0):
index += 1
nested_collections = collection.collections
if is_draw:
row = box.row()
row.active = is_active
is_collection_selected = (collection == active_collection)
if is_collection_selected:
sub_box = row.box()
row = sub_box.row()
row.label(text="{0}{1}{2}".format(
" " * depth,
u'\u21b3 ' if depth else "",
collection.name))
row.prop(collection, "hide", text="", emboss=False)
row.prop(collection, "hide_select", text="", emboss=False)
row.operator("collections.select", text="", icon='BLANK1' if is_collection_selected else 'HAND', emboss=False).collection_index=index
if nested_collections:
row.prop(collection, "is_unfolded", text="", emboss=False)
else:
row.label(icon='BLANK1')
if not collection.is_unfolded:
is_draw = False
is_active &= not collection.hide
for nested_collection in nested_collections:
index = self._draw_layer_collection(box, index, active_collection, nested_collection, is_active, is_draw, depth + 1)
return index
class VIEW3D_PT_grease_pencil(GreasePencilDataPanel, Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'

View File

@@ -54,7 +54,8 @@ struct Scene;
struct SceneCollection;
struct SceneLayer;
struct SceneLayer *BKE_scene_layer_active(struct Scene *scene);
struct SceneLayer *BKE_scene_layer_render_active(struct Scene *scene);
struct SceneLayer *BKE_scene_layer_context_active(struct Scene *scene);
struct SceneLayer *BKE_scene_layer_add(struct Scene *scene, const char *name);
bool BKE_scene_layer_remove(struct Main *bmain, struct Scene *scene, struct SceneLayer *sl);

View File

@@ -906,7 +906,7 @@ SceneLayer *CTX_data_scene_layer(const bContext *C)
return sl;
}
else {
return BKE_scene_layer_active(CTX_data_scene(C));
return BKE_scene_layer_context_active(CTX_data_scene(C));
}
}

View File

@@ -60,14 +60,26 @@ static void object_bases_Iterator_next(Iterator *iter, const int flag);
/**
* Returns the SceneLayer to be used for rendering
* Most of the time BKE_scene_layer_context_active should be used instead
*/
SceneLayer *BKE_scene_layer_active(struct Scene *scene)
SceneLayer *BKE_scene_layer_render_active(Scene *scene)
{
SceneLayer *sl = BLI_findlink(&scene->render_layers, scene->active_layer);
BLI_assert(sl);
return sl;
}
/**
* Returns the SceneLayer to be used for drawing, outliner, and
* other context related areas.
*/
SceneLayer *BKE_scene_layer_context_active(Scene *scene)
{
/* waiting for workspace to get the layer from context*/
TODO_LAYER_CONTEXT;
return BKE_scene_layer_render_active(scene);
}
/**
* Add a new renderlayer
* by default, a renderlayer has the master collection

View File

@@ -1704,8 +1704,7 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base)
/* first time looping, return the scenes first base */
/* for the first loop we should get the layer from context */
TODO_LAYER_CONTEXT;
SceneLayer *sl = BKE_scene_layer_active((*sce_iter));
SceneLayer *sl = BKE_scene_layer_context_active((*sce_iter));
if (sl->object_bases.first) {
return (Base *)sl->object_bases.first;
@@ -1717,7 +1716,7 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base)
next_set:
/* reached the end, get the next base in the set */
while ((*sce_iter = (*sce_iter)->set)) {
SceneLayer *sl = BKE_scene_layer_active((*sce_iter));
SceneLayer *sl = BKE_scene_layer_render_active((*sce_iter));
base = (Base *)sl->object_bases.first;
if (base) {

View File

@@ -653,7 +653,7 @@ void SCENE_OT_render_layer_add(wmOperatorType *ot)
static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = BKE_scene_layer_active(scene);
SceneLayer *sl = BKE_scene_layer_context_active(scene);
if (!BKE_scene_layer_remove(CTX_data_main(C), scene, sl)) {
return OPERATOR_CANCELLED;

View File

@@ -181,8 +181,8 @@ static int buttons_context_path_object(ButsContextPath *path)
/* if we have a scene, use the scene's active object */
else if (buttons_context_path_scene(path)) {
scene = path->ptr[path->len - 1].data;
TODO_LAYER_CONTEXT; /* use context, not active one */
SceneLayer *sl = BKE_scene_layer_active(scene);
SceneLayer *sl = BKE_scene_layer_context_active(scene);
ob = (sl->basact) ? sl->basact->object : NULL;
if (ob) {

View File

@@ -1849,7 +1849,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
outliner_add_orphaned_datablocks(mainvar, soops);
}
else if (soops->outlinevis == SO_COLLECTIONS) {
outliner_add_collections(soops, BLI_findlink(&scene->render_layers, scene->active_layer), scene);
outliner_add_collections(soops, BKE_scene_layer_context_active(scene), scene);
}
else {
ten = outliner_add_element(soops, &soops->tree, OBACT_NEW, NULL, 0, 0);

View File

@@ -1259,8 +1259,7 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover
short flag = v3d->flag;
float glalphaclip = U.glalphaclip;
int obcenter_dia = U.obcenter_dia;
TODO_LAYER_CONTEXT; /* we should pass context, really */
SceneLayer *sl = BKE_scene_layer_active(scene);
SceneLayer *sl = BKE_scene_layer_context_active(scene);
/* no need for color when drawing depth buffer */
const short dflag_depth = DRAW_CONSTCOLOR;
/* temp set drawtype to solid */
@@ -1548,7 +1547,7 @@ static void view3d_draw_objects(
const char **grid_unit,
const bool do_bgpic, const bool draw_offscreen, GPUFX *fx)
{
SceneLayer *sl = C ? CTX_data_scene_layer(C) : BKE_scene_layer_active(scene);
SceneLayer *sl = C ? CTX_data_scene_layer(C) : BKE_scene_layer_render_active(scene);
RegionView3D *rv3d = ar->regiondata;
Base *base;
const bool do_camera_frame = !draw_offscreen;