diff options
author | Aaron Carlisle <carlisle.b3d@gmail.com> | 2021-12-31 01:39:23 +0300 |
---|---|---|
committer | Aaron Carlisle <carlisle.b3d@gmail.com> | 2021-12-31 01:39:23 +0300 |
commit | bf4358ed0c545a14686af0d91ab78d784b988def (patch) | |
tree | e74698d9d2426d05132829b959567614781f7e8f /source/blender/nodes | |
parent | ee2b72fd29f7eddc4d18c7fd4dc02077a24d9961 (diff) |
Cleanup: Use switch to get gpu shader name
Rather than using the array syntax that doesnt work in C++,
use a switch state which is also much easier to read.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_mapping.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index cabfecdb6ee..7f192058307 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -37,21 +37,29 @@ static bNodeSocketTemplate sh_node_mapping_out[] = { {-1, ""}, }; +static const char *gpu_shader_get_name(int mode) +{ + switch (mode) { + case NODE_MAPPING_TYPE_POINT: + return "mapping_point"; + case NODE_MAPPING_TYPE_TEXTURE: + return "mapping_texture"; + case NODE_MAPPING_TYPE_VECTOR: + return "mapping_vector"; + case NODE_MAPPING_TYPE_NORMAL: + return "mapping_normal"; + } + return NULL; +} + static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) { - static const char *names[] = { - [NODE_MAPPING_TYPE_POINT] = "mapping_point", - [NODE_MAPPING_TYPE_TEXTURE] = "mapping_texture", - [NODE_MAPPING_TYPE_VECTOR] = "mapping_vector", - [NODE_MAPPING_TYPE_NORMAL] = "mapping_normal", - }; - - if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { - return GPU_stack_link(mat, node, names[node->custom1], in, out); + if (gpu_shader_get_name(node->custom1)) { + return GPU_stack_link(mat, node, gpu_shader_get_name(node->custom1), in, out); } return 0; |