From 98bfa8d4589cae47d0b7ae9ff576a9acca91ab88 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 13 Mar 2023 15:34:01 -0300 Subject: [PATCH] Fix 'use_occlusion_test' option not having effect on wireframe This is a non-recent regression that strangely went unreported. It is expected that when snapping, only visible elements are considered which does not include faces in wireframe mode. This works like this before, and this change doesn't appear to have been intentional. Ref #105664 --- .../editors/transform/transform_snap_object.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 7fa13180f67..c3405ffcfba 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -3200,7 +3200,7 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, - const eSnapMode snap_to_flag, + eSnapMode snap_to_flag, const SnapObjectParams *params, const float init_co[3], const float mval[2], @@ -3235,7 +3235,16 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont const RegionView3D *rv3d = static_cast(region->regiondata); - bool use_occlusion_test = params->use_occlusion_test && !XRAY_ENABLED(v3d); + if (snap_to_flag & (SCE_SNAP_MODE_FACE_RAYCAST | SCE_SNAP_MODE_FACE_NEAREST)) { + if (params->use_occlusion_test && XRAY_ENABLED(v3d)) { + /* Remove Snap to Face with Occlusion Test as they are not visible in wireframe mode. */ + snap_to_flag &= ~(SCE_SNAP_MODE_FACE_RAYCAST | SCE_SNAP_MODE_FACE_NEAREST); + } + else if (prev_co == nullptr || init_co == nullptr) { + /* No location to work with #SCE_SNAP_MODE_FACE_NEAREST. */ + snap_to_flag &= ~SCE_SNAP_MODE_FACE_NEAREST; + } + } /* NOTE: if both face ray-cast and face nearest are enabled, first find result of nearest, then * override with ray-cast. */ @@ -3261,7 +3270,7 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont } } - if (snap_to_flag & SCE_SNAP_MODE_FACE_RAYCAST || use_occlusion_test) { + if (snap_to_flag & SCE_SNAP_MODE_FACE_RAYCAST) { float ray_start[3], ray_normal[3]; if (!ED_view3d_win_to_ray_clipped_ex( depsgraph, region, v3d, mval, nullptr, ray_normal, ray_start, true)) {