From f11ea1eb8e51e9d2d236a4efb34e55b564eec7ba Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 4 Feb 2008 21:17:15 +0000 Subject: [PATCH] Bugfix for recent alphaover premul commit, crashed existing files and on adding a new node, maybe the commit was incomplete? --- source/blender/blenloader/intern/readfile.c | 28 +++++++++++++++++++ .../nodes/intern/CMP_nodes/CMP_alphaOver.c | 7 ++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e663bd35fa4..33fe1b36f52 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4633,6 +4633,26 @@ static void do_version_ntree_242_2(bNodeTree *ntree) } } +static void ntree_version_245(bNodeTree *ntree) +{ + bNode *node; + NodeTwoFloats *ntf; + + if(ntree->type==NTREE_COMPOSIT) { + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type == CMP_NODE_ALPHAOVER) { + if(!node->storage) { + ntf= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); + node->storage= ntf; + if(node->custom1) + ntf->x= 1.0f; + } + } + } + } +} + + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -6789,6 +6809,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ParticleSettings *part; World *wrld; Mesh *me; + bNodeTree *ntree; /* unless the file was created 2.44.3 but not 2.45, update the constraints */ if ( !(main->versionfile==244 && main->subversionfile==3) && @@ -6973,6 +6994,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) wrld->ao_approx_error= 0.25f; } + for(sce= main->scene.first; sce; sce= sce->id.next) + if(sce->nodetree) + ntree_version_245(sce->nodetree); + + for(ntree=main->nodetree.first; ntree; ntree= ntree->id.next) + ntree_version_245(ntree); + if (main->versionfile < 245 || main->subversionfile < 12) { /* initialize skeleton generation toolsettings */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c b/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c index 8e8eb07c1cc..4972ff4ae5a 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c @@ -135,6 +135,11 @@ static void node_composit_exec_alphaover(void *data, bNode *node, bNodeStack **i } } +static void node_alphaover_init(bNode* node) +{ + node->storage= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); +} + bNodeType cmp_node_alphaover= { /* *next,*prev */ NULL, NULL, /* type code */ CMP_NODE_ALPHAOVER, @@ -146,7 +151,7 @@ bNodeType cmp_node_alphaover= { /* storage */ "NodeTwoFloats", /* execfunc */ node_composit_exec_alphaover, /* butfunc */ NULL, - /* initfunc */ NULL, + /* initfunc */ node_alphaover_init, /* freestoragefunc */ node_free_standard_storage, /* copystoragefunc */ node_copy_standard_storage, /* id */ NULL