[Bf-blender-cvs] [b154aa8] master: Fix T42447: Shrinkwrap constraint: mismatch in handling sclaing in projection case.

Bastien Montagne noreply at git.blender.org
Fri Oct 31 11:12:35 CET 2014


Commit: b154aa8c060a60d476970bb8b8fab3912a2afc22
Author: Bastien Montagne
Date:   Fri Oct 31 11:07:52 2014 +0100
Branches: master
https://developer.blender.org/rBb154aa8c060a60d476970bb8b8fab3912a2afc22

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.

===================================================================

M	source/blender/blenkernel/intern/constraint.c

===================================================================

diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 8a5d313..574001e 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;




More information about the Bf-blender-cvs mailing list