Depsgraph: Object data separation, light probes
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2018 08:23:45 +0000 (10:23 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2018 10:36:51 +0000 (12:36 +0200)
This is a beginning of series of commits which will clearly separate
building IDs which are used as object data from object building.

The goal is to be able to always build whatever ID. Required to make
driver targets to work reliably with copy-on-write concept.

source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_nodes.h
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/depsgraph_type_defines.cc
source/blender/depsgraph/intern/depsgraph_types.h

index 73bacbc..3753606 100644 (file)
@@ -575,7 +575,7 @@ void DepsgraphNodeBuilder::build_object_data(Object *object)
                        build_camera(object);
                        break;
                case OB_LIGHTPROBE:
-                       build_lightprobe(object);
+                       build_object_data_lightprobe(object);
                        break;
                default:
                {
@@ -588,6 +588,16 @@ void DepsgraphNodeBuilder::build_object_data(Object *object)
        }
 }
 
+void DepsgraphNodeBuilder::build_object_data_lightprobe(Object *object)
+{
+       LightProbe *probe = (LightProbe *)object->data;
+       build_lightprobe(probe);
+       add_operation_node(&object->id,
+                          DEG_NODE_TYPE_PARAMETERS,
+                          NULL,
+                          DEG_OPCODE_LIGHT_PROBE_EVAL);
+}
+
 void DepsgraphNodeBuilder::build_object_transform(Object *object)
 {
        OperationDepsNode *op_node;
@@ -1388,9 +1398,8 @@ void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)
                           DEG_OPCODE_MOVIECLIP_EVAL);
 }
 
-void DepsgraphNodeBuilder::build_lightprobe(Object *object)
+void DepsgraphNodeBuilder::build_lightprobe(LightProbe *probe)
 {
-       LightProbe *probe = (LightProbe *)object->data;
        if (built_map_.checkIsBuiltAndTag(probe)) {
                return;
        }
@@ -1398,13 +1407,7 @@ void DepsgraphNodeBuilder::build_lightprobe(Object *object)
        add_operation_node(&probe->id,
                           DEG_NODE_TYPE_PARAMETERS,
                           NULL,
-                          DEG_OPCODE_PLACEHOLDER,
-                          "LightProbe Eval");
-       add_operation_node(&object->id,
-                          DEG_NODE_TYPE_PARAMETERS,
-                          NULL,
-                          DEG_OPCODE_PLACEHOLDER,
-                          "LightProbe Eval");
+                          DEG_OPCODE_LIGHT_PROBE_EVAL);
 
        build_animdata(&probe->id);
 }
index b7c5a33..bb9cb2b 100644 (file)
@@ -50,6 +50,7 @@ struct Main;
 struct Material;
 struct Mask;
 struct MTex;
+struct LightProbe;
 struct MovieClip;
 struct bNodeTree;
 struct Object;
@@ -165,6 +166,7 @@ struct DepsgraphNodeBuilder {
                                Object *object,
                                eDepsNode_LinkedState_Type linked_state);
        void build_object_data(Object *object);
+       void build_object_data_lightprobe(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);
@@ -198,7 +200,7 @@ struct DepsgraphNodeBuilder {
        void build_cachefile(CacheFile *cache_file);
        void build_mask(Mask *mask);
        void build_movieclip(MovieClip *clip);
-       void build_lightprobe(Object *object);
+       void build_lightprobe(LightProbe *probe);
 
 protected:
        struct SavedEntryTag {
index e0df724..8e826cd 100644 (file)
@@ -615,7 +615,7 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
                        build_camera(object);
                        break;
                case OB_LIGHTPROBE:
-                       build_lightprobe(object);
+                       build_object_data_lightprobe(object);
                        break;
        }
        Key *key = BKE_key_from_object(object);
@@ -627,6 +627,19 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
        }
 }
 
