Fix for bug #8555: geometry node front/bake was broken.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 14 Mar 2008 18:08:27 +0000 (18:08 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 14 Mar 2008 18:08:27 +0000 (18:08 +0000)
Fix for bug #7418: texture ipo's didn't show for textures in node materials.
Fix for part of bug #6758: node materials in other node materials could
miss texture coordinates.

source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/texture.c
source/blender/render/intern/include/rendercore.h
source/blender/src/editnode.c

index 42cac46c241da52ff41839b637139828e07f6826..1b95ae14ecf854792e5292af7ba653163aeab7ce 100644 (file)
@@ -633,9 +633,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
        
        if(ma->flarec==0) ma->flarec= 1;
 
-       /* add all texcoflags from mtex */
-       ma->texco= 0;
-       ma->mapto= 0;
+       /* add all texcoflags from mtex, texco and mapto were cleared in advance */
        for(a=0; a<MAX_MTEX; a++) {
                
                /* separate tex switching */
@@ -730,6 +728,16 @@ void init_render_materials(int r_mode, float *amb)
 {
        Material *ma;
        
+       /* clear these flags before going over materials, to make sure they
+        * are cleared only once, otherwise node materials contained in other
+        * node materials can go wrong */
+       for(ma= G.main->mat.first; ma; ma= ma->id.next) {
+               if(ma->id.us) {
+                       ma->texco= 0;
+                       ma->mapto= 0;
+               }
+       }
+
        /* two steps, first initialize, then or the flags for layers */
        for(ma= G.main->mat.first; ma; ma= ma->id.next) {
                /* is_used flag comes back in convertblender.c */
index bc9aa23ee157e10378d2dfec062f9b41f08164e7..0bec69f2b6f423e890f3bdf48dd3c01e7056df47 100644 (file)
@@ -1356,11 +1356,21 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
        bNode *node;
        
        if(ntree==NULL) return NULL;
+
+       /* check for group edit */
+    for(node= ntree->nodes.first; node; node= node->next)
+               if(node->flag & NODE_GROUP_EDIT)
+                       break;
+
+       if(node)
+               ntree= (bNodeTree*)node->id;
        
+       /* now find active node with this id */
        for(node= ntree->nodes.first; node; node= node->next)
                if(node->id && GS(node->id->name)==idtype)
                        if(node->flag & NODE_ACTIVE_ID)
                                break;
+
        return node;
 }
 
index 3b8292a791c9c3c7ffb82f3673486bbb8a9b37be..ab0aecdd36329737089e70a3fe105f20762e983d 100644 (file)
@@ -55,6 +55,7 @@
 #include "DNA_image_types.h"
 #include "DNA_world_types.h"
 #include "DNA_brush_types.h"
+#include "DNA_node_types.h"
 
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
@@ -75,6 +76,7 @@
 #include "BKE_icons.h"
 #include "BKE_ipo.h"
 #include "BKE_brush.h"
+#include "BKE_node.h"
 
 
 /* ------------------------------------------------------------------------- */
@@ -729,6 +731,7 @@ Tex *give_current_texture(Object *ob, int act)
        Lamp *la = 0;
        MTex *mtex = 0;
        Tex *tex = 0;
+       bNode *node;
        
        if(ob==0) return 0;
        if(ob->totcol==0) return 0;
@@ -739,7 +742,6 @@ Tex *give_current_texture(Object *ob, int act)
                        mtex= la->mtex[(int)(la->texact)];
                        if(mtex) tex= mtex->tex;
                }
-               else tex= 0;
        } else {
                if(act>ob->totcol) act= ob->totcol;
                else if(act==0) act= 1;
@@ -752,13 +754,25 @@ Tex *give_current_texture(Object *ob, int act)
                        
                        if(matarar && *matarar) ma= (*matarar)[act-1];
                        else ma= 0;
-                       
+               }
+
+               if(ma && ma->use_nodes && ma->nodetree) {
+                       node= nodeGetActiveID(ma->nodetree, ID_TE);
+
+                       if(node) {
+                               tex= (Tex *)node->id;
+                               ma= NULL;
+                       }
+                       else {
+                               node= nodeGetActiveID(ma->nodetree, ID_MA);
+                               if(node)
+                                       ma= (Material*)node->id;
+                       }
                }
                if(ma) {
                        mtex= ma->mtex[(int)(ma->texact)];
                        if(mtex) tex= mtex->tex;
                }
-               else tex= 0;
        }
        
        return tex;
index cf1eeae58ec689fc771e92ec815d73f8a14381c4..cdc348279e5a3ce0961773857df71e612950af59 100644 (file)
@@ -40,8 +40,8 @@
 
 /* vector defines */
 
-#define CROSS(dest, a, b)              dest[0]= a[1] * b[2] - a[2] * b[1]; dest[1]= a[2] * b[0] - a[0] * b[2]; dest[2]= a[0] * b[1] - a[1] * b[0]
-#define VECMUL(dest, f)                        dest[0]*= f; dest[1]*= f; dest[2]*= f
+#define CROSS(dest, a, b)              { dest[0]= a[1] * b[2] - a[2] * b[1]; dest[1]= a[2] * b[0] - a[0] * b[2]; dest[2]= a[0] * b[1] - a[1] * b[0]; }
+#define VECMUL(dest, f)                        { dest[0]*= f; dest[1]*= f; dest[2]*= f; }
 
 struct HaloRen;
 struct ShadeInput;
index a308b42889450e777488d7a99bba928b72683ff0..ab2a36aa2d3ff2b05f461bd6da87bc20cf7dbf9b 100644 (file)
@@ -1138,16 +1138,7 @@ void node_rename(SpaceNode *snode)
 /* used in buttons to check context, also checks for edited groups */
 bNode *editnode_get_active_idnode(bNodeTree *ntree, short id_code)
 {
-       bNode *node;
-       
-       /* check for edited group */
-       for(node= ntree->nodes.first; node; node= node->next)
-               if(node->flag & NODE_GROUP_EDIT)
-                       break;
-       if(node)
-               return nodeGetActiveID((bNodeTree *)node->id, id_code);
-       else
-               return nodeGetActiveID(ntree, id_code);
+       return nodeGetActiveID(ntree, id_code);
 }
 
 /* used in buttons to check context, also checks for edited groups */