Fix some inconsistencies in object visibility/selectability tests.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 3 Jan 2019 13:20:43 +0000 (14:20 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 3 Jan 2019 14:19:32 +0000 (15:19 +0100)
source/blender/editors/screen/screen_context.c
source/blender/editors/space_view3d/view3d_gizmo_armature.c
source/blender/editors/space_view3d/view3d_gizmo_camera.c
source/blender/editors/space_view3d/view3d_gizmo_empty.c
source/blender/editors/space_view3d/view3d_gizmo_forcefield.c
source/blender/editors/space_view3d/view3d_gizmo_lamp.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_object_api.c

index 15d9b3c5ccb1917491f643380755ba6f511ca9d6..d5683ae12678d65f8736042bc323a5765e9a6a41 100644 (file)
@@ -121,16 +121,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
        }
        else if (CTX_data_equals(member, "selectable_objects")) {
                for (Base *base = view_layer->object_bases.first; base; base = base->next) {
-                       if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
-                               continue;
-                       }
-                       if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
-                               continue;
-                       }
-                       if (v3d && ((v3d->object_type_exclude_select & (1 << base->object->type)) != 0)) {
-                               continue;
-                       }
-                       if (((base->flag & BASE_VISIBLE) != 0) && ((base->flag & BASE_SELECTABLE) != 0)) {
+                       if (BASE_SELECTABLE_BGMODE(v3d, base)) {
                                CTX_data_id_list_add(result, &base->object->id);
                        }
                }
@@ -180,16 +171,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
        }
        else if (CTX_data_equals(member, "selectable_bases")) {
                for (Base *base = view_layer->object_bases.first; base; base = base->next) {
-                       if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
-                               continue;
-                       }
-                       if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
-                               continue;
-                       }
-                       if (v3d && ((v3d->object_type_exclude_select & (1 << base->object->type)) != 0)) {
-                               continue;
-                       }
-                       if ((base->flag & BASE_VISIBLE) && (base->flag & BASE_SELECTABLE) != 0) {
+                       if (BASE_SELECTABLE_BGMODE(v3d, base)) {
                                CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                        }
                }
@@ -198,13 +180,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
        }
        else if (CTX_data_equals(member, "selected_bases")) {
                for (Base *base = view_layer->object_bases.first; base; base = base->next) {
-                       if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
-                               continue;
-                       }
-                       if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
-                               continue;
-                       }
-                       if ((base->flag & BASE_SELECTED) != 0) {
+                       if (BASE_VISIBLE_BGMODE(v3d, base) && (base->flag & BASE_SELECTED) != 0) {
                                CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                        }
                }
