diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-22 20:43:38 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-22 20:43:51 +0300 |
commit | 45f17e10ec5079ab94d6cf92aa5901c46f7c44aa (patch) | |
tree | d90aaa477616fbe6652d21496b0fdd7dbfa5cf9e /source/blender | |
parent | a958725f814ff6f223950e63a2b3fb8e40a3388c (diff) |
Fix redo with local orientation
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 95 |
1 files changed, 38 insertions, 57 deletions
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index a3fb09f3edf..68faddd2060 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -348,39 +348,6 @@ static void planeProjection(const TransInfo *t, const float in[3], float out[3]) add_v3_v3v3(out, in, vec); } -static void applyAxisConstraintVec_impl( - TransInfo *t, float space_mat[3][3], float proj_mat[3][3], const float in[3], float out[3]) -{ - mul_m3_v3(proj_mat, out); - - // With snap, a projection is alright, no need to correct for view alignment - if (!validSnap(t)) { - const int dims = getConstraintSpaceDimension(t); - if (dims == 2) { - if (!is_zero_v3(out)) { - if (!isPlaneProjectionViewAligned(t)) { - planeProjection(t, in, out); - } - } - } - else if (dims == 1) { - float c[3]; - - if (t->con.mode & CON_AXIS0) { - copy_v3_v3(c, space_mat[0]); - } - else if (t->con.mode & CON_AXIS1) { - copy_v3_v3(c, space_mat[1]); - } - else if (t->con.mode & CON_AXIS2) { - copy_v3_v3(c, space_mat[2]); - } - axisProjection(t, c, in, out); - } - } - postConstraintChecks(t, out); -} - /* * Generic callback for constant spatial constraints applied to linear motion * @@ -394,7 +361,34 @@ static void applyAxisConstraintVec( { copy_v3_v3(out, in); if (!td && t->con.mode & CON_APPLY) { - applyAxisConstraintVec_impl(t, t->spacemtx, t->con.pmtx, in, out); + mul_m3_v3(t->con.pmtx, out); + + // With snap, a projection is alright, no need to correct for view alignment + if (!validSnap(t)) { + const int dims = getConstraintSpaceDimension(t); + if (dims == 2) { + if (!is_zero_v3(out)) { + if (!isPlaneProjectionViewAligned(t)) { + planeProjection(t, in, out); + } + } + } + else if (dims == 1) { + float c[3]; + + if (t->con.mode & CON_AXIS0) { + copy_v3_v3(c, t->spacemtx[0]); + } + else if (t->con.mode & CON_AXIS1) { + copy_v3_v3(c, t->spacemtx[1]); + } + else if (t->con.mode & CON_AXIS2) { + copy_v3_v3(c, t->spacemtx[2]); + } + axisProjection(t, c, in, out); + } + } + postConstraintChecks(t, out); } } @@ -412,29 +406,16 @@ static void applyAxisConstraintVec( static void applyObjectConstraintVec( TransInfo *t, TransDataContainer *tc, TransData *td, const float in[3], float out[3]) { - copy_v3_v3(out, in); - if (t->con.mode & CON_APPLY) { - if (!td) { - /* No specific orientation. */ - float spacemtx[3][3], pmtx[3][3] = {{0.0f}}; - unit_m3(spacemtx); - if (!(t->con.mode & CON_AXIS0)) { - pmtx[0][0] = 1.0f; - } - if (!(t->con.mode & CON_AXIS1)) { - pmtx[1][1] = 1.0f; - } - if (!(t->con.mode & CON_AXIS2)) { - pmtx[2][2] = 1.0f; - } - applyAxisConstraintVec_impl(t, spacemtx, pmtx, in, out); - } - else { - /* Specific TransData's space, use axismtx. */ - mul_m3_v3(td->axismtx, out); - if (t->flag & T_EDIT) { - mul_m3_v3(tc->mat3_unit, out); - } + if (!td) { + applyAxisConstraintVec(t, tc, td, in, out); + } + else { + /* Specific TransData's space. */ + copy_v3_v3(out, in); + mul_m3_v3(t->spacemtx_inv, out); + mul_m3_v3(td->axismtx, out); + if (t->flag & T_EDIT) { + mul_m3_v3(tc->mat3_unit, out); } } } |