diff options
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc (renamed from source/blender/nodes/shader/nodes/node_shader_vector_rotate.c) | 36 |
2 files changed, 26 insertions, 12 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 50e29d4a447..e21959d839c 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -259,7 +259,7 @@ set(SRC shader/nodes/node_shader_vectTransform.c shader/nodes/node_shader_vector_displacement.c shader/nodes/node_shader_vector_math.cc - shader/nodes/node_shader_vector_rotate.c + shader/nodes/node_shader_vector_rotate.cc shader/nodes/node_shader_vertex_color.c shader/nodes/node_shader_volume_absorption.c shader/nodes/node_shader_volume_info.c diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc index b2132c59cde..d6ead5a8b99 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc @@ -32,7 +32,28 @@ static bNodeSocketTemplate sh_node_vector_rotate_in[] = { {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_EULER}, {-1, ""}}; -static bNodeSocketTemplate sh_node_vector_rotate_out[] = {{SOCK_VECTOR, N_("Vector")}, {-1, ""}}; +static bNodeSocketTemplate sh_node_vector_rotate_out[] = { + {SOCK_VECTOR, N_("Vector")}, + {-1, ""}, +}; + +static const char *gpu_shader_get_name(int mode) +{ + switch (mode) { + case NODE_VECTOR_ROTATE_TYPE_AXIS: + return "node_vector_rotate_axis_angle"; + case NODE_VECTOR_ROTATE_TYPE_AXIS_X: + return "node_vector_rotate_axis_x"; + case NODE_VECTOR_ROTATE_TYPE_AXIS_Y: + return "node_vector_rotate_axis_y"; + case NODE_VECTOR_ROTATE_TYPE_AXIS_Z: + return "node_vector_rotate_axis_z"; + case NODE_VECTOR_ROTATE_TYPE_EULER_XYZ: + return "node_vector_rotate_euler_xyz"; + } + + return nullptr; +} static int gpu_shader_vector_rotate(GPUMaterial *mat, bNode *node, @@ -40,18 +61,11 @@ static int gpu_shader_vector_rotate(GPUMaterial *mat, GPUNodeStack *in, GPUNodeStack *out) { + const char *name = gpu_shader_get_name(node->custom1); - static const char *names[] = { - [NODE_VECTOR_ROTATE_TYPE_AXIS] = "node_vector_rotate_axis_angle", - [NODE_VECTOR_ROTATE_TYPE_AXIS_X] = "node_vector_rotate_axis_x", - [NODE_VECTOR_ROTATE_TYPE_AXIS_Y] = "node_vector_rotate_axis_y", - [NODE_VECTOR_ROTATE_TYPE_AXIS_Z] = "node_vector_rotate_axis_z", - [NODE_VECTOR_ROTATE_TYPE_EULER_XYZ] = "node_vector_rotate_euler_xyz", - }; - - if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { + if (name != nullptr) { float invert = (node->custom2) ? -1.0 : 1.0; - return GPU_stack_link(mat, node, names[node->custom1], in, out, GPU_constant(&invert)); + return GPU_stack_link(mat, node, name, in, out, GPU_constant(&invert)); } return 0; |