@@ -213,13 +189,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
        }
        else if (CTX_data_equals(member, "selected_editable_bases")) {
                for (Base *base = view_layer->object_bases.first; base; base = base->next) {
-                       if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
-                               continue;
-                       }
-                       if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
-                               continue;
-                       }
-                       if ((base->flag & BASE_SELECTED) != 0) {
+                       if (BASE_VISIBLE_BGMODE(v3d, base) && (base->flag & BASE_SELECTED) != 0) {
                                if (0 == BKE_object_is_libdata(base->object)) {
                                        CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                                }
@@ -231,13 +201,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
        else if (CTX_data_equals(member, "editable_bases")) {
                /* Visible + Editable, but not necessarily selected */
                for (Base *base = view_layer->object_bases.first; base; base = base->next) {
-                       if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
-                               continue;
-                       }
-                       if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
-                               continue;
-                       }
-                       if ((base->flag & BASE_VISIBLE) != 0) {
+                       if (BASE_VISIBLE_BGMODE(v3d, base)) {
                                if (0 == BKE_object_is_libdata(base->object)) {
                                        CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                                }
index b29ce64eba5c0e8908b9a8dded23dae69bb0652d..3d7e8065a9fd67292f1c19b56caca04dda7179ea 100644 (file)
@@ -138,7 +138,7 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType
 
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Base *base = BASACT(view_layer);
-       if (base && BASE_VISIBLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
+       if (base && BASE_SELECTABLE(v3d, base)) {
                Object *ob = BKE_object_pose_armature_get(base->object);
                if (ob) {
                        const bArmature *arm = ob->data;
index 472c95712239ce0fb52369065ae199b8433a1dd6..bf37f9c3b49639f5c9163f924299ade1d1af3e4b 100644 (file)
@@ -72,7 +72,7 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(
 
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Base *base = BASACT(view_layer);
-       if (base && BASE_VISIBLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
+       if (base && BASE_SELECTABLE(v3d, base)) {
                Object *ob = base->object;
                if (ob->type == OB_CAMERA) {
                        Camera *camera = ob->data;
index 24236ac2e6cae5f1a965290a7fb890c542f929bf..b0eb9993576427d5bab9984fcb4459584a7d3e4a 100644 (file)
@@ -120,7 +120,7 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN
 
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Base *base = BASACT(view_layer);
-       if (base && BASE_VISIBLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
+       if (base && BASE_SELECTABLE(v3d, base)) {
                Object *ob = base->object;
                if (ob->type == OB_EMPTY) {
                        if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
index 656836488ba60e2eda84456977b90600bc461dc7..b49a38085a1567e957ab14e2bfabbd000c7940c2 100644 (file)
@@ -64,7 +64,7 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNU
 
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Base *base = BASACT(view_layer);
-       if (base && BASE_VISIBLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
+       if (base && BASE_SELECTABLE(v3d, base)) {
                Object *ob = base->object;
                if (ob->pd && ob->pd->forcefield) {
                        return true;
index 0edc30597c4568efc87ecb03c91ea98d0adc1db0..a723dae058a90c036fd27a7530527d5689c9354a 100644 (file)
@@ -65,7 +65,7 @@ static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUS
 
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Base *base = BASACT(view_layer);
-       if (base && BASE_VISIBLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
+       if (base && BASE_SELECTABLE(v3d, base)) {
                Object *ob = base->object;
                if (ob->type == OB_LAMP) {
                        Lamp *la = ob->data;
@@ -174,7 +174,7 @@ static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUS
 
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Base *base = BASACT(view_layer);
-       if (base && BASE_VISIBLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
+       if (base && BASE_SELECTABLE(v3d, base)) {
                Object *ob = base->object;
                if (ob->type == OB_LAMP) {
                        Lamp *la = ob->data;
@@ -258,7 +258,7 @@ static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UN
 
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Base *base = BASACT(view_layer);
-       if (base && BASE_VISIBLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
+       if (base && BASE_SELECTABLE(v3d, base)) {
                Object *ob = base->object;
                if (ob->type == OB_LAMP) {
                        Lamp *la = ob->data;
index 5c9d9a74af301d1e632746c25c43c5905b500372..4b66ee622696f24839dbfb9c72d1e52e3ed3e54d 100644 (file)
@@ -1819,41 +1819,32 @@ extern const char *RE_engine_id_CYCLES;
 #define MINAFRAMEF     -1048574.0f
 
 /* deprecate this! */
-#define TESTBASE(v3d, base)  (                                                \
-       (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
-       (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
-       (((base)->flag & BASE_SELECTED) != 0) &&                                  \
+#define BASE_VISIBLE(v3d, base) (                                                                        \
+       (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) &&                  \
+       (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) &&                        \
        (((base)->flag & BASE_VISIBLE) != 0))
-#define TESTBASELIB(v3d, base)  (                                             \
-       (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
-       (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
-       (((base)->flag & BASE_SELECTED) != 0) &&                                  \
-       ((base)->object->id.lib == NULL) &&                                       \
-       (((base)->flag & BASE_VISIBLE) != 0))
-#define TESTBASELIB_BGMODE(v3d, base)  (                                      \
-       ((v3d == NULL) || ((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
-       ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0)) && \
-       (((base)->flag & BASE_SELECTED) != 0) &&                                  \
-       ((base)->object->id.lib == NULL) &&                                       \
-       (((base)->flag & BASE_VISIBLE) != 0))
-#define BASE_EDITABLE_BGMODE(v3d, base)  (                                    \
+#define BASE_VISIBLE_BGMODE(v3d, base) (                                                                 \
        ((v3d == NULL) || ((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
-       ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0)) && \
-       ((base)->object->id.lib == NULL) &&                                       \
+       ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0)) &&     \
        (((base)->flag & BASE_VISIBLE) != 0))
-#define BASE_SELECTABLE(v3d, base)  (                                         \
-       (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
-       (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
-       (((1 << (base)->object->type) & (v3d)->object_type_exclude_select) == 0) && \
+
+#define BASE_SELECTABLE(v3d, base) (                                                               \
+       BASE_VISIBLE(v3d, base) &&                                                                     \
+       (((1 << (base)->object->type) & (v3d)->object_type_exclude_select) == 0) &&                    \
        (((base)->flag & BASE_SELECTABLE) != 0))
-#define BASE_VISIBLE(v3d, base)  (                                            \
-       (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
-       (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
-       (((base)->flag & BASE_VISIBLE) != 0))
-#define BASE_VISIBLE_BGMODE(v3d, base) ( \
-       ((v3d == NULL) || ((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
-       ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0)) && \
-       (((base)->flag & BASE_VISIBLE) != 0))
+#define BASE_SELECTABLE_BGMODE(v3d, base) (                                                        \
+       BASE_VISIBLE_BGMODE(v3d, base) &&                                                              \
+       ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_select) == 0)) && \
+       (((base)->flag & BASE_SELECTABLE) != 0))
+
+#define TESTBASE(v3d, base) \
+       (BASE_VISIBLE(v3d, base) && (((base)->flag & BASE_SELECTED) != 0))
+#define TESTBASELIB(v3d, base) \
+       (TESTBASE(v3d, base) && ((base)->object->id.lib == NULL))
+#define BASE_EDITABLE_BGMODE(v3d, base) \
+       (BASE_VISIBLE_BGMODE(v3d, base) && ((base)->object->id.lib == NULL))
+#define TESTBASELIB_BGMODE(v3d, base) \
+       (BASE_EDITABLE_BGMODE(v3d, base) && (((base)->flag & BASE_SELECTED) != 0))
 
 #define FIRSTBASE(_view_layer)  ((_view_layer)->object_bases.first)
 #define LASTBASE(_view_layer)   ((_view_layer)->object_bases.last)
index 163d81d6041485d3f3abe07096b3fd0c16b17305..495643b1c7ab2fe77e4803a0fd78f73ffa758b16 100644 (file)
@@ -142,11 +142,7 @@ static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports)
                return false;
        }
 
-       if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
-               return false;
-       }
-
-       return ((base->flag & BASE_VISIBLE) != 0);
+       return BASE_VISIBLE_BGMODE(v3d, base);
 }
 
 static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *view_layer)