Fix #109433: Snapping occluding objects even in wireframe mode

The internal `use_occlusion_test` option was only being removed if it
was in conjunction with the `Snap to Face` option.

Both test occlusion and Snap to Face are conflicting. In wireframe mode
the objects are not occluded, but Snap to Face can prevent them from
being snapped.

The solution is to prioritize snapping to other non-Face elements but
still allow "Snap to Face" in X-Ray mode.
This commit is contained in:
Germano Cavalcante
2023-06-28 10:34:43 -03:00
parent 128c95438f
commit fc0e110e60

View File

@@ -1213,14 +1213,7 @@ eSnapMode ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx,
{
eSnapMode retval = SCE_SNAP_TO_NONE;
bool use_occlusion_test = params->use_occlusion_test;
if (use_occlusion_test && XRAY_ENABLED(v3d)) {
if (snap_to_flag != SCE_SNAP_TO_FACE) {
/* In theory everything is visible in X-Ray except faces. */
snap_to_flag &= ~SCE_SNAP_TO_FACE;
use_occlusion_test = false;
}
}
bool use_occlusion_test = params->use_occlusion_test && !XRAY_ENABLED(v3d);
if (use_occlusion_test || (snap_to_flag & SCE_SNAP_TO_FACE)) {
if (!ED_view3d_win_to_ray_clipped_ex(depsgraph,
@@ -1290,7 +1283,7 @@ eSnapMode ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx,
}
}
if ((snap_to_flag & SCE_SNAP_TO_FACE) || sctx->runtime.params.use_occlusion_test) {
if (use_occlusion_test || (snap_to_flag & SCE_SNAP_TO_FACE)) {
has_hit = raycastObjects(sctx);
if (has_hit) {
@@ -1324,8 +1317,10 @@ eSnapMode ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx,
/* Remove what has already been computed. */
sctx->runtime.snap_to_flag &= ~(SCE_SNAP_TO_FACE | SCE_SNAP_INDIVIDUAL_NEAREST);
/* By convention we only snap to the original elements of a curve. */
if (has_hit && sctx->ret.ob->type != OB_CURVES_LEGACY) {
if (use_occlusion_test && has_hit &&
/* By convention we only snap to the original elements of a curve. */
sctx->ret.ob->type != OB_CURVES_LEGACY)
{
/* Compute the new clip_pane but do not add it yet. */
float new_clipplane[4];
BLI_ASSERT_UNIT_V3(sctx->ret.no);