forked from bartvdbraak/blender
Fix T84808: Individual projection works even when snap options don't affect the transform mode
Individual projection is a different branch of snap and always projects the transformed elements on the surface of objects. Perhaps this option should be limited to the Move mode due to similarity. But in order not to change the current behavior too much, this commit only disables this option in modes not affected by snap.
This commit is contained in:
parent
3584f1d224
commit
a1fb3dc7ae
@ -299,83 +299,93 @@ eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
|
||||
|
||||
void applyProject(TransInfo *t)
|
||||
{
|
||||
if (!t->tsnap.project) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (doForceIncrementSnap(t)) {
|
||||
return;
|
||||
}
|
||||
|
||||
float tvec[3];
|
||||
int i;
|
||||
|
||||
/* XXX FLICKER IN OBJECT MODE */
|
||||
if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) {
|
||||
float tvec[3];
|
||||
int i;
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
TransData *td = tc->data;
|
||||
for (i = 0; i < tc->data_len; i++, td++) {
|
||||
float iloc[3], loc[3], no[3];
|
||||
float mval_fl[2];
|
||||
if (td->flag & TD_SKIP) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
TransData *td = tc->data;
|
||||
for (i = 0; i < tc->data_len; i++, td++) {
|
||||
float iloc[3], loc[3], no[3];
|
||||
float mval_fl[2];
|
||||
if (td->flag & TD_SKIP) {
|
||||
continue;
|
||||
}
|
||||
if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) {
|
||||
continue;
|
||||
}
|
||||
copy_v3_v3(iloc, td->loc);
|
||||
if (tc->use_local_mat) {
|
||||
mul_m4_v3(tc->mat, iloc);
|
||||
}
|
||||
else if (t->flag & T_OBJECT) {
|
||||
BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob);
|
||||
copy_v3_v3(iloc, td->ob->obmat[3]);
|
||||
}
|
||||
|
||||
copy_v3_v3(iloc, td->loc);
|
||||
if (tc->use_local_mat) {
|
||||
mul_m4_v3(tc->mat, iloc);
|
||||
}
|
||||
else if (t->flag & T_OBJECT) {
|
||||
BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob);
|
||||
copy_v3_v3(iloc, td->ob->obmat[3]);
|
||||
}
|
||||
|
||||
if (ED_view3d_project_float_global(t->region, iloc, mval_fl, V3D_PROJ_TEST_NOP) ==
|
||||
V3D_PROJ_RET_OK) {
|
||||
if (ED_transform_snap_object_project_view3d(
|
||||
t->tsnap.object_context,
|
||||
t->depsgraph,
|
||||
SCE_SNAP_MODE_FACE,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = t->tsnap.modeSelect,
|
||||
.use_object_edit_cage = (t->flag & T_EDIT) != 0,
|
||||
.use_occlusion_test = false,
|
||||
.use_backface_culling = t->tsnap.use_backface_culling,
|
||||
},
|
||||
mval_fl,
|
||||
NULL,
|
||||
0,
|
||||
loc,
|
||||
no)) {
|
||||
if (ED_view3d_project_float_global(t->region, iloc, mval_fl, V3D_PROJ_TEST_NOP) ==
|
||||
V3D_PROJ_RET_OK) {
|
||||
if (ED_transform_snap_object_project_view3d(
|
||||
t->tsnap.object_context,
|
||||
t->depsgraph,
|
||||
SCE_SNAP_MODE_FACE,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = t->tsnap.modeSelect,
|
||||
.use_object_edit_cage = (t->flag & T_EDIT) != 0,
|
||||
.use_occlusion_test = false,
|
||||
.use_backface_culling = t->tsnap.use_backface_culling,
|
||||
},
|
||||
mval_fl,
|
||||
NULL,
|
||||
0,
|
||||
loc,
|
||||
no)) {
|
||||
#if 0
|
||||
if (tc->use_local_mat) {
|
||||
mul_m4_v3(tc->imat, loc);
|
||||
}
|
||||
#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)) {
|
||||
/* handle alignment as well */
|
||||
const float *original_normal;
|
||||
float mat[3][3];
|
||||
if (t->tsnap.align && (t->flag & T_OBJECT)) {
|
||||
/* handle alignment as well */
|
||||
const float *original_normal;
|
||||
float mat[3][3];
|
||||
|
||||
/* In pose mode, we want to align normals with Y axis of bones... */
|
||||
original_normal = td->axismtx[2];
|
||||
/* In pose mode, we want to align normals with Y axis of bones... */
|
||||
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? */
|
||||
constraintTransLim(t, td);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user