diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-10-31 13:07:52 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-10-31 13:12:16 +0300 |
commit | b154aa8c060a60d476970bb8b8fab3912a2afc22 (patch) | |
tree | 832d305af147fb82f44661d94c54b0459da1b945 /source/blender/blenkernel/intern/constraint.c | |
parent | 5e6d878318515ab777ebc218bb311c7c4e514647 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 8a5d313e3fb..574001e2f80 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -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; |