Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
| Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #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 "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_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_idcode.h" | #include "BKE_idcode.h" | ||||
| #include "BKE_group.h" | |||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mask.h" | #include "BKE_mask.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_mball.h" | #include "BKE_mball.h" | ||||
| ▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void DepsgraphNodeBuilder::build_id(ID* id) { | void DepsgraphNodeBuilder::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((Group *)id); | build_collection((Collection *)id); | ||||
| break; | break; | ||||
| case ID_OB: | case ID_OB: | ||||
| build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY); | build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY); | ||||
| 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 14 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 DepsgraphNodeBuilder::build_group(Group *group) | void DepsgraphNodeBuilder::build_collection(Collection *collection) | ||||
| { | { | ||||
| if (built_map_.checkIsBuiltAndTag(group)) { | if (built_map_.checkIsBuiltAndTag(collection)) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Build group objects. */ | /* Build collection objects. */ | ||||
| LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) { | LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { | ||||
| build_object(-1, base->object, DEG_ID_LINKED_INDIRECTLY); | build_object(-1, cob->ob, DEG_ID_LINKED_INDIRECTLY); | ||||
| } | } | ||||
| /* Operation to evaluate the whole view layer. | /* Build child collections. */ | ||||
| * | LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { | ||||
| * NOTE: We re-use DONE opcode even though the function does everything. | build_collection(child->collection); | ||||
| * This way we wouldn't need to worry about possible relations from DONE, | } | ||||
| * regardless whether it's a group or scene or something else. | |||||
| */ | add_id_node(&collection->id); | ||||
| add_id_node(&group->id); | |||||
| Group *group_cow = get_cow_datablock(group); | |||||
| add_operation_node(&group->id, | |||||
| DEG_NODE_TYPE_LAYER_COLLECTIONS, | |||||
| function_bind(BKE_group_eval_view_layers, | |||||
| _1, | |||||
| group_cow), | |||||
| DEG_OPCODE_VIEW_LAYER_EVAL); | |||||
| } | } | ||||
| void DepsgraphNodeBuilder::build_object(int base_index, | void DepsgraphNodeBuilder::build_object(int base_index, | ||||
| Object *object, | Object *object, | ||||
| eDepsNode_LinkedState_Type linked_state) | eDepsNode_LinkedState_Type linked_state) | ||||
| { | { | ||||
| const bool has_object = built_map_.checkIsBuiltAndTag(object); | const bool has_object = built_map_.checkIsBuiltAndTag(object); | ||||
| /* Skip rest of components if the ID node was already there. */ | /* Skip rest of components if the ID node was already there. */ | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | void DepsgraphNodeBuilder::build_object(int base_index, | ||||
| } | } | ||||
| /* Object that this is a proxy for. */ | /* Object that this is a proxy for. */ | ||||
| if (object->proxy) { | if (object->proxy) { | ||||
| object->proxy->proxy_from = object; | object->proxy->proxy_from = object; | ||||
| build_object(-1, object->proxy, DEG_ID_LINKED_INDIRECTLY); | build_object(-1, object->proxy, DEG_ID_LINKED_INDIRECTLY); | ||||
| } | } | ||||
| /* Object dupligroup. */ | /* Object dupligroup. */ | ||||
| if (object->dup_group != NULL) { | if (object->dup_group != NULL) { | ||||
| build_group(object->dup_group); | build_collection(object->dup_group); | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphNodeBuilder::build_object_flags( | void DepsgraphNodeBuilder::build_object_flags( | ||||
| int base_index, | int base_index, | ||||
| Object *object, | Object *object, | ||||
| eDepsNode_LinkedState_Type linked_state) | eDepsNode_LinkedState_Type linked_state) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | void DepsgraphNodeBuilder::build_rigidbody(Scene *scene) | ||||
| /* XXX: For now, the sim node is the only one that really matters here. | /* XXX: For now, the sim node is the only one that really matters here. | ||||
| * If any other sims get added later, we may have to remove these hacks... | * If any other sims get added later, we may have to remove these hacks... | ||||
| */ | */ | ||||
| sim_node->owner->entry_operation = sim_node; | sim_node->owner->entry_operation = sim_node; | ||||
| sim_node->owner->exit_operation = sim_node; | sim_node->owner->exit_operation = sim_node; | ||||
| /* 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 || (object->type != OB_MESH)) | if (!object || (object->type != OB_MESH)) | ||||
| continue; | continue; | ||||
| /* 2) create operation for flushing results */ | /* 2) create operation for flushing results */ | ||||
| /* object's transform component - where the rigidbody operation | /* object's transform component - where the rigidbody operation | ||||
| * lives. */ | * lives. */ | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | switch (part->ren_as) { | ||||
| if (part->dup_ob != NULL) { | if (part->dup_ob != NULL) { | ||||
| build_object(-1, | build_object(-1, | ||||
| part->dup_ob, | part->dup_ob, | ||||
| DEG_ID_LINKED_INDIRECTLY); | DEG_ID_LINKED_INDIRECTLY); | ||||
| } | } | ||||
| break; | break; | ||||
| case PART_DRAW_GR: | case PART_DRAW_GR: | ||||
| if (part->dup_group != NULL) { | if (part->dup_group != NULL) { | ||||
| build_group(part->dup_group); | build_collection(part->dup_group); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* TODO(sergey): Do we need a point cache operations here? */ | /* TODO(sergey): Do we need a point cache operations here? */ | ||||
| add_operation_node(&object->id, | add_operation_node(&object->id, | ||||
| DEG_NODE_TYPE_CACHE, | DEG_NODE_TYPE_CACHE, | ||||
| ▲ Show 20 Lines • Show All 544 Lines • Show Last 20 Lines | |||||