Don't draw nodes that are out of the view
authorMatt Ebb <matt@mke3.net>
Mon, 14 Jun 2010 07:02:11 +0000 (07:02 +0000)
committerMatt Ebb <matt@mke3.net>
Mon, 14 Jun 2010 07:02:11 +0000 (07:02 +0000)
speeds up node editor fairly considerably on a complex comp

source/blender/editors/space_node/node_draw.c

index 63c1d9e486c0b9bff5173e25a8132f849292a34e..5eb6d9cf94a685e4a55a0830fc459ba1f3516824 100644 (file)
@@ -626,13 +626,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
                }
        }
        
-//     if(GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) {      XXX
-//             float zoomx= curarea->winx/(float)(G.v2d->cur.xmax-G.v2d->cur.xmin);
-//             float zoomy= curarea->winy/(float)(G.v2d->cur.ymax-G.v2d->cur.ymin);
-//             glPixelZoom(zoomx*xscale, zoomy*yscale);
-//     }
-//     else
-               glPixelZoom(xscale, yscale);
+       glPixelZoom(xscale, yscale);
 
        glEnable(GL_BLEND);
        glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );  /* premul graphics */
@@ -661,6 +655,19 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        bNodeTree *ntree = snode->nodetree;
        PointerRNA ptr;
        
+       /* hurmf... another candidate for callback, have to see how this works first */
+       if(node->id && node->block && snode->treetype==NTREE_SHADER)
+               nodeShaderSynchronizeID(node, 0);
+       
+       /* skip if out of view */
+       if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
+                       node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) {
+               
+               uiEndBlock(C, node->block);
+               node->block= NULL;
+               return;
+       }
+       
        uiSetRoundBox(15-4);
        ui_dropshadow(rct, BASIS_RAD, snode->aspect, node->flag & SELECT);
        
@@ -761,10 +768,6 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
                node_draw_mute_line(v2d, snode, node);
 
        
-       /* hurmf... another candidate for callback, have to see how this works first */
-       if(node->id && node->block && snode->treetype==NTREE_SHADER)
-               nodeShaderSynchronizeID(node, 0);
-       
        /* socket inputs, buttons */
        for(sock= node->inputs.first; sock; sock= sock->next) {
                if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) {