Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_texture_types.h" | #include "DNA_texture_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_collection.h" | |||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_collision.h" | #include "BKE_collision.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_group.h" | |||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_mball.h" | #include "BKE_mball.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| ▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | DepsRelation *DepsgraphRelationBuilder::add_operation_relation( | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::add_collision_relations( | void DepsgraphRelationBuilder::add_collision_relations( | ||||
| const OperationKey &key, | const OperationKey &key, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *object, | Object *object, | ||||
| Group *group, | Collection *collection, | ||||
| bool dupli, | bool dupli, | ||||
| const char *name) | const char *name) | ||||
| { | { | ||||
| unsigned int numcollobj; | unsigned int numcollobj; | ||||
| Object **collobjs = get_collisionobjects_ext(scene, | Object **collobjs = get_collisionobjects_ext(scene, | ||||
| object, | object, | ||||
| group, | collection, | ||||
| &numcollobj, | &numcollobj, | ||||
| eModifierType_Collision, | eModifierType_Collision, | ||||
| dupli); | dupli); | ||||
| for (unsigned int i = 0; i < numcollobj; i++) { | for (unsigned int i = 0; i < numcollobj; i++) { | ||||
| Object *ob1 = collobjs[i]; | Object *ob1 = collobjs[i]; | ||||
| ComponentKey trf_key(&ob1->id, DEG_NODE_TYPE_TRANSFORM); | ComponentKey trf_key(&ob1->id, DEG_NODE_TYPE_TRANSFORM); | ||||
| add_relation(trf_key, key, name); | add_relation(trf_key, key, name); | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
| void DepsgraphRelationBuilder::build_id(ID *id) | void DepsgraphRelationBuilder::build_id(ID *id) | ||||
| { | { | ||||
| if (id == NULL) { | if (id == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| switch (GS(id->name)) { | switch (GS(id->name)) { | ||||
| case ID_GR: | case ID_GR: | ||||
| build_group(NULL, (Group *)id); | build_collection(NULL, (Collection *)id); | ||||
| break; | break; | ||||
| case ID_OB: | case ID_OB: | ||||
| build_object(NULL, (Object *)id); | build_object(NULL, (Object *)id); | ||||
| break; | break; | ||||
| case ID_NT: | case ID_NT: | ||||
| build_nodetree((bNodeTree *)id); | build_nodetree((bNodeTree *)id); | ||||
| break; | break; | ||||
| case ID_MA: | case ID_MA: | ||||
| Show All 11 Lines | switch (GS(id->name)) { | ||||
| case ID_MC: | case ID_MC: | ||||
| build_movieclip((MovieClip *)id); | build_movieclip((MovieClip *)id); | ||||
| break; | break; | ||||
| default: | default: | ||||
| fprintf(stderr, "Unhandled ID %s\n", id->name); | fprintf(stderr, "Unhandled ID %s\n", id->name); | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_group(Object *object, Group *group) | void DepsgraphRelationBuilder::build_collection(Object *object, Collection *collection) | ||||
| { | { | ||||
| const bool group_done = built_map_.checkIsBuiltAndTag(group); | const bool group_done = built_map_.checkIsBuiltAndTag(collection); | ||||
| OperationKey object_local_transform_key(object != NULL ? &object->id : NULL, | OperationKey object_local_transform_key(object != NULL ? &object->id : NULL, | ||||
| DEG_NODE_TYPE_TRANSFORM, | DEG_NODE_TYPE_TRANSFORM, | ||||
| DEG_OPCODE_TRANSFORM_LOCAL); | DEG_OPCODE_TRANSFORM_LOCAL); | ||||
| if (!group_done) { | if (!group_done) { | ||||
| LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) { | LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { | ||||
| build_object(NULL, base->object); | build_object(NULL, cob->ob); | ||||
| } | |||||
| LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { | |||||
| build_collection(NULL, child->collection); | |||||
| } | } | ||||
| } | } | ||||
| if (object != NULL) { | if (object != NULL) { | ||||
| LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) { | const ListBase group_objects = BKE_collection_object_cache_get(collection); | ||||
| LISTBASE_FOREACH (Base *, base, &group_objects) { | |||||
| ComponentKey dupli_transform_key(&base->object->id, DEG_NODE_TYPE_TRANSFORM); | ComponentKey dupli_transform_key(&base->object->id, DEG_NODE_TYPE_TRANSFORM); | ||||
| add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup"); | add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup"); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_object(Base *base, Object *object) | void DepsgraphRelationBuilder::build_object(Base *base, Object *object) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if (object->proxy != NULL) { | ||||
| * behavior and need to be investigated if it still need to be inverted. | * behavior and need to be investigated if it still need to be inverted. | ||||
| */ | */ | ||||
| ComponentKey ob_pose_key(&object->id, DEG_NODE_TYPE_EVAL_POSE); | ComponentKey ob_pose_key(&object->id, DEG_NODE_TYPE_EVAL_POSE); | ||||
| ComponentKey proxy_pose_key(&object->proxy->id, DEG_NODE_TYPE_EVAL_POSE); | ComponentKey proxy_pose_key(&object->proxy->id, DEG_NODE_TYPE_EVAL_POSE); | ||||
| add_relation(ob_pose_key, proxy_pose_key, "Proxy"); | add_relation(ob_pose_key, proxy_pose_key, "Proxy"); | ||||
| } | } | ||||
| /* Object dupligroup. */ | /* Object dupligroup. */ | ||||
| if (object->dup_group != NULL) { | if (object->dup_group != NULL) { | ||||
| build_group(object, object->dup_group); | build_collection(object, object->dup_group); | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object) | void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object) | ||||
| { | { | ||||
| if (base == NULL) { | if (base == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 787 Lines • ▼ Show 20 Lines | void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) | ||||
| /* set up dependencies between these operations and other builtin nodes --------------- */ | /* set up dependencies between these operations and other builtin nodes --------------- */ | ||||
| /* time dependency */ | /* time dependency */ | ||||
| TimeSourceKey time_src_key; | TimeSourceKey time_src_key; | ||||
| add_relation(time_src_key, init_key, "TimeSrc -> Rigidbody Reset/Rebuild (Optional)"); | add_relation(time_src_key, init_key, "TimeSrc -> Rigidbody Reset/Rebuild (Optional)"); | ||||
| /* objects - simulation participants */ | /* objects - simulation participants */ | ||||
| if (rbw->group) { | if (rbw->group) { | ||||
| LISTBASE_FOREACH (Base *, base, &rbw->group->view_layer->object_bases) { | const ListBase group_objects = BKE_collection_object_cache_get(rbw->group); | ||||
| LISTBASE_FOREACH (Base *, base, &group_objects) { | |||||
| Object *object = base->object; | Object *object = base->object; | ||||
| if (object == NULL || object->type != OB_MESH) { | if (object == NULL || object->type != OB_MESH) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* hook up evaluation order... | /* hook up evaluation order... | ||||
| * 1) flushing rigidbody results follows base transforms being applied | * 1) flushing rigidbody results follows base transforms being applied | ||||
| * 2) rigidbody flushing can only be performed after simulation has been run | * 2) rigidbody flushing can only be performed after simulation has been run | ||||
| Show All 37 Lines | LISTBASE_FOREACH (Base *, base, &group_objects) { | ||||
| /* Needed to get correct base values. */ | /* Needed to get correct base values. */ | ||||
| add_relation(trans_op, sim_key, "Base Ob Transform -> Rigidbody Sim Eval"); | add_relation(trans_op, sim_key, "Base Ob Transform -> Rigidbody Sim Eval"); | ||||
| } | } | ||||
| } | } | ||||
| /* constraints */ | /* constraints */ | ||||
| if (rbw->constraints) { | if (rbw->constraints) { | ||||
| LISTBASE_FOREACH (Base *, base, &rbw->constraints->view_layer->object_bases) { | const ListBase constraint_objects = BKE_collection_object_cache_get(rbw->constraints); | ||||
| LISTBASE_FOREACH (Base *, base, &constraint_objects) { | |||||
| Object *object = base->object; | Object *object = base->object; | ||||
| if (object == NULL || !object->rigidbody_constraint) { | if (object == NULL || !object->rigidbody_constraint) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| RigidBodyCon *rbc = object->rigidbody_constraint; | RigidBodyCon *rbc = object->rigidbody_constraint; | ||||
| /* final result of the constraint object's transform controls how the | /* final result of the constraint object's transform controls how the | ||||
| ▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | switch (part->ren_as) { | ||||
| /* Build relation for the particle visualization. */ | /* Build relation for the particle visualization. */ | ||||
| build_particles_visualization_object(object, | build_particles_visualization_object(object, | ||||
| psys, | psys, | ||||
| part->dup_ob); | part->dup_ob); | ||||
| } | } | ||||
| break; | break; | ||||
| case PART_DRAW_GR: | case PART_DRAW_GR: | ||||
| if (part->dup_group != NULL) { | if (part->dup_group != NULL) { | ||||
| build_group(NULL, part->dup_group); | build_collection(NULL, part->dup_group); | ||||
| LISTBASE_FOREACH (GroupObject *, go, &part->dup_group->gobject) { | LISTBASE_FOREACH (CollectionObject *, go, &part->dup_group->gobject) { | ||||
| build_particles_visualization_object(object, | build_particles_visualization_object(object, | ||||
| psys, | psys, | ||||
| go->ob); | go->ob); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 686 Lines • Show Last 20 Lines | |||||