+void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object)
+{
+       LightProbe *probe = (LightProbe *)object->data;
+       build_lightprobe(probe);
+       OperationKey probe_key(&probe->id,
+                              DEG_NODE_TYPE_PARAMETERS,
+                              DEG_OPCODE_LIGHT_PROBE_EVAL);
+       OperationKey object_key(&object->id,
+                               DEG_NODE_TYPE_PARAMETERS,
+                               DEG_OPCODE_LIGHT_PROBE_EVAL);
+       add_relation(probe_key, object_key, "LightProbe Update");
+}
+
 void DepsgraphRelationBuilder::build_object_parent(Object *object)
 {
        /* XXX: for now, need to use the component key (not just direct to the parent op),
@@ -2045,23 +2058,12 @@ void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip)
        build_animdata(&clip->id);
 }
 
-void DepsgraphRelationBuilder::build_lightprobe(Object *object)
+void DepsgraphRelationBuilder::build_lightprobe(LightProbe *probe)
 {
-       LightProbe *probe = (LightProbe *)object->data;
        if (built_map_.checkIsBuiltAndTag(probe)) {
                return;
        }
        build_animdata(&probe->id);
-
-       OperationKey probe_key(&probe->id,
-                              DEG_NODE_TYPE_PARAMETERS,
-                              DEG_OPCODE_PLACEHOLDER,
-                              "LightProbe Eval");
-       OperationKey object_key(&object->id,
-                               DEG_NODE_TYPE_PARAMETERS,
-                               DEG_OPCODE_PLACEHOLDER,
-                               "LightProbe Eval");
-       add_relation(probe_key, object_key, "LightProbe Update");
 }
 
 void DepsgraphRelationBuilder::build_copy_on_write_relations()
index dbfaff4..0211f5d 100644 (file)
@@ -58,6 +58,7 @@ struct FCurve;
 struct Collection;
 struct Key;
 struct LayerCollection;
+struct LightProbe;
 struct Main;
 struct Mask;
 struct Material;
@@ -201,6 +202,7 @@ struct DepsgraphRelationBuilder
        void build_object(Base *base, Object *object);
        void build_object_flags(Base *base, Object *object);
        void build_object_data(Object *object);
+       void build_object_data_lightprobe(Object *object);
        void build_object_parent(Object *object);
        void build_constraints(ID *id,
                               eDepsNode_Type component_type,
@@ -251,7 +253,7 @@ struct DepsgraphRelationBuilder
        void build_cachefile(CacheFile *cache_file);
        void build_mask(Mask *mask);
        void build_movieclip(MovieClip *clip);
-       void build_lightprobe(Object *object);
+       void build_lightprobe(LightProbe *probe);
 
        void build_nested_datablock(ID *owner, ID *id);
        void build_nested_nodetree(ID *owner, bNodeTree *ntree);
index 19cc82a..79d29f7 100644 (file)
@@ -138,6 +138,8 @@ const char *operationCodeAsString(eDepsOperation_Code opcode)
                STRINGIFY_OPCODE(GEOMETRY_UBEREVAL);
                STRINGIFY_OPCODE(GEOMETRY_CLOTH_MODIFIER);
                STRINGIFY_OPCODE(GEOMETRY_SHAPEKEY);
+               /* Object data. */
+               STRINGIFY_OPCODE(LIGHT_PROBE_EVAL);
                /* Pose. */
                STRINGIFY_OPCODE(POSE_INIT);
                STRINGIFY_OPCODE(POSE_INIT_IK);
index 14cd62e..18bc0bd 100644 (file)
@@ -205,6 +205,9 @@ typedef enum eDepsOperation_Code {
        DEG_OPCODE_GEOMETRY_CLOTH_MODIFIER,
        DEG_OPCODE_GEOMETRY_SHAPEKEY,
 
+       /* Object data. ------------------------------------- */
+       DEG_OPCODE_LIGHT_PROBE_EVAL,
+
        /* Pose. -------------------------------------------- */
        /* Init pose, clear flags, etc. */
        DEG_OPCODE_POSE_INIT,