2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2013 Blender Foundation.
19 * All rights reserved.
21 * Original Author: Joshua Leung
22 * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013)
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file blender/depsgraph/intern/builder/deg_builder_relations.cc
30 * Methods for constructing depsgraph
33 #include "intern/builder/deg_builder_relations.h"
39 #include "MEM_guardedalloc.h"
42 #include "BLI_blenlib.h"
43 #include "BLI_string.h"
44 #include "BLI_utildefines.h"
46 #include "DNA_action_types.h"
47 #include "DNA_anim_types.h"
48 #include "DNA_armature_types.h"
49 #include "DNA_camera_types.h"
50 #include "DNA_constraint_types.h"
51 #include "DNA_curve_types.h"
52 #include "DNA_effect_types.h"
53 #include "DNA_gpencil_types.h"
54 #include "DNA_group_types.h"
55 #include "DNA_key_types.h"
56 #include "DNA_lamp_types.h"
57 #include "DNA_material_types.h"
58 #include "DNA_mesh_types.h"
59 #include "DNA_meta_types.h"
60 #include "DNA_node_types.h"
61 #include "DNA_object_types.h"
62 #include "DNA_rigidbody_types.h"
63 #include "DNA_scene_types.h"
64 #include "DNA_texture_types.h"
65 #include "DNA_world_types.h"
67 #include "BKE_action.h"
68 #include "BKE_armature.h"
69 #include "BKE_animsys.h"
70 #include "BKE_constraint.h"
71 #include "BKE_curve.h"
72 #include "BKE_effect.h"
73 #include "BKE_fcurve.h"
74 #include "BKE_group.h"
76 #include "BKE_library.h"
78 #include "BKE_material.h"
79 #include "BKE_mball.h"
80 #include "BKE_modifier.h"
82 #include "BKE_object.h"
83 #include "BKE_rigidbody.h"
84 #include "BKE_sound.h"
85 #include "BKE_texture.h"
86 #include "BKE_tracking.h"
87 #include "BKE_world.h"
89 #include "DEG_depsgraph.h"
90 #include "DEG_depsgraph_build.h"
92 #include "RNA_access.h"
93 #include "RNA_types.h"
96 #include "intern/builder/deg_builder.h"
97 #include "intern/builder/deg_builder_pchanmap.h"
99 #include "intern/nodes/deg_node.h"
100 #include "intern/nodes/deg_node_component.h"
101 #include "intern/nodes/deg_node_operation.h"
103 #include "intern/depsgraph_intern.h"
104 #include "intern/depsgraph_types.h"
106 #include "util/deg_util_foreach.h"
110 /* ***************** */
111 /* Relations Builder */
113 /* **** General purpose functions **** */
115 RNAPathKey::RNAPathKey(ID *id, const char *path) :
118 /* create ID pointer for root of path lookup */
120 RNA_id_pointer_create(id, &id_ptr);
121 /* try to resolve path... */
123 if (!RNA_path_resolve_full(&id_ptr, path, &this->ptr, &this->prop, &index)) {
124 this->ptr = PointerRNA_NULL;
129 DepsgraphRelationBuilder::DepsgraphRelationBuilder(Depsgraph *graph) :
134 RootDepsNode *DepsgraphRelationBuilder::find_node(const RootKey &key) const
137 BLI_assert(!"Doesn't seem to be correct");
138 return m_graph->root_node;
141 TimeSourceDepsNode *DepsgraphRelationBuilder::find_node(
142 const TimeSourceKey &key) const
149 return m_graph->root_node->time_source;
153 ComponentDepsNode *DepsgraphRelationBuilder::find_node(
154 const ComponentKey &key) const
156 IDDepsNode *id_node = m_graph->find_id_node(key.id);
158 fprintf(stderr, "find_node component: Could not find ID %s\n",
159 (key.id != NULL) ? key.id->name : "<null>");
163 ComponentDepsNode *node = id_node->find_component(key.type, key.name);
167 OperationDepsNode *DepsgraphRelationBuilder::find_node(
168 const OperationKey &key) const
170 IDDepsNode *id_node = m_graph->find_id_node(key.id);
172 fprintf(stderr, "find_node operation: Could not find ID\n");
176 ComponentDepsNode *comp_node = id_node->find_component(key.component_type,
179 fprintf(stderr, "find_node operation: Could not find component\n");
183 OperationDepsNode *op_node = comp_node->find_operation(key.opcode, key.name);
185 fprintf(stderr, "find_node_operation: Failed for (%s, '%s')\n",
186 DEG_OPNAMES[key.opcode], key.name.c_str());
191 DepsNode *DepsgraphRelationBuilder::find_node(const RNAPathKey &key) const
193 return m_graph->find_node_from_pointer(&key.ptr, key.prop);
196 OperationDepsNode *DepsgraphRelationBuilder::has_node(
197 const OperationKey &key) const
199 IDDepsNode *id_node = m_graph->find_id_node(key.id);
203 ComponentDepsNode *comp_node = id_node->find_component(key.component_type,
208 return comp_node->has_operation(key.opcode, key.name);
211 void DepsgraphRelationBuilder::add_time_relation(TimeSourceDepsNode *timesrc,
213 const char *description)
215 if (timesrc && node_to) {
216 m_graph->add_new_relation(timesrc, node_to, DEPSREL_TYPE_TIME, description);
219 DEG_DEBUG_PRINTF("add_time_relation(%p = %s, %p = %s, %s) Failed\n",
220 timesrc, (timesrc) ? timesrc->identifier().c_str() : "<None>",
221 node_to, (node_to) ? node_to->identifier().c_str() : "<None>",
226 void DepsgraphRelationBuilder::add_operation_relation(
227 OperationDepsNode *node_from,
228 OperationDepsNode *node_to,
229 eDepsRelation_Type type,
230 const char *description)
232 if (node_from && node_to) {
233 m_graph->add_new_relation(node_from, node_to, type, description);
236 DEG_DEBUG_PRINTF("add_operation_relation(%p = %s, %p = %s, %d, %s) Failed\n",
237 node_from, (node_from) ? node_from->identifier().c_str() : "<None>",
238 node_to, (node_to) ? node_to->identifier().c_str() : "<None>",
243 /* **** Functions to build relations between entities **** */
245 void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
247 /* LIB_TAG_DOIT is used to indicate whether node for given ID was already
250 BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
251 /* XXX nested node trees are not included in tag-clearing above,
252 * so we need to do this manually.
254 FOREACH_NODETREE(bmain, nodetree, id) {
255 if (id != (ID *)nodetree)
256 nodetree->id.tag &= ~LIB_TAG_DOIT;
257 } FOREACH_NODETREE_END
260 // TODO: link set to scene, especially our timesource...
264 for (Base *base = (Base *)scene->base.first; base; base = base->next) {
265 Object *ob = base->object;
267 /* Object that this is a proxy for.
268 * Just makes sure backlink is correct.
271 ob->proxy->proxy_from = ob;
275 build_object(bmain, scene, ob);
277 /* object that this is a proxy for */
279 build_object(bmain, scene, ob->proxy);
280 /* TODO(sergey): This is an inverted relation, matches old depsgraph
281 * behavior and need to be investigated if it still need to be inverted.
283 ComponentKey ob_pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE);
284 ComponentKey proxy_pose_key(&ob->proxy->id, DEPSNODE_TYPE_EVAL_POSE);
285 add_relation(ob_pose_key, proxy_pose_key, DEPSREL_TYPE_TRANSFORM, "Proxy");
288 /* Object dupligroup. */
290 build_group(bmain, scene, ob, ob->dup_group);
295 if (scene->rigidbody_world) {
296 build_rigidbody(scene);
299 /* scene's animation and drivers */
301 build_animdata(&scene->id);
306 build_world(scene->world);
310 if (scene->nodetree) {
311 build_compositor(scene);
316 build_gpencil(&scene->id, scene->gpd);
319 for (Depsgraph::OperationNodes::const_iterator it_op = m_graph->operations.begin();
320 it_op != m_graph->operations.end();
323 OperationDepsNode *node = *it_op;
324 IDDepsNode *id_node = node->owner->owner;
325 ID *id = id_node->id;
326 if (GS(id->name) == ID_OB) {
327 Object *object = (Object *)id;
328 object->customdata_mask |= node->customdata_mask;
333 void DepsgraphRelationBuilder::build_group(Main *bmain,
338 ID *group_id = &group->id;
339 bool group_done = (group_id->tag & LIB_TAG_DOIT) != 0;
340 OperationKey object_local_transform_key(&object->id,
341 DEPSNODE_TYPE_TRANSFORM,
342 DEG_OPCODE_TRANSFORM_LOCAL);
343 for (GroupObject *go = (GroupObject *)group->gobject.first;
348 build_object(bmain, scene, go->ob);
350 ComponentKey dupli_transform_key(&go->ob->id, DEPSNODE_TYPE_TRANSFORM);
351 add_relation(dupli_transform_key,
352 object_local_transform_key,
353 DEPSREL_TYPE_TRANSFORM,
356 group_id->tag |= LIB_TAG_DOIT;
359 void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *ob)
361 if (ob->id.tag & LIB_TAG_DOIT) {
365 /* Object Transforms */
366 eDepsOperation_Code base_op = (ob->parent) ? DEG_OPCODE_TRANSFORM_PARENT : DEG_OPCODE_TRANSFORM_LOCAL;
367 OperationKey base_op_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, base_op);
369 OperationKey local_transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL);
370 OperationKey parent_transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_PARENT);
371 OperationKey final_transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
373 OperationKey ob_ubereval_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_OBJECT_UBEREVAL);
377 /* parent relationship */
378 build_object_parent(ob);
380 /* local -> parent */
381 add_relation(local_transform_key, parent_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "[ObLocal -> ObParent]");
384 /* object constraints */
385 if (ob->constraints.first) {
386 OperationKey constraint_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_CONSTRAINTS);
388 /* constraint relations */
389 // TODO: provide base op
390 // XXX: this is broken
391 build_constraints(scene, &ob->id, DEPSNODE_TYPE_TRANSFORM, "", &ob->constraints, NULL);
393 /* operation order */
394 add_relation(base_op_key, constraint_key, DEPSREL_TYPE_COMPONENT_ORDER, "[ObBase-> Constraint Stack]");
395 add_relation(constraint_key, final_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "[ObConstraints -> Done]");
398 add_relation(constraint_key, ob_ubereval_key, DEPSREL_TYPE_COMPONENT_ORDER, "Temp Ubereval");
399 add_relation(ob_ubereval_key, final_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "Temp Ubereval");
402 /* operation order */
403 add_relation(base_op_key, final_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "Object Transform");
406 add_relation(base_op_key, ob_ubereval_key, DEPSREL_TYPE_COMPONENT_ORDER, "Temp Ubereval");
407 add_relation(ob_ubereval_key, final_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "Temp Ubereval");
412 build_animdata(&ob->id);
414 // XXX: This should be hooked up by the build_animdata code
415 if (ob->adt && (ob->adt->action || ob->adt->nla_tracks.first)) {
416 ComponentKey adt_key(&ob->id, DEPSNODE_TYPE_ANIMATION);
417 add_relation(adt_key, local_transform_key, DEPSREL_TYPE_OPERATION, "Object Animation");
423 ID *obdata_id = (ID *)ob->data;
425 /* ob data animation */
426 build_animdata(obdata_id);
428 /* type-specific data... */
430 case OB_MESH: /* Geometry */
437 build_obdata_geom(bmain, scene, ob);
441 case OB_ARMATURE: /* Pose */
442 if (ob->id.lib != NULL && ob->proxy_from != NULL) {
446 build_rig(scene, ob);
450 case OB_LAMP: /* Lamp */
454 case OB_CAMERA: /* Camera */
459 Key *key = BKE_key_from_object(ob);
461 ComponentKey geometry_key((ID *)ob->data, DEPSNODE_TYPE_GEOMETRY);
462 ComponentKey key_key(&key->id, DEPSNODE_TYPE_GEOMETRY);
463 add_relation(key_key, geometry_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Shapekeys");
469 build_gpencil(&ob->id, ob->gpd);
473 void DepsgraphRelationBuilder::build_object_parent(Object *ob)
475 /* XXX: for now, need to use the component key (not just direct to the parent op), or else the matrix doesn't get reset */
476 // XXX: @sergey - it would be good if we got that backwards flushing working when tagging for updates
477 //OperationKey ob_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_PARENT);
478 ComponentKey ob_key(&ob->id, DEPSNODE_TYPE_TRANSFORM);
480 /* type-specific links */
481 switch (ob->partype) {
482 case PARSKEL: /* Armature Deform (Virtual Modifier) */
484 ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_TRANSFORM);
485 add_relation(parent_key, ob_key, DEPSREL_TYPE_STANDARD, "Armature Deform Parent");
489 case PARVERT1: /* Vertex Parent */
492 ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_GEOMETRY);
493 add_relation(parent_key, ob_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Vertex Parent");
495 /* XXX not sure what this is for or how you could be done properly - lukas */
496 OperationDepsNode *parent_node = find_operation_node(parent_key);
497 if (parent_node != NULL) {
498 parent_node->customdata_mask |= CD_MASK_ORIGINDEX;
501 ComponentKey transform_key(&ob->parent->id, DEPSNODE_TYPE_TRANSFORM);
502 add_relation(transform_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Vertex Parent TFM");
506 case PARBONE: /* Bone Parent */
508 ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_BONE, ob->parsubstr);
509 add_relation(parent_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Bone Parent");
515 if (ob->parent->type == OB_LATTICE) {
516 /* Lattice Deform Parent - Virtual Modifier */
517 // XXX: no virtual modifiers should be left!
518 ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_TRANSFORM);
519 ComponentKey geom_key(&ob->parent->id, DEPSNODE_TYPE_GEOMETRY);
521 add_relation(parent_key, ob_key, DEPSREL_TYPE_STANDARD, "Lattice Deform Parent");
522 add_relation(geom_key, ob_key, DEPSREL_TYPE_STANDARD, "Lattice Deform Parent Geom");
524 else if (ob->parent->type == OB_CURVE) {
525 Curve *cu = (Curve *)ob->parent->data;
527 if (cu->flag & CU_PATH) {
529 ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_GEOMETRY);
530 add_relation(parent_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Curve Follow Parent");
532 ComponentKey transform_key(&ob->parent->id, DEPSNODE_TYPE_TRANSFORM);
533 add_relation(transform_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Curve Follow TFM");
536 /* Standard Parent */
537 ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_TRANSFORM);
538 add_relation(parent_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Curve Parent");
542 /* Standard Parent */
543 ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_TRANSFORM);
544 add_relation(parent_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Parent");
550 /* exception case: parent is duplivert */
551 if ((ob->type == OB_MBALL) && (ob->parent->transflag & OB_DUPLIVERTS)) {
552 //dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Duplivert");
556 void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, eDepsNode_Type component_type, const char *component_subdata,
557 ListBase *constraints, RootPChanMap *root_map)
559 OperationKey constraint_op_key(id, component_type, component_subdata,
560 (component_type == DEPSNODE_TYPE_BONE) ? DEG_OPCODE_BONE_CONSTRAINTS : DEG_OPCODE_TRANSFORM_CONSTRAINTS);
562 /* add dependencies for each constraint in turn */
563 for (bConstraint *con = (bConstraint *)constraints->first; con; con = con->next) {
564 const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
566 /* invalid constraint type... */
570 /* special case for camera tracking -- it doesn't use targets to define relations */
571 // TODO: we can now represent dependencies in a much richer manner, so review how this is done...
572 if (ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) {
573 bool depends_on_camera = false;
575 if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
576 bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data;
578 if (((data->clip) || (data->flag & FOLLOWTRACK_ACTIVECLIP)) && data->track[0])
579 depends_on_camera = true;
581 if (data->depth_ob) {
582 // DAG_RL_DATA_OB | DAG_RL_OB_OB
583 ComponentKey depth_key(&data->depth_ob->id, DEPSNODE_TYPE_TRANSFORM);
584 add_relation(depth_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
587 else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
588 depends_on_camera = true;
591 if (depends_on_camera && scene->camera) {
592 // DAG_RL_DATA_OB | DAG_RL_OB_OB
593 ComponentKey camera_key(&scene->camera->id, DEPSNODE_TYPE_TRANSFORM);
594 add_relation(camera_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
597 /* TODO(sergey): This is more a TimeSource -> MovieClip -> Constraint dependency chain. */
598 TimeSourceKey time_src_key;
599 add_relation(time_src_key, constraint_op_key, DEPSREL_TYPE_TIME, "[TimeSrc -> Animation]");
601 else if (cti->get_constraint_targets) {
602 ListBase targets = {NULL, NULL};
603 cti->get_constraint_targets(con, &targets);
605 for (bConstraintTarget *ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) {
609 if (ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK)) {
610 /* ignore IK constraints - these are handled separately (on pose level) */
612 else if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) {
613 /* these constraints require path geometry data... */
614 ComponentKey target_key(&ct->tar->id, DEPSNODE_TYPE_GEOMETRY);
615 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_GEOMETRY_EVAL, cti->name); // XXX: type = geom_transform
616 // TODO: path dependency
618 else if ((ct->tar->type == OB_ARMATURE) && (ct->subtarget[0])) {
620 if (&ct->tar->id == id) {
622 eDepsOperation_Code target_key_opcode;
624 /* Using "done" here breaks in-chain deps, while using "ready" here breaks most production rigs instead...
625 * So, we do a compromise here, and only do this when an IK chain conflict may occur
627 if (root_map->has_common_root(component_subdata, ct->subtarget)) {
628 target_key_opcode = DEG_OPCODE_BONE_READY;
631 target_key_opcode = DEG_OPCODE_BONE_DONE;
634 OperationKey target_key(&ct->tar->id, DEPSNODE_TYPE_BONE, ct->subtarget, target_key_opcode);
635 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
638 /* different armature - we can safely use the result of that */
639 OperationKey target_key(&ct->tar->id, DEPSNODE_TYPE_BONE, ct->subtarget, DEG_OPCODE_BONE_DONE);
640 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
643 else if (ELEM(ct->tar->type, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) {
645 /* NOTE: for now, we don't need to represent vertex groups separately... */
646 ComponentKey target_key(&ct->tar->id, DEPSNODE_TYPE_GEOMETRY);
647 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_GEOMETRY_EVAL, cti->name);
649 if (ct->tar->type == OB_MESH) {
650 OperationDepsNode *node2 = find_operation_node(target_key);
652 node2->customdata_mask |= CD_MASK_MDEFORMVERT;
656 else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
657 /* Constraints which requires the target object surface. */
658 ComponentKey target_key(&ct->tar->id, DEPSNODE_TYPE_GEOMETRY);
659 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
661 /* NOTE: obdata eval now doesn't necessarily depend on the object's transform... */
662 ComponentKey target_transform_key(&ct->tar->id, DEPSNODE_TYPE_TRANSFORM);
663 add_relation(target_transform_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
666 /* standard object relation */
667 // TODO: loc vs rot vs scale?
668 if (&ct->tar->id == id) {
669 /* Constraint targetting own object:
670 * - This case is fine IFF we're dealing with a bone constraint pointing to
671 * its own armature. In that case, it's just transform -> bone.
672 * - If however it is a real self targetting case, just make it depend on the
673 * previous constraint (or the pre-constraint state)...
675 if ((ct->tar->type == OB_ARMATURE) && (component_type == DEPSNODE_TYPE_BONE)) {
676 OperationKey target_key(&ct->tar->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
677 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
680 OperationKey target_key(&ct->tar->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL);
681 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
685 /* normal object dependency */
686 OperationKey target_key(&ct->tar->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
687 add_relation(target_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
691 /* Constraints which needs world's matrix for transform.
692 * TODO(sergey): More constraints here?
695 CONSTRAINT_TYPE_ROTLIKE,
696 CONSTRAINT_TYPE_SIZELIKE,
697 CONSTRAINT_TYPE_LOCLIKE,
698 CONSTRAINT_TYPE_TRANSLIKE))
700 /* TODO(sergey): Add used space check. */
701 ComponentKey target_transform_key(&ct->tar->id, DEPSNODE_TYPE_TRANSFORM);
702 add_relation(target_transform_key, constraint_op_key, DEPSREL_TYPE_TRANSFORM, cti->name);
707 if (cti->flush_constraint_targets)
708 cti->flush_constraint_targets(con, &targets, 1);
713 void DepsgraphRelationBuilder::build_animdata(ID *id)
715 AnimData *adt = BKE_animdata_from_id(id);
720 ComponentKey adt_key(id, DEPSNODE_TYPE_ANIMATION);
723 if (adt->action || adt->nla_tracks.first) {
724 /* wire up dependency to time source */
725 TimeSourceKey time_src_key;
726 add_relation(time_src_key, adt_key, DEPSREL_TYPE_TIME, "[TimeSrc -> Animation]");
728 // XXX: Hook up specific update callbacks for special properties which may need it...
730 // XXX: animdata "hierarchy" - top-level overrides need to go after lower-down
734 for (FCurve *fcu = (FCurve *)adt->drivers.first; fcu; fcu = fcu->next) {
735 OperationKey driver_key(id, DEPSNODE_TYPE_PARAMETERS, DEG_OPCODE_DRIVER, deg_fcurve_id_name(fcu));
737 /* create the driver's relations to targets */
738 build_driver(id, fcu);
740 /* prevent driver from occurring before own animation... */
741 if (adt->action || adt->nla_tracks.first) {
742 add_relation(adt_key, driver_key, DEPSREL_TYPE_OPERATION,
743 "[AnimData Before Drivers]");
748 void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
750 ChannelDriver *driver = fcu->driver;
751 OperationKey driver_key(id, DEPSNODE_TYPE_PARAMETERS, DEG_OPCODE_DRIVER, deg_fcurve_id_name(fcu));
752 bPoseChannel *pchan = NULL;
754 /* create dependency between driver and data affected by it */
755 /* - direct property relationship... */
756 //RNAPathKey affected_key(id, fcu->rna_path);
757 //add_relation(driver_key, affected_key, DEPSREL_TYPE_DRIVER, "[Driver -> Data] DepsRel");
759 /* driver -> data components (for interleaved evaluation - bones/constraints/modifiers) */
760 // XXX: this probably should probably be moved out into a separate function
761 if (strstr(fcu->rna_path, "pose.bones[") != NULL) {
762 /* interleaved drivers during bone eval */
763 // TODO: ideally, if this is for a constraint, it goes to said constraint
764 Object *ob = (Object *)id;
767 bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
768 pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
771 MEM_freeN(bone_name);
776 OperationKey bone_key(id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL);
777 add_relation(driver_key, bone_key, DEPSREL_TYPE_DRIVER, "[Driver -> Bone]");
781 "Couldn't find bone name for driver path - '%s'\n",
785 else if (GS(id->name) == ID_AR && strstr(fcu->rna_path, "bones[")) {
786 /* drivers on armature-level bone settings (i.e. bbone stuff),
787 * which will affect the evaluation of corresponding pose bones
789 IDDepsNode *arm_node = m_graph->find_id_node(id);
790 char *bone_name = BLI_str_quoted_substrN(fcu->rna_path, "bones[");
792 if (arm_node && bone_name) {
793 /* find objects which use this, and make their eval callbacks depend on this */
794 foreach (DepsRelation *rel, arm_node->outlinks) {
795 IDDepsNode *to_node = (IDDepsNode *)rel->to;
797 /* we only care about objects with pose data which use this... */
798 if (GS(to_node->id->name) == ID_OB) {
799 Object *ob = (Object *)to_node->id;
800 bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name); // NOTE: ob->pose may be NULL
803 OperationKey bone_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL);
804 add_relation(driver_key, bone_key, DEPSREL_TYPE_DRIVER, "[Arm Bone -> Driver -> Bone]");
810 MEM_freeN(bone_name);
815 "Couldn't find armature bone name for driver path - '%s'\n",
819 else if (GS(id->name) == ID_OB && strstr(fcu->rna_path, "modifiers[")) {
820 /* modifier driver - connect directly to the modifier */
821 char *modifier_name = BLI_str_quoted_substrN(fcu->rna_path, "modifiers[");
823 OperationKey modifier_key(id,
824 DEPSNODE_TYPE_GEOMETRY,
825 DEG_OPCODE_GEOMETRY_MODIFIER,
827 if (has_node(modifier_key)) {
828 add_relation(driver_key, modifier_key, DEPSREL_TYPE_DRIVER, "[Driver -> Modifier]");
831 printf("Unexisting driver RNA path: %s\n", fcu->rna_path);
834 MEM_freeN(modifier_name);
837 else if (GS(id->name) == ID_KE && strstr(fcu->rna_path, "key_blocks[")) {
838 /* shape key driver - hook into the base geometry operation */
839 // XXX: double check where this points
840 Key *shape_key = (Key *)id;
842 ComponentKey geometry_key(shape_key->from, DEPSNODE_TYPE_GEOMETRY);
843 add_relation(driver_key, geometry_key, DEPSREL_TYPE_DRIVER, "[Driver -> ShapeKey Geom]");
845 else if (strstr(fcu->rna_path, "key_blocks[")) {
846 ComponentKey geometry_key(id, DEPSNODE_TYPE_GEOMETRY);
847 add_relation(driver_key, geometry_key, DEPSREL_TYPE_DRIVER, "[Driver -> ShapeKey Geom]");
850 if (GS(id->name) == ID_OB) {
851 /* assume that driver affects a transform... */
852 OperationKey local_transform_key(id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL);
853 add_relation(driver_key, local_transform_key, DEPSREL_TYPE_OPERATION, "[Driver -> Transform]");
855 else if (GS(id->name) == ID_KE) {
856 ComponentKey geometry_key(id, DEPSNODE_TYPE_GEOMETRY);
857 add_relation(driver_key, geometry_key, DEPSREL_TYPE_GEOMETRY_EVAL, "[Driver -> Shapekey Geometry]");
861 /* ensure that affected prop's update callbacks will be triggered once done */
862 // TODO: implement this once the functionality to add these links exists in RNA
863 // XXX: the data itself could also set this, if it were to be truly initialised later?
865 /* loop over variables to get the target relationships */
866 for (DriverVar *dvar = (DriverVar *)driver->variables.first; dvar; dvar = dvar->next) {
867 /* only used targets */
868 DRIVER_TARGETS_USED_LOOPER(dvar)
870 if (dtar->id == NULL)
873 /* special handling for directly-named bones */
874 if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) {
875 Object *ob = (Object *)dtar->id;
876 bPoseChannel *target_pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
877 if (target_pchan != NULL) {
878 /* get node associated with bone */
879 // XXX: watch the space!
880 /* Some cases can't use final bone transform, for example:
881 * - Driving the bone with itself (addressed here)
882 * - Relations inside an IK chain (TODO?)
884 if (dtar->id == id &&
886 STREQ(pchan->name, target_pchan->name))
890 OperationKey target_key(dtar->id, DEPSNODE_TYPE_BONE, target_pchan->name, DEG_OPCODE_BONE_DONE);
891 add_relation(target_key, driver_key, DEPSREL_TYPE_DRIVER_TARGET, "[Bone Target -> Driver]");
894 else if (dtar->flag & DTAR_FLAG_STRUCT_REF) {
895 /* get node associated with the object's transforms */
896 OperationKey target_key(dtar->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
897 add_relation(target_key, driver_key, DEPSREL_TYPE_DRIVER_TARGET, "[Target -> Driver]");
899 else if (dtar->rna_path && strstr(dtar->rna_path, "pose.bones[")) {
900 /* workaround for ensuring that local bone transforms don't end up
901 * having to wait for pose eval to finish (to prevent cycles)
903 Object *ob = (Object *)dtar->id;
904 char *bone_name = BLI_str_quoted_substrN(dtar->rna_path, "pose.bones[");
905 bPoseChannel *target_pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
907 MEM_freeN(bone_name);
911 if (dtar->id == id &&
913 STREQ(pchan->name, target_pchan->name))
917 OperationKey bone_key(dtar->id, DEPSNODE_TYPE_BONE, target_pchan->name, DEG_OPCODE_BONE_LOCAL);
918 add_relation(bone_key, driver_key, DEPSREL_TYPE_DRIVER, "[RNA Bone -> Driver]");
922 /* resolve path to get node */
923 RNAPathKey target_key(dtar->id, dtar->rna_path ? dtar->rna_path : "");
924 add_relation(target_key, driver_key, DEPSREL_TYPE_DRIVER_TARGET, "[RNA Target -> Driver]");
927 DRIVER_TARGETS_LOOPER_END
930 /* It's quite tricky to detect if the driver actually depends on time or not,
931 * so for now we'll be quite conservative here about optimization and consider
932 * all python drivers to be depending on time.
934 if (driver->type == DRIVER_TYPE_PYTHON) {
935 TimeSourceKey time_src_key;
936 add_relation(time_src_key, driver_key, DEPSREL_TYPE_TIME, "[TimeSrc -> Driver]");
940 void DepsgraphRelationBuilder::build_world(World *world)
942 ID *world_id = &world->id;
943 if (world_id->tag & LIB_TAG_DOIT) {
946 world_id->tag |= LIB_TAG_DOIT;
948 build_animdata(world_id);
950 /* TODO: other settings? */
953 build_texture_stack(world_id, world->mtex);
955 /* world's nodetree */
956 build_nodetree(world_id, world->nodetree);
959 void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
961 RigidBodyWorld *rbw = scene->rigidbody_world;
963 OperationKey init_key(&scene->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_RIGIDBODY_REBUILD);
964 OperationKey sim_key(&scene->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_RIGIDBODY_SIM);
966 /* rel between the two sim-nodes */
967 add_relation(init_key, sim_key, DEPSREL_TYPE_OPERATION, "Rigidbody [Init -> SimStep]");
969 /* set up dependencies between these operations and other builtin nodes --------------- */
971 /* time dependency */
972 TimeSourceKey time_src_key;
973 add_relation(time_src_key, init_key, DEPSREL_TYPE_TIME, "TimeSrc -> Rigidbody Reset/Rebuild (Optional)");
974 add_relation(time_src_key, sim_key, DEPSREL_TYPE_TIME, "TimeSrc -> Rigidbody Sim Step");
976 /* objects - simulation participants */
978 for (GroupObject *go = (GroupObject *)rbw->group->gobject.first; go; go = go->next) {
980 if (!ob || ob->type != OB_MESH)
983 /* hook up evaluation order...
984 * 1) flushing rigidbody results follows base transforms being applied
985 * 2) rigidbody flushing can only be performed after simulation has been run
987 * 3) simulation needs to know base transforms to figure out what to do
988 * XXX: there's probably a difference between passive and active
989 * - passive don't change, so may need to know full transform...
991 OperationKey rbo_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_RIGIDBODY);
993 eDepsOperation_Code trans_opcode = ob->parent ? DEG_OPCODE_TRANSFORM_PARENT : DEG_OPCODE_TRANSFORM_LOCAL;
994 OperationKey trans_op(&ob->id, DEPSNODE_TYPE_TRANSFORM, trans_opcode);
996 add_relation(trans_op, rbo_key, DEPSREL_TYPE_OPERATION, "Base Ob Transform -> RBO Sync");
997 add_relation(sim_key, rbo_key, DEPSREL_TYPE_COMPONENT_ORDER, "Rigidbody Sim Eval -> RBO Sync");
999 /* if constraints exist, those depend on the result of the rigidbody sim
1000 * - This allows constraints to modify the result of the sim (i.e. clamping)
1001 * while still allowing the sim to depend on some changes to the objects.
1002 * Also, since constraints are hooked up to the final nodes, this link
1003 * means that we can also fit in there too...
1004 * - Later, it might be good to include a constraint in the stack allowing us
1005 * to control whether rigidbody eval gets interleaved into the constraint stack
1007 if (ob->constraints.first) {
1008 OperationKey constraint_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_CONSTRAINTS);
1009 add_relation(rbo_key, constraint_key, DEPSREL_TYPE_COMPONENT_ORDER, "RBO Sync -> Ob Constraints");
1012 /* final object transform depends on rigidbody */
1013 OperationKey done_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL);
1014 add_relation(rbo_key, done_key, DEPSREL_TYPE_COMPONENT_ORDER, "RBO Sync -> Done");
1016 // XXX: ubereval will be removed eventually, but we still need it in the meantime
1017 OperationKey uber_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_OBJECT_UBEREVAL);
1018 add_relation(rbo_key, uber_key, DEPSREL_TYPE_COMPONENT_ORDER, "RBO Sync -> Uber (Temp)");
1022 /* needed to get correct base values */
1023 add_relation(trans_op, sim_key, DEPSREL_TYPE_OPERATION, "Base Ob Transform -> Rigidbody Sim Eval");
1028 if (rbw->constraints) {
1029 for (GroupObject *go = (GroupObject *)rbw->constraints->gobject.first; go; go = go->next) {
1030 Object *ob = go->ob;
1031 if (!ob || !ob->rigidbody_constraint)
1034 RigidBodyCon *rbc = ob->rigidbody_constraint;
1036 /* final result of the constraint object's transform controls how the
1037 * constraint affects the physics sim for these objects
1039 ComponentKey trans_key(&ob->id, DEPSNODE_TYPE_TRANSFORM);
1040 OperationKey ob1_key(&rbc->ob1->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_RIGIDBODY);
1041 OperationKey ob2_key(&rbc->ob2->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_RIGIDBODY);
1043 /* - constrained-objects sync depends on the constraint-holder */
1044 add_relation(trans_key, ob1_key, DEPSREL_TYPE_TRANSFORM, "RigidBodyConstraint -> RBC.Object_1");
1045 add_relation(trans_key, ob2_key, DEPSREL_TYPE_TRANSFORM, "RigidBodyConstraint -> RBC.Object_2");
1047 /* - ensure that sim depends on this constraint's transform */
1048 add_relation(trans_key, sim_key, DEPSREL_TYPE_TRANSFORM, "RigidBodyConstraint Transform -> RB Simulation");
1053 /* IK Solver Eval Steps */
1054 void DepsgraphRelationBuilder::build_ik_pose(Object *ob,
1055 bPoseChannel *pchan,
1057 RootPChanMap *root_map)
1059 bKinematicConstraint *data = (bKinematicConstraint *)con->data;
1061 /* attach owner to IK Solver too
1062 * - assume that owner is always part of chain
1063 * - see notes on direction of rel below...
1065 bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data);
1066 OperationKey solver_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_IK_SOLVER);
1069 // XXX: this should get handled as part of the constraint code
1070 if (data->tar != NULL) {
1071 /* TODO(sergey): For until we'll store partial matricies in the depsgraph,
1072 * we create dependency between target object and pose eval component.
1074 * This way we ensuring the whole subtree is updated from scratch without
1075 * need of intermediate matricies. This is an overkill, but good enough for
1076 * testing IK solver.
1078 // FIXME: geometry targets...
1079 ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE);
1080 if ((data->tar->type == OB_ARMATURE) && (data->subtarget[0])) {
1081 /* TODO(sergey): This is only for until granular update stores intermediate result. */
1082 if (data->tar != ob) {
1083 /* different armature - can just read the results */
1084 ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_BONE, data->subtarget);
1085 add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, con->name);
1088 /* same armature - we'll use the ready state only, just in case this bone is in the chain we're solving */
1089 OperationKey target_key(&data->tar->id, DEPSNODE_TYPE_BONE, data->subtarget, DEG_OPCODE_BONE_DONE);
1090 add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name);
1093 else if (ELEM(data->tar->type, OB_MESH, OB_LATTICE) && (data->subtarget[0])) {
1094 /* vertex group target */
1095 /* NOTE: for now, we don't need to represent vertex groups separately... */
1096 ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_GEOMETRY);
1097 add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name);
1099 if (data->tar->type == OB_MESH) {
1100 OperationDepsNode *node2 = find_operation_node(target_key);
1101 if (node2 != NULL) {
1102 node2->customdata_mask |= CD_MASK_MDEFORMVERT;
1107 /* Standard Object Target */
1108 ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_TRANSFORM);
1109 add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, con->name);
1112 if ((data->tar == ob) && (data->subtarget[0])) {
1113 /* Prevent target's constraints from linking to anything from same
1114 * chain that it controls.
1116 root_map->add_bone(data->subtarget, rootchan->name);
1121 // XXX: this should get handled as part of the constraint code
1122 if (data->poletar != NULL) {
1123 if ((data->poletar->type == OB_ARMATURE) && (data->polesubtarget[0])) {
1124 // XXX: same armature issues - ready vs done?
1125 ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_BONE, data->subtarget);
1126 add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name);
1128 else if (ELEM(data->poletar->type, OB_MESH, OB_LATTICE) && (data->subtarget[0])) {
1129 /* vertex group target */
1130 /* NOTE: for now, we don't need to represent vertex groups separately... */
1131 ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_GEOMETRY);
1132 add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name);
1134 if (data->poletar->type == OB_MESH) {
1135 OperationDepsNode *node2 = find_operation_node(target_key);
1136 if (node2 != NULL) {
1137 node2->customdata_mask |= CD_MASK_MDEFORMVERT;
1142 ComponentKey target_key(&data->poletar->id, DEPSNODE_TYPE_TRANSFORM);
1143 add_relation(target_key, solver_key, DEPSREL_TYPE_TRANSFORM, con->name);
1147 DEG_DEBUG_PRINTF("\nStarting IK Build: pchan = %s, target = (%s, %s), segcount = %d\n",
1148 pchan->name, data->tar->id.name, data->subtarget, data->rootbone);
1150 bPoseChannel *parchan = pchan;
1151 /* exclude tip from chain? */
1152 if (!(data->flag & CONSTRAINT_IK_TIP)) {
1153 OperationKey tip_transforms_key(&ob->id, DEPSNODE_TYPE_BONE,
1154 parchan->name, DEG_OPCODE_BONE_LOCAL);
1155 add_relation(solver_key, tip_transforms_key,
1156 DEPSREL_TYPE_TRANSFORM, "IK Solver Result");
1157 parchan = pchan->parent;
1160 root_map->add_bone(parchan->name, rootchan->name);
1162 OperationKey parchan_transforms_key(&ob->id, DEPSNODE_TYPE_BONE,
1163 parchan->name, DEG_OPCODE_BONE_READY);
1164 add_relation(parchan_transforms_key, solver_key,
1165 DEPSREL_TYPE_TRANSFORM, "IK Solver Owner");
1167 /* Walk to the chain's root */
1168 //size_t segcount = 0;
1172 /* Make IK-solver dependent on this bone's result,
1173 * since it can only run after the standard results
1174 * of the bone are know. Validate links step on the
1175 * bone will ensure that users of this bone only
1176 * grab the result with IK solver results...
1178 if (parchan != pchan) {
1179 OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_READY);
1180 add_relation(parent_key, solver_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Parent");
1182 OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE);
1183 add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result");
1185 parchan->flag |= POSE_DONE;
1187 OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE);
1188 add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "IK Solver Result");
1190 root_map->add_bone(parchan->name, rootchan->name);
1192 /* continue up chain, until we reach target number of items... */
1193 DEG_DEBUG_PRINTF(" %d = %s\n", segcount, parchan->name);
1195 if ((segcount == data->rootbone) || (segcount > 255)) break; /* 255 is weak */
1197 parchan = parchan->parent;
1200 OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE);
1201 add_relation(solver_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link");
1204 /* Spline IK Eval Steps */
1205 void DepsgraphRelationBuilder::build_splineik_pose(Object *ob,
1206 bPoseChannel *pchan,
1208 RootPChanMap *root_map)
1210 bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
1211 bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data);
1212 OperationKey transforms_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY);
1213 OperationKey solver_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name, DEG_OPCODE_POSE_SPLINE_IK_SOLVER);
1215 /* attach owner to IK Solver too
1216 * - assume that owner is always part of chain
1217 * - see notes on direction of rel below...
1219 add_relation(transforms_key, solver_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Owner");
1221 /* attach path dependency to solver */
1223 /* TODO(sergey): For until we'll store partial matricies in the depsgraph,
1224 * we create dependency between target object and pose eval component.
1225 * See IK pose for a bit more information.
1227 // TODO: the bigggest point here is that we need the curve PATH and not just the general geometry...
1228 ComponentKey target_key(&data->tar->id, DEPSNODE_TYPE_GEOMETRY);
1229 ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE);
1230 add_relation(target_key, pose_key, DEPSREL_TYPE_TRANSFORM, "[Curve.Path -> Spline IK] DepsRel");
1233 pchan->flag |= POSE_DONE;
1234 OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE);
1235 add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Result");
1237 root_map->add_bone(pchan->name, rootchan->name);
1239 /* Walk to the chain's root */
1240 //size_t segcount = 0;
1243 for (bPoseChannel *parchan = pchan->parent; parchan; parchan = parchan->parent) {
1244 /* Make Spline IK solver dependent on this bone's result,
1245 * since it can only run after the standard results
1246 * of the bone are know. Validate links step on the
1247 * bone will ensure that users of this bone only
1248 * grab the result with IK solver results...
1250 if (parchan != pchan) {
1251 OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_READY);
1252 add_relation(parent_key, solver_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Update");
1254 OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE);
1255 add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result");
1257 parchan->flag |= POSE_DONE;
1259 OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE);
1260 add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Result");
1262 root_map->add_bone(parchan->name, rootchan->name);
1264 /* continue up chain, until we reach target number of items... */
1266 if ((segcount == data->chainlen) || (segcount > 255)) break; /* 255 is weak */
1269 OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE);
1270 add_relation(solver_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link");
1273 /* Pose/Armature Bones Graph */
1274 void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
1277 bArmature *arm = (bArmature *)ob->data;
1279 // TODO: selection status?
1281 /* attach links between pose operations */
1282 OperationKey init_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT);
1283 OperationKey flush_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE);
1285 add_relation(init_key, flush_key, DEPSREL_TYPE_COMPONENT_ORDER, "[Pose Init -> Pose Cleanup]");
1287 /* Make sure pose is up-to-date with armature updates. */
1288 OperationKey armature_key(&arm->id,
1289 DEPSNODE_TYPE_PARAMETERS,
1290 DEG_OPCODE_PLACEHOLDER,
1292 add_relation(armature_key, init_key, DEPSREL_TYPE_COMPONENT_ORDER, "Data dependency");
1294 if (ob->adt && (ob->adt->action || ob->adt->nla_tracks.first)) {
1295 ComponentKey animation_key(&ob->id, DEPSNODE_TYPE_ANIMATION);
1296 add_relation(animation_key, init_key, DEPSREL_TYPE_OPERATION, "Rig Animation");
1300 * - These require separate processing steps are pose-level
1301 * to be executed between chains of bones (i.e. once the
1302 * base transforms of a bunch of bones is done)
1304 * - We build relations for these before the dependencies
1305 * between ops in the same component as it is necessary
1306 * to check whether such bones are in the same IK chain
1307 * (or else we get weird issues with either in-chain
1308 * references, or with bones being parented to IK'd bones)
1311 * - Care is needed to ensure that multi-headed trees work out the same as in ik-tree building
1312 * - Animated chain-lengths are a problem...
1314 RootPChanMap root_map;
1315 bool pose_depends_on_local_transform = false;
1316 for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1317 for (bConstraint *con = (bConstraint *)pchan->constraints.first; con; con = con->next) {
1318 switch (con->type) {
1319 case CONSTRAINT_TYPE_KINEMATIC:
1320 build_ik_pose(ob, pchan, con, &root_map);
1321 pose_depends_on_local_transform = true;
1324 case CONSTRAINT_TYPE_SPLINEIK:
1325 build_splineik_pose(ob, pchan, con, &root_map);
1326 pose_depends_on_local_transform = true;
1329 /* Constraints which needs world's matrix for transform.
1330 * TODO(sergey): More constraints here?
1332 case CONSTRAINT_TYPE_ROTLIKE:
1333 case CONSTRAINT_TYPE_SIZELIKE:
1334 case CONSTRAINT_TYPE_LOCLIKE:
1335 case CONSTRAINT_TYPE_TRANSLIKE:
1336 /* TODO(sergey): Add used space check. */
1337 pose_depends_on_local_transform = true;
1345 //root_map.print_debug();
1347 if (pose_depends_on_local_transform) {
1348 /* TODO(sergey): Once partial updates are possible use relation between
1349 * object transform and solver itself in it's build function.
1351 ComponentKey pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE);
1352 ComponentKey local_transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM);
1353 add_relation(local_transform_key, pose_key, DEPSREL_TYPE_TRANSFORM, "Local Transforms");
1357 /* links between operations for each bone */
1358 for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1359 OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL);
1360 OperationKey bone_pose_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_POSE_PARENT);
1361 OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY);
1362 OperationKey bone_done_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE);
1364 pchan->flag &= ~POSE_DONE;
1366 /* pose init to bone local */
1367 add_relation(init_key, bone_local_key, DEPSREL_TYPE_OPERATION, "PoseEval Source-Bone Link");
1369 /* local to pose parenting operation */
1370 add_relation(bone_local_key, bone_pose_key, DEPSREL_TYPE_OPERATION, "Bone Local - PoseSpace Link");
1372 /* parent relation */
1373 if (pchan->parent != NULL) {
1374 eDepsOperation_Code parent_key_opcode;
1376 /* NOTE: this difference in handling allows us to prevent lockups while ensuring correct poses for separate chains */
1377 if (root_map.has_common_root(pchan->name, pchan->parent->name)) {
1378 parent_key_opcode = DEG_OPCODE_BONE_READY;
1381 parent_key_opcode = DEG_OPCODE_BONE_DONE;
1384 OperationKey parent_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->parent->name, parent_key_opcode);
1385 add_relation(parent_key, bone_pose_key, DEPSREL_TYPE_TRANSFORM, "[Parent Bone -> Child Bone]");
1389 if (pchan->constraints.first != NULL) {
1390 /* constraints stack and constraint dependencies */
1391 build_constraints(scene, &ob->id, DEPSNODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map);
1393 /* pose -> constraints */
1394 OperationKey constraints_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_CONSTRAINTS);
1395 add_relation(bone_pose_key, constraints_key, DEPSREL_TYPE_OPERATION, "Constraints Stack");
1397 /* constraints -> ready */
1398 // TODO: when constraint stack is exploded, this step should occur before the first IK solver
1399 add_relation(constraints_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Constraints -> Ready");
1403 add_relation(bone_pose_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Pose -> Ready");
1406 /* bone ready -> done
1407 * NOTE: For bones without IK, this is all that's needed.
1408 * For IK chains however, an additional rel is created from IK to done,
1409 * with transitive reduction removing this one...
1411 add_relation(bone_ready_key, bone_done_key, DEPSREL_TYPE_OPERATION, "Ready -> Done");
1413 /* assume that all bones must be done for the pose to be ready (for deformers) */
1414 add_relation(bone_done_key, flush_key, DEPSREL_TYPE_OPERATION, "PoseEval Result-Bone Link");
1418 void DepsgraphRelationBuilder::build_proxy_rig(Object *ob)
1420 OperationKey pose_init_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_INIT);
1421 OperationKey pose_done_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE, DEG_OPCODE_POSE_DONE);
1422 for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first;
1424 pchan = pchan->next)
1426 OperationKey bone_local_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL);
1427 OperationKey bone_ready_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY);
1428 OperationKey bone_done_key(&ob->id, DEPSNODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE);
1429 add_relation(pose_init_key, bone_local_key, DEPSREL_TYPE_OPERATION, "Pose Init -> Bone Local");
1430 add_relation(bone_local_key, bone_ready_key, DEPSREL_TYPE_OPERATION, "Local -> Ready");
1431 add_relation(bone_ready_key, bone_done_key, DEPSREL_TYPE_OPERATION, "Ready -> Done");
1432 add_relation(bone_done_key, pose_done_key, DEPSREL_TYPE_OPERATION, "Bone Done -> Pose Done");
1437 void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key)
1439 ComponentKey obdata_key(obdata, DEPSNODE_TYPE_GEOMETRY);
1441 /* attach animdata to geometry */
1442 build_animdata(&key->id);
1445 // TODO: this should really be handled in build_animdata, since many of these cases will need it
1446 if (key->adt->action || key->adt->nla_tracks.first) {
1447 ComponentKey adt_key(&key->id, DEPSNODE_TYPE_ANIMATION);
1448 add_relation(adt_key, obdata_key, DEPSREL_TYPE_OPERATION, "Animation");
1451 /* NOTE: individual shapekey drivers are handled above already */
1454 /* attach to geometry */
1455 // XXX: aren't shapekeys now done as a pseudo-modifier on object?
1456 //ComponentKey key_key(&key->id, DEPSNODE_TYPE_GEOMETRY); // FIXME: this doesn't exist
1457 //add_relation(key_key, obdata_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Shapekeys");
1461 * ObData Geometry Evaluation
1462 * ==========================
1464 * The evaluation of geometry on objects is as follows:
1465 * - The actual evaluated of the derived geometry (e.g. DerivedMesh, DispList, etc.)
1466 * occurs in the Geometry component of the object which references this. This includes
1467 * modifiers, and the temporary "ubereval" for geometry.
1468 * - Therefore, each user of a piece of shared geometry data ends up evaluating its own
1469 * version of the stuff, complete with whatever modifiers it may use.
1471 * - The datablocks for the geometry data - "obdata" (e.g. ID_ME, ID_CU, ID_LT, etc.) are used for
1472 * 1) calculating the bounding boxes of the geometry data,
1473 * 2) aggregating inward links from other objects (e.g. for text on curve, etc.)
1474 * and also for the links coming from the shapekey datablocks
1475 * - Animation/Drivers affecting the parameters of the geometry are made to trigger
1476 * updates on the obdata geometry component, which then trigger downstream
1477 * re-evaluation of the individual instances of this geometry.
1479 // TODO: Materials and lighting should probably get their own component, instead of being lumped under geometry?
1480 void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Object *ob)
1482 ID *obdata = (ID *)ob->data;
1484 /* Init operation of object-level geometry evaluation. */
1485 OperationKey geom_init_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Init");
1487 /* get nodes for result of obdata's evaluation, and geometry evaluation on object */
1488 ComponentKey obdata_geom_key(obdata, DEPSNODE_TYPE_GEOMETRY);
1489 ComponentKey geom_key(&ob->id, DEPSNODE_TYPE_GEOMETRY);
1491 /* link components to each other */
1492 add_relation(obdata_geom_key, geom_key, DEPSREL_TYPE_DATABLOCK, "Object Geometry Base Data");
1495 if (ob->modifiers.first) {
1497 OperationKey prev_mod_key;
1499 for (md = (ModifierData *)ob->modifiers.first; md; md = md->next) {
1500 const ModifierTypeInfo *mti = modifierType_getInfo((ModifierType)md->type);
1501 OperationKey mod_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_MODIFIER, md->name);
1504 /* Stack relation: modifier depends on previous modifier in the stack */
1505 add_relation(prev_mod_key, mod_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Modifier Stack");
1508 /* Stack relation: first modifier depends on the geometry. */
1509 add_relation(geom_init_key, mod_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Modifier Stack");
1512 if (mti->updateDepsgraph) {
1513 DepsNodeHandle handle = create_node_handle(mod_key);
1514 mti->updateDepsgraph(
1519 reinterpret_cast< ::DepsNodeHandle* >(&handle));
1522 if (BKE_object_modifier_use_time(ob, md)) {
1523 TimeSourceKey time_src_key;
1524 add_relation(time_src_key, mod_key, DEPSREL_TYPE_TIME, "Time Source");
1526 /* Hacky fix for T45633 (Animated modifiers aren't updated)
1528 * This check works because BKE_object_modifier_use_time() tests
1529 * for either the modifier needing time, or that it is animated.
1531 /* XXX: Remove this hack when these links are added as part of build_animdata() instead */
1532 if (modifier_dependsOnTime(md) == false) {
1533 ComponentKey animation_key(&ob->id, DEPSNODE_TYPE_ANIMATION);
1534 add_relation(animation_key, mod_key, DEPSREL_TYPE_OPERATION, "Modifier Animation");
1538 prev_mod_key = mod_key;
1546 for (a = 1; a <= ob->totcol; a++) {
1547 Material *ma = give_current_material(ob, a);
1550 build_material(&ob->id, ma);
1554 /* geometry collision */
1555 if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
1556 // add geometry collider relations
1559 /* Make sure uber update is the last in the dependencies.
1561 * TODO(sergey): Get rid of this node.
1563 if (ob->type != OB_ARMATURE) {
1564 /* Armatures does no longer require uber node. */
1565 OperationKey obdata_ubereval_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_UBEREVAL);
1566 if (ob->modifiers.last) {
1567 ModifierData *md = (ModifierData *)ob->modifiers.last;
1568 OperationKey mod_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_MODIFIER, md->name);
1569 add_relation(mod_key, obdata_ubereval_key, DEPSREL_TYPE_OPERATION, "Object Geometry UberEval");
1572 add_relation(geom_init_key, obdata_ubereval_key, DEPSREL_TYPE_OPERATION, "Object Geometry UberEval");
1576 if (obdata->tag & LIB_TAG_DOIT) {
1579 obdata->tag |= LIB_TAG_DOIT;
1581 /* Link object data evaluation node to exit operation. */
1582 OperationKey obdata_geom_eval_key(obdata, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Geometry Eval");
1583 OperationKey obdata_geom_done_key(obdata, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Done");
1584 add_relation(obdata_geom_eval_key, obdata_geom_done_key, DEPSREL_TYPE_DATABLOCK, "ObData Geom Eval Done");
1586 /* type-specific node/links */
1593 Object *mom = BKE_mball_basis_find(scene, ob);
1595 /* motherball - mom depends on children! */
1597 /* non-motherball -> cannot be directly evaluated! */
1598 ComponentKey mom_key(&mom->id, DEPSNODE_TYPE_GEOMETRY);
1599 ComponentKey transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM);
1600 add_relation(geom_key, mom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Metaball Motherball");
1601 add_relation(transform_key, mom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Metaball Motherball");
1609 Curve *cu = (Curve *)obdata;
1611 /* curve's dependencies */
1612 // XXX: these needs geom data, but where is geom stored?
1614 ComponentKey bevob_key(&cu->bevobj->id, DEPSNODE_TYPE_GEOMETRY);
1615 add_relation(bevob_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Curve Bevel");
1618 ComponentKey taperob_key(&cu->taperobj->id, DEPSNODE_TYPE_GEOMETRY);
1619 add_relation(taperob_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Curve Taper");
1621 if (ob->type == OB_FONT) {
1622 if (cu->textoncurve) {
1623 ComponentKey textoncurve_key(&cu->taperobj->id, DEPSNODE_TYPE_GEOMETRY);
1624 add_relation(textoncurve_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Text on Curve");
1630 case OB_SURF: /* Nurbs Surface */
1635 case OB_LATTICE: /* Lattice */
1642 Key *key = BKE_key_from_object(ob);
1644 build_shapekeys(obdata, key);
1647 if (needs_animdata_node(obdata)) {
1648 ComponentKey animation_key(obdata, DEPSNODE_TYPE_ANIMATION);
1649 ComponentKey parameters_key(obdata, DEPSNODE_TYPE_PARAMETERS);
1650 add_relation(animation_key, parameters_key,
1651 DEPSREL_TYPE_COMPONENT_ORDER, "Geom Parameters");
1652 /* Evaluation usually depends on animation.
1653 * TODO(sergey): Need to re-hook it after granular update is implemented..
1655 add_relation(animation_key, obdata_geom_eval_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Animation");
1660 // TODO: Link scene-camera links in somehow...
1661 void DepsgraphRelationBuilder::build_camera(Object *ob)
1663 Camera *cam = (Camera *)ob->data;
1664 ID *camera_id = &cam->id;
1665 if (camera_id->tag & LIB_TAG_DOIT) {
1668 camera_id->tag |= LIB_TAG_DOIT;
1670 ComponentKey parameters_key(camera_id, DEPSNODE_TYPE_PARAMETERS);
1672 if (needs_animdata_node(camera_id)) {
1673 ComponentKey animation_key(camera_id, DEPSNODE_TYPE_ANIMATION);
1674 add_relation(animation_key, parameters_key,
1675 DEPSREL_TYPE_COMPONENT_ORDER, "Camera Parameters");
1680 ComponentKey ob_param_key(&ob->id, DEPSNODE_TYPE_PARAMETERS);
1681 ComponentKey dof_ob_key(&cam->dof_ob->id, DEPSNODE_TYPE_TRANSFORM);
1682 add_relation(dof_ob_key, ob_param_key, DEPSREL_TYPE_TRANSFORM, "Camera DOF");
1687 void DepsgraphRelationBuilder::build_lamp(Object *ob)
1689 Lamp *la = (Lamp *)ob->data;
1690 ID *lamp_id = &la->id;
1691 if (lamp_id->tag & LIB_TAG_DOIT) {
1694 lamp_id->tag |= LIB_TAG_DOIT;
1696 ComponentKey parameters_key(lamp_id, DEPSNODE_TYPE_PARAMETERS);
1698 if (needs_animdata_node(lamp_id)) {
1699 ComponentKey animation_key(lamp_id, DEPSNODE_TYPE_ANIMATION);
1700 add_relation(animation_key, parameters_key,
1701 DEPSREL_TYPE_COMPONENT_ORDER, "Lamp Parameters");
1704 /* lamp's nodetree */
1706 build_nodetree(lamp_id, la->nodetree);
1707 ComponentKey nodetree_key(&la->nodetree->id, DEPSNODE_TYPE_PARAMETERS);
1708 add_relation(nodetree_key, parameters_key,
1709 DEPSREL_TYPE_COMPONENT_ORDER, "NTree->Lamp Parameters");
1713 build_texture_stack(lamp_id, la->mtex);
1716 void DepsgraphRelationBuilder::build_nodetree(ID *owner, bNodeTree *ntree)
1721 ID *ntree_id = &ntree->id;
1723 build_animdata(ntree_id);
1725 OperationKey parameters_key(ntree_id,
1726 DEPSNODE_TYPE_PARAMETERS,
1727 DEG_OPCODE_PLACEHOLDER,
1730 /* nodetree's nodes... */
1731 for (bNode *bnode = (bNode *)ntree->nodes.first; bnode; bnode = bnode->next) {
1733 if (GS(bnode->id->name) == ID_MA) {
1734 build_material(owner, (Material *)bnode->id);
1736 else if (bnode->type == ID_TE) {
1737 build_texture(owner, (Tex *)bnode->id);
1739 else if (bnode->type == NODE_GROUP) {
1740 bNodeTree *group_ntree = (bNodeTree *)bnode->id;
1741 if ((group_ntree->id.tag & LIB_TAG_DOIT) == 0) {
1742 build_nodetree(owner, group_ntree);
1743 group_ntree->id.tag |= LIB_TAG_DOIT;
1745 OperationKey group_parameters_key(&group_ntree->id,
1746 DEPSNODE_TYPE_PARAMETERS,
1747 DEG_OPCODE_PLACEHOLDER,
1749 add_relation(group_parameters_key, parameters_key,
1750 DEPSREL_TYPE_COMPONENT_ORDER, "Group Node");
1755 if (needs_animdata_node(ntree_id)) {
1756 ComponentKey animation_key(ntree_id, DEPSNODE_TYPE_ANIMATION);
1757 add_relation(animation_key, parameters_key,
1758 DEPSREL_TYPE_COMPONENT_ORDER, "NTree Parameters");
1761 // TODO: link from nodetree to owner_component?
1764 /* Recursively build graph for material */
1765 void DepsgraphRelationBuilder::build_material(ID *owner, Material *ma)
1767 ID *ma_id = &ma->id;
1768 if (ma_id->tag & LIB_TAG_DOIT) {
1771 ma_id->tag |= LIB_TAG_DOIT;
1774 build_animdata(ma_id);
1777 build_texture_stack(owner, ma->mtex);
1779 /* material's nodetree */
1780 build_nodetree(owner, ma->nodetree);
1783 /* Recursively build graph for texture */
1784 void DepsgraphRelationBuilder::build_texture(ID *owner, Tex *tex)
1786 ID *tex_id = &tex->id;
1787 if (tex_id->tag & LIB_TAG_DOIT) {
1790 tex_id->tag |= LIB_TAG_DOIT;
1792 /* texture itself */
1793 build_animdata(tex_id);
1795 /* texture's nodetree */
1796 build_nodetree(owner, tex->nodetree);
1799 /* Texture-stack attached to some shading datablock */
1800 void DepsgraphRelationBuilder::build_texture_stack(ID *owner, MTex **texture_stack)
1804 /* for now assume that all texture-stacks have same number of max items */
1805 for (i = 0; i < MAX_MTEX; i++) {
1806 MTex *mtex = texture_stack[i];
1807 if (mtex && mtex->tex)
1808 build_texture(owner, mtex->tex);
1812 void DepsgraphRelationBuilder::build_compositor(Scene *scene)
1814 /* For now, just a plain wrapper? */
1815 build_nodetree(&scene->id, scene->nodetree);
1818 void DepsgraphRelationBuilder::build_gpencil(ID *UNUSED(owner), bGPdata *gpd)
1821 build_animdata(&gpd->id);
1823 // TODO: parent object (when that feature is implemented)
1826 bool DepsgraphRelationBuilder::needs_animdata_node(ID *id)
1828 AnimData *adt = BKE_animdata_from_id(id);
1830 return adt->action != NULL;