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 73bacbc61920e62faff3f8d1a6f44512c431aa3b..3753606862e330449c2bcefe5eeda6ac43b11db0 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 b7c5a33f2c0900f1ce4b7c117fcdbf77f583d71b..bb9cb2bd13458e175f4da8cf9552ab70b85f2ea8 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 e0df724818dd835859ec69b3b6bea3849a6170a0..8e826cd01dfc6b2b00380e80c51e043f4ab73938 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 dbfaff4dc18f09d16565c8d7a62577151d52a7b8..0211f5dba68e2052fe42c96d0d9cf37bd5e03018 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 19cc82a6b102976b733de751e073236a20259449..79d29f72b8dbd8ef57b7c85c2a33ace7c3fcee0d 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 14cd62e6cec0cb9bb6feb95c485fe568aa608bee..18bc0bd05013a6c14b1a998729a76749615a0449 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,