Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_edit.cc
| Show First 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | else { | ||||
| ma_default = BKE_material_default_surface(); | ma_default = BKE_material_default_surface(); | ||||
| } | } | ||||
| ma->nodetree = ntreeCopyTree(bmain, ma_default->nodetree); | ma->nodetree = ntreeCopyTree(bmain, ma_default->nodetree); | ||||
| BKE_ntree_update_main_tree(bmain, ma->nodetree, nullptr); | BKE_ntree_update_main_tree(bmain, ma->nodetree, nullptr); | ||||
| } | } | ||||
| else if (ELEM(GS(id->name), ID_WO, ID_LA)) { | else if (ELEM(GS(id->name), ID_WO, ID_LA)) { | ||||
| /* Emission */ | /* Emission */ | ||||
| bNodeTree *ntree = ntreeAddTree(nullptr, "Shader Nodetree", ntreeType_Shader->idname); | bNodeTree *ntree = ntreeAddTreeEmbedded( | ||||
| nullptr, id, "Shader Nodetree", ntreeType_Shader->idname); | |||||
| bNode *shader, *output; | bNode *shader, *output; | ||||
| if (GS(id->name) == ID_WO) { | if (GS(id->name) == ID_WO) { | ||||
| World *world = (World *)id; | World *world = (World *)id; | ||||
| world->nodetree = ntree; | |||||
| shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_BACKGROUND); | shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_BACKGROUND); | ||||
| output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_WORLD); | output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_WORLD); | ||||
| nodeAddLink(ntree, | nodeAddLink(ntree, | ||||
| shader, | shader, | ||||
| nodeFindSocket(shader, SOCK_OUT, "Background"), | nodeFindSocket(shader, SOCK_OUT, "Background"), | ||||
| output, | output, | ||||
| nodeFindSocket(output, SOCK_IN, "Surface")); | nodeFindSocket(output, SOCK_IN, "Surface")); | ||||
| bNodeSocket *color_sock = nodeFindSocket(shader, SOCK_IN, "Color"); | bNodeSocket *color_sock = nodeFindSocket(shader, SOCK_IN, "Color"); | ||||
| copy_v3_v3(((bNodeSocketValueRGBA *)color_sock->default_value)->value, &world->horr); | copy_v3_v3(((bNodeSocketValueRGBA *)color_sock->default_value)->value, &world->horr); | ||||
| } | } | ||||
| else { | else { | ||||
| Light *light = (Light *)id; | |||||
| light->nodetree = ntree; | |||||
| shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_EMISSION); | shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_EMISSION); | ||||
| output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_LIGHT); | output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_LIGHT); | ||||
| nodeAddLink(ntree, | nodeAddLink(ntree, | ||||
| shader, | shader, | ||||
| nodeFindSocket(shader, SOCK_OUT, "Emission"), | nodeFindSocket(shader, SOCK_OUT, "Emission"), | ||||
| output, | output, | ||||
| nodeFindSocket(output, SOCK_IN, "Surface")); | nodeFindSocket(output, SOCK_IN, "Surface")); | ||||
| } | } | ||||
| Show All 16 Lines | void ED_node_composit_default(const bContext *C, struct Scene *sce) | ||||
| /* but lets check it anyway */ | /* but lets check it anyway */ | ||||
| if (sce->nodetree) { | if (sce->nodetree) { | ||||
| if (G.debug & G_DEBUG) { | if (G.debug & G_DEBUG) { | ||||
| printf("error in composite initialize\n"); | printf("error in composite initialize\n"); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| sce->nodetree = ntreeAddTree(nullptr, "Compositing Nodetree", ntreeType_Composite->idname); | sce->nodetree = ntreeAddTreeEmbedded( | ||||
| nullptr, &sce->id, "Compositing Nodetree", ntreeType_Composite->idname); | |||||
| sce->nodetree->chunksize = 256; | sce->nodetree->chunksize = 256; | ||||
| sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; | sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; | ||||
| sce->nodetree->render_quality = NTREE_QUALITY_HIGH; | sce->nodetree->render_quality = NTREE_QUALITY_HIGH; | ||||
| bNode *out = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_COMPOSITE); | bNode *out = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_COMPOSITE); | ||||
| out->locx = 300.0f; | out->locx = 300.0f; | ||||
| out->locy = 400.0f; | out->locy = 400.0f; | ||||
| Show All 16 Lines | void ED_node_texture_default(const bContext *C, Tex *tex) | ||||
| /* but lets check it anyway */ | /* but lets check it anyway */ | ||||
| if (tex->nodetree) { | if (tex->nodetree) { | ||||
| if (G.debug & G_DEBUG) { | if (G.debug & G_DEBUG) { | ||||
| printf("error in texture initialize\n"); | printf("error in texture initialize\n"); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| tex->nodetree = ntreeAddTree(nullptr, "Texture Nodetree", ntreeType_Texture->idname); | tex->nodetree = ntreeAddTreeEmbedded( | ||||
| nullptr, &tex->id, "Texture Nodetree", ntreeType_Texture->idname); | |||||
| bNode *out = nodeAddStaticNode(C, tex->nodetree, TEX_NODE_OUTPUT); | bNode *out = nodeAddStaticNode(C, tex->nodetree, TEX_NODE_OUTPUT); | ||||
| out->locx = 300.0f; | out->locx = 300.0f; | ||||
| out->locy = 300.0f; | out->locy = 300.0f; | ||||
| bNode *in = nodeAddStaticNode(C, tex->nodetree, TEX_NODE_CHECKER); | bNode *in = nodeAddStaticNode(C, tex->nodetree, TEX_NODE_CHECKER); | ||||
| in->locx = 10.0f; | in->locx = 10.0f; | ||||
| in->locy = 300.0f; | in->locy = 300.0f; | ||||
| ▲ Show 20 Lines • Show All 2,496 Lines • Show Last 20 Lines | |||||