Page MenuHome

T39862
ActivePublic

Authored by Bastien Montagne (mont29) on Apr 24 2014, 4:12 PM.
diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index f528fe8..997a47d 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -55,4 +55,7 @@ bool BKE_group_is_animated(struct Group *group, struct Object *parent);
void BKE_group_tag_recalc(struct Group *group);
void BKE_group_handle_recalc_and_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *parent, struct Group *group);
+bool BKE_group_restrict_flag_get(struct Group *gr, const int flag);
+void BKE_group_restrict_flag_set(struct Group *gr, const int flag, const bool val);
+
#endif /* __BKE_GROUP_H__ */
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index e84db7e..706af4e9 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -381,3 +381,44 @@ void BKE_group_handle_recalc_and_update(EvaluationContext *eval_ctx, Scene *scen
}
}
}
+
+bool BKE_group_restrict_flag_get(Group *gr, const int flag)
+{
+ GroupObject *gob;
+
+#if 1
+ for (gob = gr->gobject.first; gob; gob = gob->next) {
+ if ((gob->ob->restrictflag & flag) == 0)
+ return false;
+ }
+ return true;
+#else
+ /* weak but fast */
+ if ((gob = gr->gobject.first))
+ if ((gob->ob->restrictflag & flag) == 0)
+ return false;
+ return true;
+#endif
+}
+
+void BKE_group_restrict_flag_set(Group *gr, const int flag, const bool val)
+{
+ GroupObject *gob;
+
+ if (val) {
+ for (gob = gr->gobject.first; gob; gob = gob->next) {
+ if (gob->ob->id.lib)
+ continue;
+
+ gob->ob->restrictflag |= flag;
+ }
+ }
+ else {
+ for (gob = gr->gobject.first; gob; gob = gob->next) {
+ if (gob->ob->id.lib)
+ continue;
+
+ gob->ob->restrictflag &= ~flag;
+ }
+ }
+}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 4db63a4..2399f21 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -188,19 +188,12 @@ static void restrictbutton_recursive_child(bContext *C, Scene *scene, Object *ob
}
}
-static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_ob_view_cb(bContext *C, void *poin, void *poin2)
{
Scene *scene = (Scene *)poin;
Object *ob = (Object *)poin2;
-
- if (!common_restrict_check(C, ob)) return;
-
- /* deselect objects that are invisible */
- if (ob->restrictflag & OB_RESTRICT_VIEW) {
- /* Ouch! There is no backwards pointer from Object to Base,
- * so have to do loop to find it. */
- ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT);
- }
+
+ if (!common_restrict_check(scene, ob, NULL)) return;
if (CTX_wm_window(C)->eventstate->ctrl) {
restrictbutton_recursive_child(C, scene, ob, OB_RESTRICT_VIEW,
@@ -208,22 +201,14 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
}
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
-
}
-static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_ob_sel_cb(bContext *C, void *poin, void *poin2)
{
Scene *scene = (Scene *)poin;
Object *ob = (Object *)poin2;
-
- if (!common_restrict_check(C, ob)) return;
-
- /* if select restriction has just been turned on */
- if (ob->restrictflag & OB_RESTRICT_SELECT) {
- /* Ouch! There is no backwards pointer from Object to Base,
- * so have to do loop to find it. */
- ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT);
- }
+
+ if (!common_restrict_check(scene, ob, NULL)) return;
if (CTX_wm_window(C)->eventstate->ctrl) {
restrictbutton_recursive_child(C, scene, ob, OB_RESTRICT_SELECT,
@@ -231,19 +216,19 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
}
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
-
}
-static void restrictbutton_rend_cb(bContext *C, void *poin, void *poin2)
+static void restrictbutton_ob_rend_cb(bContext *C, void *poin, void *poin2)
{
+ Scene *scene = (Scene *)poin;
Object *ob = (Object *)poin2;
if (CTX_wm_window(C)->eventstate->ctrl) {
- restrictbutton_recursive_child(C, (Scene *)poin, ob, OB_RESTRICT_RENDER,
+ restrictbutton_recursive_child(C, scene, ob, OB_RESTRICT_RENDER,
(ob->restrictflag & OB_RESTRICT_RENDER) != 0, false);
}
- WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, poin);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene);
}
static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2))
@@ -317,25 +302,6 @@ static void restrictbutton_ebone_visibility_cb(bContext *C, void *UNUSED(poin),
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
}
-static int group_restrict_flag(Group *gr, int flag)
-{
- GroupObject *gob;
-
-#ifdef USE_GROUP_SELECT
- for (gob = gr->gobject.first; gob; gob = gob->next) {
- if ((gob->ob->restrictflag & flag) == 0)
- return 0;
- }
- return 1;
-#else
- /* weak but fast */
- if ((gob = gr->gobject.first))
- if ((gob->ob->restrictflag & flag) == 0)
- return 0;
- return 1;
-#endif
-}
-
static int group_select_flag(Group *gr)
{
GroupObject *gob;
@@ -355,56 +321,45 @@ static int group_select_flag(Group *gr)
#endif
}
-void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
+static void restrictbutton_gr_view_cb(bContext *C, void *poin, void *poin2)
{
Scene *scene = (Scene *)poin;
- GroupObject *gob;
Group *gr = (Group *)poin2;
+ GroupObject *gob;
- if (group_restrict_flag(gr, flag)) {
- for (gob = gr->gobject.first; gob; gob = gob->next) {
- if (gob->ob->id.lib)
- continue;
-
- gob->ob->restrictflag &= ~flag;
-
- if (flag == OB_RESTRICT_VIEW)
- if (gob->ob->flag & SELECT)
- ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT);
- }
- }
- else {
- for (gob = gr->gobject.first; gob; gob = gob->next) {
- if (gob->ob->id.lib)
- continue;
-
- /* not in editmode */
- if (scene->obedit != gob->ob) {
- gob->ob->restrictflag |= flag;
+ for (gob = gr->gobject.first; gob; gob = gob->next) {
+ if (gob->ob->id.lib)
+ continue;
- if (ELEM(flag, OB_RESTRICT_SELECT, OB_RESTRICT_VIEW)) {
- if ((gob->ob->flag & SELECT)) {
- ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT);
- }
- }
- }
- }
+ common_restrict_check(scene, gob->ob, NULL);
}
-}
-static void restrictbutton_gr_restrict_view(bContext *C, void *poin, void *poin2)
-{
- restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_VIEW);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_event_add_notifier(C, NC_GROUP, NULL);
}
-static void restrictbutton_gr_restrict_select(bContext *C, void *poin, void *poin2)
+
+static void restrictbutton_gr_sel_cb(bContext *C, void *poin, void *poin2)
{
- restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_SELECT);
+ Scene *scene = (Scene *)poin;
+ Group *gr = (Group *)poin2;
+ GroupObject *gob;
+
+ for (gob = gr->gobject.first; gob; gob = gob->next) {
+ if (gob->ob->id.lib)
+ continue;
+
+ common_restrict_check(scene, gob->ob, NULL);
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_event_add_notifier(C, NC_GROUP, NULL);
}
-static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poin2)
+
+static void restrictbutton_gr_rend_cb(bContext *C, void *poin, void *UNUSED(poin2))
{
- restrictbutton_gr_restrict_flag(poin, poin2, OB_RESTRICT_RENDER);
+ Scene *scene = (Scene *)poin;
+
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_event_add_notifier(C, NC_GROUP, NULL);
}
@@ -537,6 +492,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
Group *gr = NULL;
PropertyRNA *object_prop_hide, *object_prop_hide_select, *object_prop_hide_render;
+ PropertyRNA *grp_prop_hide, *grp_prop_hide_select, *grp_prop_hide_render;
/* get RNA properties (once) */
object_prop_hide = RNA_struct_type_find_property(&RNA_Object, "hide");
@@ -544,6 +500,10 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
object_prop_hide_render = RNA_struct_type_find_property(&RNA_Object, "hide_render");
BLI_assert(object_prop_hide && object_prop_hide_select && object_prop_hide_render);
+ grp_prop_hide = RNA_struct_type_find_property(&RNA_Group, "hide");
+ grp_prop_hide_select = RNA_struct_type_find_property(&RNA_Group, "hide_select");
+ grp_prop_hide_render = RNA_struct_type_find_property(&RNA_Group, "hide_render");
+ BLI_assert(grp_prop_hide && grp_prop_hide_select && grp_prop_hide_render);
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
@@ -560,56 +520,53 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y,
&ptr, object_prop_hide, -1, 0, 0, -1, -1,
TIP_("Restrict viewport visibility (Ctrl - Recursive)"));
- uiButSetFunc(bt, restrictbutton_view_cb, scene, ob);
+ uiButSetFunc(bt, restrictbutton_ob_view_cb, scene, ob);
uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y,
&ptr, object_prop_hide_select, -1, 0, 0, -1, -1,
TIP_("Restrict viewport selection (Ctrl - Recursive)"));
- uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob);
+ uiButSetFunc(bt, restrictbutton_ob_sel_cb, scene, ob);
uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y,
&ptr, object_prop_hide_render, -1, 0, 0, -1, -1,
TIP_("Restrict rendering (Ctrl - Recursive)"));
- uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob);
+ uiButSetFunc(bt, restrictbutton_ob_rend_cb, scene, ob);
uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
uiBlockSetEmboss(block, UI_EMBOSS);
}
if (tselem->type == 0 && te->idcode == ID_GR) {
- int restrict_bool;
- int but_flag = UI_BUT_DRAG_LOCK;
+ PointerRNA ptr;
+
gr = (Group *)tselem->id;
+ RNA_pointer_create((ID *)gr, &RNA_Group, gr, &ptr);
- if (gr->id.lib)
- but_flag |= UI_BUT_DISABLED;
-
uiBlockSetEmboss(block, UI_EMBOSSN);
+ bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y,
+ &ptr, grp_prop_hide, -1, 0, 0, -1, -1,
+ TIP_("Restrict viewport visibility"));
+ uiButSetFunc(bt, restrictbutton_gr_view_cb, scene, gr);
+ uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
+
+ bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y,
+ &ptr, grp_prop_hide_select, -1, 0, 0, -1, -1,
+ TIP_("Restrict viewport selection"));
+ uiButSetFunc(bt, restrictbutton_gr_sel_cb, scene, gr);
+ uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
- restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW);
- bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF,
- (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y,
- NULL, 0, 0, 0, 0, TIP_("Restrict/Allow visibility in the 3D View"));
- uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr);
- uiButSetFlag(bt, but_flag);
-
- restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT);
- bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF,
- (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y,
- NULL, 0, 0, 0, 0, TIP_("Restrict/Allow selection in the 3D View"));
- uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr);
- uiButSetFlag(bt, but_flag);
-
- restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER);
- bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF,
- (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y,
- NULL, 0, 0, 0, 0, TIP_("Restrict/Allow renderability"));
- uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr);
- uiButSetFlag(bt, but_flag);
+ bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF,
+ (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y,
+ &ptr, grp_prop_hide_render, -1, 0, 0, -1, -1,
+ TIP_("Restrict rendering"));
+ uiButSetFunc(bt, restrictbutton_gr_rend_cb, scene, gr);
+ uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
uiBlockSetEmboss(block, UI_EMBOSS);
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 17e1e03..39e932c 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -45,6 +45,7 @@
#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
+#include "BKE_group.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_report.h"
@@ -354,12 +355,12 @@ void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short set)
/* same check needed for both object operation and restrict column button func
* return 0 when in edit mode (cannot restrict view or select)
* otherwise return 1 */
-int common_restrict_check(bContext *C, Object *ob)
+bool common_restrict_check(Scene *scene, Object *ob, Base *base)
{
/* Don't allow hide an object in edit mode,
* check the bug #22153 and #21609, #23977
*/
- Object *obedit = CTX_data_edit_object(C);
+ Object *obedit = scene->obedit;
if (obedit && obedit == ob) {
/* found object is hidden, reset */
if (ob->restrictflag & OB_RESTRICT_VIEW)
@@ -370,35 +371,61 @@ int common_restrict_check(bContext *C, Object *ob)
return 0;
}
+ if (ob->restrictflag & (OB_RESTRICT_VIEW | OB_RESTRICT_SELECT)) {
+ if (!base) {
+ /* Ouch! There is no backwards pointer from Object to Base, so have to do loop to find it. */
+ base = BKE_scene_base_find(scene, ob);
+ }
+ ED_base_object_select(base, BA_DESELECT);
+ }
+
return 1;
}
/* =============================================== */
/* Restriction toggles */
+static void group_toggle_restrict_flag(Scene *scene, Group *gr, const int flag)
+{
+ GroupObject *gob;
+ const bool set = !BKE_group_restrict_flag_get(gr, flag);
+
+ for (gob = gr->gobject.first; gob; gob = gob->next) {
+ if (gob->ob->id.lib)
+ continue;
+
+ if (set) {
+ gob->ob->restrictflag |= flag;
+ }
+ else {
+ gob->ob->restrictflag &= ~flag;
+ }
+
+ if (flag & (OB_RESTRICT_VIEW | OB_RESTRICT_SELECT)) {
+ common_restrict_check(scene, gob->ob, NULL);
+ }
+ }
+}
+
/* Toggle Visibility ---------------------------------------- */
-void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te,
+void object_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
Base *base = (Base *)te->directdata;
Object *ob = (Object *)tselem->id;
-
- /* add check for edit mode */
- if (!common_restrict_check(C, ob)) return;
-
- if (base || (base = BKE_scene_base_find(scene, ob))) {
- if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) {
- ED_base_object_select(base, BA_DESELECT);
- }
- }
+
+ ob->restrictflag ^= OB_RESTRICT_VIEW;
+
+ /* add check for edit mode, and deselect if hidden/unselectable */
+ if (!common_restrict_check(scene, ob, base)) return;
}
void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
Group *group = (Group *)tselem->id;
- restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW);
+ group_toggle_restrict_flag(scene, group, OB_RESTRICT_VIEW);
}
static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op))
@@ -437,18 +464,19 @@ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
Base *base = (Base *)te->directdata;
-
- if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id);
- if (base) {
- base->object->restrictflag ^= OB_RESTRICT_SELECT;
- }
+ Object *ob = (Object *)tselem->id;
+
+ ob->restrictflag ^= OB_RESTRICT_SELECT;
+
+ /* add check for edit mode, and deselect if hidden/unselectable */
+ if (!common_restrict_check(scene, ob, base)) return;
}
void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
Group *group = (Group *)tselem->id;
- restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT);
+ group_toggle_restrict_flag(scene, group, OB_RESTRICT_SELECT);
}
static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op))
@@ -481,22 +509,19 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot)
/* Toggle Renderability ---------------------------------------- */
-void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
+void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
- Base *base = (Base *)te->directdata;
-
- if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id);
- if (base) {
- base->object->restrictflag ^= OB_RESTRICT_RENDER;
- }
+ Object *ob = (Object *)tselem->id;
+
+ ob->restrictflag ^= OB_RESTRICT_RENDER;
}
void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
Group *group = (Group *)tselem->id;
- restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER);
+ group_toggle_restrict_flag(scene, group, OB_RESTRICT_RENDER);
}
static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op))
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 317d33d..18d8940 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -174,7 +174,6 @@ void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct Space
/* outliner_draw.c ---------------------------------------------- */
void draw_outliner(const struct bContext *C);
-void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag);
/* outliner_select.c -------------------------------------------- */
eOLDrawState tree_element_type_active(
@@ -189,7 +188,7 @@ int outliner_item_do_activate(struct bContext *C, int x, int y, bool extend, boo
void outliner_do_object_operation(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb,
void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *));
-int common_restrict_check(struct bContext *C, struct Object *ob);
+bool common_restrict_check(struct Scene *scene, struct Object *ob, struct Base *base);
int outliner_has_one_flag(struct SpaceOops *soops, ListBase *lb, short flag, const int curlevel);
void outliner_set_flag(struct SpaceOops *soops, ListBase *lb, short flag, short set);
diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c
index 2f9c12c..001ea88 100644
--- a/source/blender/makesrna/intern/rna_group.c
+++ b/source/blender/makesrna/intern/rna_group.c
@@ -42,6 +42,7 @@
#include "DNA_object_types.h"
#include "BKE_group.h"
+#include "BKE_depsgraph.h"
#include "WM_api.h"
@@ -73,6 +74,47 @@ static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *repo
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id);
}
+static void rna_Group_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+ DAG_id_type_tag(bmain, ID_OB);
+}
+
+static int rna_Group_hide_get(PointerRNA *ptr)
+{
+ Group *gr = (Group *)ptr->data;
+ return BKE_group_restrict_flag_get(gr, OB_RESTRICT_VIEW);
+}
+
+static void rna_Group_hide_set(PointerRNA *ptr, const int value)
+{
+ Group *gr = (Group *)ptr->data;
+ BKE_group_restrict_flag_set(gr, OB_RESTRICT_VIEW, (bool)value);
+}
+
+static int rna_Group_hide_select_get(PointerRNA *ptr)
+{
+ Group *gr = (Group *)ptr->data;
+ return BKE_group_restrict_flag_get(gr, OB_RESTRICT_SELECT);
+}
+
+static void rna_Group_hide_select_set(PointerRNA *ptr, const int value)
+{
+ Group *gr = (Group *)ptr->data;
+ BKE_group_restrict_flag_set(gr, OB_RESTRICT_SELECT, (bool)value);
+}
+
+static int rna_Group_hide_render_get(PointerRNA *ptr)
+{
+ Group *gr = (Group *)ptr->data;
+ return BKE_group_restrict_flag_get(gr, OB_RESTRICT_RENDER);
+}
+
+static void rna_Group_hide_render_set(PointerRNA *ptr, const int value)
+{
+ Group *gr = (Group *)ptr->data;
+ BKE_group_restrict_flag_set(gr, OB_RESTRICT_RENDER, (bool)value);
+}
+
#else
/* group.objects */
@@ -118,6 +160,32 @@ void RNA_def_group(BlenderRNA *brna)
/* this is done on save/load in readfile.c, removed if no objects are in the group */
RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
+ /* restrict */
+ RNA_define_verify_sdna(false);
+
+ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
+ //RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
+ RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
+ RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, true);
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Group_hide_update");
+ RNA_def_property_boolean_funcs(prop, "rna_Group_hide_get", "rna_Group_hide_set");
+
+ prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
+ //RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
+ RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
+ RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, true);
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+ RNA_def_property_boolean_funcs(prop, "rna_Group_hide_select_get", "rna_Group_hide_select_set");
+
+ prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
+ //RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
+ RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
+ RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, true);
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Group_hide_update");
+ RNA_def_property_boolean_funcs(prop, "rna_Group_hide_render_get", "rna_Group_hide_render_set");
+
+ RNA_define_verify_sdna(true);
+
prop = RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "dupli_ofs");
RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the origin to use when instancing as DupliGroup");

Event Timeline

Bastien Montagne (mont29) changed the title of this paste from untitled to T39862.
Bastien Montagne (mont29) updated the paste's language from autodetect to diff.