diff options
author | Aaron Carlisle <carlisle.b3d@gmail.com> | 2022-01-09 08:59:34 +0300 |
---|---|---|
committer | Aaron Carlisle <carlisle.b3d@gmail.com> | 2022-01-09 08:59:34 +0300 |
commit | e17ac8dc58c7108cfb3a784a595912c063e09cf4 (patch) | |
tree | 3a0a30fce007550c2743e423dd5f5017a0ca7753 /source/blender/nodes/shader/nodes/node_shader_normal_map.cc | |
parent | ed1ced24848824a4acbaaf7aa7ccb34441f6a8f4 (diff) |
Cleanup: Nodes: Begin splitting shader node buttons into individual files
Currently, most node buttons are defined in `drawnode.cc` however,
this is inconvenient because it requires editing many files when adding new nodes.
The goal is to minimize the number of files needed to add or update a node.
This commit moves most of the node layout functions for shader nodes into their respected
source/blender/nodes/shader/nodes file.
In the future, these functions will be simplified to node_layout.
Some nodes were left in `drawnode.cc` as this would require duplicating code
while this is likely fine it is best to leave that to a seperate commit.
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_normal_map.cc')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_normal_map.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc index cd99d0a64c9..338b4c62a3a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc @@ -19,6 +19,11 @@ #include "node_shader_util.hh" +#include "BKE_context.h" + +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_normal_map_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -28,6 +33,23 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output<decl::Vector>(N_("Normal")); } +static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiItemR(layout, ptr, "space", UI_ITEM_R_SPLIT_EMPTY_NAME, "", 0); + + if (RNA_enum_get(ptr, "space") == SHD_SPACE_TANGENT) { + PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); + + if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { + PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); + uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE); + } + else { + uiItemR(layout, ptr, "uv_map", UI_ITEM_R_SPLIT_EMPTY_NAME, "", 0); + } + } +} + static void node_shader_init_normal_map(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderNormalMap *attr = MEM_cnew<NodeShaderNormalMap>("NodeShaderNormalMap"); @@ -113,6 +135,7 @@ void register_node_type_sh_normal_map() sh_node_type_base(&ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_normal_map; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_normal_map); node_type_storage( |