[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33032] branches/particles-2010/source/ blender/nodes/intern/SIM_nodetree.c: Cleanup ( removed old socket type adaptation code).
Lukas Toenne
lukas.toenne at googlemail.com
Fri Nov 12 08:36:07 CET 2010
Revision: 33032
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33032
Author: lukastoenne
Date: 2010-11-12 08:36:06 +0100 (Fri, 12 Nov 2010)
Log Message:
-----------
Cleanup (removed old socket type adaptation code).
Modified Paths:
--------------
branches/particles-2010/source/blender/nodes/intern/SIM_nodetree.c
Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodetree.c 2010-11-12 07:16:33 UTC (rev 33031)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodetree.c 2010-11-12 07:36:06 UTC (rev 33032)
@@ -65,298 +65,6 @@
}
}
-#if 0
-static void merge_socket_islands(bNodeSocketIsland *islands, int a, int b)
-{
- bNodeSocketIsland *i;
-
- if (a == b)
- return;
- if (a < b) {
- /* merge island b into a */
- for (i = islands + a; i->next; i = i->next);
- i->next = islands + b;
- islands[b].prev = i;
-
- for (i = islands + b; i; i = i->next)
- i->sock->island = a;
- }
- else {
- /* merge island a into b */
- for (i = islands + b; i->next; i = i->next);
- i->next = islands + a;
- islands[a].prev = i;
-
- for (i = islands + a; i; i = i->next)
- i->sock->island = b;
- }
-}
-
-static void merge_node_type_islands(bNode *node, bNodeSocketIsland *islands)
-{
- bNodeSocket *sock, *msock;
- if (node->type == NODE_GROUP) {
- if (node->id) {
- /* TODO this way of merging islands by internal groups is O(n^2),
- * where n is the total number of sockets of the group node (inputs+outputs).
- * Should not be a problem as this number will probably not be very large,
- * otherwise a more elaborate method must be found (using sorting).
- */
- int cur_island = -1;
- int internal_island;
- for (sock=node->inputs.first; sock; sock = sock->next) {
- if (sock->tosock && sock->island > cur_island) {
- cur_island = sock->island;
- internal_island = sock->tosock->island;
- /* merge this socket with all remaining sockets whose internal island matches */
- for (msock=sock->next; msock; msock = msock->next)
- if (msock->tosock && msock->tosock->island == internal_island)
- merge_socket_islands(islands, cur_island, msock->island);
- for (msock=node->outputs.first; msock; msock = msock->next)
- if (msock->tosock && msock->tosock->island == internal_island)
- merge_socket_islands(islands, cur_island, msock->island);
- }
- }
- for (sock=node->outputs.first; sock; sock = sock->next) {
- if (sock->tosock && sock->island > cur_island) {
- cur_island = sock->island;
- internal_island = sock->tosock->island;
- /* merge this socket with all remaining sockets whose internal island matches */
- for (msock=sock->next; msock; msock = msock->next)
- if (msock->tosock && msock->tosock->island == internal_island)
- merge_socket_islands(islands, cur_island, msock->island);
- }
- }
- }
- }
- else {
- /* TODO This procedure merges all sockets of ANY type to the same island.
- * Is there any situation where this model is insufficient?
- */
- int any_island = -1;
- for (sock=node->inputs.first; sock; sock = sock->next) {
- if ((sock->flag & SOCK_ADAPT_TYPE)!=0) {
- if (any_island >= 0)
- merge_socket_islands(islands, any_island, sock->island);
- any_island = sock->island;
- }
- }
- for (sock=node->outputs.first; sock; sock = sock->next) {
- if ((sock->flag & SOCK_ADAPT_TYPE)!=0) {
- if (any_island >= 0)
- merge_socket_islands(islands, any_island, sock->island);
- any_island = sock->island;
- }
- }
- }
-}
-
-static int link_merge_type(bNodeLink *link)
-{
- return ((link->fromsock->flag & SOCK_ADAPT_TYPE)!=0 || (link->tosock->flag & SOCK_ADAPT_TYPE)!=0);
-}
-
-static void calc_type_islands_recursive(bNodeTree *ntree)
-{
- bNode *node;
- bNodeSocket *sock;
- bNodeLink *link;
- int totsock;
- bNodeSocketIsland *cur;
-
- /* calculate nested groups */
- for (node=ntree->nodes.first; node; node = node->next)
- if (node->type == NODE_GROUP && node->id && ((bNodeTree*)node->id)->islands == NULL)
- calc_type_islands_recursive((bNodeTree*)node->id);
-
- /* initialise island indices */
- totsock = 0;
- for (node=ntree->nodes.first; node; node = node->next) {
- for (sock=node->inputs.first; sock; sock = sock->next)
- sock->island = totsock++;
- for (sock=node->outputs.first; sock; sock = sock->next)
- sock->island = totsock++;
- }
-
- /* create the island pointer array */
- cur = ntree->islands = MEM_callocN((totsock+1) * sizeof(bNodeSocketIsland), "bNodeSocketIsland");
- for (node=ntree->nodes.first; node; node = node->next) {
- for (sock=node->inputs.first; sock; sock = sock->next) {
- cur->sock = sock;
- cur->node = node;
- cur->next = cur->prev = NULL;
- cur->is_output = 0;
- ++cur;
- }
- for (sock=node->outputs.first; sock; sock = sock->next) {
- cur->sock = sock;
- cur->node = node;
- cur->next = cur->prev = NULL;
- cur->is_output = 1;
- ++cur;
- }
- }
- /* marks the end of the island list */
- cur->sock = NULL;
- cur->node = NULL;
- cur->next = cur->prev = NULL;
-
- /* merge islands inside nodes */
- for (node=ntree->nodes.first; node; node = node->next) {
- merge_node_type_islands(node, ntree->islands);
- }
- /* 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(ntree->islands, link->fromsock->island, link->tosock->island);
- }
-}
-
-static void free_type_islands_recursive(bNodeTree *ntree)
-{
- bNode *node;
-
- /* free islands in groups */
- for (node=ntree->nodes.first; node; node = node->next)
- if (node->type == NODE_GROUP && node->id)
- free_type_islands_recursive((bNodeTree*)node->id);
-
- if (ntree->islands != NULL) {
- MEM_freeN(ntree->islands);
- ntree->islands = NULL;
- }
-}
-
-static void find_island_type_recursive(bNodeTree *ntree, int island, int *restype, int *resolved)
-{
- bNodeTreeTypeInfo *tti;
- bNodeSocketIsland *cur;
-
- tti = ntreeGetTypeInfo(ntree->type);
- if (!tti->preferredSocketType || !tti->compatibleSocketTypes)
- return;
-
- for (cur = ntree->islands + island; cur; cur = cur->next) {
- if (cur->node->type == NODE_GROUP) {
- if (cur->node->id && cur->sock->tosock)
- find_island_type_recursive((bNodeTree*)cur->node->id, cur->sock->tosock->island, restype, resolved);
- }
- else {
- if (!(*resolved)) {
- *restype = cur->sock->type;
- *resolved = ((cur->sock->flag & SOCK_ADAPT_TYPE) == 0);
- }
- else {
- /* restype == SOCK_ANY means the island contains incompatible types and cannot be resolved! */
- if (*restype != SOCK_ANY && (cur->sock->flag & SOCK_ADAPT_TYPE) == 0) {
- if (tti->compatibleSocketTypes(*restype, cur->sock->type))
- *restype = tti->preferredSocketType(*restype, cur->sock->type);
- else
- *restype = SOCK_ANY;
- }
- }
- }
- }
-}
-
-static void resolve_socket_types(bNodeTree *ntree)
-{
-
- bNodeSocketIsland *cur, *res;
- int restype, resolved, island;
-
- island = -1;
- for (cur = ntree->islands; cur->sock; ++cur) {
- if (cur->sock->island > island) {
- island = cur->sock->island;
- resolved = 0;
- restype = SOCK_ANY;
-
- find_island_type_recursive(ntree, island, &restype, &resolved);
-
- for (res = cur; res; res = res->next)
- if ((res->sock->flag & SOCK_ADAPT_TYPE)!=0)
- res->sock->type = restype;
- }
- }
-}
-#endif
-
-#if 0
-static void ntree_clear_tag_recursive(bNodeTree *ntree)
-{
- bNode *node;
-
- ntree->flag &= ~NTREE_TAGGED;
-
- for(node= ntree->nodes.first; node; node= node->next) {
- if (node->type == NODE_GROUP && node->id)
- ntree_clear_tag_recursive((bNodeTree *)node->id);
- }
-}
-
-static int get_cl_sources_recursive(bNodeTree *ntree, const char **cl_sources, int cl_totsources)
-{
- bNode *node;
-
- ntree->flag |= NTREE_TAGGED;
-
- /* TODO this could actually count node types instead, but would have to somehow tag the type struct */
- for(node= ntree->nodes.first; node; node= node->next) {
- if (node->type == NODE_GROUP) {
- bNodeTree *group= (bNodeTree*)node->id;
- if (group && (group->flag & NTREE_TAGGED)==0)
- cl_totsources += get_cl_sources_recursive((bNodeTree *)node->id, cl_sources, cl_totsources);
- }
- else if (node->typeinfo->cl_source)
- cl_sources[cl_totsources++] = node->typeinfo->cl_source;
- }
-
- return cl_totsources;
-}
-#endif
-
-#if 0
-static void resolve_socketstack_island_recursive(bNodeTree *ntree, SimSocketStack *outstack, int group_out, int island, int restype)
-{
- bNodeSocketIsland *res = ntree->islands + island;
-
- while (res) {
- if (res->node->type == NODE_GROUP) {
- if (res->node->id)
- resolve_socketstack_island_recursive((bNodeTree*)res->node->id, outstack, res->node->stack_index, res->sock->tosock->island, restype);
- }
- else {
- if (res->is_output)
- outstack[res->sock->stack_index + group_out].type = restype;
- }
- res = res->next;
- }
-}
-#endif
-
-#if 0
-static void resolve_socketstack_types(bNodeTree *ntree, SimSocketStack *outstack)
-{
- bNodeSocketIsland *cur;
- int restype, resolved, island;
-
- island = -1;
- for (cur = ntree->islands; cur->sock; ++cur) {
- if (cur->sock->island > island) {
- island = cur->sock->island;
- resolved = 0;
- restype = SOCK_ANY;
-
- find_island_type_recursive(ntree, island, &restype, &resolved);
-
- resolve_socketstack_island_recursive(ntree, outstack, 0, island, restype);
- }
- }
-}
-#endif
-
static int socket_types_compatible(int a, int b)
{
int valid;
More information about the Bf-blender-cvs
mailing list