Fix #107924: Scale limit respect negative values #107937
@ -1735,6 +1735,12 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U
|
||||
|
||||
ChengduLittleA marked this conversation as resolved
Outdated
|
||||
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) {
|
||||
|
@ -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:
|
||||
|
@ -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])));
|
||||
|
Loading…
Reference in New Issue
Block a user
Instead of a new scale function, the size could be flipped if the matrix is negative:
Although I think this might not be the way to go, I'll reply to the PR.