diff options
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
6 files changed, 65 insertions, 44 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 31a0e74b569..98881ba3e57 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -71,12 +71,12 @@ extern "C" { #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_animsys.h" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_effect.h" #include "BKE_fcurve.h" #include "BKE_idcode.h" -#include "BKE_group.h" #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_library.h" @@ -388,7 +388,7 @@ void DepsgraphNodeBuilder::build_id(ID* id) { } switch (GS(id->name)) { case ID_GR: - build_group((Group *)id); + build_collection((Collection *)id); break; case ID_OB: build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY); @@ -419,29 +419,21 @@ void DepsgraphNodeBuilder::build_id(ID* id) { } } -void DepsgraphNodeBuilder::build_group(Group *group) +void DepsgraphNodeBuilder::build_collection(Collection *collection) { - if (built_map_.checkIsBuiltAndTag(group)) { + if (built_map_.checkIsBuiltAndTag(collection)) { return; } - /* Build group objects. */ - LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) { - build_object(-1, base->object, DEG_ID_LINKED_INDIRECTLY); + /* Build collection objects. */ + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { + build_object(-1, cob->ob, DEG_ID_LINKED_INDIRECTLY); } - /* Operation to evaluate the whole view layer. - * - * NOTE: We re-use DONE opcode even though the function does everything. - * 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(&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); + /* Build child collections. */ + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { + build_collection(child->collection); + } + + add_id_node(&collection->id); } void DepsgraphNodeBuilder::build_object(int base_index, @@ -514,7 +506,7 @@ void DepsgraphNodeBuilder::build_object(int base_index, } /* Object dupligroup. */ if (object->dup_group != NULL) { - build_group(object->dup_group); + build_collection(object->dup_group); } } @@ -848,7 +840,8 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene) /* objects - simulation participants */ 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; if (!object || (object->type != OB_MESH)) @@ -922,7 +915,7 @@ void DepsgraphNodeBuilder::build_particles(Object *object) break; case PART_DRAW_GR: if (part->dup_group != NULL) { - build_group(part->dup_group); + build_collection(part->dup_group); } break; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 0ed3f5e334f..488f4f273b9 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -43,7 +43,7 @@ struct GHash; struct ID; struct Image; struct FCurve; -struct Group; +struct Collection; struct Key; struct LayerCollection; struct Main; @@ -158,10 +158,11 @@ struct DepsgraphNodeBuilder { int name_tag = -1); void build_id(ID* id); + void build_layer_collections(ListBase *lb); void build_view_layer(Scene *scene, ViewLayer *view_layer, eDepsNode_LinkedState_Type linked_state); - void build_group(Group *group); + void build_collection(Collection *collection); void build_object(int base_index, Object *object, eDepsNode_LinkedState_Type linked_state); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc index ac3970ed3ab..a396aecd3a8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc @@ -65,6 +65,14 @@ extern "C" { namespace DEG { +void DepsgraphNodeBuilder::build_layer_collections(ListBase *lb) +{ + for (LayerCollection *lc = (LayerCollection *)lb->first; lc; lc = lc->next) { + build_collection(lc->collection); + build_layer_collections(&lc->layer_collections); + } +} + void DepsgraphNodeBuilder::build_view_layer( Scene *scene, ViewLayer *view_layer, @@ -100,6 +108,7 @@ void DepsgraphNodeBuilder::build_view_layer( base->object->select_color = select_color++; ++base_index; } + build_layer_collections(&view_layer->layer_collections); if (scene->camera != NULL) { build_object(-1, scene->camera, DEG_ID_LINKED_INDIRECTLY); } @@ -140,7 +149,7 @@ void DepsgraphNodeBuilder::build_view_layer( DEG_NODE_TYPE_LAYER_COLLECTIONS, function_bind(BKE_layer_eval_view_layer_indexed, _1, - &scene_cow->id, + scene_cow, view_layer_index_), DEG_OPCODE_VIEW_LAYER_EVAL); /* Parameters evaluation for scene relations mainly. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index e1eae851ec6..edb2969fa63 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -72,12 +72,12 @@ extern "C" { #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_animsys.h" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_effect.h" #include "BKE_collision.h" #include "BKE_fcurve.h" -#include "BKE_group.h" #include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" @@ -296,14 +296,14 @@ void DepsgraphRelationBuilder::add_collision_relations( const OperationKey &key, Scene *scene, Object *object, - Group *group, + Collection *collection, bool dupli, const char *name) { unsigned int numcollobj; Object **collobjs = get_collisionobjects_ext(scene, object, - group, + collection, &numcollobj, eModifierType_Collision, dupli); @@ -397,7 +397,7 @@ void DepsgraphRelationBuilder::build_id(ID *id) } switch (GS(id->name)) { case ID_GR: - build_group(NULL, (Group *)id); + build_collection(NULL, (Collection *)id); break; case ID_OB: build_object(NULL, (Object *)id); @@ -425,19 +425,23 @@ void DepsgraphRelationBuilder::build_id(ID *id) } } -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, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL); if (!group_done) { - LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) { - build_object(NULL, base->object); + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { + build_object(NULL, cob->ob); + } + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { + build_collection(NULL, child->collection); } } 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); add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup"); } @@ -549,7 +553,7 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object) } /* Object dupligroup. */ if (object->dup_group != NULL) { - build_group(object, object->dup_group); + build_collection(object, object->dup_group); } } @@ -1353,7 +1357,8 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) /* objects - simulation participants */ 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; if (object == NULL || object->type != OB_MESH) { continue; @@ -1407,7 +1412,8 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) /* 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; if (object == NULL || !object->rigidbody_constraint) { continue; @@ -1529,8 +1535,8 @@ void DepsgraphRelationBuilder::build_particles(Object *object) break; case PART_DRAW_GR: if (part->dup_group != NULL) { - build_group(NULL, part->dup_group); - LISTBASE_FOREACH (GroupObject *, go, &part->dup_group->gobject) { + build_collection(NULL, part->dup_group); + LISTBASE_FOREACH (CollectionObject *, go, &part->dup_group->gobject) { build_particles_visualization_object(object, psys, go->ob); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 9e45d01fd79..fec30160622 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -55,7 +55,7 @@ struct ListBase; struct GHash; struct ID; struct FCurve; -struct Group; +struct Collection; struct Key; struct LayerCollection; struct Main; @@ -195,8 +195,9 @@ struct DepsgraphRelationBuilder bool check_unique = false); void build_id(ID* id); + void build_layer_collections(ListBase *lb); void build_view_layer(Scene *scene, ViewLayer *view_layer); - void build_group(Object *object, Group *group); + void build_collection(Object *object, Collection *collection); void build_object(Base *base, Object *object); void build_object_flags(Base *base, Object *object); void build_object_data(Object *object); @@ -259,7 +260,7 @@ struct DepsgraphRelationBuilder void add_collision_relations(const OperationKey &key, Scene *scene, Object *object, - Group *group, + Collection *collection, bool dupli, const char *name); void add_forcefield_relations(const OperationKey &key, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc index 99295a733fc..f575be9f659 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc @@ -69,6 +69,14 @@ extern "C" { namespace DEG { +void DepsgraphRelationBuilder::build_layer_collections(ListBase *lb) +{ + for (LayerCollection *lc = (LayerCollection *)lb->first; lc; lc = lc->next) { + build_collection(NULL, lc->collection); + build_layer_collections(&lc->layer_collections); + } +} + void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_layer) { /* Setup currently building context. */ @@ -81,6 +89,9 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { build_object(base, base->object); } + + build_layer_collections(&view_layer->layer_collections); + if (scene->camera != NULL) { build_object(NULL, scene->camera); } |