Revision: 30072
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30072
Author:   lukastoenne
Date:     2010-07-07 11:29:11 +0200 (Wed, 07 Jul 2010)

Log Message:
-----------
Ported back particle nodes basics. Also includes node tree info structs and 
execution code split-off.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/editors/include/ED_node.h
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/editors/space_node/node_draw.c
    branches/particles-2010/source/blender/editors/space_node/node_edit.c
    branches/particles-2010/source/blender/editors/space_node/node_header.c
    branches/particles-2010/source/blender/editors/space_node/space_node.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
    branches/particles-2010/source/blender/makesrna/intern/rna_space.c
    branches/particles-2010/source/blender/nodes/CMakeLists.txt
    branches/particles-2010/source/blender/nodes/intern/CMP_util.h
    branches/particles-2010/source/blender/nodes/intern/SHD_util.h
    branches/particles-2010/source/blender/nodes/intern/TEX_util.h
    branches/particles-2010/source/blender/nodes/intern/node_util.c
    branches/particles-2010/source/blender/nodes/intern/node_util.h

Added Paths:
-----------
    branches/particles-2010/source/blender/nodes/PAR_node.h
    branches/particles-2010/source/blender/nodes/intern/PAR_nodes/
    branches/particles-2010/source/blender/nodes/intern/PAR_util.c
    branches/particles-2010/source/blender/nodes/intern/PAR_util.h
    branches/particles-2010/source/blender/nodes/intern/node_tree_composite.c
    branches/particles-2010/source/blender/nodes/intern/node_tree_particles.c
    branches/particles-2010/source/blender/nodes/intern/node_tree_shader.c
    branches/particles-2010/source/blender/nodes/intern/node_tree_texture.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2010-07-07 08:10:43 UTC (rev 30071)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2010-07-07 09:29:11 UTC (rev 30072)
@@ -33,6 +33,8 @@
 #ifndef BKE_NODE_H
 #define BKE_NODE_H
 
+#include "DNA_listBase.h"
+
 /* not very important, but the stack solver likes to know a maximum */
 #define MAX_SOCKET     64
 
@@ -44,14 +46,16 @@
 struct bNodeStack;
 struct uiLayout;
 struct rctf;
-struct ListBase;
 struct RenderData;
 struct Scene;
 struct Main;
 struct Tex;
+struct MTex;
 struct GPUMaterial;
 struct GPUNode;
 struct GPUNodeStack;
+struct ParticleSimulationData;
+struct ParticleSystem;
 struct PointerRNA;
 struct bContext;
 
@@ -64,7 +68,7 @@
        float min, max;                                 /* default range for 
inputs */
        
        /* after this line is used internal only */
-       struct bNodeSocket *sock;               /* used during verify_types */
+       struct ListBase verified;                       /* used during 
verify_types */
        struct bNodeSocket *internsock; /* group nodes, the internal socket 
counterpart */
        int own_index;                                  /* verify group nodes */
        
@@ -91,7 +95,7 @@
        void (*copystoragefunc)(struct bNode *, struct bNode *);
        
        /* for use with dynamic typedefs */
-       ID *id;
+       struct ID *id;
        void *pynode; /* holds pointer to python script */
        void *pydict; /* holds pointer to python script dictionary (scope)*/
 
@@ -100,6 +104,23 @@
 
 } bNodeType;
 
+typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct 
bNodeTree *ntree);
+typedef struct bNodeTreeTypeInfo
+{
+       int type;                                               /* type 
identifier */
+       char id_name[24];                               /* id name for RNA 
identification */
+       
+       ListBase node_types;                    /* type definitions */
+       
+       /* callbacks */
+       void (*freeCache)(struct bNodeTree *ntree);
+       void (*freeNodeCache)(struct bNodeTree *ntree, struct bNode *node);
+       void (*foreachNodeTree)(void *calldata, bNodeTreeCallback func);        
        /* iteration over all node trees */
+       void (*beginExec)(struct bNodeTree *ntree);
+       void (*endExec)(struct bNodeTree *ntree);
+       void (*exec)(struct bNodeTree *ntree, void *callerdata, int thread);
+} bNodeTreeTypeInfo;
+
 /* node->exec, now in use for composites (#define for break is same as ready 
yes) */
 #define NODE_PROCESSING        1
 #define NODE_READY             2
@@ -122,9 +143,12 @@
 #define NODE_CLASS_OP_DYNAMIC  11
 #define NODE_CLASS_PATTERN 12
 #define NODE_CLASS_TEXTURE 13
+#define NODE_CLASS_SIMULATION  14
 
 /* ************** GENERIC API, TREES *************** */
 
+bNodeTreeTypeInfo      *ntreeGetTypeInfo(int type);
+
 void                   ntreeVerifyTypes(struct bNodeTree *ntree);
 
 struct bNodeTree *ntreeAddTree(int type);
@@ -137,6 +161,7 @@
 void                   ntreeMakeLocal(struct bNodeTree *ntree);
 
 void                   ntreeSocketUseFlags(struct bNodeTree *ntree);
