diff options
Diffstat (limited to 'source/blender/blenkernel/intern/depsgraph.c')
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 898 |
1 files changed, 448 insertions, 450 deletions
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 54655cf8582..51f8815fbd1 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -82,10 +82,10 @@ * the queue store a list of freenodes to avoid successive alloc/dealloc */ -DagNodeQueue * queue_create (int slots) +DagNodeQueue *queue_create(int slots) { - DagNodeQueue * queue; - DagNodeQueueElem * elem; + DagNodeQueue *queue; + DagNodeQueueElem *elem; int i; queue = MEM_mallocN(sizeof(DagNodeQueue), "DAG queue"); @@ -98,7 +98,7 @@ DagNodeQueue * queue_create (int slots) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i <slots;i++) { + for (i = 1; i < slots; i++) { elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem4"); elem->node = NULL; elem->next = NULL; @@ -111,7 +111,7 @@ DagNodeQueue * queue_create (int slots) void queue_raz(DagNodeQueue *queue) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; elem = queue->first; if (queue->freenodes->last) @@ -132,8 +132,8 @@ void queue_raz(DagNodeQueue *queue) void queue_delete(DagNodeQueue *queue) { - DagNodeQueueElem * elem; - DagNodeQueueElem * temp; + DagNodeQueueElem *elem; + DagNodeQueueElem *temp; elem = queue->first; while (elem) { @@ -156,7 +156,7 @@ void queue_delete(DagNodeQueue *queue) /* insert in queue, remove in front */ void push_queue(DagNodeQueue *queue, DagNode *node) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; int i; if (node == NULL) { @@ -168,7 +168,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node) elem = queue->freenodes->first; if (elem != NULL) { queue->freenodes->first = elem->next; - if ( queue->freenodes->last == elem) { + if (queue->freenodes->last == elem) { queue->freenodes->last = NULL; queue->freenodes->first = NULL; } @@ -180,7 +180,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i <DAGQUEUEALLOC;i++) { + for (i = 1; i < DAGQUEUEALLOC; i++) { elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem2"); elem->node = NULL; elem->next = NULL; @@ -207,13 +207,13 @@ void push_queue(DagNodeQueue *queue, DagNode *node) /* insert in front, remove in front */ void push_stack(DagNodeQueue *queue, DagNode *node) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; int i; elem = queue->freenodes->first; if (elem != NULL) { queue->freenodes->first = elem->next; - if ( queue->freenodes->last == elem) { + if (queue->freenodes->last == elem) { queue->freenodes->last = NULL; queue->freenodes->first = NULL; } @@ -225,7 +225,7 @@ void push_stack(DagNodeQueue *queue, DagNode *node) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i <DAGQUEUEALLOC;i++) { + for (i = 1; i < DAGQUEUEALLOC; i++) { elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem2"); elem->node = NULL; elem->next = NULL; @@ -246,24 +246,24 @@ void push_stack(DagNodeQueue *queue, DagNode *node) } -DagNode * pop_queue(DagNodeQueue *queue) +DagNode *pop_queue(DagNodeQueue *queue) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; DagNode *node; elem = queue->first; if (elem) { queue->first = elem->next; if (queue->last == elem) { - queue->last=NULL; - queue->first=NULL; + queue->last = NULL; + queue->first = NULL; } queue->count--; if (queue->freenodes->last) - queue->freenodes->last->next=elem; - queue->freenodes->last=elem; + queue->freenodes->last->next = elem; + queue->freenodes->last = elem; if (queue->freenodes->first == NULL) - queue->freenodes->first=elem; + queue->freenodes->first = elem; node = elem->node; elem->node = NULL; elem->next = NULL; @@ -276,17 +276,17 @@ DagNode * pop_queue(DagNodeQueue *queue) } } -void *pop_ob_queue(struct DagNodeQueue *queue) +void *pop_ob_queue(struct DagNodeQueue *queue) { return(pop_queue(queue)->ob); } -DagNode * get_top_node_queue(DagNodeQueue *queue) +DagNode *get_top_node_queue(DagNodeQueue *queue) { return queue->first->node; } -int queue_count(struct DagNodeQueue *queue) +int queue_count(struct DagNodeQueue *queue) { return queue->count; } @@ -307,37 +307,37 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node FCurve *fcu; DagNode *node1; - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { - ChannelDriver *driver= fcu->driver; + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { + ChannelDriver *driver = fcu->driver; DriverVar *dvar; int isdata_fcu = isdata || (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")); /* loop over variables to get the target relationships */ - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* only used targets */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id) { // FIXME: other data types need to be added here so that they can work! - if (GS(dtar->id->name)==ID_OB) { - Object *ob= (Object *)dtar->id; + if (GS(dtar->id->name) == ID_OB) { + Object *ob = (Object *)dtar->id; /* normal channel-drives-channel */ node1 = dag_get_node(dag, dtar->id); /* check if bone... */ - if ((ob->type==OB_ARMATURE) && - ( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) || - ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) )) + if ((ob->type == OB_ARMATURE) && + ( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) || + ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) )) { - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver"); } /* check if ob data */ else if (dtar->rna_path && strstr(dtar->rna_path, "data.")) - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver"); /* normal */ else - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_OB_DATA : DAG_RL_OB_OB, "Driver"); } } } @@ -353,12 +353,12 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec // would be nice to have a list of colliders here // so for now walk all objects in scene check 'same layer rule' - for (base = scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->lay & ob->lay) && base->object->pd) { - Object *ob1= base->object; + Object *ob1 = base->object; if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { node2 = dag_get_node(dag, ob1); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Field Collision"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision"); } } } @@ -367,16 +367,16 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, Object *ob, int mask) { bConstraint *con; - DagNode * node; - DagNode * node2; - DagNode * node3; + DagNode *node; + DagNode *node2; + DagNode *node3; Key *key; ParticleSystem *psys; - int addtoroot= 1; + int addtoroot = 1; node = dag_get_node(dag, ob); - if ((ob->data) && (mask&DAG_RL_DATA)) { + if ((ob->data) && (mask & DAG_RL_DATA)) { node2 = dag_get_node(dag, ob->data); dag_add_relation(dag, node, node2, DAG_RL_DATA, "Object-Data Relation"); node2->first_ancestor = ob; @@ -384,34 +384,34 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* also build a custom data mask for dependencies that need certain layers */ - node->customdata_mask= 0; + node->customdata_mask = 0; if (ob->type == OB_ARMATURE) { if (ob->pose) { bPoseChannel *pchan; bConstraint *con; - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->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) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar && ct->tar != ob) { // fprintf(stderr, "armature %s target :%s\n", ob->id.name, target->id.name); node3 = dag_get_node(dag, ct->tar); if (ct->subtarget[0]) { - dag_add_relation(dag, node3, node, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, cti->name); if (ct->tar->type == OB_MESH) node3->customdata_mask |= CD_MASK_MDEFORMVERT; } else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) - dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, cti->name); else dag_add_relation(dag, node3, node, DAG_RL_OB_DATA, cti->name); } @@ -431,13 +431,13 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ob->nlastrips.first) { bActionStrip *strip; bActionChannel *chan; - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->modifiers.first) { bActionModifier *amod; - for (amod= strip->modifiers.first; amod; amod= amod->next) { + for (amod = strip->modifiers.first; amod; amod = amod->next) { if (amod->ob) { node2 = dag_get_node(dag, amod->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "NLA Strip Modifier"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "NLA Strip Modifier"); } } } @@ -445,16 +445,16 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } #endif // XXX old animation system if (ob->adt) - dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation + dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation - key= ob_get_key(ob); + key = ob_get_key(ob); if (key && key->adt) dag_add_driver_relation(key->adt, dag, node, 1); if (ob->modifiers.first) { ModifierData *md; - for (md=ob->modifiers.first; md; md=md->next) { + for (md = ob->modifiers.first; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->updateDepgraph) mti->updateDepgraph(md, dag, scene, ob, node); @@ -465,22 +465,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O switch (ob->partype) { case PARSKEL: - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Parent"); break; case PARVERT1: case PARVERT3: - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Vertex Parent"); node2->customdata_mask |= CD_MASK_ORIGINDEX; break; case PARBONE: - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Bone Parent"); break; default: - if (ob->parent->type==OB_LATTICE) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Lattice Parent"); - else if (ob->parent->type==OB_CURVE) { - Curve *cu= ob->parent->data; + if (ob->parent->type == OB_LATTICE) + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Lattice Parent"); + else if (ob->parent->type == OB_CURVE) { + Curve *cu = ob->parent->data; if (cu->flag & CU_PATH) - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Curve Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Curve Parent"); else dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Curve Parent"); } @@ -488,22 +488,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Parent"); } /* exception case: parent is duplivert */ - if (ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Duplivert"); + if (ob->type == OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Duplivert"); } addtoroot = 0; } if (ob->proxy) { node2 = dag_get_node(dag, ob->proxy); - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Proxy"); + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Proxy"); /* inverted relation, so addtoroot shouldn't be set to zero */ } if (ob->transflag & OB_DUPLI) { if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { GroupObject *go; - for (go= ob->dup_group->gobject.first; go; go= go->next) { + for (go = ob->dup_group->gobject.first; go; go = go->next) { if (go->ob) { node2 = dag_get_node(dag, go->ob); /* node2 changes node1, this keeps animations updated in groups?? not logical? */ @@ -514,14 +514,14 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* softbody collision */ - if ((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) { + if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) { if (modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first) - dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ + dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ } /* object data drivers */ if (ob->data) { - AnimData *adt= BKE_animdata_from_id((ID *)ob->data); + AnimData *adt = BKE_animdata_from_id((ID *)ob->data); if (adt) dag_add_driver_relation(adt, dag, node, 1); } @@ -537,49 +537,49 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Camera DoF"); } } - break; + break; case OB_MBALL: { - Object *mom= BKE_metaball_basis_find(scene, ob); + Object *mom = BKE_metaball_basis_find(scene, ob); - if (mom!=ob) { + if (mom != ob) { node2 = dag_get_node(dag, mom); - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children! + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); // mom depends on children! } } - break; + break; case OB_CURVE: case OB_FONT: { - Curve *cu= ob->data; + Curve *cu = ob->data; if (cu->bevobj) { node2 = dag_get_node(dag, cu->bevobj); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Bevel"); } if (cu->taperobj) { node2 = dag_get_node(dag, cu->taperobj); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Taper"); } if (ob->type == OB_FONT) { if (cu->textoncurve) { node2 = dag_get_node(dag, cu->textoncurve); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Texture On Curve"); } } } - break; + break; } /* particles */ - psys= ob->particlesystem.first; + psys = ob->particlesystem.first; if (psys) { GroupObject *go; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { BoidRule *rule = NULL; BoidState *state = NULL; - ParticleSettings *part= psys->part; + ParticleSettings *part = psys->part; ListBase *effectors = NULL; EffectorCache *eff; @@ -591,12 +591,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) { ParticleTarget *pt = psys->targets.first; - for (; pt; pt=pt->next) { - if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys-1)) { + for (; pt; pt = pt->next) { + if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys - 1)) { node2 = dag_get_node(dag, pt->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Targets"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Targets"); } - } + } } if (part->ren_as == PART_DRAW_OB && part->dup_ob) { @@ -610,7 +610,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } if (part->ren_as == PART_DRAW_GR && part->dup_group) { - for (go=part->dup_group->gobject.first; go; go=go->next) { + for (go = part->dup_group->gobject.first; go; go = go->next) { node2 = dag_get_node(dag, go->ob); dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation"); } @@ -618,23 +618,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O effectors = pdInitEffectors(scene, ob, psys, part->effector_weights); - if (effectors) for (eff = effectors->first; eff; eff=eff->next) { - if (eff->psys) { - node2 = dag_get_node(dag, eff->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Field"); + if (effectors) { + for (eff = effectors->first; eff; eff = eff->next) { + if (eff->psys) { + node2 = dag_get_node(dag, eff->ob); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Field"); + } } } pdEndEffectors(&effectors); if (part->boids) { - for (state = part->boids->states.first; state; state=state->next) { - for (rule = state->rules.first; rule; rule=rule->next) { + for (state = part->boids->states.first; state; state = state->next) { + for (rule = state->rules.first; rule; rule = rule->next) { Object *ruleob = NULL; - if (rule->type==eBoidRuleType_Avoid) - ruleob = ((BoidRuleGoalAvoid*)rule)->ob; - else if (rule->type==eBoidRuleType_FollowLeader) - ruleob = ((BoidRuleFollowLeader*)rule)->ob; + if (rule->type == eBoidRuleType_Avoid) + ruleob = ((BoidRuleGoalAvoid *)rule)->ob; + else if (rule->type == eBoidRuleType_FollowLeader) + ruleob = ((BoidRuleFollowLeader *)rule)->ob; if (ruleob) { node2 = dag_get_node(dag, ruleob); @@ -647,8 +649,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* object constraints */ - for (con = ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -657,25 +659,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O /* special case for camera tracking -- it doesn't use targets to define relations */ if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) { - int depends_on_camera= 0; + int depends_on_camera = 0; - if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) { - bFollowTrackConstraint *data= (bFollowTrackConstraint *)con->data; + if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) { + bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data; - if ((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0]) - depends_on_camera= 1; + if ((data->clip || data->flag & FOLLOWTRACK_ACTIVECLIP) && data->track[0]) + depends_on_camera = 1; if (data->depth_ob) { node2 = dag_get_node(dag, data->depth_ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); } } - else if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) - depends_on_camera= 1; + else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) + depends_on_camera = 1; if (depends_on_camera && scene->camera) { node2 = dag_get_node(dag, scene->camera); - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); } dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); @@ -684,20 +686,20 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O else if (cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { Object *obt; if (ct->tar) - obt= ct->tar; + obt = ct->tar; else continue; node2 = dag_get_node(dag, obt); if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); else { if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); if (obt->type == OB_MESH) node2->customdata_mask |= CD_MASK_MDEFORMVERT; } @@ -712,12 +714,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } } - if (addtoroot == 1 ) + if (addtoroot == 1) dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); } -struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) -{ +struct DagForest *build_dag(Main *bmain, Scene *sce, short mask){ Base *base; Object *ob; Group *group; @@ -728,8 +729,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) DagAdjList *itA; dag = sce->theDag; - sce->dagisvalid=1; - if ( dag) + sce->dagisvalid = 1; + if (dag) free_forest(dag); else { dag = dag_init(); @@ -740,8 +741,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) scenenode = dag_add_node(dag, sce); /* add current scene objects */ - for (base = sce->base.first; base; base= base->next) { - ob= base->object; + for (base = sce->base.first; base; base = base->next) { + ob = base->object; build_dag_object(dag, scenenode, sce, ob, mask); if (ob->proxy) @@ -753,9 +754,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) } /* add groups used in current scene objects */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { build_dag_object(dag, scenenode, sce, go->ob, mask); } group->id.flag &= ~LIB_DOIT; @@ -767,23 +768,23 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) * the relation type has to be synced. One of the parents can change, and should give same event to child */ /* nodes were callocced, so we can use node->color for temporal storage */ - for (node = sce->theDag->DagNode.first; node; node= node->next) { - if (node->type==ID_OB) { - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { + if (node->type == ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { itA->node->color |= itA->type; } } /* also flush custom data mask */ - ((Object*)node->ob)->customdata_mask= node->customdata_mask; + ((Object *)node->ob)->customdata_mask = node->customdata_mask; } } /* now set relations equal, so that when only one parent changes, the correct recalcs are found */ - for (node = sce->theDag->DagNode.first; node; node= node->next) { - if (node->type==ID_OB) { - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { + if (node->type == ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { itA->type |= itA->node->color; } } @@ -825,14 +826,14 @@ void free_forest(DagForest *Dag) } BLI_ghash_free(Dag->nodeHash, NULL, NULL); - Dag->nodeHash= NULL; + Dag->nodeHash = NULL; Dag->DagNode.first = NULL; Dag->DagNode.last = NULL; Dag->numNodes = 0; } -DagNode * dag_find_node (DagForest *forest, void * fob) +DagNode *dag_find_node(DagForest *forest, void *fob) { if (forest->nodeHash) return BLI_ghash_lookup(forest->nodeHash, fob); @@ -840,11 +841,11 @@ DagNode * dag_find_node (DagForest *forest, void * fob) return NULL; } -static int ugly_hack_sorry= 1; // prevent type check -static int dag_print_dependencies= 0; // debugging +static int ugly_hack_sorry = 1; // prevent type check +static int dag_print_dependencies = 0; // debugging /* no checking of existence, use dag_find_node first or dag_get_node */ -DagNode * dag_add_node (DagForest *forest, void * fob) +DagNode *dag_add_node(DagForest *forest, void *fob) { DagNode *node; @@ -853,7 +854,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob) node->ob = fob; node->color = DAG_WHITE; - if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting + if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting if (forest->numNodes) { ((DagNode *) forest->DagNode.last)->next = node; forest->DagNode.last = node; @@ -866,18 +867,18 @@ DagNode * dag_add_node (DagForest *forest, void * fob) } if (!forest->nodeHash) - forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); + forest->nodeHash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); BLI_ghash_insert(forest->nodeHash, fob, node); } return node; } -DagNode * dag_get_node (DagForest *forest, void * fob) +DagNode *dag_get_node(DagForest *forest, void *fob) { DagNode *node; - node = dag_find_node (forest, fob); + node = dag_find_node(forest, fob); if (!node) node = dag_add_node(forest, fob); return node; @@ -885,10 +886,10 @@ DagNode * dag_get_node (DagForest *forest, void * fob) -DagNode * dag_get_sub_node (DagForest *forest, void * fob) +DagNode *dag_get_sub_node(DagForest *forest, void *fob) { DagNode *node; - DagAdjList *mainchild, *prev=NULL; + DagAdjList *mainchild, *prev = NULL; mainchild = ((DagNode *) forest->DagNode.first)->child; /* remove from first node (scene) adj list if present */ @@ -908,7 +909,7 @@ DagNode * dag_get_sub_node (DagForest *forest, void * fob) prev = mainchild; mainchild = mainchild->next; } - node = dag_find_node (forest, fob); + node = dag_find_node(forest, fob); if (!node) node = dag_add_node(forest, fob); return node; @@ -966,9 +967,9 @@ static const char *dag_node_name(DagNode *node) if (node->ob == NULL) return "null"; else if (ugly_hack_sorry) - return ((ID*)(node->ob))->name+2; + return ((ID *)(node->ob))->name + 2; else - return ((bPoseChannel*)(node->ob))->name; + return ((bPoseChannel *)(node->ob))->name; } static void dag_node_print_dependencies(DagNode *node) @@ -977,7 +978,7 @@ static void dag_node_print_dependencies(DagNode *node) printf("%s depends on:\n", dag_node_name(node)); - for (itA= node->parent; itA; itA= itA->next) + for (itA = node->parent; itA; itA = itA->next) printf(" %s through %s\n", dag_node_name(itA->node), itA->name); printf("\n"); } @@ -989,12 +990,12 @@ static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode) if (node->color == DAG_BLACK) return 0; - node->color= DAG_BLACK; + node->color = DAG_BLACK; if (node == endnode) return 1; - for (itA= node->parent; itA; itA= itA->next) { + for (itA = node->parent; itA; itA = itA->next) { if (dag_node_print_dependency_recurs(itA->node, endnode)) { printf(" %s depends on %s through %s.\n", dag_node_name(node), dag_node_name(itA->node), itA->name); return 1; @@ -1008,8 +1009,8 @@ static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode, { DagNode *node; - for (node = dag->DagNode.first; node; node= node->next) - node->color= DAG_WHITE; + for (node = dag->DagNode.first; node; node = node->next) + node->color = DAG_WHITE; printf(" %s depends on %s through %s.\n", dag_node_name(endnode), dag_node_name(startnode), name); dag_node_print_dependency_recurs(startnode, endnode); @@ -1021,16 +1022,16 @@ static int dag_node_recurs_level(DagNode *node, int level) DagAdjList *itA; int newlevel; - node->color= DAG_BLACK; /* done */ - newlevel= ++level; + node->color = DAG_BLACK; /* done */ + newlevel = ++level; - for (itA= node->parent; itA; itA= itA->next) { - if (itA->node->color==DAG_WHITE) { - itA->node->ancestor_count= dag_node_recurs_level(itA->node, level); - newlevel= MAX2(newlevel, level+itA->node->ancestor_count); + for (itA = node->parent; itA; itA = itA->next) { + if (itA->node->color == DAG_WHITE) { + itA->node->ancestor_count = dag_node_recurs_level(itA->node, level); + newlevel = MAX2(newlevel, level + itA->node->ancestor_count); } else - newlevel= MAX2(newlevel, level+itA->node->ancestor_count); + newlevel = MAX2(newlevel, level + itA->node->ancestor_count); } return newlevel; @@ -1043,22 +1044,22 @@ static void dag_check_cycle(DagForest *dag) /* debugging print */ if (dag_print_dependencies) - for (node = dag->DagNode.first; node; node= node->next) + for (node = dag->DagNode.first; node; node = node->next) dag_node_print_dependencies(node); /* tag nodes unchecked */ - for (node = dag->DagNode.first; node; node= node->next) - node->color= DAG_WHITE; + for (node = dag->DagNode.first; node; node = node->next) + node->color = DAG_WHITE; - for (node = dag->DagNode.first; node; node= node->next) { - if (node->color==DAG_WHITE) { - node->ancestor_count= dag_node_recurs_level(node, 0); + for (node = dag->DagNode.first; node; node = node->next) { + if (node->color == DAG_WHITE) { + node->ancestor_count = dag_node_recurs_level(node, 0); } } /* check relations, and print errors */ - for (node = dag->DagNode.first; node; node= node->next) { - for (itA= node->parent; itA; itA= itA->next) { + for (node = dag->DagNode.first; node; node = node->next) { + for (itA = node->parent; itA; itA = itA->next) { if (itA->node->ancestor_count > node->ancestor_count) { if (node->ob && itA->node->ob) { printf("Dependency cycle detected:\n"); @@ -1069,7 +1070,7 @@ static void dag_check_cycle(DagForest *dag) } /* parent relations are only needed for cycle checking, so free now */ - for (node = dag->DagNode.first; node; node= node->next) { + for (node = dag->DagNode.first; node; node = node->next) { while (node->parent) { itA = node->parent->next; MEM_freeN(node->parent); @@ -1082,7 +1083,7 @@ static void dag_check_cycle(DagForest *dag) * MainDAG is the DAG of all objects in current scene * used only for drawing there is one also in each scene */ -static DagForest * MainDag = NULL; +static DagForest *MainDag = NULL; DagForest *getMainDag(void) { @@ -1121,7 +1122,7 @@ void graph_bfs(void) /* fprintf(stderr, "starting BFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); - for ( i=0; i<50; i++) + for (i = 0; i < 50; i++) pos[i] = 0; /* Init @@ -1160,14 +1161,14 @@ void graph_bfs(void) itA = itA->next; } - if (pos[node->BFS_dist] > node->k ) { + if (pos[node->BFS_dist] > node->k) { pos[node->BFS_dist] += 1; node->k = (float) pos[node->BFS_dist]; } else { - pos[node->BFS_dist] = (int) node->k +1; + pos[node->BFS_dist] = (int) node->k + 1; } - set_node_xy(node, node->BFS_dist*DEPSX*2, pos[node->BFS_dist]*DEPSY*2); + set_node_xy(node, node->BFS_dist * DEPSX * 2, pos[node->BFS_dist] * DEPSY * 2); node->color = DAG_BLACK; // fprintf(stderr, "BFS node : %20s %i %5.0f %5.0f\n", ((ID *) node->ob)->name, node->BFS_dist, node->x, node->y); @@ -1190,7 +1191,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a DagNode *node; DagNodeQueue *nqueue; DagAdjList *itA; - int retval = 0; + int retval = 0; /* fprintf(stderr, "starting BFS\n ------------\n"); */ /* Init @@ -1238,7 +1239,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a } /* non recursive version of DFS, return queue -- outer loop present to catch odd cases (first level cycles)*/ -DagNodeQueue * graph_dfs(void) +DagNodeQueue *graph_dfs(void) { DagNode *node; DagNodeQueue *nqueue; @@ -1249,14 +1250,14 @@ DagNodeQueue * graph_dfs(void) int time; int skip = 0; int minheight; - int maxpos=0; + int maxpos = 0; /* int is_cycle = 0; */ /* UNUSED */ /* - *fprintf(stderr, "starting DFS\n ------------\n"); + *fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); retqueue = queue_create(MainDag->numNodes); - for ( i=0; i<50; i++) + for (i = 0; i < 50; i++) pos[i] = 0; /* Init @@ -1276,86 +1277,86 @@ DagNodeQueue * graph_dfs(void) node = MainDag->DagNode.first; do { - if (node->color == DAG_WHITE) { - node->color = DAG_GRAY; - node->DFS_dist = 1; - node->DFS_dvtm = time; - time++; - push_stack(nqueue, node); + if (node->color == DAG_WHITE) { + node->color = DAG_GRAY; + node->DFS_dist = 1; + node->DFS_dvtm = time; + time++; + push_stack(nqueue, node); - while (nqueue->count) { - //graph_print_queue(nqueue); + while (nqueue->count) { + //graph_print_queue(nqueue); - skip = 0; - node = get_top_node_queue(nqueue); + skip = 0; + node = get_top_node_queue(nqueue); - minheight = pos[node->DFS_dist]; + minheight = pos[node->DFS_dist]; - itA = node->child; - while (itA != NULL) { - if (itA->node->color == DAG_WHITE) { - itA->node->DFS_dvtm = time; - itA->node->color = DAG_GRAY; + itA = node->child; + while (itA != NULL) { + if (itA->node->color == DAG_WHITE) { + itA->node->DFS_dvtm = time; + itA->node->color = DAG_GRAY; - time++; - itA->node->DFS_dist = node->DFS_dist + 1; - itA->node->k = (float) minheight; - push_stack(nqueue, itA->node); - skip = 1; - break; - } - else { - if (itA->node->color == DAG_GRAY) { // back edge - fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); - /* is_cycle = 1; */ /* UNUSED */ + time++; + itA->node->DFS_dist = node->DFS_dist + 1; + itA->node->k = (float) minheight; + push_stack(nqueue, itA->node); + skip = 1; + break; } - else if (itA->node->color == DAG_BLACK) { - /* already processed node but we may want later to change distance either to shorter to longer. - * DFS_dist is the first encounter - */ + else { + if (itA->node->color == DAG_GRAY) { // back edge + fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); + /* is_cycle = 1; */ /* UNUSED */ + } + else if (itA->node->color == DAG_BLACK) { + /* already processed node but we may want later to change distance either to shorter to longer. + * DFS_dist is the first encounter + */ #if 0 - if (node->DFS_dist >= itA->node->DFS_dist) - itA->node->DFS_dist = node->DFS_dist + 1; + if (node->DFS_dist >= itA->node->DFS_dist) + itA->node->DFS_dist = node->DFS_dist + 1; fprintf(stderr, "dfs forward or cross edge :%15s %i-%i %15s %i-%i\n", - ((ID *) node->ob)->name, - node->DFS_dvtm, - node->DFS_fntm, - ((ID *) itA->node->ob)->name, - itA->node->DFS_dvtm, - itA->node->DFS_fntm); + ((ID *) node->ob)->name, + node->DFS_dvtm, + node->DFS_fntm, + ((ID *) itA->node->ob)->name, + itA->node->DFS_dvtm, + itA->node->DFS_fntm); #endif + } + else + fprintf(stderr, "dfs unknown edge\n"); } - else - fprintf(stderr, "dfs unknown edge\n"); + itA = itA->next; } - itA = itA->next; - } - if (!skip) { - node = pop_queue(nqueue); - node->color = DAG_BLACK; + if (!skip) { + node = pop_queue(nqueue); + node->color = DAG_BLACK; - node->DFS_fntm = time; - time++; - if (node->DFS_dist > maxpos) - maxpos = node->DFS_dist; - if (pos[node->DFS_dist] > node->k ) { - pos[node->DFS_dist] += 1; - node->k = (float) pos[node->DFS_dist]; - } - else { - pos[node->DFS_dist] = (int) node->k +1; - } - set_node_xy(node, node->DFS_dist*DEPSX*2, pos[node->DFS_dist]*DEPSY*2); + node->DFS_fntm = time; + time++; + if (node->DFS_dist > maxpos) + maxpos = node->DFS_dist; + if (pos[node->DFS_dist] > node->k) { + pos[node->DFS_dist] += 1; + node->k = (float) pos[node->DFS_dist]; + } + else { + pos[node->DFS_dist] = (int) node->k + 1; + } + set_node_xy(node, node->DFS_dist * DEPSX * 2, pos[node->DFS_dist] * DEPSY * 2); - // fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); + // fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); - push_stack(retqueue, node); + push_stack(retqueue, node); + } } } - } node = node->next; } while (node); // fprintf(stderr, "i size : %i\n", maxpos); @@ -1382,7 +1383,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a int skip = 0; int retval = 0; /* - *fprintf(stderr, "starting DFS\n ------------\n"); + * fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); @@ -1429,7 +1430,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a break; } else { - if (itA->node->color == DAG_GRAY) {// back edge + if (itA->node->color == DAG_GRAY) { // back edge retval = 1; } // else if (itA->node->color == DAG_BLACK) { // cross or forward @@ -1457,14 +1458,13 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a // used to get the obs owning a datablock -struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) -{ - DagNode * node, *node1; +struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob){ + DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; node = dag_find_node(dag, ob); - if (node==NULL) { + if (node == NULL) { return NULL; } else if (node->ancestor_count == 1) { // simple case @@ -1491,9 +1491,8 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) return nqueue; } -struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) -{ - DagNode * node, *node1; +struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob){ + DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; @@ -1520,8 +1519,7 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) } // standard DFS list -struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) -{ +struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob){ DagNode *node; DagNodeQueue *nqueue; DagNodeQueue *retqueue; @@ -1581,9 +1579,9 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) /* unused */ #if 0 -short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) +short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) { - DagNode * node; + DagNode *node; DagAdjList *itA; node = dag_find_node(dag, ob1); @@ -1599,7 +1597,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) } #endif -int is_acyclic(DagForest *dag) +int is_acyclic(DagForest *dag) { return dag->is_acyclic; } @@ -1634,9 +1632,9 @@ void graph_print_queue_dist(DagNodeQueue *nqueue) count = 0; while (queueElem) { fprintf(stderr, "** %25s %2.2i-%2.2i ", ((ID *) queueElem->node->ob)->name, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm); - while (count < queueElem->node->DFS_dvtm-1) { fputc(' ', stderr); count++;} + while (count < queueElem->node->DFS_dvtm - 1) { fputc(' ', stderr); count++; } fputc('|', stderr); - while (count < queueElem->node->DFS_fntm-2) { fputc('-', stderr); count++;} + while (count < queueElem->node->DFS_fntm - 2) { fputc('-', stderr); count++; } fputc('|', stderr); fputc('\n', stderr); count = 0; @@ -1668,13 +1666,13 @@ void graph_print_adj_list(void) /* mechanism to allow editors to be informed of depsgraph updates, * to do their own updates based on changes... */ -static void (*EditorsUpdateIDCb)(Main *bmain, ID *id)= NULL; -static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated)= NULL; +static void (*EditorsUpdateIDCb)(Main *bmain, ID *id) = NULL; +static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated) = NULL; void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated)) { - EditorsUpdateIDCb= id_func; - EditorsUpdateSceneCb= scene_func; + EditorsUpdateIDCb = id_func; + EditorsUpdateSceneCb = scene_func; } static void dag_editors_id_update(Main *bmain, ID *id) @@ -1698,37 +1696,37 @@ static void scene_sort_groups(Main *bmain, Scene *sce) Object *ob; /* test; are group objects all in this scene? */ - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ob->id.flag &= ~LIB_DOIT; - ob->id.newid= NULL; /* newid abuse for GroupObject */ + ob->id.newid = NULL; /* newid abuse for GroupObject */ } - for (base = sce->base.first; base; base= base->next) + for (base = sce->base.first; base; base = base->next) base->object->id.flag |= LIB_DOIT; - for (group= bmain->group.first; group; group= group->id.next) { - for (go= group->gobject.first; go; go= go->next) { - if ((go->ob->id.flag & LIB_DOIT)==0) + for (group = bmain->group.first; group; group = group->id.next) { + for (go = group->gobject.first; go; go = go->next) { + if ((go->ob->id.flag & LIB_DOIT) == 0) break; } /* this group is entirely in this scene */ - if (go==NULL) { - ListBase listb= {NULL, NULL}; + if (go == NULL) { + ListBase listb = {NULL, NULL}; - for (go= group->gobject.first; go; go= go->next) - go->ob->id.newid= (ID *)go; + for (go = group->gobject.first; go; go = go->next) + go->ob->id.newid = (ID *)go; /* in order of sorted bases we reinsert group objects */ - for (base = sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { if (base->object->id.newid) { - go= (GroupObject *)base->object->id.newid; - base->object->id.newid= NULL; + go = (GroupObject *)base->object->id.newid; + base->object->id.newid = NULL; BLI_remlink(&group->gobject, go); BLI_addtail(&listb, go); } } /* copy the newly sorted listbase */ - group->gobject= listb; + group->gobject = listb; } } } @@ -1744,7 +1742,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) ListBase tempbase; Base *base; - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA); @@ -1752,7 +1750,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) nqueue = queue_create(DAGQUEUEALLOC); - for (node = sce->theDag->DagNode.first; node; node= node->next) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { node->color = DAG_WHITE; } @@ -1785,7 +1783,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == sce) // we are done + if (node->ob == sce) // we are done break; node->color = DAG_BLACK; @@ -1807,7 +1805,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) BLI_remlink(&sce->base, base); BLI_addhead(&tempbase, base); //if (G.debug & G_DEBUG) - printf("cyclic %s\n", base->object->id.name); + printf("cyclic %s\n", base->object->id.name); base = sce->base.first; } @@ -1819,12 +1817,12 @@ void DAG_scene_sort(Main *bmain, Scene *sce) if (G.debug & G_DEBUG) { printf("\nordered\n"); - for (base = sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { printf(" %s\n", base->object->id.name); } } /* temporal...? */ - sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ + sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ } static void lib_id_recalc_tag(Main *bmain, ID *id) @@ -1842,26 +1840,26 @@ static void lib_id_recalc_data_tag(Main *bmain, ID *id) /* node was checked to have lasttime != curtime and is if type ID_OB */ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) { - Main *bmain= G.main; + Main *bmain = G.main; DagAdjList *itA; Object *ob, *obc; - int oldflag, changed=0; + int oldflag, changed = 0; unsigned int all_layer; - node->lasttime= curtime; + node->lasttime = curtime; - ob= node->ob; + ob = node->ob; if (ob && (ob->recalc & OB_RECALC_ALL)) { - all_layer= node->scelay; + all_layer = node->scelay; /* got an object node that changes, now check relations */ - for (itA = node->child; itA; itA= itA->next) { + for (itA = node->child; itA; itA = itA->next) { all_layer |= itA->lay; /* the relationship is visible */ if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) - if (itA->node->type==ID_OB) { - obc= itA->node->ob; - oldflag= obc->recalc; + if (itA->node->type == ID_OB) { + obc = itA->node->ob; + oldflag = obc->recalc; /* got a ob->obc relation, now check if flag needs flush */ if (ob->recalc & OB_RECALC_OB) { @@ -1888,12 +1886,12 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) lib_id_recalc_data_tag(bmain, &obc->id); } } - if (oldflag!=obc->recalc) changed= 1; + if (oldflag != obc->recalc) changed = 1; } } } /* even nicer, we can clear recalc flags... */ - if ((all_layer & layer)==0) { // XXX && (ob != obedit)) { + if ((all_layer & layer) == 0) { // XXX && (ob != obedit)) { /* but existing displaylists or derivedmesh should be freed */ if (ob->recalc & OB_RECALC_DATA) BKE_object_free_display(ob); @@ -1905,15 +1903,15 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) /* check case where child changes and parent forcing obdata to change */ /* should be done regardless if this ob has recalc set */ /* could merge this in with loop above...? (ton) */ - for (itA = node->child; itA; itA= itA->next) { + for (itA = node->child; itA; itA = itA->next) { /* the relationship is visible */ - if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) - if (itA->node->type==ID_OB) { - obc= itA->node->ob; + if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) + if (itA->node->type == ID_OB) { + obc = itA->node->ob; /* child moves */ - if ((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) { + if ((obc->recalc & OB_RECALC_ALL) == OB_RECALC_OB) { /* parent has deforming info */ - if (itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) { + if (itA->type & (DAG_RL_OB_DATA | DAG_RL_DATA_DATA)) { // printf("parent %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obc->id); @@ -1924,8 +1922,8 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) } /* we only go deeper if node not checked or something changed */ - for (itA = node->child; itA; itA= itA->next) { - if (changed || itA->node->lasttime!=curtime) + for (itA = node->child; itA; itA = itA->next) { + if (changed || itA->node->lasttime != curtime) flush_update_node(itA->node, layer, curtime); } @@ -1936,15 +1934,15 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) { DagAdjList *itA; - node->lasttime= curtime; - node->lay= node->scelay; + node->lasttime = curtime; + node->lay = node->scelay; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { - if (itA->node->lasttime!=curtime) { - itA->lay= flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { + if (itA->node->lasttime != curtime) { + itA->lay = flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation } - else itA->lay= itA->node->lay; + else itA->lay = itA->node->lay; node->lay |= itA->lay; } @@ -1956,16 +1954,16 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) /* node was checked to have lasttime != curtime, and is of type ID_OB */ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset) { - Main *bmain= G.main; + Main *bmain = G.main; DagAdjList *itA; Object *ob; - node->lasttime= curtime; + node->lasttime = curtime; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { - if (itA->node->lasttime!=curtime) { - ob= (Object*)(itA->node->ob); + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { + if (itA->node->lasttime != curtime) { + ob = (Object *)(itA->node->ob); if (reset || (ob->recalc & OB_RECALC_ALL)) { if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) { @@ -1990,18 +1988,18 @@ static void dag_scene_flush_layers(Scene *sce, int lay) Base *base; int lasttime; - firstnode= sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; // always scene node - for (itA = firstnode->child; itA; itA= itA->next) - itA->lay= 0; + for (itA = firstnode->child; itA; itA = itA->next) + itA->lay = 0; - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; /* update layer flags in nodes */ - for (base= sce->base.first; base; base= base->next) { - node= dag_get_node(sce->theDag, base->object); - node->scelay= base->object->lay; + for (base = sce->base.first; base; base = base->next) { + node = dag_get_node(sce->theDag, base->object); + node->scelay = base->object->lay; } /* ensure cameras are set as if they are on a visible layer, because @@ -2009,7 +2007,7 @@ static void dag_scene_flush_layers(Scene *sce, int lay) * * XXX, this wont work for local view / unlocked camera's */ if (sce->camera) { - node= dag_get_node(sce->theDag, sce->camera); + node = dag_get_node(sce->theDag, sce->camera); node->scelay |= lay; } @@ -2017,9 +2015,9 @@ static void dag_scene_flush_layers(Scene *sce, int lay) { TimeMarker *m; - for (m= sce->markers.first; m; m= m->next) { + for (m = sce->markers.first; m; m = m->next) { if (m->camera) { - node= dag_get_node(sce->theDag, m->camera); + node = dag_get_node(sce->theDag, m->camera); node->scelay |= lay; } } @@ -2027,8 +2025,8 @@ static void dag_scene_flush_layers(Scene *sce, int lay) #endif /* flush layer nodes to dependencies */ - for (itA = firstnode->child; itA; itA= itA->next) - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) + for (itA = firstnode->child; itA; itA = itA->next) + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) flush_layer_node(sce, itA->node, lasttime); } @@ -2037,16 +2035,16 @@ static void dag_tag_renderlayers(Scene *sce, unsigned int lay) if (sce->nodetree) { bNode *node; Base *base; - unsigned int lay_changed= 0; + unsigned int lay_changed = 0; - for (base= sce->base.first; base; base= base->next) + for (base = sce->base.first; base; base = base->next) if (base->lay & lay) if (base->object->recalc) lay_changed |= base->lay; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==(ID *)sce) { - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == (ID *)sce) { + SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); if (srl && (srl->lay & lay_changed)) nodeUpdate(sce->nodetree, node); } @@ -2062,30 +2060,30 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho Object *ob; int lasttime; - if (sce->theDag==NULL) { + if (sce->theDag == NULL) { printf("DAG zero... not allowed to happen!\n"); DAG_scene_sort(bmain, sce); } - firstnode= sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; // always scene node /* first we flush the layer flags */ dag_scene_flush_layers(sce, lay); /* then we use the relationships + layer info to flush update events */ - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; - for (itA = firstnode->child; itA; itA= itA->next) - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; + for (itA = firstnode->child; itA; itA = itA->next) + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) flush_update_node(itA->node, lay, lasttime); /* if update is not due to time change, do pointcache clears */ if (!time) { - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; - for (itA = firstnode->child; itA; itA= itA->next) { - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) { - ob= (Object*)(itA->node->ob); + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; + for (itA = firstnode->child; itA; itA = itA->next) { + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) { + ob = (Object *)(itA->node->ob); if (ob->recalc & OB_RECALC_ALL) { if (BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) { @@ -2109,7 +2107,7 @@ static int object_modifiers_use_time(Object *ob) ModifierData *md; /* check if a modifier in modifier stack needs time input */ - for (md=ob->modifiers.first; md; md=md->next) + for (md = ob->modifiers.first; md; md = md->next) if (modifier_dependsOnTime(md)) return 1; @@ -2148,14 +2146,14 @@ static short animdata_use_time(AnimData *adt) { NlaTrack *nlt; - if (adt==NULL) return 0; + if (adt == NULL) return 0; /* check action - only if assigned, and it has anim curves */ if (adt->action && adt->action->curves.first) return 1; /* check NLA tracks + strips */ - for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { if (nlt->strips.first) return 1; } @@ -2184,8 +2182,8 @@ static void dag_object_time_update_flags(Object *ob) { if (ob->constraints.first) { bConstraint *con; - for (con = ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -2197,7 +2195,7 @@ static void dag_object_time_update_flags(Object *ob) else if (cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar) { ob->recalc |= OB_RECALC_OB; break; @@ -2214,7 +2212,7 @@ static void dag_object_time_update_flags(Object *ob) if (ob->parent) { /* motion path or bone child */ - if (ob->parent->type==OB_CURVE || ob->parent->type==OB_ARMATURE) ob->recalc |= OB_RECALC_OB; + if (ob->parent->type == OB_CURVE || ob->parent->type == OB_ARMATURE) ob->recalc |= OB_RECALC_OB; } #if 0 // XXX old animation system @@ -2222,7 +2220,7 @@ static void dag_object_time_update_flags(Object *ob) if (ob->dup_group) { bActionStrip *strip; /* this case is for groups with nla, whilst nla target has no action or nla */ - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) strip->object->recalc |= OB_RECALC_ALL; } @@ -2235,20 +2233,20 @@ static void dag_object_time_update_flags(Object *ob) ob->adt->recalc |= ADT_RECALC_ANIM; } - if ((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA; + if ((ob->adt) && (ob->type == OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA; if (object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA; if ((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA; { - AnimData *adt= BKE_animdata_from_id((ID *)ob->data); + AnimData *adt = BKE_animdata_from_id((ID *)ob->data); Mesh *me; Curve *cu; Lattice *lt; switch (ob->type) { case OB_MESH: - me= ob->data; + me = ob->data; if (me->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; @@ -2259,7 +2257,7 @@ static void dag_object_time_update_flags(Object *ob) break; case OB_CURVE: case OB_SURF: - cu= ob->data; + cu = ob->data; if (cu->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; @@ -2267,18 +2265,18 @@ static void dag_object_time_update_flags(Object *ob) } break; case OB_FONT: - cu= ob->data; - if (cu->nurb.first==NULL && cu->str && cu->vfont) + cu = ob->data; + if (cu->nurb.first == NULL && cu->str && cu->vfont) ob->recalc |= OB_RECALC_DATA; break; case OB_LATTICE: - lt= ob->data; + lt = ob->data; if (lt->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; } } - break; + break; case OB_MBALL: if (ob->transflag & OB_DUPLI) ob->recalc |= OB_RECALC_DATA; break; @@ -2290,9 +2288,9 @@ static void dag_object_time_update_flags(Object *ob) } if (ob->particlesystem.first) { - ParticleSystem *psys= ob->particlesystem.first; + ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { if (psys_check_enabled(ob, psys)) { ob->recalc |= OB_RECALC_DATA; break; @@ -2319,7 +2317,7 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s /* set ob flags where animated systems are */ for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; + ob = base->object; if (do_time) { /* now if DagNode were part of base, the node->lay could be checked... */ @@ -2334,22 +2332,22 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s if (do_time) { /* we do groups each once */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { dag_object_time_update_flags(go->ob); } } } } - for (sce_iter= scene; sce_iter; sce_iter= sce_iter->set) + for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set) DAG_scene_flush_update(bmain, sce_iter, lay, 1); if (do_time) { /* test: set time flag, to disable baked systems to update */ for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; + ob = base->object; if (ob->recalc) ob->recalc |= OB_RECALC_TIME; } @@ -2360,10 +2358,10 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s } /* and store the info in groupobject */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { - go->recalc= go->ob->recalc; + for (go = group->gobject.first; go; go = go->next) { + go->recalc = go->ob->recalc; // printf("ob %s recalc %d\n", go->ob->id.name, go->recalc); } group->id.flag &= ~LIB_DOIT; @@ -2380,22 +2378,22 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay /* only one scene supported currently, making more scenes work * correctly requires changes beyond just the dependency graph */ - *sce= NULL; - *lay= 0; + *sce = NULL; + *lay = 0; - if ((wm= bmain->wm.first)) { + if ((wm = bmain->wm.first)) { /* if we have a windowmanager, look into windows */ - for (win=wm->windows.first; win; win=win->next) { + for (win = wm->windows.first; win; win = win->next) { if (win->screen) { - if (!*sce) *sce= win->screen->scene; + if (!*sce) *sce = win->screen->scene; *lay |= BKE_screen_visible_layers(win->screen, win->screen->scene); } } } else { /* if not, use the first sce */ - *sce= bmain->scene.first; - if (*sce) *lay= (*sce)->lay; + *sce = bmain->scene.first; + if (*sce) *lay = (*sce)->lay; /* XXX for background mode, we should get the scene * from somewhere, for the -S option, but it's in @@ -2435,9 +2433,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) dag_scene_flush_layers(scene, lay); for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; - node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL; - oblay= (node)? node->lay: ob->lay; + ob = base->object; + node = (sce_iter->theDag) ? dag_get_node(sce_iter->theDag, ob) : NULL; + oblay = (node) ? node->lay : ob->lay; if ((oblay & lay) & ~scene->lay_updated) { if (ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) @@ -2447,9 +2445,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) } } - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) go->ob->recalc |= OB_RECALC_DATA; if (go->ob->proxy_from) @@ -2473,7 +2471,7 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS { struct { ID *id; int is_dependent; } *data = userData; - if (*idpoin && GS((*idpoin)->name)==ID_TE) { + if (*idpoin && GS((*idpoin)->name) == ID_TE) { if (data->id == (*idpoin)) data->is_dependent = 1; } @@ -2481,8 +2479,8 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS static void dag_id_flush_update(Scene *sce, ID *id) { - Main *bmain= G.main; - Object *obt, *ob= NULL; + Main *bmain = G.main; + Object *obt, *ob = NULL; short idtype; /* here we flush a few things before actual scene wide flush, mostly @@ -2490,27 +2488,27 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags & pointcache for object */ if (GS(id->name) == ID_OB) { - ob= (Object*)id; + ob = (Object *)id; BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); if (ob->recalc & OB_RECALC_DATA) { /* all users of this ob->data should be checked */ - id= ob->data; + id = ob->data; /* no point in trying in this cases */ if (id && id->us <= 1) { dag_editors_id_update(bmain, id); - id= NULL; + id = NULL; } } } /* set flags & pointcache for object data */ if (id) { - idtype= GS(id->name); + idtype = GS(id->name); if (ELEM8(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR, ID_SPK)) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { if (!(ob && obt == ob) && obt->data == id) { obt->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obt->id); @@ -2521,10 +2519,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on textures - can influence depgraph via modifiers */ if (idtype == ID_TE) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { struct { ID *id; int is_dependent; } data; - data.id= id; - data.is_dependent= 0; + data.id = id; + data.is_dependent = 0; modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); if (data.is_dependent) { @@ -2537,11 +2535,11 @@ static void dag_id_flush_update(Scene *sce, ID *id) ParticleSystem *psys = obt->particlesystem.first; MTex **mtexp, *mtex; int a; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { mtexp = psys->part->mtex; - for (a=0; a<MAX_MTEX; a++, mtexp++) { + for (a = 0; a < MAX_MTEX; a++, mtexp++) { mtex = *mtexp; - if (mtex && mtex->tex == (Tex*)id) { + if (mtex && mtex->tex == (Tex *)id) { obt->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obt->id); @@ -2560,10 +2558,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on ShapeKey */ if (idtype == ID_KE) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { - Key *key= ob_get_key(obt); + for (obt = bmain->object.first; obt; obt = obt->id.next) { + Key *key = ob_get_key(obt); if (!(ob && obt == ob) && ((ID *)key == id)) { - obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA); + obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA); lib_id_recalc_tag(bmain, &obt->id); lib_id_recalc_data_tag(bmain, &obt->id); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); @@ -2574,8 +2572,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on particle settings */ if (idtype == ID_PA) { ParticleSystem *psys; - for (obt=bmain->object.first; obt; obt= obt->id.next) - for (psys=obt->particlesystem.first; psys; psys=psys->next) + for (obt = bmain->object.first; obt; obt = obt->id.next) + for (psys = obt->particlesystem.first; psys; psys = psys->next) if (&psys->part->id == id) BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } @@ -2585,12 +2583,12 @@ static void dag_id_flush_update(Scene *sce, ID *id) BKE_tracking_dopesheet_tag_update(&clip->tracking); - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { bConstraint *con; - for (con = obt->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = obt->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, - CONSTRAINT_TYPE_OBJECTSOLVER)) + CONSTRAINT_TYPE_OBJECTSOLVER)) { obt->recalc |= OB_RECALC_OB; break; @@ -2601,8 +2599,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) if (sce->nodetree) { bNode *node; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==id) { + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == id) { nodeUpdate(sce->nodetree, node); } } @@ -2646,8 +2644,8 @@ void DAG_ids_flush_tagged(Main *bmain) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - for (; id; id=id->next) { - if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) { + for (; id; id = id->next) { + if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) { dag_id_flush_update(sce, id); do_flush = 1; } @@ -2675,7 +2673,7 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - updated= 1; + updated = 1; break; } } @@ -2698,9 +2696,9 @@ void DAG_ids_clear_recalc(Main *bmain) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - for (; id; id=id->next) - if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) - id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA); + for (; id; id = id->next) + if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) + id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA); } } @@ -2709,15 +2707,15 @@ void DAG_ids_clear_recalc(Main *bmain) void DAG_id_tag_update(ID *id, short flag) { - Main *bmain= G.main; + Main *bmain = G.main; - if (id==NULL) return; + if (id == NULL) return; /* tag ID for update */ if (flag) { if (flag & OB_RECALC_OB) lib_id_recalc_tag(bmain, id); - if (flag & (OB_RECALC_DATA|PSYS_RECALC)) + if (flag & (OB_RECALC_DATA | PSYS_RECALC)) lib_id_recalc_data_tag(bmain, id); } else @@ -2730,14 +2728,14 @@ void DAG_id_tag_update(ID *id, short flag) if (idtype == ID_OB) { /* only quick tag */ - ob = (Object*)id; + ob = (Object *)id; ob->recalc |= (flag & OB_RECALC_ALL); } else if (idtype == ID_PA) { ParticleSystem *psys; /* this is weak still, should be done delayed as well */ - for (ob=bmain->object.first; ob; ob=ob->id.next) { - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { if (&psys->part->id == id) { ob->recalc |= (flag & OB_RECALC_ALL); psys->recalc |= (flag & PSYS_RECALC); @@ -2757,12 +2755,12 @@ void DAG_id_tag_update(ID *id, short flag) void DAG_id_type_tag(struct Main *bmain, short idtype) { - bmain->id_tag_update[((char*)&idtype)[0]] = 1; + bmain->id_tag_update[((char *)&idtype)[0]] = 1; } int DAG_id_type_tagged(Main *bmain, short idtype) { - return bmain->id_tag_update[((char*)&idtype)[0]]; + return bmain->id_tag_update[((char *)&idtype)[0]]; } #if 0 // UNUSED @@ -2772,22 +2770,22 @@ static int parent_check_node(DagNode *node, int curtime) { DagAdjList *itA; - node->lasttime= curtime; + node->lasttime = curtime; - if (node->color==DAG_GRAY) + if (node->color == DAG_GRAY) return DAG_GRAY; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { - if (itA->node->color==DAG_GRAY) + if (itA->node->color == DAG_GRAY) return DAG_GRAY; /* descend if not done */ - if (itA->node->lasttime!=curtime) { - itA->node->color= parent_check_node(itA->node, curtime); + if (itA->node->lasttime != curtime) { + itA->node->color = parent_check_node(itA->node, curtime); - if (itA->node->color==DAG_GRAY) + if (itA->node->color == DAG_GRAY) return DAG_GRAY; } } @@ -2802,7 +2800,7 @@ static int parent_check_node(DagNode *node, int curtime) /* we assume its an armature with pose */ void DAG_pose_sort(Object *ob) { - bPose *pose= ob->pose; + bPose *pose = ob->pose; bPoseChannel *pchan; bConstraint *con; DagNode *node; @@ -2815,12 +2813,12 @@ void DAG_pose_sort(Object *ob) int skip = 0; dag = dag_init(); - ugly_hack_sorry= 0; // no ID structs + ugly_hack_sorry = 0; // no ID structs - rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL + rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL /* we add the hierarchy and the constraints */ - for (pchan = pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { int addtoroot = 1; node = dag_get_node(dag, pchan); @@ -2830,40 +2828,40 @@ void DAG_pose_sort(Object *ob) dag_add_relation(dag, node2, node, 0, "Parent Relation"); addtoroot = 0; } - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = pchan->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->subtarget[0]) { - bPoseChannel *target= BKE_pose_channel_find_name(ob->pose, ct->subtarget); + for (ct = targets.first; ct; ct = ct->next) { + if (ct->tar == ob && ct->subtarget[0]) { + bPoseChannel *target = BKE_pose_channel_find_name(ob->pose, ct->subtarget); if (target) { - node2= dag_get_node(dag, target); + node2 = dag_get_node(dag, target); dag_add_relation(dag, node2, node, 0, "Pose Constraint"); - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = (bKinematicConstraint *)con->data; bPoseChannel *parchan; - int segcount= 0; + int segcount = 0; /* exclude tip from chain? */ if (!(data->flag & CONSTRAINT_IK_TIP)) - parchan= pchan->parent; + parchan = pchan->parent; else - parchan= pchan; + parchan = pchan; /* Walk to the chain's root */ while (parchan) { - node3= dag_get_node(dag, parchan); + node3 = dag_get_node(dag, parchan); dag_add_relation(dag, node2, node3, 0, "IK Constraint"); segcount++; - if (segcount==data->rootbone || segcount>255) break; // 255 is weak - parchan= parchan->parent; + if (segcount == data->rootbone || segcount > 255) break; // 255 is weak + parchan = parchan->parent; } } } @@ -2874,7 +2872,7 @@ void DAG_pose_sort(Object *ob) cti->flush_constraint_targets(con, &targets, 1); } } - if (addtoroot == 1 ) { + if (addtoroot == 1) { dag_add_relation(dag, rootnode, node, 0, "Root Bone Relation"); } } @@ -2882,12 +2880,12 @@ void DAG_pose_sort(Object *ob) dag_check_cycle(dag); /* now we try to sort... */ - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; nqueue = queue_create(DAGQUEUEALLOC); /* tag nodes unchecked */ - for (node = dag->DagNode.first; node; node= node->next) + for (node = dag->DagNode.first; node; node = node->next) node->color = DAG_WHITE; rootnode->color = DAG_GRAY; @@ -2912,7 +2910,7 @@ void DAG_pose_sort(Object *ob) if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == NULL) // we are done + if (node->ob == NULL) // we are done break; node->color = DAG_BLACK; @@ -2925,7 +2923,7 @@ void DAG_pose_sort(Object *ob) /* temporal correction for circular dependencies */ while (pose->chanbase.first) { - pchan= pose->chanbase.first; + pchan = pose->chanbase.first; BLI_remlink(&pose->chanbase, pchan); BLI_addhead(&tempbase, pchan); @@ -2943,7 +2941,7 @@ void DAG_pose_sort(Object *ob) free_forest(dag); MEM_freeN(dag); - ugly_hack_sorry= 1; + ugly_hack_sorry = 1; } /* ************************ DAG DEBUGGING ********************* */ @@ -2951,17 +2949,17 @@ void DAG_pose_sort(Object *ob) void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob) { /* utility for debugging dependencies */ - dag_print_dependencies= 1; + dag_print_dependencies = 1; if (ob && (ob->mode & OB_MODE_POSE)) { - printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2); + printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name + 2); DAG_pose_sort(ob); } else { - printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name+2); + printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name + 2); DAG_scene_sort(bmain, scene); } - dag_print_dependencies= 0; + dag_print_dependencies = 0; } |