Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/node_shader_tree.c
| Show All 33 Lines | |||||
| #include "DNA_lamp_types.h" | #include "DNA_lamp_types.h" | ||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "DNA_linestyle_types.h" | #include "DNA_linestyle_types.h" | ||||
| #include "DNA_workspace_types.h" | |||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| Show All 12 Lines | |||||
| #include "node_common.h" | #include "node_common.h" | ||||
| #include "node_exec.h" | #include "node_exec.h" | ||||
| #include "node_util.h" | #include "node_util.h" | ||||
| #include "node_shader_util.h" | #include "node_shader_util.h" | ||||
| static int shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype)) | static int shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| ViewRender *view_render = BKE_viewrender_get(scene, workspace); | |||||
| const char *engine_id = view_render->engine_id; | |||||
| /* allow empty engine string too, this is from older versions that didn't have registerable engines yet */ | /* allow empty engine string too, this is from older versions that didn't have registerable engines yet */ | ||||
| return (scene->r.engine[0] == '\0' || | return (engine_id[0] == '\0' || | ||||
| STREQ(scene->r.engine, RE_engine_id_BLENDER_RENDER) || | STREQ(engine_id, RE_engine_id_BLENDER_RENDER) || | ||||
| STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME) || | STREQ(engine_id, RE_engine_id_BLENDER_GAME) || | ||||
| STREQ(scene->r.engine, RE_engine_id_CYCLES) || | STREQ(engine_id, RE_engine_id_CYCLES) || | ||||
| !BKE_scene_use_shading_nodes_custom(scene)); | !BKE_viewrender_use_shading_nodes_custom(view_render)); | ||||
| } | } | ||||
| static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from) | static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from) | ||||
| { | { | ||||
| SpaceNode *snode = CTX_wm_space_node(C); | SpaceNode *snode = CTX_wm_space_node(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| SceneLayer *sl = CTX_data_scene_layer(C); | SceneLayer *sl = CTX_data_scene_layer(C); | ||||
| Object *ob = OBACT_NEW(sl); | Object *ob = OBACT_NEW(sl); | ||||
| ViewRender *view_render = BKE_viewrender_get(scene, workspace); | |||||
| if ((snode->shaderfrom == SNODE_SHADER_OBJECT) || | if ((snode->shaderfrom == SNODE_SHADER_OBJECT) || | ||||
| (BKE_scene_use_new_shading_nodes(scene) == false)) | (BKE_viewrender_use_new_shading_nodes(view_render) == false)) | ||||
| { | { | ||||
| if (ob) { | if (ob) { | ||||
| *r_from = &ob->id; | *r_from = &ob->id; | ||||
| if (ob->type == OB_LAMP) { | if (ob->type == OB_LAMP) { | ||||
| *r_id = ob->data; | *r_id = ob->data; | ||||
| *r_ntree = ((Lamp *)ob->data)->nodetree; | *r_ntree = ((Lamp *)ob->data)->nodetree; | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 19 Lines | else { /* SNODE_SHADER_WORLD */ | ||||
| if (scene->world) { | if (scene->world) { | ||||
| *r_from = NULL; | *r_from = NULL; | ||||
| *r_id = &scene->world->id; | *r_id = &scene->world->id; | ||||
| *r_ntree = scene->world->nodetree; | *r_ntree = scene->world->nodetree; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback func) | static void foreach_nodeclass(ViewRender *view_render, void *calldata, bNodeClassCallback func) | ||||
| { | { | ||||
| func(calldata, NODE_CLASS_INPUT, N_("Input")); | func(calldata, NODE_CLASS_INPUT, N_("Input")); | ||||
| func(calldata, NODE_CLASS_OUTPUT, N_("Output")); | func(calldata, NODE_CLASS_OUTPUT, N_("Output")); | ||||
| if (BKE_scene_use_new_shading_nodes(scene)) { | if (BKE_viewrender_use_new_shading_nodes(view_render)) { | ||||
| func(calldata, NODE_CLASS_SHADER, N_("Shader")); | func(calldata, NODE_CLASS_SHADER, N_("Shader")); | ||||
| func(calldata, NODE_CLASS_TEXTURE, N_("Texture")); | func(calldata, NODE_CLASS_TEXTURE, N_("Texture")); | ||||
| } | } | ||||
| func(calldata, NODE_CLASS_OP_COLOR, N_("Color")); | func(calldata, NODE_CLASS_OP_COLOR, N_("Color")); | ||||
| func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector")); | func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector")); | ||||
| func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor")); | func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor")); | ||||
| func(calldata, NODE_CLASS_SCRIPT, N_("Script")); | func(calldata, NODE_CLASS_SCRIPT, N_("Script")); | ||||
| ▲ Show 20 Lines • Show All 537 Lines • Show Last 20 Lines | |||||