Fix T42447: Shrinkwrap constraint: mismatch in handling sclaing in projection case.

Constraint space conversion ignores object scale, which is OK in most cases. But here,
we are converting a normal from world to local space, and when later converting it
into target space to actually do the BVH raycast, we use TransformSpace which
does applies objects' scaling to normals, as expected.

Best solution here is to also take object's scale into account when converting
from local to world space.
This commit is contained in:
Bastien Montagne 2014-10-31 11:07:52 +01:00
parent 5e6d878318
commit b154aa8c06
Notes: blender-bot 2023-02-14 09:53:01 +01:00
Referenced by commit 599c8a2c8e, Fix T43204: Shrinkwrap constraint, project mode: Space ignored in bone case.
Referenced by issue #42447, Shrinkwrap constraint / wrong rotation of the constrained object in "project" mode
1 changed files with 10 additions and 4 deletions

View File

@ -3461,10 +3461,16 @@ static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
}
/* transform normal into requested space */
unit_m4(mat);
BKE_constraint_mat_convertspace(cob->ob, cob->pchan, mat, CONSTRAINT_SPACE_LOCAL, scon->projAxisSpace);
invert_m4(mat);
mul_mat3_m4_v3(mat, no);
/* We cannot use BKE_constraint_mat_convertspace here, it does not take into account scaling...
* In theory we would not need it, but in this case we'd have to tweak SpaceTransform to also
* optionally ignore scaling when handling normals - simpler to directly call BKE_object_to_mat4
* if needed! See T42447. */
if (scon->projAxisSpace == CONSTRAINT_SPACE_WORLD) {
BKE_object_to_mat4(cob->ob, mat);
invert_m4(mat);
mul_mat3_m4_v3(mat, no);
}
/* Else, we remain in local space, nothing to do. */
if (normalize_v3(no) < FLT_EPSILON) {
fail = true;