Depsgraph: Object data separation, lamp
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2018 08:47:54 +0000 (10:47 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2018 10:36:51 +0000 (12:36 +0200)
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

index 3753606862e330449c2bcefe5eeda6ac43b11db0..b1a31ebf4a9a13624c20412922a2ffc8acb4d6d2 100644 (file)
@@ -569,7 +569,7 @@ void DepsgraphNodeBuilder::build_object_data(Object *object)
                        }
                        break;
                case OB_LAMP:
-                       build_lamp(object);
+                       build_object_data_lamp(object);
                        break;
                case OB_CAMERA:
                        build_camera(object);
@@ -588,6 +588,12 @@ void DepsgraphNodeBuilder::build_object_data(Object *object)
        }
 }
 
+void DepsgraphNodeBuilder::build_object_data_lamp(Object *object)
+{
+       Lamp *lamp = (Lamp *)object->data;
+       build_lamp(lamp);
+}
+
 void DepsgraphNodeBuilder::build_object_data_lightprobe(Object *object)
 {
        LightProbe *probe = (LightProbe *)object->data;
@@ -1176,11 +1182,8 @@ void DepsgraphNodeBuilder::build_camera(Object *object)
                           DEG_OPCODE_PARAMETERS_EVAL);
 }
 
-/* Lamps */
-void DepsgraphNodeBuilder::build_lamp(Object *object)
+void DepsgraphNodeBuilder::build_lamp(Lamp *lamp)
 {
-       /* Object data. */
-       Lamp *lamp = (Lamp *)object->data;
        if (built_map_.checkIsBuiltAndTag(lamp)) {
                return;
        }
index bb9cb2bd13458e175f4da8cf9552ab70b85f2ea8..564d15781f2805c5b81925448ca812b3f89ba9cf 100644 (file)
@@ -45,12 +45,13 @@ struct Image;
 struct FCurve;
 struct Collection;
 struct Key;
+struct Lamp;
 struct LayerCollection;
+struct LightProbe;
 struct Main;
 struct Material;
 struct Mask;
 struct MTex;
-struct LightProbe;
 struct MovieClip;
 struct bNodeTree;
 struct Object;
@@ -166,6 +167,7 @@ struct DepsgraphNodeBuilder {
                                Object *object,
                                eDepsNode_LinkedState_Type linked_state);
        void build_object_data(Object *object);
+       void build_object_data_lamp(Object *object);
        void build_object_data_lightprobe(Object *object);
        void build_object_transform(Object *object);
        void build_object_constraints(Object *object);
@@ -189,7 +191,7 @@ struct DepsgraphNodeBuilder {
        void build_shapekeys(Key *key);
        void build_obdata_geom(Object *object);
        void build_camera(Object *object);
-       void build_lamp(Object *object);
+       void build_lamp(Lamp *lamp);
        void build_nodetree(bNodeTree *ntree);
        void build_material(Material *ma);
        void build_texture(Tex *tex);
index 8e826cd01dfc6b2b00380e80c51e043f4ab73938..9d978aff9fb92f13036da7b01efd156d0f354c31 100644 (file)
@@ -609,7 +609,7 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
                        }
                        break;
                case OB_LAMP:
-                       build_lamp(object);
+                       build_object_data_lamp(object);
                        break;
                case OB_CAMERA:
                        build_camera(object);
@@ -627,6 +627,15 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
        }
 }
 
+void DepsgraphRelationBuilder::build_object_data_lamp(Object *object)
+{
+       Lamp *lamp = (Lamp *)object->data;
+       build_lamp(lamp);
+       ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS);
+       ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
+       add_relation(lamp_parameters_key, object_parameters_key, "Lamp -> Object");
+}
+
 void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object)
 {
        LightProbe *probe = (LightProbe *)object->data;
@@ -1873,37 +1882,19 @@ void DepsgraphRelationBuilder::build_camera(Object *object)
 }
 
 /* Lamps */
-void DepsgraphRelationBuilder::build_lamp(Object *object)
+void DepsgraphRelationBuilder::build_lamp(Lamp *lamp)
 {
-       Lamp *lamp = (Lamp *)object->data;
        if (built_map_.checkIsBuiltAndTag(lamp)) {
                return;
        }
-
-       ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS);
-       ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
-
-       add_relation(lamp_parameters_key, object_parameters_key,
-                    "Lamp -> Object");
-
        /* lamp's nodetree */
        if (lamp->nodetree != NULL) {
                build_nodetree(lamp->nodetree);
+               ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS);
                ComponentKey nodetree_key(&lamp->nodetree->id, DEG_NODE_TYPE_SHADING);
                add_relation(nodetree_key, lamp_parameters_key, "NTree->Lamp Parameters");
                build_nested_nodetree(&lamp->id, lamp->nodetree);
        }
-
-       /* Make sure copy on write of lamp data is always properly updated for
-        * visible lamps.
-        */
-       OperationKey ob_copy_on_write_key(&object->id,
-                                         DEG_NODE_TYPE_COPY_ON_WRITE,
-                                         DEG_OPCODE_COPY_ON_WRITE);
-       OperationKey lamp_copy_on_write_key(&lamp->id,
-                                           DEG_NODE_TYPE_COPY_ON_WRITE,
-                                           DEG_OPCODE_COPY_ON_WRITE);
-       add_relation(lamp_copy_on_write_key, ob_copy_on_write_key, "Eval Order");
 }
 
 void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
index 0211f5dba68e2052fe42c96d0d9cf37bd5e03018..5546d6fd32e5e9639d44ce83271cecf3dce0526a 100644 (file)
@@ -57,6 +57,7 @@ struct ID;
 struct FCurve;
 struct Collection;
 struct Key;
+struct Lamp;
 struct LayerCollection;
 struct LightProbe;
 struct Main;
@@ -202,6 +203,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_lamp(Object *object);
        void build_object_data_lightprobe(Object *object);
        void build_object_parent(Object *object);
        void build_constraints(ID *id,
@@ -244,7 +246,7 @@ struct DepsgraphRelationBuilder
        void build_shapekeys(ID *obdata, Key *key);
        void build_obdata_geom(Object *object);
        void build_camera(Object *object);
-       void build_lamp(Object *object);
+       void build_lamp(Lamp *lamp);
        void build_nodetree(bNodeTree *ntree);
        void build_material(Material *ma);
        void build_texture(Tex *tex);