+void                   ntreeUpdateListSockets(struct bNodeTree *ntree);
 
 void                   ntreeSolveOrder(struct bNodeTree *ntree);
 
@@ -175,6 +200,7 @@
 struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, 
struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
 void                   nodeRemLink(struct bNodeTree *ntree, struct bNodeLink 
*link);
 void                   nodeRemSocketLinks(struct bNodeTree *ntree, struct 
bNodeSocket *sock);
+void                   nodeCheckLink(struct bNodeLink *link);
 
 struct bNode   *nodeFindNodebyName(struct bNodeTree *ntree, const char *name);
 int                    nodeFindNode(struct bNodeTree *ntree, struct 
bNodeSocket *sock, struct bNode **nodep, int *sockindex);
@@ -191,6 +217,8 @@
 void                   NodeTagChanged(struct bNodeTree *ntree, struct bNode 
*node);
 void                   NodeTagIDChanged(struct bNodeTree *ntree, struct ID 
*id);
 
+int                            nodeIsListSocket(bNodeSocketType *stype);
+
 /* ************** Groups ****************** */
 
 struct bNode   *nodeMakeGroupFromSelected(struct bNodeTree *ntree);
@@ -258,9 +286,6 @@
 #define NODE_DYNAMIC_REPARSE   6 /* 64 */
 #define NODE_DYNAMIC_SET       15 /* sign */
 
-/* the type definitions array */
-extern struct ListBase node_all_shaders;
-
 /* API */
 
 void                   ntreeShaderExecTree(struct bNodeTree *ntree, struct 
ShadeInput *shi, struct ShadeResult *shr);
@@ -385,9 +410,6 @@
 #define CMP_SCALE_SCENEPERCENT 2
 
 
-/* the type definitions array */
-extern struct ListBase node_all_composit;
-
 /* API */
 struct CompBuf;
 void ntreeCompositTagRender(struct Scene *sce);
@@ -430,8 +452,6 @@
 #define TEX_NODE_PROC      500
 #define TEX_NODE_PROC_MAX  600
 
-extern struct ListBase node_all_textures;
-
 /* API */
 int  ntreeTexTagAnimated(struct bNodeTree *ntree);
 void ntreeTexSetPreviewFlag(int);
@@ -440,6 +460,24 @@
 char* ntreeTexOutputMenu(struct bNodeTree *ntree);
 
 
+/* ************** PARTICLE NODES *************** */
+
+/* note: types are needed to restore callbacks, don't change values */
+/* range 1 - 100 is reserved for common nodes */
+/* using toolbox, we add node groups by assuming the values below don't exceed 
NODE_GROUP_MENU for now */
+
+#define PAR_NODE_PROGRAM       601
+#define PAR_NODE_NEWTONIAN     602
+#define PAR_NODE_INPUT         603
+#define PAR_NODE_EMITTER       604
+#define PAR_NODE_OBJECT                605
+
+/* the type definitions array */
+extern struct ListBase node_all_particles;
+
+/* API */
+void ntreeParticlesExecTree(struct ParticleSimulationData *sim, float cfra, 
float dfra, int thread);
+
 /**/
 
 void init_nodesystem(void);

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c     
2010-07-07 08:10:43 UTC (rev 30071)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c     
2010-07-07 09:29:11 UTC (rev 30072)
@@ -49,20 +49,37 @@
 
 #include "CMP_node.h"
 #include "intern/CMP_util.h"   /* stupid include path... */
-
 #include "SHD_node.h"
+#include "intern/SHD_util.h"
 #include "TEX_node.h"
 #include "intern/TEX_util.h"
+#include "PAR_node.h"
+#include "intern/PAR_util.h"
 
 #include "GPU_material.h"
 
-static ListBase empty_list = {NULL, NULL};
-ListBase node_all_composit = {NULL, NULL};
-ListBase node_all_shaders = {NULL, NULL};
-ListBase node_all_textures = {NULL, NULL};
 
-/* ************** Type stuff **********  */
+bNodeTreeTypeInfo *ntreeGetTypeInfo(int type)
+{
+       static bNodeTreeTypeInfo *types[NUM_NTREE_TYPES];
+       static int types_init = 1;
+       if (types_init) {
+               types[NTREE_SHADER] = &ntreeType_Shader;
+               types[NTREE_COMPOSIT] = &ntreeType_Composite;
+               types[NTREE_TEXTURE] = &ntreeType_Texture;
+               types[NTREE_PARTICLES] = &ntreeType_Particles;
+               types_init = 0;
+       }
+       
+       if(type >= 0 && type < NUM_NTREE_TYPES) {
+               return types[type];
+       }
+       else {
+               return NULL;
+       }
+}
 
