[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34215] trunk/blender/source/blender/ editors/object/object_constraint.c: add constraint operator

Campbell Barton ideasman42 at gmail.com
Mon Jan 10 04:30:29 CET 2011


Revision: 34215
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34215
Author:   campbellbarton
Date:     2011-01-10 03:30:27 +0000 (Mon, 10 Jan 2011)
Log Message:
-----------
add constraint operator
- report an error if adding a pose constraint with no active pose channel.
- dont run update_pose_constraint_flags() when adding an object constrant to an armature object.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_constraint.c

Modified: trunk/blender/source/blender/editors/object/object_constraint.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_constraint.c	2011-01-10 02:40:24 UTC (rev 34214)
+++ trunk/blender/source/blender/editors/object/object_constraint.c	2011-01-10 03:30:27 UTC (rev 34215)
@@ -1245,11 +1245,18 @@
 	bPoseChannel *pchan;
 	bConstraint *con;
 	
-	if(list == &ob->constraints)
+	if(list == &ob->constraints) {
 		pchan= NULL;
-	else
+	}
+	else {
 		pchan= get_active_posechannel(ob);
 
+		/* ensure not to confuse object/pose adding */
+		if (pchan == NULL) {
+			BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to.");
+			return OPERATOR_CANCELLED;
+		}
+	}
 	/* check if constraint to be added is valid for the given constraints stack */
 	if (type == CONSTRAINT_TYPE_NULL) {
 		return OPERATOR_CANCELLED;
@@ -1332,11 +1339,11 @@
 	
 	/* make sure all settings are valid - similar to above checks, but sometimes can be wrong */
 	object_test_constraints(ob);
-	
-	if (ob->pose)
+
+	if (pchan)
 		update_pose_constraint_flags(ob->pose);
-	
-	
+
+
 	/* force depsgraph to get recalculated since new relationships added */
 	DAG_scene_sort(bmain, scene);		/* sort order of objects */
 	




More information about the Bf-blender-cvs mailing list