Fix #107924: Scale limit respect negative values #107937

Open
YimingWu wants to merge 3 commits from ChengduLittleA/blender:limit_scale_fix into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 6 additions and 15 deletions
Showing only changes of commit 778fe2774e - Show all commits

View File

@ -1735,6 +1735,12 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U
ChengduLittleA marked this conversation as resolved Outdated

Instead of a new scale function, the size could be flipped if the matrix is negative:

   mat4_to_size(size, cob->matrix);
+  if (is_negative_m4(cob->matrix)) {
+    negate_v3(size);
+  } 

Although I think this might not be the way to go, I'll reply to the PR.

Instead of a new scale function, the size could be flipped if the matrix is negative: ``` mat4_to_size(size, cob->matrix); + if (is_negative_m4(cob->matrix)) { + negate_v3(size); + } ``` Although I think this might not be the way to go, I'll reply to the PR.
mat4_to_size(size, cob->matrix);
/* This will only correctly handle the situation where xyz scales being all negative or all positive.
* Flipping the size is effectively flipping the limit range. */
if (is_negative_m4(cob->matrix)) {
negate_v3(size);
}
copy_v3_v3(obsize, size);
if (data->flag & LIMIT_XMIN) {

View File

@ -413,7 +413,6 @@ void size_to_mat4(float R[4][4], const float size[3]);
void mat3_to_size_2d(float size[2], const float M[3][3]);
void mat3_to_size(float size[3], const float M[3][3]);
void mat4_to_size(float size[3], const float M[4][4]);
void mat4_to_size_handed(float size[3], const float M[4][4]);
/**
* Return the largest scale on any axis, the equivalent of calling:

View File

@ -2136,20 +2136,6 @@ void mat4_to_size(float size[3], const float M[4][4])
size[2] = len_v3(M[2]);
}
void mat4_to_size_handed(float size[3], const float M[4][4])
{
size[0] = len_v3(M[0]);
size[1] = len_v3(M[1]);
size[2] = len_v3(M[2]);
/* Check handedness, correctly represent negative scaling. */
float t[3];
cross_v3_v3v3(t, M[0], M[1]);
if (dot_v3v3(t, M[2]) < 0) {
negate_v3(size);
}
}
float mat3_to_size_max_axis(const float M[3][3])
{
return sqrtf(max_fff(len_squared_v3(M[0]), len_squared_v3(M[1]), len_squared_v3(M[2])));