Orange: fixes in Compositor:
authorTon Roosendaal <ton@blender.org>
Tue, 24 Jan 2006 15:24:38 +0000 (15:24 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 24 Jan 2006 15:24:38 +0000 (15:24 +0000)
- Curves in Image window didn't copy alpha (when no 32 bits rect for
  display was made already).
- Code was missing to validate grouped nodes in Compositor, didnt work
  at all yet
- Loading new Images in a Node (using filewindow) didn't assign the image

Image window now displays Alpha for float images too

source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/node.c
source/blender/src/drawimage.c
source/blender/src/editnode.c

index f9854fae98c1f511c8e3ddf17930cec1729241cc..ce0db15603f5e700da1c6a0d8cfaf38c4b3a1427 100644 (file)
@@ -584,7 +584,7 @@ void curvemapping_do_image(CurveMapping *cumap, Image *ima)
                        pixc[0]= FTOCHAR(col[0]);
                        pixc[1]= FTOCHAR(col[1]);
                        pixc[2]= FTOCHAR(col[2]);
-                       /* assume alpha was set */
+                       pixc[3]= FTOCHAR(pixf[3]);
                }
        }
        
index f7d0be1ac33002167b31655a41b5eb0963019e36..fc23758c4b35f214d60cd6f816802429be6401ae 100644 (file)
@@ -33,6 +33,7 @@
 #include "DNA_ID.h"
 #include "DNA_node_types.h"
 #include "DNA_material_types.h"
+#include "DNA_scene_types.h"
 
 #include "BKE_blender.h"
 #include "BKE_colortools.h"
@@ -498,12 +499,12 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree)
 /* should become callbackable... */
 void nodeVerifyGroup(bNodeTree *ngroup)
 {
-       Material *ma;
        
        /* group changed, so we rebuild the type definition */
        ntreeMakeOwnType(ngroup);
        
        if(ngroup->type==NTREE_SHADER) {
+               Material *ma;
                for(ma= G.main->mat.first; ma; ma= ma->id.next) {
                        if(ma->nodetree) {
                                bNode *node;
@@ -524,6 +525,28 @@ void nodeVerifyGroup(bNodeTree *ngroup)
                        }
                }
        }
+       else if(ngroup->type==NTREE_COMPOSIT) {
+               Scene *sce;
+               for(sce= G.main->scene.first; sce; sce= sce->id.next) {
+                       if(sce->nodetree) {
+                               bNode *node;
+                               
+                               /* find if group is in tree */
+                               for(node= sce->nodetree->nodes.first; node; node= node->next)
+                                       if(node->id == (ID *)ngroup)
+                                               break;
+                               
+                               if(node) {
+                                       /* set all type pointers OK */
+                                       ntreeInitTypes(sce->nodetree);
+                                       
+                                       for(node= sce->nodetree->nodes.first; node; node= node->next)
+                                               if(node->id == (ID *)ngroup)
+                                                       nodeVerifyType(sce->nodetree, node);
+                               }
+                       }
+               }
+       }
 }
 
 /* also to check all users of groups. Now only used in editor for hide/unhide */
@@ -532,7 +555,6 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup)
 {
        bNode *node;
        bNodeSocket *sock;
-       Material *ma;
 
        /* clear flags */
        for(node= ngroup->nodes.first; node; node= node->next) {
@@ -544,6 +566,7 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup)
        
        /* tag all thats in use */
        if(ngroup->type==NTREE_SHADER) {
+               Material *ma;
                for(ma= G.main->mat.first; ma; ma= ma->id.next) {
                        if(ma->nodetree) {
                                for(node= ma->nodetree->nodes.first; node; node= node->next) {
@@ -561,6 +584,25 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup)
                        }
                }
        }
+       else if(ngroup->type==NTREE_COMPOSIT) {
+               Scene *sce;
+               for(sce= G.main->scene.first; sce; sce= sce->id.next) {
+                       if(sce->nodetree) {
+                               for(node= sce->nodetree->nodes.first; node; node= node->next) {
+                                       if(node->id==(ID *)ngroup) {
+                                               for(sock= node->inputs.first; sock; sock= sock->next)
+                                                       if(sock->link)
+                                                               if(sock->tosock) 
+                                                                       sock->tosock->flag |= SOCK_IN_USE;
+                                               for(sock= node->outputs.first; sock; sock= sock->next)
+                                                       if(nodeCountSocketLinks(sce->nodetree, sock))
+                                                               if(sock->tosock) 
+                                                                       sock->tosock->flag |= SOCK_IN_USE;
+                                       }
+                               }
+                       }
+               }
+       }
 }
 
 static void find_node_with_socket(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex)
index fa6a91b701d95c163cb5610b854835c75a318a16..e3655beaac09239c5def640ff42230f734edacdd 100644 (file)
@@ -47,6 +47,7 @@
 #include "BLI_arithb.h"
 #include "BLI_blenlib.h"
 
+#include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
 #include "DNA_camera_types.h"
@@ -1125,6 +1126,26 @@ static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, uns
        glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
 }
 
+static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, float *rectf)
+{
+       float *trectf= MEM_mallocN(rectx*recty*4, "temp");
+       int a, b;
+       
+       for(a= rectx*recty -1, b= 4*a+3; a>=0; a--, b-=4)
+               trectf[a]= rectf[b];
+       
+       glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf);
+       MEM_freeN(trectf);
+       /* ogl trick below is slower... (on ATI 9600) */
+//     glColorMask(1, 0, 0, 0);
+//     glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+3);
+//     glColorMask(0, 1, 0, 0);
+//     glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+2);
+//     glColorMask(0, 0, 1, 0);
+//     glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+1);
+//     glColorMask(1, 1, 1, 1);
+}
+
 static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *recti)
 {
        if(recti==NULL)
@@ -1288,6 +1309,8 @@ void drawimagespace(ScrArea *sa, void *spacedata)
                                if(sima->flag & SI_SHOW_ALPHA) {
                                        if(ibuf->rect)
                                                sima_draw_alpha_pixels(x1, y1, ibuf->x, ibuf->y, ibuf->rect);
+                                       else if(ibuf->rect_float)
+                                               sima_draw_alpha_pixelsf(x1, y1, ibuf->x, ibuf->y, ibuf->rect_float);
                                }
                                else if(sima->flag & SI_SHOW_ZBUF) {
                                        if(ibuf->zbuf)
index e6fce5f948d7d87f2adb0534cc34f20fe7f2c417..ce6344b7b8df4271347b581cba014f5643adbb53 100644 (file)
@@ -167,10 +167,10 @@ static void load_node_image(char *str)    /* called from fileselect */
        if(ima) {
                if(node->id)
                        node->id->us--;
-               else {
-                       node->id= &ima->id;
-                       ima->id.us++;
-               }
+               
+               node->id= &ima->id;
+               ima->id.us++;
+
                free_image_buffers(ima);        /* force read again */
                ima->ok= 1;
                
@@ -198,7 +198,7 @@ static void composit_node_event(SpaceNode *snode, short event)
                                strcpy(name, ((Image *)node->id)->name);
                        else strcpy(name, U.textudir);
                        
-                       /* we make store node->block pointers, and filesel frees it, so we need to clear them */
+                       /* node->block pointers are stored, but filesel frees it, so we need to clear them */
                        for(node= snode->edittree->nodes.first; node; node= node->next)
                                node->block= NULL;