[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31256] branches/particles-2010/source/ blender: Fixed saving and loading and lots of bugs.
Lukas Toenne
lukas.toenne at googlemail.com
Wed Aug 11 18:08:54 CEST 2010
Revision: 31256
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31256
Author: lukastoenne
Date: 2010-08-11 18:08:54 +0200 (Wed, 11 Aug 2010)
Log Message:
-----------
Fixed saving and loading and lots of bugs. Added a few macros for making node execution functions as easy as possible.
Modified Paths:
--------------
branches/particles-2010/source/blender/blenkernel/intern/node.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_vertex_data.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_if.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_math.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_vertex_data.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_timestep.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vector_compose.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vector_decompose.c
branches/particles-2010/source/blender/nodes/intern/SIM_util.c
branches/particles-2010/source/blender/nodes/intern/SIM_util.h
branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c
Added Paths:
-----------
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_add_particle.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_particle_data.c
Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-08-11 15:42:01 UTC (rev 31255)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-08-11 16:08:54 UTC (rev 31256)
@@ -1744,25 +1744,27 @@
if (sock->stype->type == SOCK_ANY) {
if (any_island > 0)
merge_socket_islands(islands, any_island, sock->island);
- else
- any_island = sock->island;
+ any_island = sock->island;
}
}
for (sock=node->outputs.first; sock; sock = sock->next) {
if (sock->stype->type == SOCK_ANY) {
if (any_island > 0)
merge_socket_islands(islands, any_island, sock->island);
- else
- any_island = sock->island;
+ any_island = sock->island;
}
}
}
-static void ntreeFindSocketTypeIslands(bNodeTree *ntree, bNodeSocketIsland **r_islands, int *r_totsock)
+static int link_merge_type(bNodeLink *link)
{
+ return (link->fromsock->stype->type == SOCK_ANY || link->tosock->stype->type == SOCK_ANY);
+}
+
+static void ntreeInitSocketIslands(bNodeTree *ntree, bNodeSocketIsland **r_islands, int *r_totsock)
+{
bNode *node;
bNodeSocket *sock;
- bNodeLink *link;
bNodeSocketIsland *islands, *cur;
int totsock;
@@ -1790,17 +1792,6 @@
}
}
- /* merge islands inside nodes */
- for (node=ntree->nodes.first; node; node = node->next) {
- node_merge_type_islands(node, islands);
- }
- /* merge islands by links */
- for (link=ntree->links.first; link; link = link->next) {
- if (link->fromsock && link->tosock)
- if (link->fromsock->stype->type == SOCK_ANY || link->tosock->stype->type == SOCK_ANY)
- merge_socket_islands(islands, link->fromsock->island, link->tosock->island);
- }
-
*r_islands = islands;
*r_totsock = totsock;
}
@@ -1808,6 +1799,8 @@
static void ntreeUpdateSocketTypes(bNodeTree *ntree)
{
bNodeTreeTypeInfo *tti;
+ bNode *node;
+ bNodeLink *link;
bNodeSocketIsland *island_map, *island;
int totsock;
int i, number;
@@ -1818,7 +1811,19 @@
if (!tti->preferredSocketType || !tti->compatibleSocketTypes)
return;
- ntreeFindSocketTypeIslands(ntree, &island_map, &totsock);
+// ntreeFindSocketIslands(ntree, node_merge_type_islands, link_merge_type, &island_map, &totsock);
+ ntreeInitSocketIslands(ntree, &island_map, &totsock);
+
+ /* merge islands inside nodes */
+ for (node=ntree->nodes.first; node; node = node->next) {
+ node_merge_type_islands(node, island_map);
+ }
+ /* merge islands by links */
+ for (link=ntree->links.first; link; link = link->next) {
+ if (link->fromsock && link->tosock)
+ if (link_merge_type(link))
+ merge_socket_islands(island_map, link->fromsock->island, link->tosock->island);
+ }
number = -1;
island = island_map;
@@ -1852,6 +1857,162 @@
MEM_freeN(island_map);
}
+typedef struct bNodeLinkSortList {
+ struct bNodeLinkSortList *next, *prev;
+ struct bNodeLink *link;
+} bNodeLinkSortList;
+
+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);
+ }
+ else
+ return 0;
+}
+
+static void ntreeNodeResolveContexts(bNode *node)
+{
+ bNodeSocket *sock;
+ bNodeDataContext resctx;
+
+ resctx.type = NDC_UNDEFINED;
+ resctx.source = NULL;
+ for (sock=node->inputs.first; sock; sock=sock->next) {
+ if (sock->stype->contexttype == NDC_UNDEFINED) {
+ if (resctx.type == NDC_UNDEFINED) {
+ if (sock->context.type != NDC_UNDEFINED)
+ resctx = sock->context;
+ }
+ else if (ELEM(sock->context.type, NDC_UNDEFINED, NDC_SINGLETON)==0) {
+ if (resctx.type == NDC_SINGLETON) {
+ resctx = sock->context;
+ }
+ else {
+ if (resctx.type != sock->context.type || resctx.source != sock->context.source) {
+ resctx.type = NDC_UNDEFINED;
+ resctx.source = NULL;
+ }
+ }
+ }
+ }
+ }
+
+ if (resctx.type == NDC_UNDEFINED) {
+ for (sock=node->inputs.first; sock; sock=sock->next) {
+ if (sock->stype->contexttype == NDC_UNDEFINED) {
+ if (ELEM(sock->context.type, NDC_UNDEFINED, NDC_SINGLETON)==0) {
+ resctx.type = NDC_UNDEFINED;
+ resctx.source = NULL;
+ }
+ }
+ }
+ }
+ for (sock=node->outputs.first; sock; sock=sock->next) {
+ if (sock->stype->contexttype == NDC_UNDEFINED) {
+ sock->context = resctx;
+ }
+ }
+}
+
+static void ntreeUpdateSocketContexts(bNodeTree *ntree)
+{
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeLink *link;
+ ListBase sortlist;
+ bNodeLinkSortList *item;
+
+ /* initialise contexts */
+ for (node=ntree->nodes.first; node; node=node->next) {
+ for (sock=node->inputs.first; sock; sock=sock->next) {
+ if (sock->stype->contexttype == NDC_UNDEFINED) {
+ if (sock->link) {
+ sock->context.type = NDC_UNDEFINED;
+ sock->context.source = NULL;
+ }
+ else {
+ /* default socket data context is singleton */
+ sock->context.type = NDC_SINGLETON;
+ sock->context.source = NULL;
+ }
+ }
+ }
+
+ ntreeNodeResolveContexts(node);
+ }
+
+ sortlist.first = sortlist.last = NULL;
+ for (link=ntree->links.first; link; link=link->next) {
+ item = MEM_callocN(sizeof(bNodeLinkSortList), "bNodeLinkSortList");
+ item->link = link;
+ BLI_addtail(&sortlist, item);
+ }
+
+ BLI_sortlist(&sortlist, ntreeSortLinkFromnode);
+
+ for (item=sortlist.first; item; item = item->next) {
+ link = item->link;
+ if (link->fromnode && link->tonode) {
+ if (link->tosock->stype->contexttype == NDC_UNDEFINED) {
+ link->tosock->context = link->fromsock->context;
+ ntreeNodeResolveContexts(link->tonode);
+ }
+ }
+ }
+
+ {
+ printf("------------------\n");
+ for (node=ntree->nodes.first; node; node = node->next) {
+ printf("Node %s:\n", node->name);
+ printf("\tInputs:\n");
+ for (sock=node->inputs.first; sock; sock = sock->next) {
+ printf("\t\t%s, context ", sock->name);
+ switch (sock->context.type) {
+ case NDC_UNDEFINED: printf("undefined"); break;
+ case NDC_SINGLETON: printf("singleton"); break;
+ case NDC_NODE: printf("node"); break;
+ case NDC_PARTICLE: printf("particle"); break;
+ case NDC_VERTEX: printf("vertex"); break;
+ case NDC_EDGE: printf("edge"); break;
+ case NDC_FACE: printf("face"); break;
+ }
+ printf(" [%p]\n", sock->context.source);
+ }
+ printf("\tOutputs:\n");
+ for (sock=node->outputs.first; sock; sock = sock->next) {
+ printf("\t\t%s, context ", sock->name);
+ switch (sock->context.type) {
+ case NDC_UNDEFINED: printf("undefined"); break;
+ case NDC_SINGLETON: printf("singleton"); break;
+ case NDC_NODE: printf("node"); break;
+ case NDC_PARTICLE: printf("particle"); break;
+ case NDC_VERTEX: printf("vertex"); break;
+ case NDC_EDGE: printf("edge"); break;
+ case NDC_FACE: printf("face"); break;
+ }
+ printf(" [%p]\n", sock->context.source);
+ }
+ }
+ #if 0
+ printf("Sorted Link List:\n");
+ for (item=sortlist.first; item; item = item->next) {
+ if (item->link->fromnode && item->link->tonode) {
+ printf("\tfrom '%s:%s' to '%s:%s'\n", item->link->fromnode->name, item->link->fromsock->name, item->link->tonode->name, item->link->tosock->name);
+ }
+ }
+ #endif
+ printf("------------------ \n");
+ }
+
+ BLI_freelistN(&sortlist);
+}
+
static void ntreeUpdateLinks(bNodeTree *ntree)
{
bNodeTreeTypeInfo *tti = ntreeGetTypeInfo(ntree->type);
@@ -1866,6 +2027,33 @@
}
else {
valid = tti->compatibleSocketTypes(link->fromsock->type, link->tosock->type);
+
+ if (valid) {
+ int fromtype= link->fromsock->context.type;
+ int totype= link->tosock->context.type;
+ if (totype == NDC_UNDEFINED && fromtype != NDC_UNDEFINED)
+ valid = 0;
+ else if (ELEM(fromtype, NDC_UNDEFINED, NDC_SINGLETON)==0) {
+ if (totype == NDC_SINGLETON)
+ valid =0;
+ 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
+ }
}
if (valid)
@@ -1885,6 +2073,7 @@
ntreeSolveOrder(ntree);
ntreeUpdateListSockets(ntree);
ntreeUpdateSocketTypes(ntree);
+ ntreeUpdateSocketContexts(ntree);
ntreeUpdateLinks(ntree);
}
Added: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_add_particle.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_add_particle.c (rev 0)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_add_particle.c 2010-08-11 16:08:54 UTC (rev 31256)
@@ -0,0 +1,74 @@
+/**
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* The Original Code is Copyright (C) 2006 Blender Foundation.
+* All rights reserved.
+*
+* The Original Code is: all of this file.
+*
+* Contributor(s): none yet.
+*
+* ***** END GPL LICENSE BLOCK *****
+
+*/
+
+#if 0
+#include "../SIM_util.h"
+
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "RNA_access.h"
+
+/* **************** Get mesh vertex data ******************** */
+
+static bNodeSocketType inputs[]= {
+ { -1, 0, "" }
+};
+
+static bNodeSocketType outputs[]= {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list