Bugfix for recent alphaover premul commit, crashed existing files

and on adding a new node, maybe the commit was incomplete?
This commit is contained in:
Brecht Van Lommel 2008-02-04 21:17:15 +00:00
parent 234a5bd969
commit f11ea1eb8e
2 changed files with 34 additions and 1 deletions

@ -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 */

@ -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