Revision: 31310
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31310
Author:   lukastoenne
Date:     2010-08-13 10:51:10 +0200 (Fri, 13 Aug 2010)

Log Message:
-----------
Fixed context propagation bug: links must be sorted, so that a comes before b 
if the result of context propagation along a can influence that of b. This 
means a comes before be if its tonode level is lower than the fromnode level of 
b.
Added a small debugging feature to display the context type next to the socket 
circle. Should be removed after fixing bugs, but some sort of feedback of this 
type could be useful in future, maybe show this in a tooltip when hovering over 
the socket?

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/editors/space_node/node_draw.c
    
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_vertex_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_util.h
    branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c     
2010-08-13 07:14:22 UTC (rev 31309)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c     
2010-08-13 08:51:10 UTC (rev 31310)
@@ -1864,13 +1864,12 @@
 
 static int ntreeSortLinkFromnode(void *a, void *b)
 {
-       bNode *afrom = ((bNodeLinkSortList*)a)->link->fromnode;
        bNode *ato = ((bNodeLinkSortList*)a)->link->tonode;
        bNode *bfrom = ((bNodeLinkSortList*)b)->link->fromnode;
-       bNode *bto = ((bNodeLinkSortList*)b)->link->tonode;
        
-       if (afrom && bfrom && ato && bto) {
-               return (afrom->level < bfrom->level || ato->level < bto->level);
+       if (bfrom && ato) {
+               /* this ensures that links, whose from/to-nodes can influence 
each other are sorted */
+               return (ato->level >= bfrom->level);
        }
        else
                return 0;
@@ -1966,6 +1965,7 @@
                }
        }
        
+       #if 0
        {
                printf("------------------\n");
                for (node=ntree->nodes.first; node; node = node->next) {
@@ -2009,6 +2009,7 @@
                #endif
                printf("------------------ \n");
        }
+       #endif
 
        BLI_freelistN(&sortlist);
 }
@@ -2031,28 +2032,17 @@
                                if (valid) {
                                        int fromtype= 
link->fromsock->context.type;
                                        int totype= link->tosock->context.type;
-                                       if (totype == NDC_UNDEFINED && fromtype 
!= NDC_UNDEFINED)
+                                       if (totype == NDC_UNDEFINED && fromtype 
!= NDC_UNDEFINED) {
                                                valid = 0;
+                                       }
                                        else if (ELEM(fromtype, NDC_UNDEFINED, 
NDC_SINGLETON)==0) {
-                                               if (totype == NDC_SINGLETON)
+                                               if (totype == NDC_SINGLETON) {
                                                        valid =0;
-                                               else if (fromtype != totype || 
link->fromsock->context.source != link->tosock->context.source)
+                                               }
+                                               else if (fromtype != totype || 
link->fromsock->context.source != link->tosock->context.source) {
                                                        valid = 0;
+                                               }
                                        }
-                                       #if 0
-                                       if ((fromtype==NDC_UNDEFINED && 
totype==NDC_UNDEFINED) ||
-                                           ((fromtype!=NDC_UNDEFINED && 
totype!=NDC_UNDEFINED) &&
-                                            (fromtype==NDC_SINGLETON ||
-                                             (totype!=NDC_SINGLETON && 
fromtype==totype &&
-                                              link->fromsock->context.source 
== link->tosock->context.source
-                                             )
-                                            )
-                                           )
-                                          ) {
-                                       }
-                                       else
-                                               valid = 0;
-                                       #endif
                                }
                        }
                        

Modified: branches/particles-2010/source/blender/editors/space_node/node_draw.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_draw.c       
2010-08-13 07:14:22 UTC (rev 31309)
+++ branches/particles-2010/source/blender/editors/space_node/node_draw.c       
2010-08-13 08:51:10 UTC (rev 31310)
@@ -887,6 +887,17 @@
                                uiDefBut(node->block, LABEL, 0, sock->name, 
(short)(sock->locx+7), (short)(sock->locy-9.0f), 
                                                 (short)(node->width-NODE_DY), 
NODE_DY,  NULL, 0, 0, 0, 0, "");
                        }
