[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27014] trunk/blender/source/blender/ editors/object/object_constraint.c: another speedup to constraint checking, skip the bone list and only lookup pose channels that have constraints.

Campbell Barton ideasman42 at gmail.com
Thu Feb 18 17:41:48 CET 2010


Revision: 27014
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27014
Author:   campbellbarton
Date:     2010-02-18 17:41:47 +0100 (Thu, 18 Feb 2010)

Log Message:
-----------
another speedup to constraint checking, skip the bone list and only lookup pose channels that have constraints.

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	2010-02-18 16:05:01 UTC (rev 27013)
+++ trunk/blender/source/blender/editors/object/object_constraint.c	2010-02-18 16:41:47 UTC (rev 27014)
@@ -251,9 +251,8 @@
 
 /* checks validity of object pointers, and NULLs,
  * if Bone doesnt exist it sets the CONSTRAINT_DISABLE flag.
- * 'data' saves a bone name lookup.
  */
-static void test_constraints (Object *owner, const char substring[], void *data)
+static void test_constraints (Object *owner, bPoseChannel *pchan)
 {
 	bConstraint *curcon;
 	ListBase *conlist= NULL;
@@ -262,7 +261,7 @@
 	if (owner==NULL) return;
 	
 	/* Check parents */
-	if (strlen(substring)) {
+	if (pchan) {
 		switch (owner->type) {
 			case OB_ARMATURE:
 				type = CONSTRAINT_OBTYPE_BONE;
@@ -281,16 +280,7 @@
 			conlist = &owner->constraints;
 			break;
 		case CONSTRAINT_OBTYPE_BONE:
-			{
-				Bone *bone;
-				bPoseChannel *chan;
-				
-				bone = data ? data : get_named_bone( ((bArmature *)owner->data), substring );
-				chan = get_pose_channel(owner->pose, substring);
-				if (bone && chan) {
-					conlist = &chan->constraints;
-				}
-			}
+			conlist = &pchan->constraints;
 			break;
 	}
 	
@@ -432,25 +422,17 @@
 	}
 }
 
-static void test_bonelist_constraints (Object *owner, ListBase *list)
-{
-	Bone *bone;
-
-	for (bone = list->first; bone; bone = bone->next) {
-		test_constraints(owner, bone->name, (void *)bone);
-		test_bonelist_constraints(owner, &bone->childbase);
-	}
-}
-
 void object_test_constraints (Object *owner)
 {
-	test_constraints(owner, "", NULL);
+	if(owner->constraints.first)
+		test_constraints(owner, NULL);
 
-	if (owner->type==OB_ARMATURE) {
-		bArmature *arm= get_armature(owner);
-		
-		if (arm)
-			test_bonelist_constraints(owner, &arm->bonebase);
+	if (owner->type==OB_ARMATURE && owner->pose) {
+		bPoseChannel *pchan;
+
+		for (pchan= list->first; pchan; pchan= pchan->next)
+			if(pchan->constraints.first)
+				test_constraints(owner, pchan);
 	}
 }
 





More information about the Bf-blender-cvs mailing list