[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34319] branches/particles-2010: Added new tree type for modifiers.
Lukas Toenne
lukas.toenne at googlemail.com
Fri Jan 14 17:01:48 CET 2011
Revision: 34319
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34319
Author: lukastoenne
Date: 2011-01-14 16:01:45 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
Added new tree type for modifiers. This should implement the new design ideas for operator trees.
Modified Paths:
--------------
branches/particles-2010/release/scripts/ui/space_node.py
branches/particles-2010/source/blender/blenkernel/BKE_node.h
branches/particles-2010/source/blender/blenkernel/intern/material.c
branches/particles-2010/source/blender/blenkernel/intern/node.c
branches/particles-2010/source/blender/blenkernel/intern/texture.c
branches/particles-2010/source/blender/blenloader/intern/readfile.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/makesdna/DNA_node_types.h
branches/particles-2010/source/blender/makesrna/RNA_enum_types.h
branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
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_nodes/CMP_normal.c
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_value.c
branches/particles-2010/source/blender/nodes/intern/CMP_nodetree.c
branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_normal.c
branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_rgb.c
branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_value.c
branches/particles-2010/source/blender/nodes/intern/SHD_nodetree.c
branches/particles-2010/source/blender/nodes/intern/SHD_util.c
branches/particles-2010/source/blender/nodes/intern/SIM_intern.h
branches/particles-2010/source/blender/nodes/intern/SIM_nodetree.c
branches/particles-2010/source/blender/nodes/intern/SIM_util.c
branches/particles-2010/source/blender/nodes/intern/TEX_nodetree.c
branches/particles-2010/source/blender/nodes/intern/TEX_util.c
branches/particles-2010/source/blender/nodes/intern/node_util.c
branches/particles-2010/source/blender/nodes/intern/node_util.h
branches/particles-2010/source/blender/render/intern/source/texture.c
Modified: branches/particles-2010/release/scripts/ui/space_node.py
===================================================================
--- branches/particles-2010/release/scripts/ui/space_node.py 2011-01-14 15:21:13 UTC (rev 34318)
+++ branches/particles-2010/release/scripts/ui/space_node.py 2011-01-14 16:01:45 UTC (rev 34319)
@@ -70,13 +70,14 @@
layout.prop(snode, "show_backdrop")
elif snode.tree_type == 'SIMULATION':
- scene = snode.id
-
layout.template_ID(snode, "node_tree", new="node.new_node_tree")
props = layout.operator("node.compile_opencl_program", text="Compile Program")
props.force = True
+ elif snode.tree_type == 'MODIFIER':
+ layout.template_ID(snode, "node_tree", new="node.new_node_tree")
+
layout.separator()
layout.template_running_jobs()
Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h 2011-01-14 15:21:13 UTC (rev 34318)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h 2011-01-14 16:01:45 UTC (rev 34319)
@@ -189,6 +189,13 @@
#define NODE_CLASS_MATH_ROTATION 19
#define NODE_CLASS_PARTICLES 25
+/* Execution Data for each instance of node tree execution.
+ * Tree types may extend this to include custom data.
+ */
+typedef struct bNodeTreeExecData {
+ struct bNodeTree *nodetree;
+} bNodeTreeExecData;
+
typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
typedef struct bNodeTreeType
{
@@ -203,9 +210,9 @@
void (*freeCache)(struct bNodeTree *ntree);
void (*freeNodeCache)(struct bNodeTree *ntree, struct bNode *node);
void (*foreachNodeTree)(struct Main *main, void *calldata, bNodeTreeCallback func); /* iteration over all node trees */
- void *(*beginExec)(struct bNodeTree *ntree);
- void (*endExec)(struct bNodeTree *ntree, void *execdata);
- void (*exec)(struct bNodeTree *ntree, void *execdata, void *callerdata, int thread);
+ struct bNodeTreeExecData *(*beginExec)(struct bNodeTree *ntree);
+ void (*endExec)(bNodeTreeExecData *execdata);
+ void (*exec)(bNodeTreeExecData *execdata, void *callerdata, int thread);
/* general update function */
void (*update)(struct bNodeTree *ntree);
@@ -241,10 +248,10 @@
void ntreeSetOutput(struct bNodeTree *ntree);
void ntreeValidateLinks(struct bNodeTree *ntree);
-void ntreeBeginExecTree(struct bNodeTree *ntree);
-void ntreeExecTree(struct bNodeTree *ntree, void *callerdata, int thread);
+struct bNodeTreeExecData *ntreeBeginExecTree(struct bNodeTree *ntree);
+void ntreeExecTree(struct bNodeTreeExecData *execdata, void *callerdata, int thread);
void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int do_previews);
-void ntreeEndExecTree(struct bNodeTree *ntree);
+void ntreeEndExecTree(struct bNodeTreeExecData *execdata);
void ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
void ntreeClearPreview(struct bNodeTree *ntree);
Modified: branches/particles-2010/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/material.c 2011-01-14 15:21:13 UTC (rev 34318)
+++ branches/particles-2010/source/blender/blenkernel/intern/material.c 2011-01-14 16:01:45 UTC (rev 34319)
@@ -891,7 +891,8 @@
if(mat->nodetree && mat->use_nodes) {
init_render_nodetree(mat->nodetree, mat, r_mode, amb);
- ntreeBeginExecTree(mat->nodetree); /* has internal flag to detect it only does it once */
+ if (!mat->nodetree->execdata)
+ mat->nodetree->execdata = ntreeBeginExecTree(mat->nodetree);
}
}
@@ -923,8 +924,10 @@
/* only needed for nodes now */
void end_render_material(Material *mat)
{
- if(mat && mat->nodetree && mat->use_nodes)
- ntreeEndExecTree(mat->nodetree); /* has internal flag to detect it only does it once */
+ if(mat && mat->nodetree && mat->use_nodes) {
+ if (mat->nodetree->execdata)
+ ntreeEndExecTree(mat->nodetree->execdata);
+ }
}
void end_render_materials(Main *bmain)
Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c 2011-01-14 15:21:13 UTC (rev 34318)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2011-01-14 16:01:45 UTC (rev 34319)
@@ -67,6 +67,7 @@
#include "SHD_node.h"
#include "TEX_node.h"
#include "SIM_node.h"
+#include "MOD_node.h"
bNodeTreeType *ntreeGetType(int type)
@@ -78,6 +79,7 @@
types[NTREE_COMPOSIT] = &ntreeType_Composite;
types[NTREE_TEXTURE] = &ntreeType_Texture;
types[NTREE_SIMULATION] = &ntreeType_Simulation;
+ types[NTREE_MODIFIER] = &ntreeType_Modifier;
types_init = 0;
}
@@ -141,38 +143,10 @@
ntree->init |= NTREE_TYPE_INIT;
}
-static void init_socket_inputdata(bNodeTree *ntree, bNodeSocket *sock)
-{
- bNodeSocketType *sti= ntreeGetSocketType(ntree->type, sock->type);
-
- if (sti->data_size > 0) {
- sock->inputdata = MEM_callocN((size_t)sti->data_size, "Node socket input data");
- if (sti->data_set_default)
- sti->data_set_default(sock->inputdata);
- }
- else
- sock->inputdata = NULL;
-}
-
-static void copy_socket_inputdata(bNodeTree *ntree, bNodeSocket *nsock, bNodeSocket *sock)
-{
- if (sock->inputdata) {
- if (nsock->inputdata)
- memcpy(nsock->inputdata, sock->inputdata, ntreeGetSocketType(ntree->type, sock->type)->data_size);
- else
- nsock->inputdata = MEM_dupallocN(sock->inputdata);
- }
- else {
- if (nsock->inputdata) {
- MEM_freeN(nsock->inputdata);
- nsock->inputdata = NULL;
- }
- }
-}
-
static bNodeSocket *make_socket(bNodeTree *ntree, int in_out, const char *name, int type)
{
bNodeSocket *sock= MEM_callocN(sizeof(bNodeSocket), "sock");
+ bNodeSocketType *sti= ntreeGetSocketType(ntree->type, type);
BLI_strncpy(sock->name, name, NODE_MAXSTR);
sock->limit = (in_out==SOCK_IN ? 1 : 0xFFF);
@@ -183,7 +157,11 @@
sock->flag |= SOCK_ADAPT_CONTEXT;
sock->storage = NULL;
- init_socket_inputdata(ntree, sock);
+ if (sti->data_size > 0) {
+ sock->inputdata = MEM_callocN((size_t)sti->data_size, "Node socket input data");
+ if (sti->data_set_default)
+ sti->data_set_default(sock->inputdata);
+ }
return sock;
}
@@ -261,11 +239,13 @@
{
to->type= from->type;
to->limit= from->limit;
- to->inputmin = from->inputmin;
- to->inputmax = from->inputmax;
+ to->ns.min= from->ns.min;
+ to->ns.max= from->ns.max;
+ to->ns.imin= from->ns.imin;
+ to->ns.imax= from->ns.imax;
}
-static bNodeSocket *verify_group_socket(bNodeTree *ntree, ListBase *lb, bNodeGroupSocket *gsock)
+static bNodeSocket *verify_group_socket(ListBase *lb, bNodeGroupSocket *gsock)
{
bNodeSocket *sock = NULL;
@@ -280,7 +260,11 @@
copy_socket_properties(sock, sock->tosock);
/* initialise the default socket value */
- copy_socket_inputdata(ntree, sock, sock->tosock);
+ sock->ns.vec[0]= sock->tosock->ns.vec[0];
+ sock->ns.vec[1]= sock->tosock->ns.vec[1];
+ sock->ns.vec[2]= sock->tosock->ns.vec[2];
+ sock->ns.vec[3]= sock->tosock->ns.vec[3];
+ sock->ns.ival= sock->tosock->ns.ival;
break;
}
@@ -300,7 +284,7 @@
/* step by step compare */
for (gsock = socklist; gsock->internnode; ++gsock) {
bNodeSocket *tosock= gsock->internsock;
- gsock->sock = verify_group_socket(ntree, lb, gsock);
+ gsock->sock = verify_group_socket(lb, gsock);
if (gsock->sock) {
/* exclude from socket list to avoid deletion */
BLI_remlink(lb, gsock->sock);
@@ -844,8 +828,9 @@
for(sock= node->inputs.first; sock; sock= sock->next) {
if(sock->intern==0) {
bNodeSocket *nsock= groupnode_find_input(gnode, sock->own_index);
- if(nsock)
- copy_socket_inputdata(ntree, nsock, sock);
+ if(nsock) {
+ QUATCOPY(nsock->ns.vec, sock->ns.vec);
+ }
}
}
}
@@ -1291,7 +1276,7 @@
for(sock= nnode->inputs.first; sock; sock= sock->next, oldsock= oldsock->next) {
oldsock->new_sock= sock;
sock->stack_index= 0;
- copy_socket_inputdata(ntree, sock, oldsock);
+ sock->ns.data= NULL;
if(internal)
sock->own_index= 0;
@@ -1676,8 +1661,6 @@
if(ntree==NULL) return;
- ntreeEndExecTree(ntree); /* checks for if it is still initialized */
-
BKE_free_animdata((ID *)ntree);
BLI_freelistN(&ntree->links); /* do first, then unlink_node goes fast */
@@ -2153,9 +2136,6 @@
{
bNodeTreeType *tti= ntreeGetType(ntree->type);
- /* the solve-order is called on each tree change, so we should be sure no exec can be running */
- ntreeEndExecTree(ntree);
-
ntree->flag |= NTREE_UPDATE;
set_update_flag_recursive(ntree);
@@ -2169,9 +2149,6 @@
{
bNodeTreeType *tti= ntreeGetType(ntree->type);
- /* the solve-order is called on each tree change, so we should be sure no exec can be running */
- ntreeEndExecTree(ntree);
-
group->flag |= NTREE_UPDATE;
set_update_flag_recursive(ntree);
@@ -2185,9 +2162,6 @@
{
bNodeTreeType *tti= ntreeGetType(ntree->type);
- /* the solve-order is called on each tree change, so we should be sure no exec can be running */
- ntreeEndExecTree(ntree);
-
set_all_update_flags_recursive(ntree);
if (tti->update)
@@ -2239,46 +2213,39 @@
/* ******************* executing ************* */
-void ntreeBeginExecTree(bNodeTree *ntree)
+bNodeTreeExecData *ntreeBeginExecTree(bNodeTree *ntree)
{
- bNodeTreeType *treetype;
-
- /* let's make it sure */
- if(ntree->execdata)
- return;
-
- treetype = ntreeGetType(ntree->type);
- if (treetype->beginExec)
- ntree->execdata = treetype->beginExec(ntree);
+ bNodeTreeType *treetype= ntreeGetType(ntree->type);
+ bNodeTreeExecData *execdata= NULL;
+ if (treetype->beginExec) {
+ execdata = treetype->beginExec(ntree);
+ execdata->nodetree = ntree;
+ }
+ return execdata;
}
-void ntreeEndExecTree(bNodeTree *ntree)
+void ntreeEndExecTree(bNodeTreeExecData *execdata)
{
bNodeTreeType *treetype;
- if(ntree->execdata) {
- treetype = ntreeGetType(ntree->type);
+ if(execdata) {
+ treetype = ntreeGetType(execdata->nodetree->type);
if (treetype->endExec)
- treetype->endExec(ntree, ntree->execdata);
+ treetype->endExec(execdata);
- MEM_freeN(ntree->execdata);
- ntree->execdata = NULL;
+ MEM_freeN(execdata);
}
}
/* nodes are presorted, so exec is in order of list */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list