Merge branch 'master' into blender2.8
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_nodes.h
index 17d2a4ad5583514d17f4a99ec4050247d5fde3c6..8dfbc4fa37ca04a0ead0a18687b07f0cd328a63e 100644 (file)
@@ -33,6 +33,8 @@
 #include "intern/builder/deg_builder_map.h"
 #include "intern/depsgraph_types.h"
 
+#include "DEG_depsgraph.h"  /* used for DEG_depsgraph_use_copy_on_write() */
+
 struct Base;
 struct CacheFile;
 struct bGPdata;
@@ -43,6 +45,7 @@ struct Image;
 struct FCurve;
 struct Group;
 struct Key;
+struct LayerCollection;
 struct Main;
 struct Material;
 struct Mask;
@@ -50,6 +53,8 @@ struct MTex;
 struct MovieClip;
 struct bNodeTree;
 struct Object;
+struct ParticleSettings;
+struct Probe;
 struct bPoseChannel;
 struct bConstraint;
 struct Scene;
@@ -71,9 +76,45 @@ struct DepsgraphNodeBuilder {
        DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph);
        ~DepsgraphNodeBuilder();
 
+       /* For given original ID get ID which is created by CoW system. */
+       ID *get_cow_id(const ID *id_orig) const;
+       /* Similar to above, but for the cases when there is no ID node we create
+        * one.
+        */
+       ID *ensure_cow_id(ID *id_orig);
+
+       /* Helper wrapper function which wraps get_cow_id with a needed type cast. */
+       template<typename T>
+       T *get_cow_datablock(const T *orig) const {
+               return (T *)get_cow_id(&orig->id);
+       }
+
+       /* Get fully expanded (ready for use) copy-on-write datablock for the given
+        * original datablock.
+        */
+       ID *expand_cow_id(IDDepsNode *id_node);
+       ID *expand_cow_id(ID *id_orig);
+       template<typename T>
+       T *expand_cow_datablock(T *orig) {
+               return (T *)expand_cow_id(&orig->id);
+       }
+
+       /* For a given COW datablock get corresponding original one. */
+       template<typename T>
+       T *get_orig_datablock(const T *cow) const {
+               if (DEG_depsgraph_use_copy_on_write()) {
+                       return (T *)cow->id.orig_id;
+               }
+               else {
+                       return (T *)cow;
+               }
+       }
+
        void begin_build();
+       void end_build();
 
        IDDepsNode *add_id_node(ID *id);
+       IDDepsNode *find_id_node(ID *id);
        TimeSourceDepsNode *add_time_source();
 
        ComponentDepsNode *add_component_node(ID *id,
@@ -126,15 +167,23 @@ struct DepsgraphNodeBuilder {
                                               const char *name = "",
                                               int name_tag = -1);
 
-       void build_scene(Scene *scene);
-       void build_group(Base *base, Group *group);
-       void build_object(Base *base, Object *object);
+       void build_view_layer(Scene *scene,
+                              ViewLayer *view_layer,
+                              eDepsNode_LinkedState_Type linked_state);
+       void build_group(Group *group);
+       void build_object(Base *base,
+                         Object *object,
+                         eDepsNode_LinkedState_Type linked_state);
+       void build_object_flags(Base *base,
+                               Object *object,
+                               eDepsNode_LinkedState_Type linked_state);
        void build_object_data(Object *object);
        void build_object_transform(Object *object);
        void build_object_constraints(Object *object);
        void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index);
        void build_rigidbody(Scene *scene);
        void build_particles(Object *object);
+       void build_particle_settings(ParticleSettings *part);
        void build_cloth(Object *object);
        void build_animdata(ID *id);
        void build_driver(ID *id, FCurve *fcurve);
@@ -163,8 +212,27 @@ struct DepsgraphNodeBuilder {
        void build_cachefile(CacheFile *cache_file);
        void build_mask(Mask *mask);
        void build_movieclip(MovieClip *clip);
-
+       void build_lightprobe(Object *object);
+
+       struct LayerCollectionState {
+               int index;
+               LayerCollection *parent;
+       };
+       void build_layer_collection(ID *owner_id,
+                                   LayerCollection *layer_collection,
+                                   LayerCollectionState *state);
+       void build_layer_collections(ID *owner_id,
+                                    ListBase *layer_collections,
+                                    LayerCollectionState *state);
+       void build_view_layer_collections(ID *owner_id, ViewLayer *view_layer);
 protected:
+       struct SavedEntryTag {
+               ID *id;
+               eDepsNode_Type component_type;
+               eDepsOperation_Code opcode;
+       };
+       vector<SavedEntryTag> saved_entry_tags_;
+
        /* State which never changes, same for the whole builder time. */
        Main *bmain_;
        Depsgraph *graph_;
@@ -172,6 +240,7 @@ protected:
        /* State which demotes currently built entities. */
        Scene *scene_;
 
+       GHash *cow_id_hash_;
        BuilderMap built_map_;
 };