[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29704] branches/particles-2010/source/ blender: Initial particle nodes commit.

Lukas Tönne lukas.toenne at hotmail.com
Sat Jun 26 13:19:25 CEST 2010


Revision: 29704
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29704
Author:   lukastoenne
Date:     2010-06-26 13:19:25 +0200 (Sat, 26 Jun 2010)

Log Message:
-----------
Initial particle nodes commit.
This adds a further node tree type for particles. Some changes were made to the basic node system:
- Added SOCK_ID and SOCK_EXEC socket types.
SOCK_ID is used to pass pointers to library data between nodes. This is used for object nodes currently, which serve as emitter inputs.
SOCK_EXEC defines operator sockets, which can be called by target nodes on different contexts.
- Extensible socket lists.
These are used for operator links, which can be called by the target node as required and add very flexible simulation possibilities. Currently only on input sockets of the SOCK_EXEC type.
- Basic type checking on link creation.
Socket types are checked by a generic function for compatibility. Current socket types (VALUE, RGBA and VECTOR) are all compatible using the current conversion policies, ID sockets should only match for the same ID type (not implemented yet), operators generally match. By default other socket combinations are not compatible, displayed by red links and preventing invalid links.

Particle nodes are all prototypes and test implementations currently and will be changed/removed.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenkernel/BKE_particle_emitter.h
    branches/particles-2010/source/blender/blenkernel/BKE_particle_system.h
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/blenkernel/intern/particle_emitter.c
    branches/particles-2010/source/blender/blenkernel/intern/particle_settings.c
    branches/particles-2010/source/blender/blenkernel/intern/particle_system.c
    branches/particles-2010/source/blender/editors/include/ED_node.h
    branches/particles-2010/source/blender/editors/space_buttons/space_buttons.c
    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/makesdna/DNA_particle_link_types.h
    branches/particles-2010/source/blender/makesdna/DNA_particle_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_particle.c
    branches/particles-2010/source/blender/makesrna/intern/rna_space.c
    branches/particles-2010/source/blender/modifiers/intern/MOD_particlesystem.c
    branches/particles-2010/source/blender/nodes/CMakeLists.txt
    branches/particles-2010/source/blender/nodes/intern/node_util.h
    branches/particles-2010/source/blender/windowmanager/WM_types.h

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-06-26 10:39:41 UTC (rev 29703)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-06-26 11:19:25 UTC (rev 29704)
@@ -52,6 +52,8 @@
 struct GPUMaterial;
 struct GPUNode;
 struct GPUNodeStack;
+struct ParticleSimulationData;
+struct ParticleSystem;
 struct PointerRNA;
 struct bContext;
 
@@ -64,7 +66,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 */
 	
@@ -122,6 +124,7 @@
 #define NODE_CLASS_OP_DYNAMIC	11
 #define NODE_CLASS_PATTERN 12
 #define NODE_CLASS_TEXTURE 13
+#define NODE_CLASS_SIMULATION	14
 
 /* ************** GENERIC API, TREES *************** */
 
@@ -137,6 +140,7 @@
 void			ntreeMakeLocal(struct bNodeTree *ntree);
 
 void			ntreeSocketUseFlags(struct bNodeTree *ntree);
+void			ntreeUpdateListSockets(struct bNodeTree *ntree);
 
 void			ntreeSolveOrder(struct bNodeTree *ntree);
 
@@ -175,6 +179,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 +196,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);
@@ -440,6 +447,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/BKE_particle_emitter.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_particle_emitter.h	2010-06-26 10:39:41 UTC (rev 29703)
+++ branches/particles-2010/source/blender/blenkernel/BKE_particle_emitter.h	2010-06-26 11:19:25 UTC (rev 29704)
@@ -51,6 +51,7 @@
 void pemit_distribute_particles(struct ParticleSimulationData *sim, int from);
 void pemit_thread_distribute_particle(struct ParticleThread *thread, struct ParticleData *pa, struct ChildParticle *cpa, int p);
 
+void psys_distribute_particle(struct ParticleSimulationData *sim, int emi, struct ParticleData *pa, int index);
 void pemit_emitter_step(struct ParticleSimulationData *sim, int emitter, float cfra, float dfra);
 
 #endif

