[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34518] trunk/blender/source/blender: Bugfix [#25707] / Todo Item: "Local Space" for Object constraining

Joshua Leung aligorith at gmail.com
Thu Jan 27 00:33:09 CET 2011


Revision: 34518
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34518
Author:   aligorith
Date:     2011-01-26 23:33:08 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
Bugfix [#25707] / Todo Item: "Local Space" for Object constraining

For Constraints, there's now a working "Local" Space for Objects
without parents. This is defined as relative to the object's rotated
set of axes which results from rotation that gets set via "rotation"
transform properties.

I'm not sure whether this different behaviour between parented and
unparented objects will be too confusing (and thus require separate
settings + a round of version patching), so I'll wait until we get
proper testing from experienced riggers first.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/makesrna/intern/rna_constraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2011-01-26 22:38:05 UTC (rev 34517)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2011-01-26 23:33:08 UTC (rev 34518)
@@ -372,7 +372,7 @@
 	else {
 		/* objects */
 		if (from==CONSTRAINT_SPACE_WORLD && to==CONSTRAINT_SPACE_LOCAL) {
-			/* check if object has a parent - otherwise this won't work */
+			/* check if object has a parent */
 			if (ob->parent) {
 				/* 'subtract' parent's effects from owner */
 				mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
@@ -380,6 +380,18 @@
 				copy_m4_m4(tempmat, mat);
 				mul_m4_m4m4(mat, tempmat, imat);
 			}
+			else {
+				/* Local space in this case will have to be defined as local to the owner's 
+				 * transform-property-rotated axes. So subtract this rotation component.
+				 */
+				object_to_mat4(ob, diff_mat);
+				normalize_m4(diff_mat);
+				zero_v3(diff_mat[3]);
+				
+				invert_m4_m4(imat, diff_mat);
+				copy_m4_m4(tempmat, mat);
+				mul_m4_m4m4(mat, tempmat, imat);
+			}
 		}
 		else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) {
 			/* check that object has a parent - otherwise this won't work */
@@ -389,6 +401,17 @@
 				mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat);
 				mul_m4_m4m4(mat, tempmat, diff_mat);
 			}
+			else {
+				/* Local space in this case will have to be defined as local to the owner's 
+				 * transform-property-rotated axes. So add back this rotation component.
+				 */
+				object_to_mat4(ob, diff_mat);
+				normalize_m4(diff_mat);
+				zero_v3(diff_mat[3]);
+				
+				copy_m4_m4(tempmat, mat);
+				mul_m4_m4m4(mat, tempmat, diff_mat);
+			}
 		}
 	}
 }

Modified: trunk/blender/source/blender/makesrna/intern/rna_constraint.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_constraint.c	2011-01-26 22:38:05 UTC (rev 34517)
+++ trunk/blender/source/blender/makesrna/intern/rna_constraint.c	2011-01-26 23:33:08 UTC (rev 34518)
@@ -79,7 +79,7 @@
 
 EnumPropertyItem space_object_items[] = {
 	{0, "WORLD", 0, "World Space", ""},
-	{1, "LOCAL", 0, "Local (Without Parent) Space", ""},
+	{1, "LOCAL", 0, "Local Space", ""},
 	{0, NULL, 0, NULL, NULL}};
 
 EnumPropertyItem constraint_ik_type_items[] ={




More information about the Bf-blender-cvs mailing list