Fix #106323: Snap to Face Nearest not working

Face Nearest only works with individual projection, so always set the
`SCE_SNAP_PROJECT` flag in this case.

Also gray out the `Project Individual Elements` option in the UI if
`Face Nearest` is enabled.

And change the description to indicate that `Project Individual Elements`
is always enabled with the `Face Nearest` option.

(I feel a better design for this option needs to be considered).
This commit is contained in:
Germano Cavalcante 2023-03-31 17:30:26 -03:00
parent f898c22349
commit 6778460e53
4 changed files with 20 additions and 10 deletions

View File

@ -7053,13 +7053,16 @@ class VIEW3D_PT_snapping(Panel):
col.prop(tool_settings, "use_snap_backface_culling")
if 'FACE' in snap_elements:
col.prop(tool_settings, "use_snap_project")
is_face_nearest_enabled = 'FACE_NEAREST' in snap_elements
if is_face_nearest_enabled or 'FACE' in snap_elements:
sub = col.column()
sub.active = not is_face_nearest_enabled
sub.prop(tool_settings, "use_snap_project")
if 'FACE_NEAREST' in snap_elements:
col.prop(tool_settings, "use_snap_to_same_target")
if object_mode == 'EDIT':
col.prop(tool_settings, "snap_face_nearest_steps")
if is_face_nearest_enabled:
col.prop(tool_settings, "use_snap_to_same_target")
if object_mode == 'EDIT':
col.prop(tool_settings, "snap_face_nearest_steps")
if 'VOLUME' in snap_elements:
col.prop(tool_settings, "use_snap_peel_object")

View File

@ -740,12 +740,18 @@ static void initSnappingMode(TransInfo *t)
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
}
if ((t->spacetype != SPACE_VIEW3D) || !(t->tsnap.mode & SCE_SNAP_MODE_FACE_RAYCAST) ||
(t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST) || (t->flag & T_NO_PROJECT)) {
if ((t->spacetype != SPACE_VIEW3D) ||
!(t->tsnap.mode & (SCE_SNAP_MODE_FACE_RAYCAST | SCE_SNAP_MODE_FACE_NEAREST)) ||
(t->flag & T_NO_PROJECT)) {
/* Force project off when not supported. */
t->tsnap.flag &= ~SCE_SNAP_PROJECT;
}
if (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST) {
/* This mode only works with individual projection. */
t->tsnap.flag |= SCE_SNAP_PROJECT;
}
setSnappingCallback(t);
if (t->spacetype == SPACE_VIEW3D) {

View File

@ -2307,7 +2307,7 @@ typedef enum eSnapMode {
/* Due to dependency conflicts with Cycles, header cannot directly include `BLI_utildefines.h`. */
/* TODO: move this macro to a more general place. */
#ifdef ENUM_OPERATORS
ENUM_OPERATORS(eSnapMode, SCE_SNAP_MODE_GRID)
ENUM_OPERATORS(eSnapMode, SCE_SNAP_MODE_FACE_NEAREST)
#endif
#define SCE_SNAP_MODE_GEOM \

View File

@ -3414,7 +3414,8 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT);
RNA_def_property_ui_text(prop,
"Project Individual Elements",
"Project individual elements on the surface of other objects");
"Project individual elements on the surface of other objects (Always "
"enabled with Face Nearest)");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
prop = RNA_def_property(srna, "use_snap_backface_culling", PROP_BOOLEAN, PROP_NONE);