Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_snap.c
| Show First 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | static bool bm_face_is_snap_target(BMFace *f, void *UNUSED(user_data)) | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void initSnappingMode(TransInfo *t) | static void initSnappingMode(TransInfo *t) | ||||
| { | { | ||||
| ToolSettings *ts = t->settings; | ToolSettings *ts = t->settings; | ||||
| /* All obedit types will match. */ | /* All obedit types will match. */ | ||||
| const int obedit_type = t->data_container->obedit ? t->data_container->obedit->type : -1; | const int obedit_type = t->obedit_type; | ||||
| ViewLayer *view_layer = t->view_layer; | ViewLayer *view_layer = t->view_layer; | ||||
| Base *base_act = view_layer->basact; | Base *base_act = view_layer->basact; | ||||
| if (t->spacetype == SPACE_NODE) { | if (t->spacetype == SPACE_NODE) { | ||||
| /* force project off when not supported */ | /* force project off when not supported */ | ||||
| t->tsnap.project = 0; | t->tsnap.project = 0; | ||||
| t->tsnap.mode = ts->snap_node_mode; | t->tsnap.mode = ts->snap_node_mode; | ||||
| Show All 14 Lines | else { | ||||
| if ((t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) && (ts->snap_flag & SCE_SNAP_ABS_GRID) && | if ((t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) && (ts->snap_flag & SCE_SNAP_ABS_GRID) && | ||||
| (t->mode == TFM_TRANSLATION)) { | (t->mode == TFM_TRANSLATION)) { | ||||
| /* Special case in which snap to increments is transformed to snap to grid. */ | /* Special case in which snap to increments is transformed to snap to grid. */ | ||||
| t->tsnap.mode &= ~SCE_SNAP_MODE_INCREMENT; | t->tsnap.mode &= ~SCE_SNAP_MODE_INCREMENT; | ||||
| t->tsnap.mode |= SCE_SNAP_MODE_GRID; | t->tsnap.mode |= SCE_SNAP_MODE_GRID; | ||||
| } | } | ||||
| } | } | ||||
| if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && | if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE) && !(t->options & CTX_CAMERA)) { | ||||
| (t->options & CTX_CAMERA) == 0) { | |||||
| /* Only 3D view or UV. */ | /* Only 3D view or UV. */ | ||||
| /* Not with camera selected in camera view. */ | /* Not with camera selected in camera view. */ | ||||
| setSnappingCallback(t); | setSnappingCallback(t); | ||||
| if ((obedit_type != -1) && | if (t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR | CTX_OBMODE_XFORM_OBDATA)) { | ||||
| /* In "Edit Strokes" mode, | |||||
| * snap tool can perform snap to selected or active objects (see T49632) | |||||
| * TODO: perform self snap in gpencil_strokes. | |||||
| * | |||||
| * When we're moving the origins, allow snapping onto our own geometry (see T69132). */ | |||||
| t->tsnap.modeSelect = SNAP_ALL; | |||||
| } | |||||
| else if ((obedit_type != -1) && | |||||
| ELEM(obedit_type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) { | ELEM(obedit_type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) { | ||||
| /* Edit mode */ | /* Edit mode */ | ||||
| /* Temporary limited to edit mode meshes, armature, curves, metaballs. */ | /* Temporary limited to edit mode meshes, armature, curves, metaballs. */ | ||||
| if ((obedit_type == OB_MESH) && (t->flag & T_PROP_EDIT)) { | if ((obedit_type == OB_MESH) && (t->flag & T_PROP_EDIT)) { | ||||
| /* Exclude editmesh if using proportional edit */ | /* Exclude editmesh if using proportional edit */ | ||||
| t->tsnap.modeSelect = SNAP_NOT_ACTIVE; | t->tsnap.modeSelect = SNAP_NOT_ACTIVE; | ||||
| } | } | ||||
| else { | else { | ||||
| t->tsnap.modeSelect = t->tsnap.snap_self ? SNAP_ALL : SNAP_NOT_ACTIVE; | t->tsnap.modeSelect = t->tsnap.snap_self ? SNAP_ALL : SNAP_NOT_ACTIVE; | ||||
| } | } | ||||
| } | } | ||||
| else if ((obedit_type == -1) && base_act && base_act->object && | else if ((obedit_type == -1) && base_act && base_act->object && | ||||
| (base_act->object->mode & OB_MODE_PARTICLE_EDIT)) { | (base_act->object->mode & OB_MODE_PARTICLE_EDIT)) { | ||||
| /* Particles edit mode. */ | /* Particles edit mode. */ | ||||
| t->tsnap.modeSelect = SNAP_ALL; | t->tsnap.modeSelect = SNAP_ALL; | ||||
| } | } | ||||
| else if (obedit_type == -1) { | else if (obedit_type == -1) { | ||||
| /* Object mode */ | /* Object mode */ | ||||
| if (t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR | CTX_OBMODE_XFORM_OBDATA)) { | |||||
| /* In "Edit Strokes" mode, | |||||
| * snap tool can perform snap to selected or active objects (see T49632) | |||||
| * TODO: perform self snap in gpencil_strokes. | |||||
| * | |||||
| * When we're moving the origins, allow snapping onto our own geometry (see T69132). */ | |||||
| t->tsnap.modeSelect = SNAP_ALL; | |||||
| } | |||||
| else { | |||||
| t->tsnap.modeSelect = SNAP_NOT_SELECTED; | t->tsnap.modeSelect = SNAP_NOT_SELECTED; | ||||
| } | } | ||||
| } | |||||
| else { | else { | ||||
| /* Increment if snap is not possible */ | /* Increment if snap is not possible */ | ||||
| t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; | t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; | ||||
| } | } | ||||
| } | } | ||||
| else if (t->spacetype == SPACE_NODE) { | else if (t->spacetype == SPACE_NODE) { | ||||
| setSnappingCallback(t); | setSnappingCallback(t); | ||||
| t->tsnap.modeSelect = SNAP_NOT_SELECTED; | t->tsnap.modeSelect = SNAP_NOT_SELECTED; | ||||
| ▲ Show 20 Lines • Show All 985 Lines • Show Last 20 Lines | |||||