Merge branch 'master' into sculpt-dev

This commit is contained in:
Pablo Dobarro 2021-01-30 18:15:24 +01:00
commit 5fb15545c1
6 changed files with 41 additions and 60 deletions

View File

@ -104,9 +104,8 @@ static bool add_reroute_intersect_check(bNodeLink *link,
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
for (int i = 0; i < tot - 1; i++) {
for (int b = 0; b < NODE_LINK_RESOL; b++) {
if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) {
result[0] = (mcoords[i][0] + mcoords[i + 1][0]) / 2.0f;
result[1] = (mcoords[i][1] + mcoords[i + 1][1]) / 2.0f;
if (isect_seg_seg_v2_point(
mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1], result) > 0) {
return true;
}
}

View File

@ -538,6 +538,36 @@ static void applyObjectConstraintSize(TransInfo *t,
}
}
static void constraints_rotation_imp(TransInfo *t,
float axismtx[3][3],
float r_vec[3],
float *r_angle)
{
BLI_assert(t->con.mode & CON_APPLY);
int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
switch (mode) {
case CON_AXIS0:
case (CON_AXIS1 | CON_AXIS2):
negate_v3_v3(r_vec, t->spacemtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0 | CON_AXIS2):
negate_v3_v3(r_vec, t->spacemtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0 | CON_AXIS1):
negate_v3_v3(r_vec, t->spacemtx[2]);
break;
}
/* don't flip axis if asked to or if num input */
if (r_angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
if (dot_v3v3(r_vec, t->viewinv[2]) > 0.0f) {
*r_angle = -(*r_angle);
}
}
}
/*
* Generic callback for constant spatial constraints applied to rotations
*
@ -551,33 +581,11 @@ static void applyObjectConstraintSize(TransInfo *t,
* This insures that the rotation is always logically following the mouse.
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
*/
static void applyAxisConstraintRot(
TransInfo *t, TransDataContainer *UNUSED(tc), TransData *td, float vec[3], float *angle)
{
if (!td && t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
switch (mode) {
case CON_AXIS0:
case (CON_AXIS1 | CON_AXIS2):
copy_v3_v3(vec, t->spacemtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0 | CON_AXIS2):
copy_v3_v3(vec, t->spacemtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0 | CON_AXIS1):
copy_v3_v3(vec, t->spacemtx[2]);
break;
}
/* don't flip axis if asked to or if num input */
if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
if (dot_v3v3(vec, t->viewinv[2]) > 0.0f) {
*angle = -(*angle);
}
}
constraints_rotation_imp(t, t->spacemtx, vec, angle);
}
}
@ -594,12 +602,10 @@ static void applyAxisConstraintRot(
* This insures that the rotation is always logically following the mouse.
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
*/
static void applyObjectConstraintRot(
TransInfo *t, TransDataContainer *tc, TransData *td, float vec[3], float *angle)
{
if (t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
float tmp_axismtx[3][3];
float(*axismtx)[3];
@ -618,25 +624,7 @@ static void applyObjectConstraintRot(
axismtx = td->axismtx;
}
switch (mode) {
case CON_AXIS0:
case (CON_AXIS1 | CON_AXIS2):
copy_v3_v3(vec, axismtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0 | CON_AXIS2):
copy_v3_v3(vec, axismtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0 | CON_AXIS1):
copy_v3_v3(vec, axismtx[2]);
break;
}
if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
if (dot_v3v3(vec, t->viewinv[2]) > 0.0f) {
*angle = -(*angle);
}
}
constraints_rotation_imp(t, axismtx, vec, angle);
}
}

View File

@ -1322,21 +1322,21 @@ void drawDial3d(const TransInfo *t)
if (tc->mode & CON_APPLY) {
if (tc->mode & CON_AXIS0) {
axis_idx = MAN_AXIS_ROT_X;
negate_v3_v3(mat_basis[2], t->spacemtx[0]);
copy_v3_v3(mat_basis[2], t->spacemtx[0]);
}
else if (tc->mode & CON_AXIS1) {
axis_idx = MAN_AXIS_ROT_Y;
negate_v3_v3(mat_basis[2], t->spacemtx[1]);
copy_v3_v3(mat_basis[2], t->spacemtx[1]);
}
else {
BLI_assert((tc->mode & CON_AXIS2) != 0);
axis_idx = MAN_AXIS_ROT_Z;
negate_v3_v3(mat_basis[2], t->spacemtx[2]);
copy_v3_v3(mat_basis[2], t->spacemtx[2]);
}
}
else {
axis_idx = MAN_AXIS_ROT_C;
negate_v3_v3(mat_basis[2], t->spacemtx[t->orient_axis]);
copy_v3_v3(mat_basis[2], t->spacemtx[t->orient_axis]);
scale *= 1.2f;
line_with -= 1.0f;
}

View File

@ -200,12 +200,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
t->con.applyRot(t, NULL, NULL, axis_final, NULL);
}
else {
copy_v3_v3(axis_final, t->spacemtx[t->orient_axis]);
if (!(t->flag & T_INPUT_IS_VALUES_FINAL) && (dot_v3v3(axis_final, t->viewinv[2]) > 0.0f)) {
/* The input is obtained according to the position of the mouse.
* Flip to better match the movement. */
final *= -1;
}
negate_v3_v3(axis_final, t->spacemtx[t->orient_axis]);
}
if (applyNumInput(&t->num, &final)) {

View File

@ -56,12 +56,12 @@ static void initShear_mouseInputMode(TransInfo *t)
/* Needed for axis aligned view gizmo. */
if (t->orient[t->orient_curr].type == V3D_ORIENT_VIEW) {
if (t->orient_axis_ortho == 0) {
if (t->center2d[1] < t->mouse.imval[1]) {
if (t->center2d[1] > t->mouse.imval[1]) {
dir_flip = !dir_flip;
}
}
else if (t->orient_axis_ortho == 1) {
if (t->center2d[0] < t->mouse.imval[0]) {
if (t->center2d[0] > t->mouse.imval[0]) {
dir_flip = !dir_flip;
}
}

View File

@ -561,7 +561,6 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C,
if (rv3d != NULL) {
copy_m3_m4(r_mat, rv3d->viewinv);
normalize_m3(r_mat);
negate_v3(r_mat[2]);
}
else {
unit_m3(r_mat);