Fix #35703, Viewer node doesn't updates image sometimes. The viewer node was not...
authorLukas Toenne <lukas.toenne@googlemail.com>
Wed, 12 Jun 2013 11:26:44 +0000 (11:26 +0000)
committerLukas Toenne <lukas.toenne@googlemail.com>
Wed, 12 Jun 2013 11:26:44 +0000 (11:26 +0000)
proposal was to add another special init hack for the viewer node->id, but rather would do it right and so moved all the special init hacks for constant ID backpointers (Scene for RenderLayer, Composite,
Defocus, FileOutput and MovieClip for MovieClip, MovieDistortion and Stabilization nodes). These are now part of the local init callbacks functions of the appropriate nodes, using the new initfunc_api
callback which takes a Context pointer, so they have access to Scene.

16 files changed:
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/node.c
source/blender/editors/space_node/node_add.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_scene.c
source/blender/nodes/NOD_composite.h
source/blender/nodes/composite/node_composite_tree.c
source/blender/nodes/composite/nodes/node_composite_composite.c
source/blender/nodes/composite/nodes/node_composite_defocus.c
source/blender/nodes/composite/nodes/node_composite_image.c
source/blender/nodes/composite/nodes/node_composite_movieclip.c
source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
source/blender/nodes/composite/nodes/node_composite_outputFile.c
source/blender/nodes/composite/nodes/node_composite_splitViewer.c
source/blender/nodes/composite/nodes/node_composite_stabilize2d.c
source/blender/nodes/composite/nodes/node_composite_viewer.c

index 55f68fcb8bdf2ccc3b15a44168aec406f235ddd7..ec0dd11392d09eb4de05ee91e1326493b4b28072 100644 (file)
@@ -925,7 +925,7 @@ void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int r
 void ntreeCompositTagRender(struct Scene *sce);
 int ntreeCompositTagAnimated(struct bNodeTree *ntree);
 void ntreeCompositTagGenerators(struct bNodeTree *ntree);
-void ntreeCompositForceHidden(struct bNodeTree *ntree, struct Scene *scene);
+void ntreeCompositForceHidden(struct bNodeTree *ntree);
 void ntreeCompositClearTags(struct bNodeTree *ntree);
 
 struct bNodeSocket *ntreeCompositOutputFileAddSocket(struct bNodeTree *ntree, struct bNode *node,
index f805005e911d1fe2e8e66baccd26f50c9d10a0ed..d40e0daf247e86d2ccd77c155cc21c476aed72e4 100644 (file)
@@ -150,6 +150,9 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
                ntype->initfunc_api(C, &ptr);
        }
        
+       if (node->id)
+               id_us_plus(node->id);
+       
        node->flag |= NODE_INIT;
 }
 
index 509339dd3d4a18db70f4ec14477d16454dafb949..d5224a37358f478acd951e17336d4fe0864d007a 100644 (file)
 
 /* XXX Does some additional initialization on top of nodeAddNode
  * Can be used with both custom and static nodes, if idname==NULL the static int type will be used instead.
- * Can be called from menus too, but they should do own undopush and redraws.
  */
 bNode *node_add_node(const bContext *C, const char *idname, int type, float locx, float locy)
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        Main *bmain = CTX_data_main(C);
-       Scene *scene = CTX_data_scene(C);
        bNode *node = NULL;
        
        node_deselect_all(snode);
@@ -96,20 +94,6 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
        ntreeUpdateTree(bmain, snode->edittree);
        ED_node_set_active(bmain, snode->edittree, node);
        
-       if (snode->nodetree->type == NTREE_COMPOSIT) {
-               if (ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) {
-                       node->id = &scene->id;
-               }
-               else if (ELEM3(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_MOVIEDISTORTION, CMP_NODE_STABILIZE2D)) {
-                       node->id = (ID *)scene->clip;
-               }
-               
-               ntreeCompositForceHidden(snode->edittree, scene);
-       }
-       
-       if (node->id)
-               id_us_plus(node->id);
-       
        if (snode->flag & SNODE_USE_HIDDEN_PREVIEW)
                node->flag &= ~NODE_PREVIEW;
        
