Commit: e4c408ca71132bf54d753e4c2031e974d08bf29a
Author: Dalai Felinto
Date: Mon Nov 6 19:42:08 2017 -0200
Branches: temp-group-collections
https://developer.blender.org/rBe4c408ca71132bf54d753e4c2031e974d08bf29a
Merge remote-tracking branch 'origin/blender2.8' into temp-group-collections
===================================================================
===================================================================
diff --cc source/blender/depsgraph/DEG_depsgraph_query.h
index 2001053eb8b,59158ef0454..cbd2927f255
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@@ -102,8 -101,10 +101,12 @@@ typedef struct DEGObjectsIteratorData
* other users of the iterator.
*/
struct Object temp_dupli_object;
+
+ /* **** ghash **** */
+ struct GHashIterator gh_iter;
+
+ /* List of all groups in current scene layer. */
+ struct GSet *groups;
} DEGObjectsIteratorData;
void DEG_objects_iterator_begin(struct BLI_Iterator *iter,
DEGObjectsIteratorData *data);
diff --cc source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 73aa75076e2,464a1454749..3f9c906dbbc
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@@ -392,34 -396,14 +397,36 @@@ void DepsgraphNodeBuilder::build_group(
}
group_id->tag |= LIB_TAG_DOIT;
- LINKLIST_FOREACH (GroupObject *, go, &group->gobject) {
- build_object(scene, go->ob, DEG_ID_LINKED_INDIRECTLY);
+ LINKLIST_FOREACH (Base *, base, &group->scene_layer->object_bases) {
- build_object(scene, base->object);
++ build_object(scene, base->object, DEG_ID_LINKED_INDIRECTLY);
}
}
+void DepsgraphNodeBuilder::build_group(Scene *scene, Group *group,
LayerCollectionState *state)
+{
+ /* XXX What happens if the group is instanced AND is in a layer
collection?
+ * We need to test something different than LIB_TAG_DOIT here
(dfelinto). */
+ ID *group_id = &group->id;
+ if (group_id->tag & LIB_TAG_DOIT) {
+ return;
+ }
+ group_id->tag |= LIB_TAG_DOIT;
+
+ LINKLIST_FOREACH (Base *, base, &group->scene_layer->object_bases) {
- build_object(scene, base->object);
++ build_object(scene, base->object, DEG_ID_LINKED_INDIRECTLY);
+ }
+
+ ComponentDepsNode *comp = add_component_node(&group->id,
DEG_NODE_TYPE_LAYER_COLLECTIONS);
+ add_operation_node(comp,
+ function_bind(BKE_layer_eval_layer_collection_pre,
_1, scene, group->scene_layer, false),
+ DEG_OPCODE_SCENE_LAYER_GROUP,
+ group->id.name + 2);
+ ++state->index;
+}
+
- void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob)
+ void DepsgraphNodeBuilder::build_object(Scene *scene,
+ Object *ob,
+ eDepsNode_LinkedState_Type
linked_state)
{
/* Skip rest of components if the ID node was already there. */
if (ob->id.tag & LIB_TAG_DOIT) {
diff --cc source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 8e7138f6be0,e7bf8c9998d..b576e7eab23
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@@ -156,15 -157,13 +157,22 @@@ struct DepsgraphNodeBuilder
const char *name = "",
int name_tag = -1);
+ struct LayerCollectionState {
+ int index;
+ LayerCollection *parent;
+ };
+
- void build_scene(Main *bmain, Scene *scene);
- void build_group(Scene *scene, Group *group);
- void build_group(Scene *scene, Group *group, LayerCollectionState
*state);
- void build_object(Scene *scene, Object *ob);
+ void build_scene(Main *bmain,
+ Scene *scene,
+ eDepsNode_LinkedState_Type linked_state);
- void build_group(Scene *scene, Group *group);
++ void build_group(Scene *scene,
++ Group *group);
++ void build_group(Scene *scene,
++ Group *group,
++ LayerCollectionState *state);
+ void build_object(Scene *scene,
+ Object *ob,
+ eDepsNode_LinkedState_Type linked_state);
void build_object_transform(Scene *scene, Object *ob);
void build_object_constraints(Scene *scene, Object *ob);
void build_pose_constraints(Scene *scene, Object *ob, bPoseChannel
*pchan);
diff --cc source/blender/depsgraph/intern/depsgraph_query.cc
index 9c884c0ecbd,156b98a6421..9e330efcff9
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@@ -117,89 -117,59 +118,103 @@@ ID *DEG_get_evaluated_id(struct Depsgra
return id_node->id_cow;
}
- /* ************************ DAG ITERATORS ********************* */
+ /* ************************ DEG ITERATORS ********************* */
+
+ /**
+ * XXX (dfelinto/sergey) big hack, waiting for:
+ * "Reshuffle collections base flags evaluation, make it so object is
gathering its base flags from collections."
+ *
+ * Returns false if object shouldn't be found (which should never happen in
the final implementation
+ * and instead we should have a tag to the objects that were not directly
part of the depsgraph).
+ *
+ * That means that the object is not in a collection but it's part of
depsgraph, or the object is simply
+ * not in the current SceneLayer - Depsgraph at the moment includes all the
SceneLayer in the Scene.
+ */
+ static bool deg_flush_base_flags_and_settings(
+ DEGObjectsIteratorData *data, Object *ob_dst, Object *ob_src, const
bool is_dupli)
+ {
+ Base *base;
+ Depsgraph *graph = data->graph;
+ SceneLayer *scene_layer = DEG_get_evaluated_scene_layer(graph);
+ int flag = is_dupli ? BASE_FROMDUPLI : 0;
+
+ /* First attempt, see if object is in the current SceneLayer. */
+ base = (Base *)BLI_findptr(&scene_layer->object_bases, ob_src,
offsetof(Base, object));
+
+ /* Next attempt, see if object is in one of the sets. */
+ if (base == NULL) {
+ Scene *scene_iter, *scene = DEG_get_evaluated_scene(graph);
+ scene_iter = scene;
+
+ while ((scene_iter = (scene_iter)->set)) {
+ SceneLayer *scene_layer_set =
BKE_scene_layer_from_scene_get(scene_iter);
+ base = (Base
*)BLI_findptr(&scene_layer_set->object_bases, ob_src, offsetof(Base, object));
+ if (base != NULL) {
+ flag |= BASE_FROM_SET;
+ flag &= ~(BASE_SELECTED | BASE_SELECTABLED);
+ break;
+ }
+ }
+ }
+
+ if (base == NULL) {
+ return false;
+ }
+
+ /* Make sure we have the base collection settings is already populated.
+ * This will fail when BKE_layer_eval_layer_collection_pre hasn't run
yet
+ * Which usually means a missing call to DEG_id_tag_update(). */
+
BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
+
+ ob_dst->base_flag = base->flag | flag;
+ ob_dst->base_collection_properties = base->collection_properties;
+ return true;
+ }
- #define BASE_FLUSH_FLAGS (BASE_FROM_SET | BASE_FROMDUPLI)
+
+/**
+ * \param groups: GSet of looped over groups.
+ * \param lb: ListBase of LayerCollection elements.
+ */
+static void populate_scene_layer_groups_doit(GSet *groups, ListBase *lb)
+{
+ LayerCollection *layer_collection;
+ for (layer_collection = (LayerCollection *) lb->first;
+ layer_collection;
+ layer_collection = layer_collection->next)
+ {
+ /* TODO: Disabled collections shouldn't even be evaluated by
the Depsgraph (dfelinto/sergey). */
+ if (layer_collection->flag & COLLECTION_DISABLED) {
+ continue;
+ }
+
+ SceneCollection *scene_collection =
layer_collection->scene_collection;
+ if (scene_collection->type == COLLECTION_TYPE_GROUP) {
+ Group *group = scene_collection->group;
+ if (group != NULL && !BLI_gset_haskey(groups, group)) {
+ BLI_gset_add(groups, group);
+ }
+ }
+ else {
+ /* Continue recursively. */
+ populate_scene_layer_groups_doit(groups,
&layer_collection->layer_collections);
+ }
+ }
+
+}
+
+static void populate_scene_layer_groups(GSet **groups, SceneLayer
*scene_layer)
+{
+ *groups = BLI_gset_ptr_new(__func__);
+
+ populate_scene_layer_groups_doit(*groups,
&scene_layer->layer_collections);
+
+ if (BLI_gset_size(*groups) == 0) {
+ BLI_gset_free(*groups, NULL);
+ *groups = NULL;
+ }
+}
+
- void DEG_objects_iterator_begin(BLI_Iterator *iter, DEGObjectsIteratorData
*data)
- {
- Depsgraph *graph = data->graph;
- SceneLayer *scene_layer = DEG_get_evaluated_scene_layer(graph);
-
- iter->data = data;
- iter->valid = true;
-
- data->scene = DEG_get_evaluated_scene(graph);
- DEG_evaluation_context_init(&data->eval_ctx, DAG_EVAL_RENDER);
-
- /* TODO(sergey): It's really confusing to store pointer to a local
data. */
- Base base = {(Base *)scene_layer->object_bases.first, NULL};
- data->base = &base;
-
- data->base_flag = ~(BASE_FLUSH_FLAGS);
-
- data->dupli_parent = NULL;
- data->dupli_list = NULL;
- data->dupli_object_next = NULL;
- data->dupli_object_current = NULL;
-
- populate_scene_layer_groups(&data->groups, scene_layer);
-
- DEG_objects_iterator_next(iter);
- }
-
- /**
- * Temporary function to flush depsgraph until we get copy on write (CoW)
- */
- static void deg_flush_base_flags_and_settings(Object *ob, Base *base, const
int flag)
- {
- ob->base_flag = (base->flag | BASE_FLUSH_FLAGS) & flag;
- ob->base_collection_properties = base->collection_properties;
- }
-
static bool deg_objects_dupli_iterator_next(BLI_Iterator *iter)
{
DEGObjectsIteratorData *data = (DEGObjectsIteratorData *)iter->data;
@@@ -238,59 -209,75 +254,77 @@@
return false;
}
- void DEG_objects_iterator_next(BLI_Iterator *iter)
+ static void def_objects_iterator_step(BLI_Iterator *iter, DEG::IDDepsNode
*id_node)
{
DEGObjectsIteratorData *data = (DEGObjectsIteratorData *)iter->data;
- Base *base;
+ const ID_Type id_type = GS(id_node->id_orig->name);
- if (data->dupli_list) {
- if (deg_objects_dupli_iterator_next(iter)) {
+ if (id_type != ID_OB) {
+ iter->skip = true;
+ return;
+ }
+
+ switch (id_node->linked_state) {
+ case DEG::DEG_ID_LINKED_DIRECTLY:
+ break;
+ case DEG::DEG_ID_LINKED_VIA_SET:
+ if (data->flag & DEG_OBJECT_ITER_FLAG_SET) {
+ break;
+ }
+ else {
+ ATTR_FALLTHROUGH;
+ }
+ case DEG::DEG_ID_LINKED_INDIRECTLY:
+ iter->skip = true;
return;
- }
- else {
- free_object_duplilist(data->dupli_list);
- data->dupli_parent = NULL;
- data->dupli_list = NULL;
- data->dupli_object_next = NULL;
- data->dupli_object_current = NULL;
- }
}
- base
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs