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-12-14 16:46:49 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-12-15 13:56:48 +0300
commit1f5106de610b115b87ab6121d7871d447ca48cd2 (patch)
treed929ef94556eac6063c24983cc6b89f52075701c /source/blender/editors/space_outliner/outliner_draw.c
parent7402b8ec74b4f74371d92816d22869ec9bd95da4 (diff)
Group collection viewport/render options and remove collection visibility
Users can change the group collection visibility in the outliner when looking at groups. Regular collections on the other hand don't have any special visibility control, if you need a collection to be invisible during render, either don't link it into the view layer used for F12, or disable it. This includes: * Updated unittests - update your lib/tests/layers folder. * Subversion bump - branches be aware of that. Note: Although we are using eval_ctx to determine the visibility of a group collection when rendering, the depsgraph is still using the same depsgraph for the viewport and the render engine, so at the moment the render visibility is ignored. Following next is a workaround for this separately to tag the groups before and after rendering to tackle that.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_draw.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c105
1 files changed, 44 insertions, 61 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index cecfc0cb71d..bc40067c2a8 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -247,49 +247,16 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
-static void enablebutton_collection_flag_cb(bContext *C, void *poin, void *poin2)
-{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- ID *id = poin;
- LayerCollection *layer_collection = poin2;
- ViewLayer *view_layer = BKE_view_layer_find_from_collection(id, layer_collection);
-
- /* TODO: This breaks when you see the collections of a group. (dfelinto) */
- if (view_layer == NULL) {
- WM_reportf(RPT_INFO, "Enable/disable of group collections disabled for now");
- return;
- }
-
- /* We need to toggle the flag since this is called after the flag is already set. */
- layer_collection->flag ^= COLLECTION_DISABLED;
-
- if (layer_collection->flag & COLLECTION_DISABLED) {
- BKE_collection_enable(view_layer, layer_collection);
- }
- else {
- BKE_collection_disable(view_layer, layer_collection);
- }
-
- DEG_relations_tag_update(bmain);
- /* TODO(sergey): Use proper flag for tagging here. */
- DEG_id_tag_update(&scene->id, 0);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
- WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
-}
-
static void restrictbutton_collection_flag_cb(bContext *C, void *poin, void *UNUSED(poin2))
{
ID *id = (ID *)poin;
- /* hide and deselect bases that are directly influenced by this LayerCollection */
/* TODO(sergey): Use proper flag for tagging here. */
DEG_id_tag_update(id, 0);
if (GS(id->name) == ID_SCE) {
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, id);
}
-
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
}
@@ -602,21 +569,6 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
UI_block_emboss_set(block, UI_EMBOSS_NONE);
- bt = uiDefIconButBitS(block, UI_BTYPE_BUT_TOGGLE, COLLECTION_DISABLED, 0,
- is_enabled ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
- (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), te->ys, UI_UNIT_X,
- UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
- TIP_("Enable/Disable collection from depsgraph"));
- UI_but_func_set(bt, enablebutton_collection_flag_cb, tselem->id, collection);
- UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
- bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_VISIBLE, 0, ICON_RESTRICT_VIEW_OFF,
- (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
- UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
- TIP_("Restrict/Allow 3D View visibility of objects in the collection"));
- UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
- UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
-
if (collection->scene_collection->type == COLLECTION_TYPE_NONE) {
bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_SELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
@@ -625,6 +577,31 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection);
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
}
+ else if ((soops->outlinevis == SO_GROUPS) &&
+ (collection->scene_collection->type == COLLECTION_TYPE_GROUP_INTERNAL))
+ {
+ bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_VIEWPORT, 0, ICON_RESTRICT_VIEW_OFF,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWPORTX), te->ys, UI_UNIT_X,
+ UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+ TIP_("Restrict/Allow 3D View selection of objects in the collection"));
+ UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
+ UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+
+ bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_RENDER, 0, ICON_RESTRICT_RENDER_OFF,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X,
+ UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+ TIP_("Restrict/Allow 3D View selection of objects in the collection"));
+ UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
+ UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+ }
+
+ bt = uiDefIconButBitS(block, UI_BTYPE_BUT_TOGGLE, COLLECTION_DISABLED, 0,
+ is_enabled ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), te->ys, UI_UNIT_X,
+ UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
+ TIP_("Enable/Disable collection"));
+ UI_but_func_set(bt, restrictbutton_collection_flag_cb, tselem->id, collection);
+ UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
UI_block_emboss_set(block, UI_EMBOSS);
}
@@ -1805,8 +1782,9 @@ static void outliner_draw_tree(
/* set scissor so tree elements or lines can't overlap restriction icons */
GLfloat scissor[4] = {0};
+ const bool is_group = (soops->outlinevis == SO_GROUPS);
if (has_restrict_icons) {
- int mask_x = BLI_rcti_size_x(&ar->v2d.mask) - (int)OL_TOGW + 1;
+ int mask_x = BLI_rcti_size_x(&ar->v2d.mask) - (int)(is_group ? OL_TOG_GROUPW : OL_TOGW) + 1;
CLAMP_MIN(mask_x, 0);
glGetFloatv(GL_SCISSOR_BOX, scissor);
@@ -1872,27 +1850,31 @@ static void outliner_back(ARegion *ar)
immUnbindProgram();
}
-static void outliner_draw_restrictcols(ARegion *ar)
+static void outliner_draw_restrictcols(ARegion *ar, SpaceOops *soops)
{
glLineWidth(1.0f);
+ const bool is_group = (soops->outlinevis == SO_GROUPS);
+
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
- immBegin(GWN_PRIM_LINES, 6);
+ immBegin(GWN_PRIM_LINES, is_group ? 6 : 4);
/* view */
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin);
-
- /* render */
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymin);
+ immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), (int)ar->v2d.cur.ymax);
+ immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_ENABLEX), (int)ar->v2d.cur.ymin);
/* render */
immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymax);
immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymin);
+ if (is_group) {
+ /* render */
+ immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWPORTX), (int)ar->v2d.cur.ymax);
+ immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWPORTX), (int)ar->v2d.cur.ymin);
+ }
+
immEnd();
immUnbindProgram();
}
@@ -1943,8 +1925,9 @@ void draw_outliner(const bContext *C)
/* constant offset for restriction columns */
// XXX this isn't that great yet...
- if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0)
- sizex += OL_TOGW * 3;
+ if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) {
+ sizex += OL_TOGW * ((soops->flag & SO_GROUPS) != 0 ? 3 : 2);
+ }
has_restrict_icons = !(soops->flag & SO_HIDE_RESTRICTCOLS);
}
@@ -1972,12 +1955,12 @@ void draw_outliner(const bContext *C)
}
else if ((soops->outlinevis == SO_ID_ORPHANS) && has_restrict_icons) {
/* draw user toggle columns */
- outliner_draw_restrictcols(ar);
+ outliner_draw_restrictcols(ar, soops);
outliner_draw_userbuts(block, ar, soops, &soops->tree);
}
else if (has_restrict_icons) {
/* draw restriction columns */
- outliner_draw_restrictcols(ar);
+ outliner_draw_restrictcols(ar, soops);
outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree);
}