== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were: * To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes. * To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target. As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up. Known issues: * PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon. * Constraints BPy-API is currently has a few features which currently don't work yet * Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
This commit is contained in:
@@ -264,7 +264,6 @@ void unlink_object(Object *ob)
|
||||
bConstraint *con;
|
||||
bActionStrip *strip;
|
||||
int a;
|
||||
char *str;
|
||||
|
||||
unlink_controllers(&ob->controllers);
|
||||
unlink_actuators(&ob->actuators);
|
||||
@@ -313,9 +312,23 @@ void unlink_object(Object *ob)
|
||||
bPoseChannel *pchan;
|
||||
for(pchan= obt->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (con = pchan->constraints.first; con; con=con->next) {
|
||||
if(ob==get_constraint_target(con, &str)) {
|
||||
set_constraint_target(con, NULL, NULL);
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
if (ct->tar == ob) {
|
||||
ct->tar = NULL;
|
||||
strcpy(ct->subtarget, "");
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (cti->flush_constraint_targets)
|
||||
cti->flush_constraint_targets(con, &targets, 0);
|
||||
}
|
||||
}
|
||||
if(pchan->custom==ob)
|
||||
@@ -326,9 +339,23 @@ void unlink_object(Object *ob)
|
||||
sca_remove_ob_poin(obt, ob);
|
||||
|
||||
for (con = obt->constraints.first; con; con=con->next) {
|
||||
if(ob==get_constraint_target(con, &str)) {
|
||||
set_constraint_target(con, NULL, NULL);
|
||||
obt->recalc |= OB_RECALC_OB;
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
if (ct->tar == ob) {
|
||||
ct->tar = NULL;
|
||||
strcpy(ct->subtarget, "");
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (cti->flush_constraint_targets)
|
||||
cti->flush_constraint_targets(con, &targets, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,11 +952,27 @@ static void copy_object_pose(Object *obn, Object *ob)
|
||||
|
||||
for (chan = obn->pose->chanbase.first; chan; chan=chan->next){
|
||||
bConstraint *con;
|
||||
char *str;
|
||||
|
||||
chan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
|
||||
for(con= chan->constraints.first; con; con= con->next) {
|
||||
if(ob==get_constraint_target(con, &str))
|
||||
set_constraint_target(con, obn, NULL);
|
||||
|
||||
for (con= chan->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
if (ct->tar == ob) {
|
||||
ct->tar = obn;
|
||||
strcpy(ct->subtarget, "");
|
||||
}
|
||||
}
|
||||
|
||||
if (cti->flush_constraint_targets)
|
||||
cti->flush_constraint_targets(con, &targets, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1606,7 +1649,7 @@ void where_is_object_time(Object *ob, float ctime)
|
||||
if (ob->constraints.first) {
|
||||
bConstraintOb *cob;
|
||||
|
||||
cob= constraints_make_evalob(ob, NULL, TARGET_OBJECT);
|
||||
cob= constraints_make_evalob(ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
||||
|
||||
/* constraints need ctime, not stime. Some call where_is_object_time and bsystem_time */
|
||||
solve_constraints (&ob->constraints, cob, ctime);
|
||||
@@ -1783,7 +1826,7 @@ for a lamp that is the child of another object */
|
||||
if (ob->constraints.first) {
|
||||
bConstraintOb *cob;
|
||||
|
||||
cob= constraints_make_evalob(ob, NULL, TARGET_OBJECT);
|
||||
cob= constraints_make_evalob(ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
||||
solve_constraints (&ob->constraints, cob, G.scene->r.cfra);
|
||||
constraints_clear_evalob(cob);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user