Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-05-25 11:07:10 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-05-25 11:07:10 +0300
commit41bb0548b0c1ac62d30cf14fca371b220e40f72e (patch)
treea7842ef640ec36ba74649711eb893106ee0a57ff
parent9b9f84b317feff9454f124330bd3aa774493c003 (diff)
Fix T76897: Lamp Power Not Updating from Driver
Lamps were not tagged with `ID_RECALC_SHADING` when they were updated from drivers. As a result, Cycles considered the lamp as unchanged. This is resolved by having a (seemingly non-functional) callback in a new `LIGHT_UPDATE` depsgraph node. This patch unconditionally adds the `LIGHT_UPDATE` node + the relation from the lamp's PARAMETERS node. Differential Revision: https://developer.blender.org/D7822 Reviewed by: brecht
-rw-r--r--source/blender/blenkernel/BKE_light.h3
-rw-r--r--source/blender/blenkernel/intern/light.c7
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc7
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc8
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.cc2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.h1
6 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_light.h b/source/blender/blenkernel/BKE_light.h
index a6f0fdbc8a3..2764233bc68 100644
--- a/source/blender/blenkernel/BKE_light.h
+++ b/source/blender/blenkernel/BKE_light.h
@@ -30,6 +30,7 @@ extern "C" {
#include "BLI_compiler_attrs.h"
+struct Depsgraph;
struct Light;
struct Main;
@@ -37,6 +38,8 @@ struct Light *BKE_light_add(struct Main *bmain, const char *name) ATTR_WARN_UNUS
struct Light *BKE_light_copy(struct Main *bmain, const struct Light *la) ATTR_WARN_UNUSED_RESULT;
struct Light *BKE_light_localize(struct Light *la) ATTR_WARN_UNUSED_RESULT;
+void BKE_light_eval(struct Depsgraph *depsgraph, struct Light *la);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index 3d0503b2e70..58d50787c9f 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -47,6 +47,8 @@
#include "BLT_translation.h"
+#include "DEG_depsgraph.h"
+
static void light_init_data(ID *id)
{
Light *la = (Light *)id;
@@ -167,3 +169,8 @@ Light *BKE_light_localize(Light *la)
return lan;
}
+
+void BKE_light_eval(struct Depsgraph *depsgraph, Light *la)
+{
+ DEG_debug_print_eval(depsgraph, __func__, la->id.name, la);
+}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 0e84494b2b7..6f4333ee81d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -83,6 +83,7 @@ extern "C" {
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_layer.h"
+#include "BKE_light.h"
#include "BKE_mask.h"
#include "BKE_material.h"
#include "BKE_mball.h"
@@ -1452,6 +1453,12 @@ void DepsgraphNodeBuilder::build_light(Light *lamp)
build_parameters(&lamp->id);
/* light's nodetree */
build_nodetree(lamp->nodetree);
+
+ Light *lamp_cow = get_cow_datablock(lamp);
+ add_operation_node(&lamp->id,
+ NodeType::SHADING,
+ OperationCode::LIGHT_UPDATE,
+ function_bind(BKE_light_eval, _1, lamp_cow));
}
void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 9bad796c541..9cd150fb8df 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2246,14 +2246,20 @@ void DepsgraphRelationBuilder::build_light(Light *lamp)
build_idproperties(lamp->id.properties);
build_animdata(&lamp->id);
build_parameters(&lamp->id);
+
+ ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
+
/* light's nodetree */
if (lamp->nodetree != nullptr) {
build_nodetree(lamp->nodetree);
- ComponentKey lamp_parameters_key(&lamp->id, NodeType::PARAMETERS);
ComponentKey nodetree_key(&lamp->nodetree->id, NodeType::SHADING);
add_relation(nodetree_key, lamp_parameters_key, "NTree->Light Parameters");
build_nested_nodetree(&lamp->id, lamp->nodetree);
}
+
+ /* For allowing drivers on lamp properties. */
+ ComponentKey shading_key(&lamp->id, NodeType::SHADING);
+ add_relation(lamp_parameters_key, shading_key, "Light Shading Parameters");
}
void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc
index 1e03d51f557..1a73d81d053 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc
@@ -173,6 +173,8 @@ const char *operationCodeAsString(OperationCode opcode)
return "SHADING";
case OperationCode::MATERIAL_UPDATE:
return "MATERIAL_UPDATE";
+ case OperationCode::LIGHT_UPDATE:
+ return "LIGHT_UPDATE";
case OperationCode::WORLD_UPDATE:
return "WORLD_UPDATE";
/* Movie clip. */
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h
index 2faf139ec93..214f5e8b094 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.h
@@ -170,6 +170,7 @@ enum class OperationCode {
/* Shading. ------------------------------------------------------------- */
SHADING,
MATERIAL_UPDATE,
+ LIGHT_UPDATE,
WORLD_UPDATE,
/* Batch caches. -------------------------------------------------------- */