+                       
+                       #if 1
+                       {
+                               static char *context_str[] = { "U", "S", "N", 
"P", "V", "E", "F" };
+                               if (node->block) {
+                                       glColor3ub(220, 220, 30);
+                                       uiDefBut(node->block, LABEL, 0, 
context_str[sock->context.type], 
+                                                        
(short)(sock->locx-25), (short)(sock->locy-9.0f), (short)(node->width-NODE_DY), 
NODE_DY,  NULL, 0, 0, 0, 0, "");
+                               }
+                       }
+                       #endif
                }
        }
        
@@ -907,6 +918,15 @@
                        
                        uiDefBut(node->block, LABEL, 0, sock->name+ofs, 
(short)(sock->locx-15.0f-slen), (short)(sock->locy-9.0f), 
                                         (short)(node->width-NODE_DY), NODE_DY, 
 NULL, 0, 0, 0, 0, "");
+                       
+                       #if 1
+                       {
+                               static char *context_str[] = { "U", "S", "N", 
"P", "V", "E", "F" };
+                               glColor3ub(220, 220, 30);
+                               uiDefBut(node->block, LABEL, 0, 
context_str[sock->context.type], (short)(sock->locx+5), 
(short)(sock->locy-9.0f), 
+                                                (short)(node->width-NODE_DY), 
NODE_DY,  NULL, 0, 0, 0, 0, "");
+                       }
+                       #endif
                }
        }
        

Modified: 
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_vertex_data.c
===================================================================
--- 
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_vertex_data.c
 2010-08-13 07:14:22 UTC (rev 31309)
+++ 
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_vertex_data.c
 2010-08-13 08:51:10 UTC (rev 31310)
@@ -60,13 +60,9 @@
        if (ob && ob->type == OB_MESH) {
                Mesh *mesh = (Mesh*)ob->data;
                
-               if (MEM_check_memory_integrity())
-                       printf("!!! Memory currupt A !!!");
                SIM_JOBEXEC_OUTPUT_BEGIN(ctx, job, istream)
                copy_v3_v3(mesh->mvert[job->current].co, 
sim_istream_read_vector(istream, 0));
                SIM_JOBEXEC_OUTPUT_END(ctx, job)
-               if (MEM_check_memory_integrity())
-                       printf("!!! Memory currupt B !!!");
        }
        return NODE_EXEC_FINISHED;
 }

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_util.h
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_util.h      
2010-08-13 07:14:22 UTC (rev 31309)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_util.h      
2010-08-13 08:51:10 UTC (rev 31310)
@@ -201,7 +201,6 @@
                job->current = job->input_start; \
        ivalid = sim_istream_init(istream, ctx, job); \
        ovalid = sim_ostream_init(ostream, ctx, job, job->current); \
-       printf("ivalid=%d, ovalid=%d\n", ivalid, ovalid); \
        for (i=0; ivalid && ovalid && i < job->input_totdata; ++i, 
++job->current) { \
                SIM_JOBEXEC_DEBUGPRINT \
                {
@@ -210,7 +209,6 @@
                ivalid = sim_istream_next(istream); \
                ovalid = sim_ostream_next(ostream); \
        } \
-       printf("ivalid=%d, ovalid=%d\n", ivalid, ovalid); \
        SIM_JOBEXEC_DEBUGPRINT_END \
        sim_istream_close(istream, ctx); \
        sim_ostream_close(ostream, ctx, job); \

Modified: 
branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c  
2010-08-13 07:14:22 UTC (rev 31309)
+++ branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c  
2010-08-13 08:51:10 UTC (rev 31310)
@@ -805,8 +805,6 @@
                        else
                                suspend = NODE_EXEC_FINISHED;
                        
-                       /* TODO add new data, check for new jobs and notify 
other threads if any */
-                       
                        #if 0
                        /* ========= DEBUG ========= */
                        {


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to