Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_snap.c
| Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | if (event->type == MOUSEMOVE) { | ||||
| status |= updateSelectedSnapPoint(t); | status |= updateSelectedSnapPoint(t); | ||||
| } | } | ||||
| return status; | return status; | ||||
| } | } | ||||
| void applyProject(TransInfo *t) | void applyProject(TransInfo *t) | ||||
| { | { | ||||
| /* XXX FLICKER IN OBJECT MODE */ | if (!t->tsnap.project) { | ||||
| if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) { | return; | ||||
| } | |||||
| if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) { | |||||
| return; | |||||
| } | |||||
| if (doForceIncrementSnap(t)) { | |||||
| return; | |||||
| } | |||||
| float tvec[3]; | float tvec[3]; | ||||
| int i; | int i; | ||||
| /* XXX FLICKER IN OBJECT MODE */ | |||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; 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]; | ||||
| 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 (tc->use_local_mat) { | if (tc->use_local_mat) { | ||||
| mul_m4_v3(tc->mat, iloc); | mul_m4_v3(tc->mat, iloc); | ||||
| } | } | ||||
| else if (t->flag & T_OBJECT) { | else if (t->flag & T_OBJECT) { | ||||
| BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob); | BKE_object_eval_transform_all(t->depsgraph, 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->region, iloc, mval_fl, V3D_PROJ_TEST_NOP) == | if (ED_view3d_project_float_global(t->region, iloc, mval_fl, V3D_PROJ_TEST_NOP) == | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| if (ED_transform_snap_object_project_view3d( | if (ED_transform_snap_object_project_view3d( | ||||
| t->tsnap.object_context, | t->tsnap.object_context, | ||||
| t->depsgraph, | t->depsgraph, | ||||
| SCE_SNAP_MODE_FACE, | SCE_SNAP_MODE_FACE, | ||||
| &(const struct SnapObjectParams){ | &(const struct SnapObjectParams){ | ||||
| .snap_select = t->tsnap.modeSelect, | .snap_select = t->tsnap.modeSelect, | ||||
| .use_object_edit_cage = (t->flag & T_EDIT) != 0, | .use_object_edit_cage = (t->flag & T_EDIT) != 0, | ||||
| .use_occlusion_test = false, | .use_occlusion_test = false, | ||||
| .use_backface_culling = t->tsnap.use_backface_culling, | .use_backface_culling = t->tsnap.use_backface_culling, | ||||
| }, | }, | ||||
| mval_fl, | mval_fl, | ||||
| NULL, | NULL, | ||||
| 0, | 0, | ||||
| loc, | loc, | ||||
| no)) { | no)) { | ||||
| #if 0 | #if 0 | ||||
| if (tc->use_local_mat) { | if (tc->use_local_mat) { | ||||
| mul_m4_v3(tc->imat, loc); | mul_m4_v3(tc->imat, loc); | ||||
| } | } | ||||
| #endif | #endif | ||||
| 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); | ||||
| if (t->tsnap.align && (t->flag & T_OBJECT)) { | if (t->tsnap.align && (t->flag & T_OBJECT)) { | ||||
| /* handle alignment as well */ | /* handle alignment as well */ | ||||
| const float *original_normal; | const float *original_normal; | ||||
| float mat[3][3]; | float mat[3][3]; | ||||
| /* In pose mode, we want to align normals with Y axis of bones... */ | /* In pose mode, we want to align normals with Y axis of bones... */ | ||||
| original_normal = td->axismtx[2]; | original_normal = td->axismtx[2]; | ||||
| rotation_between_vecs_to_mat3(mat, original_normal, no); | rotation_between_vecs_to_mat3(mat, original_normal, no); | ||||
| transform_data_ext_rotate(td, mat, true); | transform_data_ext_rotate(td, mat, true); | ||||
| /* TODO support constraints for rotation too? see ElementRotation */ | /* TODO support constraints for rotation too? see ElementRotation */ | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #if 0 /* TODO: sipport this? */ | #if 0 /* TODO: sipport this? */ | ||||
| constraintTransLim(t, td); | constraintTransLim(t, td); | ||||
| #endif | #endif | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| void applyGridAbsolute(TransInfo *t) | void applyGridAbsolute(TransInfo *t) | ||||
| { | { | ||||
| int i; | int i; | ||||
| if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) { | if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,199 Lines • Show Last 20 Lines | |||||