+
 static bNodeType *node_get_type(bNodeTree *ntree, int type, bNodeTree *ngroup, 
ID *id)
 {
        if(type==NODE_GROUP) {
@@ -72,7 +89,7 @@
                return NULL;
        }
        else {
-               bNodeType *ntype = ntree->alltypes.first;
+               bNodeType *ntype = 
ntreeGetTypeInfo(ntree->type)->node_types.first;
                for(; ntype; ntype= ntype->next)
                        if(ntype->type==type && id==ntype->id )
                                return ntype;
@@ -85,17 +102,6 @@
 {
        bNode *node, *next;
        
-       if(ntree->type==NTREE_SHADER)
-               ntree->alltypes= node_all_shaders;
-       else if(ntree->type==NTREE_COMPOSIT)
-               ntree->alltypes= node_all_composit;
-       else if(ntree->type==NTREE_TEXTURE)
-               ntree->alltypes= node_all_textures;
-       else {
-               ntree->alltypes= empty_list;
-               printf("Error: no type definitions for nodes\n");
-       }
-       
        for(node= ntree->nodes.first; node; node= next) {
                next= node->next;
                if(node->type==NODE_DYNAMIC) {
@@ -141,6 +147,12 @@
        }
 }
 
+int nodeIsListSocket(bNodeSocketType *stype)
+{
+       /* TODO needs a more generic way of allowing list sockets - phonybone */
+       return (stype->type == SOCK_OP);
+}
+
 /* only used internal... we depend on type definitions! */
 static bNodeSocket *node_add_socket_type(ListBase *lb, bNodeSocketType *stype)
 {
@@ -167,6 +179,36 @@
        return sock;
 }
 
+/* only used internal... we depend on type definitions! */
+static bNodeSocket *node_insert_before_socket_type(ListBase *lb, bNodeSocket 
*next_sock, bNodeSocketType *stype)
+{
+       bNodeSocket *sock= MEM_callocN(sizeof(bNodeSocket), "sock");
+       
+       BLI_strncpy(sock->name, stype->name, NODE_MAXSTR);
+       if(stype->limit==0) sock->limit= 0xFFF;
+       else sock->limit= stype->limit;
+       sock->type= stype->type;
+       
+       sock->to_index= stype->own_index;
+       sock->tosock= stype->internsock;
+       
+       sock->ns.vec[0]= stype->val1;
+       sock->ns.vec[1]= stype->val2;
+       sock->ns.vec[2]= stype->val3;
+       sock->ns.vec[3]= stype->val4;
+       sock->ns.min= stype->min;
+       sock->ns.max= stype->max;
+       
+       if(lb) {
+               if (next_sock)
+                       BLI_insertlinkbefore(lb, next_sock, sock);
+               else
+                       BLI_addtail(lb, sock);
+       }
+
+       return sock;
+}
+
 static void node_rem_socket(bNodeTree *ntree, ListBase *lb, bNodeSocket *sock)
 {
        bNodeLink *link, *next;
@@ -182,31 +224,59 @@
        MEM_freeN(sock);
 }
 
-static bNodeSocket *verify_socket(ListBase *lb, bNodeSocketType *stype)
+static void verify_socket(ListBase *lb, bNodeSocketType *stype, ListBase 
*r_verified)
 {
        bNodeSocket *sock;
+       int list_socket= nodeIsListSocket(stype);
        
+       r_verified->first = r_verified->last = NULL;
+       
        for(sock= lb->first; sock; sock= sock->next) {
                /* both indices are zero for non-groups, otherwise it's a 
unique index */
-               if(sock->to_index==stype->own_index)
-                       if(strncmp(sock->name, stype->name, NODE_MAXSTR)==0)
+               if(sock->to_index==stype->own_index && strncmp(sock->name, 
stype->name, NODE_MAXSTR)==0) {
+                       sock->type= stype->type;                /* in future, 
read this from tydefs! */
+                       if(stype->limit==0) sock->limit= 0xFFF;
+                       else sock->limit= stype->limit;
+                       sock->ns.min= stype->min;
+                       sock->ns.max= stype->max;
+                       sock->tosock= stype->internsock;
+                       
+                       BLI_remlink(lb, sock);
+                       
+                       /* non-list sockets may only have one of each type */
+                       if (!list_socket) {
+                               /* add to verified list */
+                               BLI_addtail(r_verified, sock);
                                break;
+                       }
+                       else {
+                               /* only the last socket may be without link 
(checked after the loop) */
+                               if (sock->link) {
+                                       if (r_verified->last)
+                                               sock->list_index = 
((bNodeSocket*)r_verified->last)->list_index + 1;
+                                       else
+                                               sock->list_index = -1;
+                                       /* add to verified list */
+                                       BLI_addtail(r_verified, sock);
+                               }
+                       }
+                       
+                       
+                       if (!list_socket) {
+                               break;
+                       }
+               }
        }
-       if(sock) {
-               sock->type= stype->type;                /* in future, read this 
from tydefs! */
-               if(stype->limit==0) sock->limit= 0xFFF;
-               else sock->limit= stype->limit;
-               sock->ns.min= stype->min;
-               sock->ns.max= stype->max;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to