[Bf-blender-cvs] [bf4358ed0c5] master: Cleanup: Use switch to get gpu shader name
Aaron Carlisle
noreply at git.blender.org
Thu Dec 30 23:39:32 CET 2021
Commit: bf4358ed0c545a14686af0d91ab78d784b988def
Author: Aaron Carlisle
Date: Thu Dec 30 17:39:23 2021 -0500
Branches: master
https://developer.blender.org/rBbf4358ed0c545a14686af0d91ab78d784b988def
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.
===================================================================
M source/blender/nodes/shader/nodes/node_shader_mapping.c
===================================================================
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;
More information about the Bf-blender-cvs
mailing list