Page MenuHome
Paste P1132

Masterwork From Distant Lands
ActivePublic

Authored by Dalai Felinto (dfelinto) on Oct 8 2019, 5:04 PM.
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index d2c869532c8..19eb40debe6 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -115,6 +115,7 @@ void BKE_base_set_visible(struct Scene *scene,
struct Base *base,
bool extend);
bool BKE_base_is_visible(const struct View3D *v3d, const struct Base *base);
+bool BKE_object_is_visible_in_viewport(const struct View3D *v3d, const struct Object *ob);
void BKE_layer_collection_isolate_global(struct Scene *scene,
struct ViewLayer *view_layer,
struct LayerCollection *lc,
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 726ca9d705b..b915fddca18 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1059,6 +1059,33 @@ bool BKE_base_is_visible(const View3D *v3d, const Base *base)
return base->flag & BASE_VISIBLE_VIEWLAYER;
}
+bool BKE_object_is_visible_in_viewport(const struct View3D *v3d, const struct Object *ob)
+{
+ if (ob->restrictflag & OB_RESTRICT_VIEWPORT) {
+ return false;
+ }
+
+ if ((v3d->object_type_exclude_viewport & (1 << ob->type)) != 0) {
+ return false;
+ }
+
+ if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
+ return false;
+ }
+
+ if ((v3d->flag & V3D_LOCAL_COLLECTIONS) &&
+ ((v3d->local_collections_uuid & ob->runtime.local_collections_bits) == 0)) {
+ return false;
+ }
+
+ /* If not using local view or local collection the object may still be in a hidden collection. */
+ if (((v3d->localvd) == NULL) && ((v3d->flag & V3D_LOCAL_COLLECTIONS) == 0)) {
+ return (ob->base_flag & BASE_VISIBLE_VIEWLAYER) != 0;
+ }
+
+ return true;
+}
+
static void layer_collection_flag_set_recursive(LayerCollection *lc, const int flag)
{
lc->flag |= flag;
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 6366ed0bb6f..92acf466fa3 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1575,25 +1575,6 @@ void DRW_draw_view(const bContext *C)
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, C);
}
-static bool is_object_visible_in_viewport(View3D *v3d, Object *ob)
-{
- if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
- return false;
- }
-
- if ((v3d->flag & V3D_LOCAL_COLLECTIONS) &&
- ((v3d->local_collections_uuid & ob->runtime.local_collections_bits) == 0)) {
- return false;
- }
-
- /* If not using local view or local collection the object may still be in a hidden collection. */
- if (((v3d->localvd) == NULL) && ((v3d->flag & V3D_LOCAL_COLLECTIONS) == 0)) {
- return (ob->base_flag & BASE_VISIBLE_VIEWLAYER) != 0;
- }
-
- return true;
-}
-
/**
* Used for both regular and off-screen drawing.
* Need to reset DST before calling this function
@@ -1669,7 +1650,7 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph,
if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
continue;
}
- if (!is_object_visible_in_viewport(v3d, ob)) {
+ if (!BKE_object_is_visible_in_viewport(v3d, ob)) {
continue;
}
DST.dupli_parent = data_.dupli_parent;
@@ -2369,7 +2350,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
v3d->object_type_exclude_select);
bool filter_exclude = false;
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN (depsgraph, ob) {
- if (!is_object_visible_in_viewport(v3d, ob)) {
+ if (!BKE_object_is_visible_in_viewport(v3d, ob)) {
continue;
}
if ((ob->base_flag & BASE_SELECTABLE) &&
@@ -2519,7 +2500,7 @@ static void drw_draw_depth_loop_imp(struct Depsgraph *depsgraph,
if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
continue;
}
- if (!is_object_visible_in_viewport(v3d, ob)) {
+ if (!BKE_object_is_visible_in_viewport(v3d, ob)) {
continue;
}
DST.dupli_parent = data_.dupli_parent;
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index cc1f53eabde..05df2be26d7 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -51,6 +51,7 @@
#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_icons.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mask.h"
@@ -339,35 +340,43 @@ bool ED_operator_console_active(bContext *C)
return ed_spacetype_test(C, SPACE_CONSOLE);
}
-static bool ed_object_hidden(Object *ob)
+static bool ed_object_hidden(bContext *C, Object *ob)
{
/* if hidden but in edit mode, we still display, can happen with animation */
- return ((ob->restrictflag & OB_RESTRICT_VIEWPORT) && !(ob->mode & OB_MODE_EDIT));
+ if (ob->mode & OB_MODE_EDIT) {
+ return false;
+ }
+
+ /* We need evaluated object so we have the runtime data valid. */
+ Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+
+ return !BKE_object_is_visible_in_viewport(CTX_wm_view3d(C), ob_eval);
}
bool ED_operator_object_active(bContext *C)
{
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ed_object_hidden(ob));
+ return ((ob != NULL) && !ed_object_hidden(C, ob));
}
bool ED_operator_object_active_editable(bContext *C)
{
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob));
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(C, ob));
}
bool ED_operator_object_active_editable_mesh(bContext *C)
{
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_MESH) &&
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(C, ob) && (ob->type == OB_MESH) &&
!ID_IS_LINKED(ob->data));
}
bool ED_operator_object_active_editable_font(bContext *C)
{
Object *ob = ED_object_active_context(C);
- return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_FONT));
+ return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(C, ob) && (ob->type == OB_FONT));
}
bool ED_operator_editable_mesh(bContext *C)