diff options
Diffstat (limited to 'source/blender')
21 files changed, 65 insertions, 67 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 3a111724d18..d219c1c6e8d 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -931,7 +931,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria /* API */ struct CompBuf; -void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews, +void ntreeCompositExecTree(struct Scene *scene, struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings); void ntreeCompositTagRender(struct Scene *sce); int ntreeCompositTagAnimated(struct bNodeTree *ntree); @@ -999,6 +999,4 @@ int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, void init_nodesystem(void); void free_nodesystem(void); -void clear_scene_in_nodes(struct Main *bmain, struct Scene *sce); - #endif diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f058bbc5f78..bc616934fef 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3658,31 +3658,6 @@ void free_nodesystem(void) } } -/* called from BKE_scene_unlink, when deleting a scene goes over all scenes - * other than the input, checks if they have render layer nodes referencing - * the to-be-deleted scene, and resets them to NULL. */ - -/* XXX needs to get current scene then! */ -void clear_scene_in_nodes(Main *bmain, Scene *sce) -{ - Scene *sce1; - bNode *node; - - for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next) { - if (sce1 != sce) { - if (sce1->nodetree) { - for (node = sce1->nodetree->nodes.first; node; node = node->next) { - if (node->type == CMP_NODE_R_LAYERS) { - Scene *nodesce = (Scene *)node->id; - - if (nodesce == sce) node->id = NULL; - } - } - } - } - } -} - /* -------------------------------------------------------------------- */ /* NodeTree Iterator Helpers (FOREACH_NODETREE) */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 936f76765c2..120a791d679 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -727,8 +727,17 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce) if (sce1->set == sce) sce1->set = NULL; - /* check render layer nodes in other scenes */ - clear_scene_in_nodes(bmain, sce); + for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next) { + bNode *node; + + if (sce1 == sce || !sce1->nodetree) + continue; + + for (node = sce1->nodetree->nodes.first; node; node = node->next) { + if (node->id == &sce->id) + node->id = NULL; + } + } /* al screens */ for (sc = bmain->screen.first; sc; sc = sc->id.next) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 883e03b6a3d..738b682188a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5061,7 +5061,7 @@ static void composite_patch(bNodeTree *ntree, Scene *scene) bNode *node; for (node = ntree->nodes.first; node; node = node->next) { - if (node->id==NULL && ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) + if (node->id==NULL && node->type == CMP_NODE_R_LAYERS) node->id = &scene->id; } } diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 218313ebb44..791ddb36ba2 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -2686,4 +2686,18 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + { + /* nodes don't use fixed node->id any more, clean up */ + FOREACH_NODETREE(main, ntree, id) { + if (ntree->type == NTREE_COMPOSIT) { + bNode *node; + for (node = ntree->nodes.first; node; node = node->next) { + if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) { + node->id = NULL; + } + } + } + } FOREACH_NODETREE_END + } } diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index 1936909b004..b79c26aa236 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -315,7 +315,7 @@ extern "C" { * should be checked further, probably it'll be also needed for preview * generation in display space */ -void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering, +void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rendering, const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings); /** diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index 6008a889205..807d78b620d 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -26,6 +26,7 @@ CompositorContext::CompositorContext() { + this->m_scene = NULL; this->m_rd = NULL; this->m_quality = COM_QUALITY_HIGH; this->m_hasActiveOpenCLDevices = false; diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 2120c12b04e..223f900b391 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -51,6 +51,8 @@ private: */ CompositorQuality m_quality; + Scene *m_scene; + /** * @brief Reference to the render data that is being composited. * This field is initialized in ExecutionSystem and must only be read from that point on. @@ -120,6 +122,9 @@ public: * @brief get the scene of the context */ const RenderData *getRenderData() const { return this->m_rd; } + + void setScene(Scene *scene) { m_scene = scene; } + Scene *getScene() const { return m_scene; } /** * @brief set the preview image hash table diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 716e99a0fa3..6a208001f46 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -46,9 +46,10 @@ extern "C" { #include "MEM_guardedalloc.h" #endif -ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation, +ExecutionSystem::ExecutionSystem(RenderData *rd, Scene *scene, bNodeTree *editingtree, bool rendering, bool fastcalculation, const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) { + this->m_context.setScene(scene); this->m_context.setbNodeTree(editingtree); this->m_context.setPreviewHash(editingtree->previews); this->m_context.setFastCalculation(fastcalculation); diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 9beccba0c73..7402ff90fb5 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -167,7 +167,7 @@ public: * @param editingtree [bNodeTree *] * @param rendering [true false] */ - ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation, + ExecutionSystem(RenderData *rd, Scene *scene, bNodeTree *editingtree, bool rendering, bool fastcalculation, const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings); /** diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 59714282d93..1c1dcf1c37d 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -43,7 +43,7 @@ static void intern_freeCompositorCaches() deintializeDistortionCache(); } -void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering, +void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rendering, const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) { @@ -81,7 +81,7 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering, bool twopass = (editingtree->flag & NTREE_TWO_PASS) > 0 && !rendering; /* initialize execution system */ if (twopass) { - ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass, viewSettings, displaySettings); + ExecutionSystem *system = new ExecutionSystem(rd, scene, editingtree, rendering, twopass, viewSettings, displaySettings); system->execute(); delete system; @@ -93,7 +93,7 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering, } } - ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false, + ExecutionSystem *system = new ExecutionSystem(rd, scene, editingtree, rendering, false, viewSettings, displaySettings); system->execute(); delete system; diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index f555e53f156..7e192af0cd9 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -40,7 +40,7 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte InputSocket *depthSocket = this->getInputSocket(2); CompositorOperation *compositorOperation = new CompositorOperation(); - compositorOperation->setSceneName(editorNode->id->name); + compositorOperation->setSceneName(context->getScene()->id.name); compositorOperation->setRenderData(context->getRenderData()); compositorOperation->setbNodeTree(context->getbNodeTree()); compositorOperation->setIgnoreAlpha(editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA); diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index c2bd8997525..c2d25bbccd8 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -42,9 +42,9 @@ DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode) void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { bNode *node = this->getbNode(); - Scene *scene = (Scene *)node->id; - Object *camob = (scene) ? scene->camera : NULL; NodeDefocus *data = (NodeDefocus *)node->storage; + Scene *scene = node->id ? (Scene *)node->id : context->getScene(); + Object *camob = scene ? scene->camera : NULL; NodeOperation *radiusOperation; if (data->no_zbuf) { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 558fc160cf9..582e6861974 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1242,7 +1242,7 @@ static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED( uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE); } -static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiLayout *sub, *col; @@ -1262,7 +1262,9 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), Po col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE); - + + uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE); sub = uiLayoutColumn(col, FALSE); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 7a12ed9ef08..9f76a9f1eb5 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -259,7 +259,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog // XXX BIF_store_spare(); /* 1 is do_previews */ - ntreeCompositExecTree(ntree, &cj->scene->r, FALSE, TRUE, &scene->view_settings, &scene->display_settings); + ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, FALSE, TRUE, &scene->view_settings, &scene->display_settings); ntree->test_break = NULL; ntree->stats_draw = NULL; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index b6a031f527f..08bb87fb18f 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4841,7 +4841,7 @@ static void def_cmp_map_uv(StructRNA *srna) static void def_cmp_defocus(StructRNA *srna) { PropertyRNA *prop; - + static EnumPropertyItem bokeh_items[] = { {8, "OCTAGON", 0, "Octagonal", "8 sides"}, {7, "HEPTAGON", 0, "Heptagonal", "7 sides"}, @@ -4852,9 +4852,17 @@ static void def_cmp_defocus(StructRNA *srna) {0, "CIRCLE", 0, "Circular", ""}, {0, NULL, 0, NULL, NULL} }; - + + prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL); + RNA_def_property_struct_type(prop, "Scene"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Scene", "Scene from which to select the active camera (render scene if undefined)"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_struct_sdna_from(srna, "NodeDefocus", "storage"); - + prop = RNA_def_property(srna, "bokeh", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "bktype"); RNA_def_property_enum_items(prop, bokeh_items); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 31aefe4f027..c2ba6d32cb2 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -257,12 +257,12 @@ void register_node_tree_type_cmp(void) void *COM_linker_hack = NULL; -void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview, +void ntreeCompositExecTree(Scene *scene, bNodeTree *ntree, RenderData *rd, int rendering, int do_preview, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings) { #ifdef WITH_COMPOSITOR - COM_execute(rd, ntree, rendering, view_settings, display_settings); + COM_execute(rd, scene, ntree, rendering, view_settings, display_settings); #else (void)ntree, (void)rd, (void)rendering, (void)do_preview; (void)view_settings, (void)display_settings; diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index c6c6a612bc4..41d417c2cb4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -43,21 +43,12 @@ 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); diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index c057ba904ba..ef670b760c2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -48,10 +48,8 @@ static bNodeSocketTemplate cmp_node_defocus_out[] = { { -1, 0, "" } }; -static void node_composit_init_defocus(const bContext *C, PointerRNA *ptr) +static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode *node) { - 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; @@ -65,8 +63,6 @@ static void node_composit_init_defocus(const bContext *C, PointerRNA *ptr) nbd->scale = 1.f; nbd->no_zbuf = 1; node->storage = nbd; - - node->id = &scene->id; } void register_node_type_cmp_defocus(void) @@ -75,7 +71,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); - ntype.initfunc_api = node_composit_init_defocus; + node_type_init(&ntype, node_composit_init_defocus); node_type_storage(&ntype, "NodeDefocus", node_free_standard_storage, node_copy_standard_storage); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index 89c6fbe4590..952ec15f2aa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -179,8 +179,6 @@ 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; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index c0ef820b6d8..1501c04a650 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1940,7 +1940,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) ntreeCompositTagRender(re->scene); ntreeCompositTagAnimated(ntree); - ntreeCompositExecTree(ntree, &re->r, TRUE, G.background == 0, &re->scene->view_settings, &re->scene->display_settings); + ntreeCompositExecTree(re->scene, ntree, &re->r, TRUE, G.background == 0, &re->scene->view_settings, &re->scene->display_settings); } /* ensure we get either composited result or the active layer */ @@ -2136,7 +2136,7 @@ static void do_render_composite_fields_blur_3d(Render *re) if (re->r.scemode & R_FULL_SAMPLE) do_merge_fullsample(re, ntree); else { - ntreeCompositExecTree(ntree, &re->r, TRUE, G.background == 0, &re->scene->view_settings, &re->scene->display_settings); + ntreeCompositExecTree(re->scene, ntree, &re->r, TRUE, G.background == 0, &re->scene->view_settings, &re->scene->display_settings); } ntree->stats_draw = NULL; |