Modified: branches/particles-2010/source/blender/blenkernel/BKE_particle_system.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_particle_system.h	2010-06-26 10:39:41 UTC (rev 29703)
+++ branches/particles-2010/source/blender/blenkernel/BKE_particle_system.h	2010-06-26 11:19:25 UTC (rev 29704)
@@ -341,6 +341,7 @@
 void psys_particle_on_dm(struct DerivedMesh *dm, int from, int index, int index_dmcache, float *fw, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor);
 
 /* particle_system.c */
+void psys_update_emitter_cache(struct ParticleSystem *psys, int emi, struct Object *emob);
 void pemit_calc_dmcache(struct ParticleSimulationData *sim, int emitter_index, struct DerivedMesh *dm);
 int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, int index, float *fw, struct LinkNode *node);
 

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-06-26 10:39:41 UTC (rev 29703)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-06-26 11:19:25 UTC (rev 29704)
@@ -49,10 +49,11 @@
 
 #include "CMP_node.h"
 #include "intern/CMP_util.h"	/* stupid include path... */
-
 #include "SHD_node.h"
 #include "TEX_node.h"
 #include "intern/TEX_util.h"
+#include "PAR_node.h"
+#include "intern/PAR_util.h"
 
 #include "GPU_material.h"
 
@@ -60,6 +61,7 @@
 ListBase node_all_composit = {NULL, NULL};
 ListBase node_all_shaders = {NULL, NULL};
 ListBase node_all_textures = {NULL, NULL};
+ListBase node_all_particles = {NULL, NULL};
 
 /* ************** Type stuff **********  */
 
@@ -91,6 +93,8 @@
 		ntree->alltypes= node_all_composit;
 	else if(ntree->type==NTREE_TEXTURE)
 		ntree->alltypes= node_all_textures;
+	else if(ntree->type==NTREE_PARTICLES)
+		ntree->alltypes= node_all_particles;
 	else {
 		ntree->alltypes= empty_list;
 		printf("Error: no type definitions for nodes\n");
@@ -141,6 +145,12 @@
 	}
 }
 
+int nodeIsListSocket(bNodeSocketType *stype)
+{
+	/* TODO needs a more generic way of allowing list sockets */
+	return (stype->type == SOCK_EXEC);
+}
+
 /* only used internal... we depend on type definitions! */
 static bNodeSocket *node_add_socket_type(ListBase *lb, bNodeSocketType *stype)
 {
@@ -167,6 +177,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 +222,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;
-		sock->tosock= stype->internsock;
-		
-		BLI_remlink(lb, sock);
-		
-		return sock;
+	
+#if 0
+	if(!r_verified->first) {
+		r_verified->first = r_verified->last = node_add_socket_type(NULL, stype);
 	}
-	else {
-		return node_add_socket_type(NULL, stype);
+	else if (list_socket && ((bNodeSocket*)r_verified->last)->link) {
+		/* add an unlinked socket for extending the list */
+		node_add_socket_type(r_verified, stype);
 	}
+#endif
 }
 
 static void verify_socket_list(bNodeTree *ntree, ListBase *lb, bNodeSocketType *stype_first)
@@ -222,7 +290,7 @@
 		/* step by step compare */
 		stype= stype_first;
 		while(stype->type != -1) {
-			stype->sock= verify_socket(lb, stype);
+			verify_socket(lb, stype, &stype->verified);
 			stype++;
 		}
 		/* leftovers are removed */
@@ -231,7 +299,7 @@
 		/* and we put back the verified sockets */
 		stype= stype_first;
 		while(stype->type != -1) {
-			BLI_addtail(lb, stype->sock);
+			addlisttolist(lb, &stype->verified);
 			stype++;
 		}
 	}
@@ -390,7 +458,7 @@
 		for(node= ngroup->nodes.first; node; node= node->next) {
 			/* nodes are presumed fully verified, stype and socket list are in sync */
 			stype= node->typeinfo->inputs;
-			for(sock= node->inputs.first; sock; sock= sock->next, stype++) {
+			for(sock= node->inputs.first; sock; sock= sock->next) {
 				if(sock->intern==0) {
 					/* debug only print */
 					if(stype==NULL || stype->type==-1) printf("group verification error %s\n", ngroup->id.name);
@@ -400,7 +468,9 @@
 					inputs[a].internsock= sock;	
 					a++;
 				}
-			}
+				if (sock->next && sock->next->list_index <= sock->list_index)
+					stype++;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list