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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-11-09 17:57:09 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-11-09 17:57:09 +0400
commitdc5ba03945c9f9cc8cbc93c91ff872a29c38659c (patch)
tree0aa4387b569001a94d416aedbffbe1e6f7549338 /source/blender/blenkernel/intern/lamp.c
parent079a0a30e49c036c1ce4425c949e0c370a91492b (diff)
Fix #33123: lamp nodes drivers not working, now uses same hacks as material
to work around dependency graph limitations.
Diffstat (limited to 'source/blender/blenkernel/intern/lamp.c')
-rw-r--r--source/blender/blenkernel/intern/lamp.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 576afe123c0..2f37db846f3 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -33,9 +33,12 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BLI_listbase.h"
@@ -232,3 +235,38 @@ void BKE_lamp_free(Lamp *la)
la->id.icon_id = 0;
}
+/* Calculate all drivers for lamps, see material_drivers_update for why this is a bad hack */
+
+static void lamp_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime)
+{
+ bNode *node;
+
+ /* nodetree itself */
+ if (ntree->adt && ntree->adt->drivers.first)
+ BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS);
+
+ /* nodes */
+ for (node = ntree->nodes.first; node; node = node->next)
+ if (node->id && node->type == NODE_GROUP)
+ lamp_node_drivers_update(scene, (bNodeTree *)node->id, ctime);
+}
+
+void lamp_drivers_update(Scene *scene, Lamp *la, float ctime)
+{
+ /* Prevent infinite recursion by checking (and tagging the lamp) as having been visited already
+ * (see BKE_scene_update_tagged()). This assumes la->id.flag & LIB_DOIT isn't set by anything else
+ * in the meantime... [#32017] */
+ if (la->id.flag & LIB_DOIT)
+ return;
+ else
+ la->id.flag |= LIB_DOIT;
+
+ /* lamp itself */
+ if (la->adt && la->adt->drivers.first)
+ BKE_animsys_evaluate_animdata(scene, &la->id, la->adt, ctime, ADT_RECALC_DRIVERS);
+
+ /* nodes */
+ if (la->nodetree)
+ lamp_node_drivers_update(scene, la->nodetree, ctime);
+}
+