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

This commit is contained in:
2010-02-18 16:41:47 +00:00
parent f4b3d2dc9c
commit 3142c4367c

View File

@@ -251,9 +251,8 @@ static void set_constraint_nth_target (bConstraint *con, Object *target, char su
/* 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 @@ static void test_constraints (Object *owner, const char substring[], void *data)
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 @@ static void test_constraints (Object *owner, const char substring[], void *data)
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_constraints (Object *owner, const char substring[], void *data)
}
}
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= owner->pose->chanbase.first; pchan; pchan= pchan->next)
if(pchan->constraints.first)
test_constraints(owner, pchan);
}
}