Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_snap.c
| Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | #endif | ||||
| return status; | return status; | ||||
| } | } | ||||
| void applyProject(TransInfo *t) | void applyProject(TransInfo *t) | ||||
| { | { | ||||
| /* XXX FLICKER IN OBJECT MODE */ | /* XXX FLICKER IN OBJECT MODE */ | ||||
| if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) { | if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) { | ||||
| TransData *td = t->data; | |||||
| float tvec[3]; | float tvec[3]; | ||||
| float imat[4][4]; | |||||
| int i; | int i; | ||||
| FOREACH_TRANS_DATA_CONTAINER(t, tc) { | |||||
| TransData *td = tc->data; | |||||
| float imat[4][4]; | |||||
| if (t->flag & (T_EDIT | T_POSE)) { | if (t->flag & (T_EDIT | T_POSE)) { | ||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | Object *ob = tc->obedit ? tc->obedit : tc->poseobj; | ||||
| invert_m4_m4(imat, ob->obmat); | invert_m4_m4(imat, ob->obmat); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| float iloc[3], loc[3], no[3]; | float iloc[3], loc[3], no[3]; | ||||
| float mval_fl[2]; | float mval_fl[2]; | ||||
| float dist_px = TRANSFORM_DIST_MAX_PX; | float dist_px = TRANSFORM_DIST_MAX_PX; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) | if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) | ||||
| continue; | continue; | ||||
| copy_v3_v3(iloc, td->loc); | copy_v3_v3(iloc, td->loc); | ||||
| if (t->flag & (T_EDIT | T_POSE)) { | if (t->flag & (T_EDIT | T_POSE)) { | ||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | Object *ob = tc->obedit ? tc->obedit : tc->poseobj; | ||||
| mul_m4_v3(ob->obmat, iloc); | mul_m4_v3(ob->obmat, iloc); | ||||
| } | } | ||||
| else if (t->flag & T_OBJECT) { | else if (t->flag & T_OBJECT) { | ||||
| BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob); | BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob); | ||||
| copy_v3_v3(iloc, td->ob->obmat[3]); | copy_v3_v3(iloc, td->ob->obmat[3]); | ||||
| } | } | ||||
| if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { | if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { | ||||
| Show All 25 Lines | // } | ||||
| /* TODO support constraints for rotation too? see ElementRotation */ | /* TODO support constraints for rotation too? see ElementRotation */ | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| //XXX constraintTransLim(t, td); | //XXX constraintTransLim(t, td); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| } | } | ||||
| void applyGridAbsolute(TransInfo *t) | void applyGridAbsolute(TransInfo *t) | ||||
| { | { | ||||
| float grid_size = 0.0f; | float grid_size = 0.0f; | ||||
| GearsType grid_action; | GearsType grid_action; | ||||
| TransData *td; | |||||
| float (*obmat)[4] = NULL; | float (*obmat)[4] = NULL; | ||||
| bool use_obmat = false; | bool use_obmat = false; | ||||
| int i; | int i; | ||||
| if (!(activeSnap(t) && (ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID)))) | if (!(activeSnap(t) && (ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID)))) | ||||
| return; | return; | ||||
| grid_action = BIG_GEARS; | grid_action = BIG_GEARS; | ||||
| if (t->modifiers & MOD_PRECISION) | if (t->modifiers & MOD_PRECISION) | ||||
| grid_action = SMALL_GEARS; | grid_action = SMALL_GEARS; | ||||
| switch (grid_action) { | switch (grid_action) { | ||||
| case NO_GEARS: grid_size = t->snap_spatial[0]; break; | case NO_GEARS: grid_size = t->snap_spatial[0]; break; | ||||
| case BIG_GEARS: grid_size = t->snap_spatial[1]; break; | case BIG_GEARS: grid_size = t->snap_spatial[1]; break; | ||||
| case SMALL_GEARS: grid_size = t->snap_spatial[2]; break; | case SMALL_GEARS: grid_size = t->snap_spatial[2]; break; | ||||
| } | } | ||||
| /* early exit on unusable grid size */ | /* early exit on unusable grid size */ | ||||
| if (grid_size == 0.0f) | if (grid_size == 0.0f) | ||||
| return; | return; | ||||
| FOREACH_TRANS_DATA_CONTAINER(t, tc) { | |||||
| TransData *td; | |||||
| if (t->flag & (T_EDIT | T_POSE)) { | if (t->flag & (T_EDIT | T_POSE)) { | ||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | Object *ob = tc->obedit ? tc->obedit : tc->poseobj; | ||||
| obmat = ob->obmat; | obmat = ob->obmat; | ||||
| use_obmat = true; | use_obmat = true; | ||||
| } | } | ||||
| for (i = 0, td = t->data; i < t->total; i++, td++) { | for (i = 0, td = tc->data; i < tc->data_len; i++, td++) { | ||||
| float iloc[3], loc[3], tvec[3]; | float iloc[3], loc[3], tvec[3]; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| Show All 14 Lines | for (i = 0, td = tc->data; i < tc->data_len; i++, td++) { | ||||
| loc[1] = roundf(loc[1]); | loc[1] = roundf(loc[1]); | ||||
| loc[2] = roundf(loc[2]); | loc[2] = roundf(loc[2]); | ||||
| mul_v3_fl(loc, grid_size); | mul_v3_fl(loc, grid_size); | ||||
| sub_v3_v3v3(tvec, loc, iloc); | sub_v3_v3v3(tvec, loc, iloc); | ||||
| mul_m3_v3(td->smtx, tvec); | mul_m3_v3(td->smtx, tvec); | ||||
| add_v3_v3(td->loc, tvec); | add_v3_v3(td->loc, tvec); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| void applySnapping(TransInfo *t, float *vec) | void applySnapping(TransInfo *t, float *vec) | ||||
| { | { | ||||
| /* project is not applied this way */ | /* project is not applied this way */ | ||||
| if (t->tsnap.project) | if (t->tsnap.project) | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | static bool bm_face_is_snap_target(BMFace *f, void *UNUSED(user_data)) | ||||
| } while ((l_iter = l_iter->next) != l_first); | } while ((l_iter = l_iter->next) != l_first); | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void initSnappingMode(TransInfo *t) | static void initSnappingMode(TransInfo *t) | ||||
| { | { | ||||
| ToolSettings *ts = t->settings; | ToolSettings *ts = t->settings; | ||||
| Object *obedit = t->obedit; | /* All obedit types will match. */ | ||||
| const int obedit_type = t->data_container->obedit ? t->data_container->obedit->type : -1; | |||||
| 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 | static void initSnappingMode(TransInfo *t) | ||||
| if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && /* Only 3D view or UV */ | if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && /* Only 3D view or UV */ | ||||
| (t->flag & T_CAMERA) == 0) /* Not with camera selected in camera view */ | (t->flag & T_CAMERA) == 0) /* Not with camera selected in camera view */ | ||||
| { | { | ||||
| setSnappingCallback(t); | setSnappingCallback(t); | ||||
| /* Edit mode */ | /* Edit mode */ | ||||
| if (t->tsnap.applySnap != NULL && // A snapping function actually exist | if (t->tsnap.applySnap != NULL && // A snapping function actually exist | ||||
| (obedit != NULL && ELEM(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs | ((obedit_type != -1) && ELEM(obedit_type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs | ||||
| { | { | ||||
| /* Exclude editmesh if using proportional edit */ | /* Exclude editmesh if using proportional edit */ | ||||
| if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) { | if ((obedit_type == OB_MESH) && (t->flag & T_PROP_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; | ||||
| } | } | ||||
| } | } | ||||
| /* Particles edit mode*/ | /* Particles edit mode*/ | ||||
| else if (t->tsnap.applySnap != NULL && // A snapping function actually exist | else if (t->tsnap.applySnap != NULL && // A snapping function actually exist | ||||
| (obedit == NULL && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT)) | ((obedit_type == -1) && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT)) | ||||
| { | { | ||||
| t->tsnap.modeSelect = SNAP_ALL; | t->tsnap.modeSelect = SNAP_ALL; | ||||
| } | } | ||||
| /* Object mode */ | /* Object mode */ | ||||
| else if (t->tsnap.applySnap != NULL && // A snapping function actually exist | else if (t->tsnap.applySnap != NULL && // A snapping function actually exist | ||||
| (obedit == NULL) ) // Object Mode | (obedit_type == -1) ) // Object Mode | ||||
| { | { | ||||
| /* In "Edit Strokes" mode, Snap tool can perform snap to selected or active objects (see T49632) | /* In "Edit Strokes" mode, Snap tool can perform snap to selected or active objects (see T49632) | ||||
| * TODO: perform self snap in gpencil_strokes */ | * TODO: perform self snap in gpencil_strokes */ | ||||
| t->tsnap.modeSelect = ((t->options & CTX_GPENCIL_STROKES) != 0) ? SNAP_ALL : SNAP_NOT_SELECTED; | t->tsnap.modeSelect = ((t->options & CTX_GPENCIL_STROKES) != 0) ? SNAP_ALL : SNAP_NOT_SELECTED; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Grid if snap is not possible */ | /* Grid if snap is not possible */ | ||||
| t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; | t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; | ||||
| ▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | |||||
| /********************** DISTANCE **************************/ | /********************** DISTANCE **************************/ | ||||
| static float TranslationBetween(TransInfo *UNUSED(t), const float p1[3], const float p2[3]) | static float TranslationBetween(TransInfo *UNUSED(t), const float p1[3], const float p2[3]) | ||||
| { | { | ||||
| return len_squared_v3v3(p1, p2); | return len_squared_v3v3(p1, p2); | ||||
| } | } | ||||
| static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3]) | static float RotationBetween( | ||||
| TransInfo *t, const float p1[3], const float p2[3]) | |||||
| { | { | ||||
| float angle, start[3], end[3]; | float angle, start[3], end[3]; | ||||
| sub_v3_v3v3(start, p1, t->center_global); | sub_v3_v3v3(start, p1, t->center_global); | ||||
| sub_v3_v3v3(end, p2, t->center_global); | sub_v3_v3v3(end, p2, t->center_global); | ||||
| // Angle around a constraint axis (error prone, will need debug) | // Angle around a constraint axis (error prone, will need debug) | ||||
| if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { | if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { | ||||
| float axis[3], tmp[3]; | float axis[3], tmp[3]; | ||||
| t->con.applyRot(t, NULL, axis, NULL); | t->con.applyRot(t, NULL, NULL, axis, NULL); | ||||
| project_v3_v3v3(tmp, end, axis); | project_v3_v3v3(tmp, end, axis); | ||||
| sub_v3_v3v3(end, end, tmp); | sub_v3_v3v3(end, end, tmp); | ||||
| project_v3_v3v3(tmp, start, axis); | project_v3_v3v3(tmp, start, axis); | ||||
| sub_v3_v3v3(start, start, tmp); | sub_v3_v3v3(start, start, tmp); | ||||
| normalize_v3(end); | normalize_v3(end); | ||||
| ▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | if (found == true) { | ||||
| copy_v3_v3(t->tsnap.snapNormal, no); | copy_v3_v3(t->tsnap.snapNormal, no); | ||||
| t->tsnap.status |= POINT_INIT; | t->tsnap.status |= POINT_INIT; | ||||
| } | } | ||||
| else { | else { | ||||
| t->tsnap.status &= ~POINT_INIT; | t->tsnap.status &= ~POINT_INIT; | ||||
| } | } | ||||
| } | } | ||||
| else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type == OB_MESH) { | else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) { | ||||
| /* same as above but for UV's */ | /* same as above but for UV's */ | ||||
| Image *ima = ED_space_image(t->sa->spacedata.first); | Image *ima = ED_space_image(t->sa->spacedata.first); | ||||
| float co[2]; | float co[2]; | ||||
| UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]); | UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]); | ||||
| if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) { | if (ED_uvedit_nearest_uv(t->scene, TRANS_DATA_CONTAINER_FIRST_EVIL(t)->obedit, ima, co, t->tsnap.snapPoint)) { | ||||
| t->tsnap.snapPoint[0] *= t->aspect[0]; | t->tsnap.snapPoint[0] *= t->aspect[0]; | ||||
| t->tsnap.snapPoint[1] *= t->aspect[1]; | t->tsnap.snapPoint[1] *= t->aspect[1]; | ||||
| t->tsnap.status |= POINT_INIT; | t->tsnap.status |= POINT_INIT; | ||||
| } | } | ||||
| else { | else { | ||||
| t->tsnap.status &= ~POINT_INIT; | t->tsnap.status &= ~POINT_INIT; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | static void TargetSnapCenter(TransInfo *t) | ||||
| } | } | ||||
| } | } | ||||
| static void TargetSnapActive(TransInfo *t) | static void TargetSnapActive(TransInfo *t) | ||||
| { | { | ||||
| /* Only need to calculate once */ | /* Only need to calculate once */ | ||||
| if ((t->tsnap.status & TARGET_INIT) == 0) { | if ((t->tsnap.status & TARGET_INIT) == 0) { | ||||
| if (calculateCenterActive(t, true, t->tsnap.snapTarget)) { | if (calculateCenterActive(t, true, t->tsnap.snapTarget)) { | ||||
| if (t->flag & (T_EDIT | T_POSE)) { | |||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | |||||
| mul_m4_v3(ob->obmat, t->tsnap.snapTarget); | |||||
| } | |||||
| TargetSnapOffset(t, NULL); | TargetSnapOffset(t, NULL); | ||||
| t->tsnap.status |= TARGET_INIT; | t->tsnap.status |= TARGET_INIT; | ||||
| } | } | ||||
| /* No active, default to median */ | /* No active, default to median */ | ||||
| else { | else { | ||||
| t->tsnap.target = SCE_SNAP_TARGET_MEDIAN; | t->tsnap.target = SCE_SNAP_TARGET_MEDIAN; | ||||
| t->tsnap.targetSnap = TargetSnapMedian; | t->tsnap.targetSnap = TargetSnapMedian; | ||||
| TargetSnapMedian(t); | TargetSnapMedian(t); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void TargetSnapMedian(TransInfo *t) | static void TargetSnapMedian(TransInfo *t) | ||||
| { | { | ||||
| // Only need to calculate once | // Only need to calculate once | ||||
| if ((t->tsnap.status & TARGET_INIT) == 0) { | if ((t->tsnap.status & TARGET_INIT) == 0) { | ||||
| TransData *td = NULL; | int i_accum = 0; | ||||
| int i; | |||||
| t->tsnap.snapTarget[0] = 0; | t->tsnap.snapTarget[0] = 0; | ||||
| t->tsnap.snapTarget[1] = 0; | t->tsnap.snapTarget[1] = 0; | ||||
| t->tsnap.snapTarget[2] = 0; | t->tsnap.snapTarget[2] = 0; | ||||
| for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| Object *ob_xform = NULL; | |||||
| if (t->flag & (T_EDIT | T_POSE)) { | |||||
| ob_xform = tc->obedit ? tc->obedit : tc->poseobj; | |||||
| } | |||||
| TransData *td = tc->data; | |||||
| int i; | |||||
| for (i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) { | |||||
| /* TODO(campbell): perform the global transformation once per TransDataContainer */ | |||||
| if (ob_xform) { | |||||
| float v[3]; | |||||
| mul_v3_m4v3(v, ob_xform->obmat, td->center); | |||||
| add_v3_v3(t->tsnap.snapTarget, v); | |||||
| } | |||||
| else { | |||||
| add_v3_v3(t->tsnap.snapTarget, td->center); | add_v3_v3(t->tsnap.snapTarget, td->center); | ||||
| } | } | ||||
| mul_v3_fl(t->tsnap.snapTarget, 1.0 / i); | |||||
| if (t->flag & (T_EDIT | T_POSE)) { | |||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | |||||
| mul_m4_v3(ob->obmat, t->tsnap.snapTarget); | |||||
| } | } | ||||
| i_accum += i; | |||||
| } | |||||
| mul_v3_fl(t->tsnap.snapTarget, 1.0 / i_accum); | |||||
| TargetSnapOffset(t, NULL); | TargetSnapOffset(t, NULL); | ||||
| t->tsnap.status |= TARGET_INIT; | t->tsnap.status |= TARGET_INIT; | ||||
| } | } | ||||
| } | } | ||||
| static void TargetSnapClosest(TransInfo *t) | static void TargetSnapClosest(TransInfo *t) | ||||
| { | { | ||||
| // Only valid if a snap point has been selected | // Only valid if a snap point has been selected | ||||
| if (t->tsnap.status & POINT_INIT) { | if (t->tsnap.status & POINT_INIT) { | ||||
| float dist_closest = 0.0f; | float dist_closest = 0.0f; | ||||
| TransData *closest = NULL, *td = NULL; | TransData *closest = NULL; | ||||
| /* Object mode */ | /* Object mode */ | ||||
| if (t->flag & T_OBJECT) { | if (t->flag & T_OBJECT) { | ||||
| int i; | int i; | ||||
| for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER(t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (td = tc->data, i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) { | |||||
| struct BoundBox *bb = BKE_object_boundbox_get(td->ob); | struct BoundBox *bb = BKE_object_boundbox_get(td->ob); | ||||
| /* use boundbox if possible */ | /* use boundbox if possible */ | ||||
| if (bb) { | if (bb) { | ||||
| int j; | int j; | ||||
| for (j = 0; j < 8; j++) { | for (j = 0; j < 8; j++) { | ||||
| float loc[3]; | float loc[3]; | ||||
| Show All 25 Lines | if (t->flag & T_OBJECT) { | ||||
| if ((dist != TRANSFORM_DIST_INVALID) && | if ((dist != TRANSFORM_DIST_INVALID) && | ||||
| (closest == NULL || fabsf(dist) < fabsf(dist_closest))) | (closest == NULL || fabsf(dist) < fabsf(dist_closest))) | ||||
| { | { | ||||
| copy_v3_v3(t->tsnap.snapTarget, loc); | copy_v3_v3(t->tsnap.snapTarget, loc); | ||||
| closest = td; | closest = td; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| else { | else { | ||||
| FOREACH_TRANS_DATA_CONTAINER(t, tc) { | |||||
| TransData *td = tc->data; | |||||
| int i; | int i; | ||||
| for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { | for (i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) { | ||||
| float loc[3]; | float loc[3]; | ||||
| float dist; | float dist; | ||||
| copy_v3_v3(loc, td->center); | copy_v3_v3(loc, td->center); | ||||
| if (t->flag & (T_EDIT | T_POSE)) { | if (t->flag & (T_EDIT | T_POSE)) { | ||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | Object *ob = tc->obedit ? tc->obedit : tc->poseobj; | ||||
| mul_m4_v3(ob->obmat, loc); | mul_m4_v3(ob->obmat, loc); | ||||
| } | } | ||||
| dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint); | dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint); | ||||
| if ((dist != TRANSFORM_DIST_INVALID) && | if ((dist != TRANSFORM_DIST_INVALID) && | ||||
| (closest == NULL || fabsf(dist) < fabsf(dist_closest))) | (closest == NULL || fabsf(dist) < fabsf(dist_closest))) | ||||
| { | { | ||||
| copy_v3_v3(t->tsnap.snapTarget, loc); | copy_v3_v3(t->tsnap.snapTarget, loc); | ||||
| closest = td; | closest = td; | ||||
| dist_closest = dist; | dist_closest = dist; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| TargetSnapOffset(t, closest); | TargetSnapOffset(t, closest); | ||||
| t->tsnap.status |= TARGET_INIT; | t->tsnap.status |= TARGET_INIT; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines | |||||