index 4433dc456014fb6dc8b479f64cb59a267f32361f..04051cf3418df41e5ca8945b56b2a3232fac7fff 100644 (file)
@@ -724,23 +724,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r
        node = nodeAddNode(C, ntree, type);
        BLI_assert(node && node->typeinfo);
        
-       /* XXX ugly stuff, should be done with specialized operators (after actual node creation)! */
-       if (ntree->type == NTREE_COMPOSIT) {
-               if (ELEM4(node->type, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE, CMP_NODE_R_LAYERS)) {
-                       /* annoying, find the node tree we are in, scene can be NULL */
-                       Scene *scene;
-                       for (scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) {
-                               if (scene->nodetree == ntree) {
-                                       break;
-                               }
-                       }
-                       node->id = (ID *)scene;
-                       id_us_plus(node->id);
-               }
-               
-               ntreeCompositForceHidden(ntree, CTX_data_scene(C));
-       }
-       else if (ntree->type == NTREE_TEXTURE) {
+       if (ntree->type == NTREE_TEXTURE) {
                ntreeTexCheckCyclics(ntree);
        }
        
index 0218c188062d485fe0cb36afc979d2151b8f4024..44eee64208145d9de03d35ee10d8d6374719456a 100644 (file)
@@ -1195,7 +1195,7 @@ static void rna_SceneRenderLayer_pass_update(Main *bmain, Scene *activescene, Po
        Scene *scene = (Scene *)ptr->id.data;
 
        if (scene->nodetree)
-               ntreeCompositForceHidden(scene->nodetree, scene);
+               ntreeCompositForceHidden(scene->nodetree);
        
        rna_Scene_glsl_update(bmain, activescene, ptr);
 }
index 896714338e5f1058e0d9871cddb30080e830c41b..626e7955b08d648836e0c05db23440218eda790b 100644 (file)
@@ -138,4 +138,6 @@ void register_node_type_cmp_switch(void);
 void register_node_type_cmp_pixelate(void);
 void register_node_type_cmp_trackpos(void);
 
+void node_cmp_rlayers_force_hidden_passes(struct bNode *node);
+
 #endif
index a00ddf3d5e07e6bd7f52bd271488d0244d7f68e7..0b62481b2f741b6291d75606d4beb210af151e38 100644 (file)
@@ -74,7 +74,7 @@ static void composite_get_from_context(const bContext *C, bNodeTreeType *UNUSED(
        *r_ntree = scene->nodetree;
        
        /* update output sockets based on available layers */
-       ntreeCompositForceHidden(scene->nodetree, scene);
+       ntreeCompositForceHidden(scene->nodetree);
        
 }
 
@@ -262,69 +262,17 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int
 
 /* *********************************************** */
 
-static void set_output_visible(bNode *node, int passflag, int index, int pass)
-{
-       bNodeSocket *sock = BLI_findlink(&node->outputs, index);
-       /* clear the SOCK_HIDDEN flag as well, in case a socket was hidden before */
-       if (passflag & pass)
-               sock->flag &= ~(SOCK_HIDDEN | SOCK_UNAVAIL);
-       else
-               sock->flag |= SOCK_UNAVAIL;
-}
-
-/* clumsy checking... should do dynamic outputs once */
-static void force_hidden_passes(bNode *node, int passflag)
-{
-       bNodeSocket *sock;
-       
-       for (sock = node->outputs.first; sock; sock = sock->next)
-               sock->flag &= ~SOCK_UNAVAIL;
-       
-       set_output_visible(node, passflag, RRES_OUT_IMAGE,            SCE_PASS_COMBINED);
-       set_output_visible(node, passflag, RRES_OUT_ALPHA,            SCE_PASS_COMBINED);
-       
-       set_output_visible(node, passflag, RRES_OUT_Z,                SCE_PASS_Z);
-       set_output_visible(node, passflag, RRES_OUT_NORMAL,           SCE_PASS_NORMAL);
-       set_output_visible(node, passflag, RRES_OUT_VEC,              SCE_PASS_VECTOR);
-       set_output_visible(node, passflag, RRES_OUT_UV,               SCE_PASS_UV);
-       set_output_visible(node, passflag, RRES_OUT_RGBA,             SCE_PASS_RGBA);
-       set_output_visible(node, passflag, RRES_OUT_DIFF,             SCE_PASS_DIFFUSE);
-       set_output_visible(node, passflag, RRES_OUT_SPEC,             SCE_PASS_SPEC);
-       set_output_visible(node, passflag, RRES_OUT_SHADOW,           SCE_PASS_SHADOW);
-       set_output_visible(node, passflag, RRES_OUT_AO,               SCE_PASS_AO);
-       set_output_visible(node, passflag, RRES_OUT_REFLECT,          SCE_PASS_REFLECT);
-       set_output_visible(node, passflag, RRES_OUT_REFRACT,          SCE_PASS_REFRACT);
-       set_output_visible(node, passflag, RRES_OUT_INDIRECT,         SCE_PASS_INDIRECT);
-       set_output_visible(node, passflag, RRES_OUT_INDEXOB,          SCE_PASS_INDEXOB);
-       set_output_visible(node, passflag, RRES_OUT_INDEXMA,          SCE_PASS_INDEXMA);
-       set_output_visible(node, passflag, RRES_OUT_MIST,             SCE_PASS_MIST);
-       set_output_visible(node, passflag, RRES_OUT_EMIT,             SCE_PASS_EMIT);
-       set_output_visible(node, passflag, RRES_OUT_ENV,              SCE_PASS_ENVIRONMENT);
-       set_output_visible(node, passflag, RRES_OUT_DIFF_DIRECT,      SCE_PASS_DIFFUSE_DIRECT);
-       set_output_visible(node, passflag, RRES_OUT_DIFF_INDIRECT,    SCE_PASS_DIFFUSE_INDIRECT);
-       set_output_visible(node, passflag, RRES_OUT_DIFF_COLOR,       SCE_PASS_DIFFUSE_COLOR);
-       set_output_visible(node, passflag, RRES_OUT_GLOSSY_DIRECT,    SCE_PASS_GLOSSY_DIRECT);
-       set_output_visible(node, passflag, RRES_OUT_GLOSSY_INDIRECT,  SCE_PASS_GLOSSY_INDIRECT);
-       set_output_visible(node, passflag, RRES_OUT_GLOSSY_COLOR,     SCE_PASS_GLOSSY_COLOR);
-       set_output_visible(node, passflag, RRES_OUT_TRANSM_DIRECT,    SCE_PASS_TRANSM_DIRECT);
-       set_output_visible(node, passflag, RRES_OUT_TRANSM_INDIRECT,  SCE_PASS_TRANSM_INDIRECT);
-       set_output_visible(node, passflag, RRES_OUT_TRANSM_COLOR,     SCE_PASS_TRANSM_COLOR);
-}
-
 /* based on rules, force sockets hidden always */
-void ntreeCompositForceHidden(bNodeTree *ntree, Scene *curscene)
+void ntreeCompositForceHidden(bNodeTree *ntree)
 {
        bNode *node;
 
        if (ntree == NULL) return;
 
        for (node = ntree->nodes.first; node; node = node->next) {
-               if (node->type == CMP_NODE_R_LAYERS) {
-                       Scene *sce = node->id ? (Scene *)node->id : curscene;
-                       SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1);
-                       if (srl)
-                               force_hidden_passes(node, srl->passflag);
-               }
+               if (node->type == CMP_NODE_R_LAYERS)
+                       node_cmp_rlayers_force_hidden_passes(node);
+               
                /* XXX this stuff is called all the time, don't want that.
                 * Updates should only happen when actually necessary.
                 */
index be9ed4571500ec4e5f2fd8d6634817bd3912c770..c6c6a612bc455f969e5b1fc12553cd3299fed99b 100644 (file)
 
 #include "node_composite_util.h"
 
+#include "BKE_context.h"
+
+#include "RNA_access.h"
+
 /* **************** COMPOSITE ******************** */
 static bNodeSocketTemplate cmp_node_composite_in[] = {
        {       SOCK_RGBA, 1, N_("Image"),              0.0f, 0.0f, 0.0f, 1.0f},
@@ -39,12 +43,21 @@ static bNodeSocketTemplate cmp_node_composite_in[] = {
        {       -1, 0, ""       }
 };
 
+static void init(const bContext *C, PointerRNA *ptr)
+{
+       Scene *scene = CTX_data_scene(C);
+       bNode *node = ptr->data;
+       
+       node->id = &scene->id;
+}
+
 void register_node_type_cmp_composite(void)
 {
        static bNodeType ntype;
 
        cmp_node_type_base(&ntype, CMP_NODE_COMPOSITE, "Composite", NODE_CLASS_OUTPUT, NODE_PREVIEW);
        node_type_socket_templates(&ntype, cmp_node_composite_in, NULL);
+       ntype.initfunc_api = init;
 
        /* Do not allow muting for this node. */
        node_type_internal_links(&ntype, NULL);
index a33117557178adb5930646573858eb34ad81aa23..c057ba904ba90f1d10a1cfa2dd1d59e2122c6a35 100644 (file)
 
 #include <limits.h>
 
+#include "BKE_context.h"
+
+#include "RNA_access.h"
+
 /* ************ qdn: Defocus node ****************** */
 static bNodeSocketTemplate cmp_node_defocus_in[] = {
        {       SOCK_RGBA, 1, N_("Image"),                      1.0f, 1.0f, 1.0f, 1.0f},
@@ -44,8 +48,10 @@ static bNodeSocketTemplate cmp_node_defocus_out[] = {
        {       -1, 0, ""       }
 };
 
-static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_defocus(const bContext *C, PointerRNA *ptr)
 {
+       Scene *scene = CTX_data_scene(C);
+       bNode *node = ptr->data;
        /* qdn: defocus node */
        NodeDefocus *nbd = MEM_callocN(sizeof(NodeDefocus), "node defocus data");
        nbd->bktype = 0;
@@ -59,6 +65,8 @@ static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode *node)
        nbd->scale = 1.f;
        nbd->no_zbuf = 1;
        node->storage = nbd;
+       
+       node->id = &scene->id;
 }
 
 void register_node_type_cmp_defocus(void)
@@ -67,7 +75,7 @@ void register_node_type_cmp_defocus(void)
 
        cmp_node_type_base(&ntype, CMP_NODE_DEFOCUS, "Defocus", NODE_CLASS_OP_FILTER, 0);
        node_type_socket_templates(&ntype, cmp_node_defocus_in, cmp_node_defocus_out);
-       node_type_init(&ntype, node_composit_init_defocus);
+       ntype.initfunc_api = node_composit_init_defocus;
        node_type_storage(&ntype, "NodeDefocus", node_free_standard_storage, node_copy_standard_storage);
 
        nodeRegisterType(&ntype);
index b02bf6f438a43c86e021a13531994d4c2eccc31d..41f1f81e048cf055171a112259ea82de7517e70c 100644 (file)
 
 #include "node_composite_util.h"
 
+#include "BLI_utildefines.h"
+
+#include "DNA_scene_types.h"
+
+#include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
 
+#include "RNA_access.h"
+
 /* **************** IMAGE (and RenderResult, multilayer image) ******************** */
 
 static bNodeSocketTemplate cmp_node_rlayers_out[] = {
@@ -347,6 +354,77 @@ void register_node_type_cmp_image(void)
 
 /* **************** RENDER RESULT ******************** */
 
+static void set_output_visible(bNode *node, int passflag, int index, int pass)
+{
+       bNodeSocket *sock = BLI_findlink(&node->outputs, index);
+       /* clear the SOCK_HIDDEN flag as well, in case a socket was hidden before */
+       if (passflag & pass)
+               sock->flag &= ~(SOCK_HIDDEN | SOCK_UNAVAIL);
+       else
+               sock->flag |= SOCK_UNAVAIL;
+}
+
+/* clumsy checking... should do dynamic outputs once */
+void node_cmp_rlayers_force_hidden_passes(bNode *node)
+{
+       Scene *scene = (Scene *)node->id;
+       SceneRenderLayer *srl;
+       int passflag;
+       bNodeSocket *sock;
+       
+       /* must always have valid scene pointer */
+       BLI_assert(scene != NULL);
+       
+       srl = BLI_findlink(&scene->r.layers, node->custom1);
+       if (!srl)
+               return;
+       
+       passflag = srl->passflag;
+       
+       for (sock = node->outputs.first; sock; sock = sock->next)
+               sock->flag &= ~SOCK_UNAVAIL;
+       
+       set_output_visible(node, passflag, RRES_OUT_IMAGE,            SCE_PASS_COMBINED);
+       set_output_visible(node, passflag, RRES_OUT_ALPHA,            SCE_PASS_COMBINED);
+       
+       set_output_visible(node, passflag, RRES_OUT_Z,                SCE_PASS_Z);
+       set_output_visible(node, passflag, RRES_OUT_NORMAL,           SCE_PASS_NORMAL);
+       set_output_visible(node, passflag, RRES_OUT_VEC,              SCE_PASS_VECTOR);
+       set_output_visible(node, passflag, RRES_OUT_UV,               SCE_PASS_UV);
+       set_output_visible(node, passflag, RRES_OUT_RGBA,             SCE_PASS_RGBA);
+       set_output_visible(node, passflag, RRES_OUT_DIFF,             SCE_PASS_DIFFUSE);
+       set_output_visible(node, passflag, RRES_OUT_SPEC,             SCE_PASS_SPEC);
+       set_output_visible(node, passflag, RRES_OUT_SHADOW,           SCE_PASS_SHADOW);
+       set_output_visible(node, passflag, RRES_OUT_AO,               SCE_PASS_AO);
+       set_output_visible(node, passflag, RRES_OUT_REFLECT,          SCE_PASS_REFLECT);
+       set_output_visible(node, passflag, RRES_OUT_REFRACT,          SCE_PASS_REFRACT);
+       set_output_visible(node, passflag, RRES_OUT_INDIRECT,         SCE_PASS_INDIRECT);
+       set_output_visible(node, passflag, RRES_OUT_INDEXOB,          SCE_PASS_INDEXOB);
+       set_output_visible(node, passflag, RRES_OUT_INDEXMA,          SCE_PASS_INDEXMA);
+       set_output_visible(node, passflag, RRES_OUT_MIST,             SCE_PASS_MIST);
+       set_output_visible(node, passflag, RRES_OUT_EMIT,             SCE_PASS_EMIT);
+       set_output_visible(node, passflag, RRES_OUT_ENV,              SCE_PASS_ENVIRONMENT);
+       set_output_visible(node, passflag, RRES_OUT_DIFF_DIRECT,      SCE_PASS_DIFFUSE_DIRECT);
+       set_output_visible(node, passflag, RRES_OUT_DIFF_INDIRECT,    SCE_PASS_DIFFUSE_INDIRECT);
+       set_output_visible(node, passflag, RRES_OUT_DIFF_COLOR,       SCE_PASS_DIFFUSE_COLOR);
+       set_output_visible(node, passflag, RRES_OUT_GLOSSY_DIRECT,    SCE_PASS_GLOSSY_DIRECT);
+       set_output_visible(node, passflag, RRES_OUT_GLOSSY_INDIRECT,  SCE_PASS_GLOSSY_INDIRECT);
+       set_output_visible(node, passflag, RRES_OUT_GLOSSY_COLOR,     SCE_PASS_GLOSSY_COLOR);
+       set_output_visible(node, passflag, RRES_OUT_TRANSM_DIRECT,    SCE_PASS_TRANSM_DIRECT);
+       set_output_visible(node, passflag, RRES_OUT_TRANSM_INDIRECT,  SCE_PASS_TRANSM_INDIRECT);
+       set_output_visible(node, passflag, RRES_OUT_TRANSM_COLOR,     SCE_PASS_TRANSM_COLOR);
+}
+
+static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr)
+{
+       Scene *scene = CTX_data_scene(C);
+       bNode *node = ptr->data;
+       
+       node->id = &scene->id;
+       
+       node_cmp_rlayers_force_hidden_passes(node);
+}
+
 static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree)
 {
        if (strcmp(ntree->idname, "CompositorNodeTree") == 0) {
@@ -371,6 +449,7 @@ void register_node_type_cmp_rlayers(void)
 
        cmp_node_type_base(&ntype, CMP_NODE_R_LAYERS, "Render Layers", NODE_CLASS_INPUT, NODE_PREVIEW);
        node_type_socket_templates(&ntype, NULL, cmp_node_rlayers_out);
+       ntype.initfunc_api = node_composit_init_rlayers;
        ntype.poll = node_composit_poll_rlayers;
 
        nodeRegisterType(&ntype);
index b42b8d36c0c6210b91fbae5b09a5624b52f9377b..fc0d8060644483e7fe29e36bb45d60a406b9c745 100644 (file)
 
 #include "node_composite_util.h"
 
+#include "BKE_context.h"
+
+#include "RNA_access.h"
+
 static bNodeSocketTemplate cmp_node_movieclip_out[] = {
        {       SOCK_RGBA,              0,      N_("Image")},
        {       SOCK_FLOAT,             0,      N_("Alpha")},
@@ -43,10 +47,13 @@ static bNodeSocketTemplate cmp_node_movieclip_out[] = {
        {       -1, 0, ""       }
 };
 
-static void init(bNodeTree *UNUSED(ntree), bNode *node)
+static void init(const bContext *C, PointerRNA *ptr)
 {
+       bNode *node = ptr->data;
+       Scene *scene = CTX_data_scene(C);
        MovieClipUser *user = MEM_callocN(sizeof(MovieClipUser), "node movie clip user");
 
+       node->id = (ID *)scene->clip;
        node->storage = user;
        user->framenr = 1;
 }
@@ -57,7 +64,7 @@ void register_node_type_cmp_movieclip(void)
 
        cmp_node_type_base(&ntype, CMP_NODE_MOVIECLIP, "Movie Clip", NODE_CLASS_INPUT, NODE_PREVIEW);
        node_type_socket_templates(&ntype, NULL, cmp_node_movieclip_out);
-       node_type_init(&ntype, init);
+       ntype.initfunc_api = init;
        node_type_storage(&ntype, "MovieClipUser", node_free_standard_storage, node_copy_standard_storage);
 
        nodeRegisterType(&ntype);
index 103a05f900ee3c480575f7999fb924d30ee8b891..b110cffd080dd7e5a45a6d8a3bad43bd2e028038 100644 (file)
 
 #include "node_composite_util.h"
 
+#include "BKE_context.h"
+
+#include "RNA_access.h"
+
 /* **************** Translate  ******************** */
 
 static bNodeSocketTemplate cmp_node_moviedistortion_in[] = {
@@ -52,6 +56,14 @@ static const char *label(bNode *node)
                return IFACE_("Distortion");
 }
 
+static void init(const bContext *C, PointerRNA *ptr)
+{
+       bNode *node = ptr->data;
+       Scene *scene = CTX_data_scene(C);
+       
+       node->id = (ID *)scene->clip;
+}
+
 static void storage_free(bNode *node)
 {
        if (node->storage)
@@ -74,6 +86,7 @@ void register_node_type_cmp_moviedistortion(void)
        node_type_socket_templates(&ntype, cmp_node_moviedistortion_in, cmp_node_moviedistortion_out);
        node_type_label(&ntype, label);
 
+       ntype.initfunc_api = init;
        node_type_storage(&ntype, NULL, storage_free, storage_copy);
 
        nodeRegisterType(&ntype);
index a6c59c1bc9176aef6e97667a3e0c12fc65e4ebc0..90b21f1bab0aea3c4d663831a0c7bf26682075e0 100644 (file)
@@ -179,6 +179,8 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
        ImageFormatData *format = NULL;
        node->storage = nimf;
        
+       node->id = &scene->id;
+       
        if (scene) {
                RenderData *rd = &scene->r;
 
index 6d1cd56fa4acee3f577dbffe02424d7ac9db907d..c3eb44281f53b7115bbb178274ae371fa7bf45ed 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "node_composite_util.h"
 
+#include "BKE_image.h"
+
 /* **************** SPLIT VIEWER ******************** */
 static bNodeSocketTemplate cmp_node_splitviewer_in[] = {
        {       SOCK_RGBA, 1, N_("Image"),              0.0f, 0.0f, 0.0f, 1.0f},
@@ -47,6 +49,8 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node
        iuser->fie_ima = 2;
        iuser->ok = 1;
        node->custom1 = 50;  /* default 50% split */
+       
+       node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
 }
 
 void register_node_type_cmp_splitviewer(void)
index 2daf240ab18b095679d46576bde88ad877e91033..28e2a2a205b77d58643b4ef6c846b73a063ac928 100644 (file)
 
 #include "node_composite_util.h"
 
+#include "BKE_context.h"
+
+#include "RNA_access.h"
+
 /* **************** Translate  ******************** */
 
 static bNodeSocketTemplate cmp_node_stabilize2d_in[] = {
@@ -45,8 +49,13 @@ static bNodeSocketTemplate cmp_node_stabilize2d_out[] = {
        {       -1, 0, ""       }
 };
 
-static void init(bNodeTree *UNUSED(ntree), bNode *node)
+static void init(const bContext *C, PointerRNA *ptr)
 {
+       bNode *node = ptr->data;
+       Scene *scene = CTX_data_scene(C);
+       
+       node->id = (ID *)scene->clip;
+       
        /* default to bilinear, see node_sampler_type_items in rna_nodetree.c */
        node->custom1 = 1;
 }
@@ -57,7 +66,7 @@ void register_node_type_cmp_stabilize2d(void)
 
        cmp_node_type_base(&ntype, CMP_NODE_STABILIZE2D, "Stabilize 2D", NODE_CLASS_DISTORT, 0);
        node_type_socket_templates(&ntype, cmp_node_stabilize2d_in, cmp_node_stabilize2d_out);
-       node_type_init(&ntype, init);
+       ntype.initfunc_api = init;
 
        nodeRegisterType(&ntype);
 }
index 54d3f372c5054b1a6010af212c2768221a106c6f..4b96270d36cef51b5969542ae8725e7003e12d65 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "node_composite_util.h"
 
+#include "BKE_image.h"
+
 
 /* **************** VIEWER ******************** */
 static bNodeSocketTemplate cmp_node_viewer_in[] = {
@@ -50,6 +52,8 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
        iuser->ok = 1;
        node->custom3 = 0.5f;
        node->custom4 = 0.5f;
+       
+       node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
 }
 
 void register_node_type_cmp_viewer(void)