diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/render/render_shading.c | 26 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_header.c | 27 |
2 files changed, 42 insertions, 11 deletions
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 35d679146fe..80c54d970b4 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -26,7 +26,6 @@ * \ingroup edrend */ - #include <stdlib.h> #include <string.h> @@ -76,6 +75,7 @@ #include "ED_curve.h" #include "ED_mesh.h" +#include "ED_node.h" #include "ED_render.h" #include "ED_screen.h" @@ -363,16 +363,24 @@ void OBJECT_OT_material_slot_copy(wmOperatorType *ot) static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene= CTX_data_scene(C); Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; PointerRNA ptr, idptr; PropertyRNA *prop; /* add or copy material */ - if(ma) + if(ma) { ma= copy_material(ma); - else + } + else { ma= add_material("Material"); + if(scene_use_new_shading_nodes(scene)) { + ED_node_shader_default(scene, &ma->id); + ma->use_nodes= 1; + } + } + /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); @@ -455,16 +463,24 @@ void TEXTURE_OT_new(wmOperatorType *ot) static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene= CTX_data_scene(C); World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data; PointerRNA ptr, idptr; PropertyRNA *prop; /* add or copy world */ - if(wo) + if(wo) { wo= copy_world(wo); - else + } + else { wo= add_world("World"); + if(scene_use_new_shading_nodes(scene)) { + ED_node_shader_default(scene, &wo->id); + wo->use_nodes= 1; + } + } + /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 68f5dd6bf14..42b5dafa3e1 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -46,9 +46,10 @@ #include "BKE_context.h" #include "BKE_global.h" -#include "BKE_screen.h" -#include "BKE_node.h" #include "BKE_main.h" +#include "BKE_node.h" +#include "BKE_scene.h" +#include "BKE_screen.h" #include "RNA_access.h" @@ -168,10 +169,11 @@ static int node_tree_has_type(int treetype, int nodetype) static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) { Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree; int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass); - int event; + int event, compatibility= 0; ntree = snode->nodetree; @@ -179,6 +181,13 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) uiItemS(layout); return; } + + if(ntree->type == NTREE_SHADER) { + if(scene_use_new_shading_nodes(scene)) + compatibility= NODE_NEW_SHADING; + else + compatibility= NODE_OLD_SHADING; + } if (nodeclass==NODE_CLASS_GROUP) { bNodeTree *ngroup; @@ -210,14 +219,16 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) uiLayoutSetFunc(layout, do_node_add_static, NULL); for (ntype=ntreeGetType(ntree->type)->node_types.first; ntype; ntype=ntype->next) { - if(ntype->nclass==nodeclass && ntype->name) - uiItemV(layout, ntype->name, 0, ntype->type); + if (ntype->nclass==nodeclass && ntype->name) + if (!compatibility || (ntype->compatibility & compatibility)) + uiItemV(layout, ntype->name, 0, ntype->type); } } } static void node_menu_add(const bContext *C, Menu *menu) { + Scene *scene= CTX_data_scene(C); SpaceNode *snode= CTX_wm_space_node(C); uiLayout *layout= menu->layout; @@ -227,11 +238,15 @@ static void node_menu_add(const bContext *C, Menu *menu) if(snode->treetype==NTREE_SHADER) { uiItemMenuF(layout, IFACE_("Input"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); uiItemMenuF(layout, IFACE_("Output"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + if(scene_use_new_shading_nodes(scene)) { + uiItemMenuF(layout, IFACE_("Shader"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_SHADER)); + uiItemMenuF(layout, IFACE_("Texture"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE)); + } uiItemMenuF(layout, IFACE_("Color"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); uiItemMenuF(layout, IFACE_("Vector"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); uiItemMenuF(layout, IFACE_("Convertor"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); uiItemMenuF(layout, IFACE_("Group"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); - uiItemMenuF(layout, IFACE_("Dynamic"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC)); + //uiItemMenuF(layout, IFACE_("Dynamic"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC)); uiItemMenuF(layout, IFACE_("Layout"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_LAYOUT)); } else if(snode->treetype==NTREE_COMPOSIT) { |