[Bf-blender-cvs] [890e503] soc-2016-layer_manager: Add more layer visibility checks
Julian Eisel
noreply at git.blender.org
Thu Jul 14 17:06:46 CEST 2016
Commit: 890e503ec4c1087808fcdb74ecdcbc12b8ffe272
Author: Julian Eisel
Date: Thu Jul 14 16:59:26 2016 +0200
Branches: soc-2016-layer_manager
https://developer.blender.org/rB890e503ec4c1087808fcdb74ecdcbc12b8ffe272
Add more layer visibility checks
Also had to add Object.layer which is synced with Base.layer, a bit hacky though. Could clean this up, but ideally we'd get rid of Base struct completely (think this is doable).
===================================================================
M source/blender/blenkernel/intern/object_dupli.c
M source/blender/blenkernel/intern/scene.c
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/animation/anim_filter.c
M source/blender/editors/object/object_edit.c
M source/blender/editors/screen/screen_ops.c
M source/blender/editors/space_outliner/outliner_select.c
M source/blender/editors/space_outliner/outliner_tools.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/space_view3d/space_view3d.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/makesdna/DNA_object_types.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_object_api.c
M source/blender/render/intern/source/convertblender.c
===================================================================
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 90020b2..e57c066 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -310,7 +310,8 @@ static void make_duplis_group(const DupliContext *ctx)
/* check the group instance and object layers match, also that the object visible flags are ok. */
hide = (go->ob->lay & group->layer) == 0 ||
- (for_render ? go->ob->restrictflag & OB_RESTRICT_RENDER : go->ob->restrictflag & OB_RESTRICT_VIEW);
+ (for_render ? go->ob->restrictflag & OB_RESTRICT_RENDER : go->ob->restrictflag & OB_RESTRICT_VIEW) ||
+ !BKE_layeritem_is_visible(ob->layer);
make_dupli(ctx, go->ob, mat, id, animated, hide);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 51c4535..8928d26 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1137,6 +1137,9 @@ char *BKE_scene_find_last_marker_name(Scene *scene, int frame)
}
+/**
+ * Creates a base and assigns it to the active layer.
+ */
Base *BKE_scene_base_add(Scene *sce, Object *ob)
{
Base *b = MEM_callocN(sizeof(*b), __func__);
@@ -1144,6 +1147,7 @@ Base *BKE_scene_base_add(Scene *sce, Object *ob)
BLI_assert(sce->object_layers->active_layer != NULL); /* XXX quite easy to break currently */
BKE_objectlayer_base_assign(b, sce->object_layers->active_layer, false);
+ ob->layer = b->layer; /* XXX ugly to do this here, alternative would be to do this all over the place :/ */
b->object = ob;
b->flag = ob->flag;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bb91d4d..13a0d1d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5643,8 +5643,10 @@ static void lib_link_scene(FileData *fd, Main *main)
next = base->next;
base->object = newlibadr_us(fd, sce->id.lib, base->object);
-
- if (base->object == NULL) {
+ if (base->object) {
+ base->object->layer = base->layer;
+ }
+ else if (base->object == NULL) {
blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"),
sce->id.name + 2);
BLI_remlink(&sce->base, base);
@@ -9732,6 +9734,8 @@ static void give_base_to_objects(Main *mainvar, Scene *scene, View3D *v3d, Libra
base = MEM_callocN(sizeof(Base), __func__);
BLI_addtail(&scene->base, base);
+ BKE_objectlayer_base_assign(base, scene->object_layers->active_layer, false);
+ ob->layer = base->layer;
if (active_lay) {
ob->lay = active_lay;
}
@@ -9775,6 +9779,7 @@ static void give_base_to_groups(
base->object->flag = base->flag;
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
scene->basact = base;
+ ob->layer = base->layer;
/* assign the group */
ob->dup_group = group;
@@ -9866,6 +9871,7 @@ static void link_object_postprocess(ID *id, Scene *scene, View3D *v3d, const sho
if (flag & FILE_ACTIVELAY) {
ob->lay = BKE_screen_view3d_layer_active(v3d, scene);
BKE_objectlayer_base_assign(base, scene->object_layers->active_layer, false);
+ ob->layer = base->layer;
}
ob->mode = OB_MODE_OBJECT;
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 381987f..5f8687d 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -2754,6 +2754,8 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Scene *scene, Base *base
* try to add the channels)
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
+ if (!BKE_layeritem_is_visible(base->layer)) return false;
+
/* layer visibility - we check both object and base, since these may not be in sync yet */
if ((scene->lay & (ob->lay | base->lay)) == 0)
return false;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 3dc7d8e..8365771 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -69,6 +69,7 @@
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_lattice.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_material.h"
@@ -138,12 +139,12 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
Scene *scene = CTX_data_scene(C);
- Base *base;
bool changed = false;
/* XXX need a context loop to handle such cases */
- for (base = FIRSTBASE; base; base = base->next) {
- if ((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) {
+ BKE_BASES_ITER_VISIBLE_START(scene)
+ {
+ if ((base->lay & v3d->lay)) {
if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) {
base->flag |= SELECT;
}
@@ -152,6 +153,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op))
changed = true;
}
}
+ BKE_BASES_ITER_END;
if (changed) {
DAG_id_type_tag(bmain, ID_OB);
DAG_relations_tag_update(bmain);
@@ -625,8 +627,11 @@ static int editmode_toggle_poll(bContext *C)
return 0;
/* if hidden but in edit mode, we still display */
- if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT))
+ if (!(ob->mode & OB_MODE_EDIT) &&
+ ((ob->restrictflag & OB_RESTRICT_VIEW) || !BKE_layeritem_is_visible(ob->layer)))
+ {
return 0;
+ }
return OB_TYPE_SUPPORT_EDITMODE(ob->type);
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index a95d7d5..ca18b87 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -54,6 +54,7 @@
#include "BKE_customdata.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_layer.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@@ -333,7 +334,8 @@ int ED_operator_console_active(bContext *C)
static int ed_object_hidden(Object *ob)
{
/* if hidden but in edit mode, we still display, can happen with animation */
- return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT));
+ return (!(ob->mode & OB_MODE_EDIT) &&
+ ((ob->restrictflag & OB_RESTRICT_VIEW) || !BKE_layeritem_is_visible(ob->layer)));
}
int ED_operator_object_active(bContext *C)
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 21bee2c..f1019b6 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -45,6 +45,7 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
+#include "BKE_layer.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -148,14 +149,15 @@ static eOLDrawState tree_element_active_renderlayer(
*/
static void do_outliner_object_select_recursive(Scene *scene, Object *ob_parent, bool select)
{
- Base *base;
- for (base = FIRSTBASE; base; base = base->next) {
+ BKE_BASES_ITER_VISIBLE_START(scene)
+ {
Object *ob = base->object;
if ((((ob->restrictflag & OB_RESTRICT_VIEW) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) {
ED_base_object_select(base, select ? BA_SELECT : BA_DESELECT);
}
}
+ BKE_BASES_ITER_END;
}
static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent, bool select)
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index f3235d0..aef04c0 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -56,6 +56,7 @@
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_group.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_library_remap.h"
@@ -366,7 +367,7 @@ static void object_select_cb(
Base *base = (Base *)te->directdata;
if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id);
- if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0)) {
+ if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && BKE_layeritem_is_visible(base->layer)) {
base->flag |= SELECT;
base->object->flag |= SELECT;
}
@@ -524,13 +525,9 @@ static void group_linkobs2scene_cb(
base->flag |= SELECT;
}
else {
- /* link to scene */
- base = MEM_callocN(sizeof(Base), "add_base");
- BLI_addhead(&scene->base, base);
- base->lay = gob->ob->lay;
gob->ob->flag |= SELECT;
- base->flag = gob->ob->flag;
- base->object = gob->ob;
+ /* link to scene */
+ base = BKE_scene_base_add(scene, gob->ob);
id_lib_extern((ID *)gob->ob); /* in case these are from a linked group */
}
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 06d61b0..1d00085 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -63,6 +63,7 @@
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
+#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_material.h"
@@ -7472,7 +7473,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (ob != scene->obedit) {
if (ob->restrictflag & OB_RESTRICT_VIEW)
return;
-
+ /* XXX Checking this for every object is quite inefficient.
+ * Caller should check, but needs to be done carefully. */
+ if (!BKE_layeritem_is_visible(base->layer))
+ return;
+
if (render_override) {
if (ob->restrictflag & OB_RESTRICT_RENDER)
return;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index a42c4b2..e318b24 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list