Cycles: svn merge -r41225:41232 ^/trunk/blender
[blender.git] / source / blender / nodes / shader / node_shader_tree.c
index cc8e161..7851654 100644 (file)
 
 #include <string.h>
 
+#include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
 #include "DNA_node_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
 
 #include "BLI_listbase.h"
 #include "BLI_math.h"
 static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func)
 {
        Material *ma;
-       for(ma= main->mat.first; ma; ma= ma->id.next) {
-               if(ma->nodetree) {
+       Lamp *la;
+       World *wo;
+       Tex *tex;
+
+       for(ma= main->mat.first; ma; ma= ma->id.next)
+               if(ma->nodetree)
                        func(calldata, &ma->id, ma->nodetree);
-               }
-       }
+
+       for(la= main->lamp.first; la; la= la->id.next)
+               if(la->nodetree)
+                       func(calldata, &la->id, la->nodetree);
+
+       for(wo= main->world.first; wo; wo= wo->id.next)
+               if(wo->nodetree)
+                       func(calldata, &wo->id, wo->nodetree);
+
+       for(tex= main->tex.first; tex; tex= tex->id.next)
+               if(tex->nodetree)
+                       func(calldata, &tex->id, tex->nodetree);
 }
 
 static void local_sync(bNodeTree *localtree, bNodeTree *ntree)
@@ -198,16 +215,20 @@ void ntreeShaderEndExecTree(bNodeTreeExec *exec, int use_tree_data)
 void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
 {
        ShaderCallData scd;
+       float co[3] = {0.0f, 0.0f, 0.0f};
        /*
        @note: preserve material from ShadeInput for material id, nodetree execs change it
        fix for bug "[#28012] Mat ID messy with shader nodes"
        */
-       Material *mat = shi->mat;       bNodeThreadStack *nts = NULL;
+       Material *mat = shi->mat;
+       bNodeThreadStack *nts = NULL;
        bNodeTreeExec *exec = ntree->execdata;
        
        /* convert caller data to struct */
+       memset(&scd, 0, sizeof(scd));
        scd.shi= shi;
        scd.shr= shr;
+       scd.co= co;
        
        /* each material node has own local shaderesult, with optional copying */
        memset(shr, 0, sizeof(ShadeResult));