diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
5 files changed, 83 insertions, 49 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c index 0a3d20979a0..9766e8f7ff9 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_armature.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c @@ -129,19 +129,22 @@ static void gizmo_bbone_offset_set( static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - if (ob != NULL) { - const bArmature *arm = ob->data; - if (arm->drawtype == ARM_B_BONE) { - bPoseChannel *pchan = BKE_pose_channel_active(ob); - if (pchan && pchan->bone->segments > 1) { - View3D *v3d = CTX_wm_view3d(C); - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || - (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) - { - /* pass */ - } - else { + View3D *v3d = CTX_wm_view3d(C); + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) + { + return false; + } + + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BASACT(view_layer); + if (base && BASE_VISIBLE(v3d, base)) { + Object *ob = BKE_object_pose_armature_get(base->object); + if (ob) { + const bArmature *arm = ob->data; + if (arm->drawtype == ARM_B_BONE) { + bPoseChannel *pchan = BKE_pose_channel_active(ob); + if (pchan && pchan->bone->segments > 1) { return true; } } @@ -153,7 +156,8 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *gzgroup) { - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = BKE_object_pose_armature_get(OBACT(view_layer)); bPoseChannel *pchan = BKE_pose_channel_active(ob); const wmGizmoType *gzt_move = WM_gizmotype_find("GIZMO_GT_move_3d", true); @@ -183,7 +187,8 @@ static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *g static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = BKE_object_pose_armature_get(OBACT(view_layer)); if (!gzgroup->customdata) return; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index 3c29d4c407b..ace22094e53 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -70,12 +70,16 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED( return false; } - Object *ob = CTX_data_active_object(C); - if (ob && ob->type == OB_CAMERA) { - Camera *camera = ob->data; - /* TODO: support overrides. */ - if (camera->id.lib == NULL) { - return true; + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BASACT(view_layer); + if (base && BASE_VISIBLE(v3d, base)) { + Object *ob = base->object; + if (ob->type == OB_CAMERA) { + Camera *camera = ob->data; + /* TODO: support overrides. */ + if (camera->id.lib == NULL) { + return true; + } } } return false; @@ -83,7 +87,8 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED( static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup) { - Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); float dir[3]; const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); @@ -132,7 +137,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) return; struct CameraWidgetGroup *cagzgroup = gzgroup->customdata; - Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); Camera *ca = ob->data; PointerRNA camera_ptr; float dir[3]; @@ -234,7 +240,8 @@ static void WIDGETGROUP_camera_message_subscribe( const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { ARegion *ar = CTX_wm_region(C); - Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); Camera *ca = ob->data; wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c index df1ae8c82e9..695ffc1d7ef 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_empty.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c @@ -118,11 +118,14 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN return false; } - Object *ob = CTX_data_active_object(C); - - if (ob && ob->type == OB_EMPTY) { - if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - return BKE_object_empty_image_is_visible_in_view3d(ob, rv3d); + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BASACT(view_layer); + if (BASE_VISIBLE(v3d, base)) { + Object *ob = base->object; + if (ob->type == OB_EMPTY) { + if (ob->empty_drawtype == OB_EMPTY_IMAGE) { + return BKE_object_empty_image_is_visible_in_view3d(ob, rv3d); + } } } return false; @@ -147,8 +150,9 @@ static void WIDGETGROUP_empty_image_setup(const bContext *UNUSED(C), wmGizmoGrou static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *gzgroup) { struct EmptyImageWidgetGroup *igzgroup = gzgroup->customdata; - Object *ob = CTX_data_active_object(C); wmGizmo *gz = igzgroup->gizmo; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); copy_m4_m4(gz->matrix_basis, ob->obmat); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c index e2a8d2802e7..0e3d214ae3c 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.c @@ -62,9 +62,15 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNU return false; } - Object *ob = CTX_data_active_object(C); - - return (ob && ob->pd && ob->pd->forcefield); + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BASACT(view_layer); + if (base && BASE_VISIBLE(v3d, base)) { + Object *ob = base->object; + if (ob->pd && ob->pd->forcefield) { + return true; + } + } + return false; } static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) @@ -87,7 +93,8 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *gzgr { wmGizmoWrapper *wwrapper = gzgroup->customdata; wmGizmo *gz = wwrapper->gizmo; - Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); PartDeflect *pd = ob->pd; if (pd->forcefield == PFIELD_WIND) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c index b50f69950fb..88da7d0b4f4 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_lamp.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_lamp.c @@ -63,11 +63,14 @@ static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmGizmoGroupType *UNUS return false; } - Object *ob = CTX_data_active_object(C); - - if (ob && ob->type == OB_LAMP) { - Lamp *la = ob->data; - return (la->type == LA_SPOT); + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BASACT(view_layer); + if (base && BASE_VISIBLE(v3d, base)) { + Object *ob = base->object; + if (ob->type == OB_LAMP) { + Lamp *la = ob->data; + return (la->type == LA_SPOT); + } } return false; } @@ -91,7 +94,8 @@ static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmGizmoGroup *gzgro { wmGizmoWrapper *wwrapper = gzgroup->customdata; wmGizmo *gz = wwrapper->gizmo; - Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); Lamp *la = ob->data; float dir[3]; @@ -168,10 +172,14 @@ static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmGizmoGroupType *UNUS return false; } - Object *ob = CTX_data_active_object(C); - if (ob && ob->type == OB_LAMP) { - Lamp *la = ob->data; - return (la->type == LA_AREA); + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BASACT(view_layer); + if (base && BASE_VISIBLE(v3d, base)) { + Object *ob = base->object; + if (ob->type == OB_LAMP) { + Lamp *la = ob->data; + return (la->type == LA_AREA); + } } return false; } @@ -195,7 +203,8 @@ static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmGizmoGroup static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmGizmoGroup *gzgroup) { wmGizmoWrapper *wwrapper = gzgroup->customdata; - Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); Lamp *la = ob->data; wmGizmo *gz = wwrapper->gizmo; @@ -247,9 +256,10 @@ static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmGizmoGroupType *UN return false; } - Object *ob = CTX_data_active_object(C); - - if (ob != NULL) { + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BASACT(view_layer); + if (base && BASE_VISIBLE(v3d, base)) { + Object *ob = base->object; if (ob->type == OB_LAMP) { Lamp *la = ob->data; return (ELEM(la->type, LA_SUN, LA_SPOT, LA_AREA)); @@ -287,7 +297,8 @@ static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmGizmoGrou static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { wmGizmoWrapper *wwrapper = gzgroup->customdata; - Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); wmGizmo *gz = wwrapper->gizmo; copy_m4_m4(gz->matrix_basis, ob->obmat); |