Cleanup: Nodes: Use common prefix instead of sh_fn

Nodes that are shared between Geometry and Shader nodes use the prefix
sh_fn for their base type and poll functions. The compositor will also
share those nodes very soon, so we generalize the name to use the prefix
"common".
This commit is contained in:
Omar Emara
2025-02-27 14:51:24 +02:00
parent 2833c0f283
commit fdeda50b5c
24 changed files with 36 additions and 36 deletions

View File

@@ -38,9 +38,9 @@ bool sh_node_poll_default(const blender::bke::bNodeType * /*ntype*/,
return true;
}
static bool sh_fn_poll_default(const blender::bke::bNodeType * /*ntype*/,
const bNodeTree *ntree,
const char **r_disabled_hint)
static bool common_poll_default(const blender::bke::bNodeType * /*ntype*/,
const bNodeTree *ntree,
const char **r_disabled_hint)
{
if (!STR_ELEM(ntree->idname, "ShaderNodeTree", "GeometryNodeTree")) {
*r_disabled_hint = RPT_("Not a shader or geometry node tree");
@@ -60,12 +60,12 @@ void sh_node_type_base(blender::bke::bNodeType *ntype,
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
}
void sh_fn_node_type_base(blender::bke::bNodeType *ntype,
std::string idname,
const std::optional<int16_t> legacy_type)
void common_node_type_base(blender::bke::bNodeType *ntype,
std::string idname,
const std::optional<int16_t> legacy_type)
{
sh_node_type_base(ntype, idname, legacy_type);
ntype->poll = sh_fn_poll_default;
ntype->poll = common_poll_default;
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
}

View File

@@ -45,9 +45,9 @@ bool sh_node_poll_default(const blender::bke::bNodeType *ntype,
void sh_node_type_base(blender::bke::bNodeType *ntype,
std::string idname,
std::optional<int16_t> legacy_type = std::nullopt);
void sh_fn_node_type_base(blender::bke::bNodeType *ntype,
std::string idname,
std::optional<int16_t> legacy_type = std::nullopt);
void common_node_type_base(blender::bke::bNodeType *ntype,
std::string idname,
std::optional<int16_t> legacy_type = std::nullopt);
bool line_style_shader_nodes_poll(const bContext *C);
bool world_shader_nodes_poll(const bContext *C);
bool object_shader_nodes_poll(const bContext *C);

View File

@@ -70,7 +70,7 @@ void register_node_type_sh_blackbody()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeBlackbody", SH_NODE_BLACKBODY);
common_node_type_base(&ntype, "ShaderNodeBlackbody", SH_NODE_BLACKBODY);
ntype.ui_name = "Blackbody";
ntype.ui_description = "Convert a blackbody temperature to an RGB value";
ntype.enum_name_legacy = "BLACKBODY";

View File

@@ -99,7 +99,7 @@ void register_node_type_sh_clamp()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeClamp", SH_NODE_CLAMP);
common_node_type_base(&ntype, "ShaderNodeClamp", SH_NODE_CLAMP);
ntype.ui_name = "Clamp";
ntype.ui_description = "Clamp a value between a minimum and a maximum";
ntype.enum_name_legacy = "CLAMP";

View File

@@ -162,7 +162,7 @@ void register_node_type_sh_valtorgb()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeValToRGB", SH_NODE_VALTORGB);
common_node_type_base(&ntype, "ShaderNodeValToRGB", SH_NODE_VALTORGB);
ntype.ui_name = "Color Ramp";
ntype.ui_description = "Map values to colors with the use of a gradient";
ntype.enum_name_legacy = "VALTORGB";

View File

@@ -132,7 +132,7 @@ void register_node_type_sh_curve_vec()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeVectorCurve", SH_NODE_CURVE_VEC);
common_node_type_base(&ntype, "ShaderNodeVectorCurve", SH_NODE_CURVE_VEC);
ntype.ui_name = "Vector Curves";
ntype.ui_description = "Map input vector components with curves";
ntype.enum_name_legacy = "CURVE_VEC";
@@ -296,7 +296,7 @@ void register_node_type_sh_curve_rgb()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeRGBCurve", SH_NODE_CURVE_RGB);
common_node_type_base(&ntype, "ShaderNodeRGBCurve", SH_NODE_CURVE_RGB);
ntype.ui_name = "RGB Curves";
ntype.ui_description = "Apply color corrections for each color channel";
ntype.enum_name_legacy = "CURVE_RGB";
@@ -428,7 +428,7 @@ void register_node_type_sh_curve_float()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeFloatCurve", SH_NODE_CURVE_FLOAT);
common_node_type_base(&ntype, "ShaderNodeFloatCurve", SH_NODE_CURVE_FLOAT);
ntype.ui_name = "Float Curve";
ntype.ui_description = "Map an input float to a curve and outputs a float value";
ntype.enum_name_legacy = "CURVE_FLOAT";

View File

@@ -524,7 +524,7 @@ void register_node_type_sh_map_range()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeMapRange", SH_NODE_MAP_RANGE);
common_node_type_base(&ntype, "ShaderNodeMapRange", SH_NODE_MAP_RANGE);
ntype.ui_name = "Map Range";
ntype.ui_description = "Remap a value from a range to a target range";
ntype.enum_name_legacy = "MAP_RANGE";

View File

@@ -361,7 +361,7 @@ void register_node_type_sh_math()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeMath", SH_NODE_MATH);
common_node_type_base(&ntype, "ShaderNodeMath", SH_NODE_MATH);
ntype.ui_name = "Math";
ntype.ui_description = "Perform math operations";
ntype.enum_name_legacy = "MATH";

View File

@@ -599,7 +599,7 @@ void register_node_type_sh_mix()
namespace file_ns = blender::nodes::node_sh_mix_cc;
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeMix", SH_NODE_MIX);
common_node_type_base(&ntype, "ShaderNodeMix", SH_NODE_MIX);
ntype.ui_name = "Mix";
ntype.ui_description = "Mix values by a factor";
ntype.enum_name_legacy = "MIX";

View File

@@ -158,7 +158,7 @@ void register_node_type_sh_mix_rgb()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeMixRGB", SH_NODE_MIX_RGB_LEGACY);
common_node_type_base(&ntype, "ShaderNodeMixRGB", SH_NODE_MIX_RGB_LEGACY);
ntype.ui_name = "Mix (Legacy)";
ntype.ui_description = "Mix two input colors";
ntype.enum_name_legacy = "MIX_RGB";

View File

@@ -79,7 +79,7 @@ void register_node_type_sh_seprgb()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeSeparateRGB", SH_NODE_SEPRGB_LEGACY);
common_node_type_base(&ntype, "ShaderNodeSeparateRGB", SH_NODE_SEPRGB_LEGACY);
ntype.ui_name = "Separate RGB (Legacy)";
ntype.ui_description = "Deprecated";
ntype.enum_name_legacy = "SEPRGB";
@@ -127,7 +127,7 @@ void register_node_type_sh_combrgb()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeCombineRGB", SH_NODE_COMBRGB_LEGACY);
common_node_type_base(&ntype, "ShaderNodeCombineRGB", SH_NODE_COMBRGB_LEGACY);
ntype.ui_name = "Combine RGB (Legacy)";
ntype.ui_description = "Deprecated";
ntype.enum_name_legacy = "COMBRGB";

View File

@@ -137,7 +137,7 @@ void register_node_type_sh_sepxyz()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeSeparateXYZ", SH_NODE_SEPXYZ);
common_node_type_base(&ntype, "ShaderNodeSeparateXYZ", SH_NODE_SEPXYZ);
ntype.ui_name = "Separate XYZ";
ntype.ui_description = "Split a vector into its X, Y, and Z components";
ntype.enum_name_legacy = "SEPXYZ";
@@ -229,7 +229,7 @@ void register_node_type_sh_combxyz()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeCombineXYZ", SH_NODE_COMBXYZ);
common_node_type_base(&ntype, "ShaderNodeCombineXYZ", SH_NODE_COMBXYZ);
ntype.ui_name = "Combine XYZ";
ntype.ui_description = "Create a vector from X, Y, and Z components";
ntype.enum_name_legacy = "COMBXYZ";

View File

@@ -301,7 +301,7 @@ void register_node_type_sh_tex_brick()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexBrick", SH_NODE_TEX_BRICK);
common_node_type_base(&ntype, "ShaderNodeTexBrick", SH_NODE_TEX_BRICK);
ntype.ui_name = "Brick Texture";
ntype.ui_description = "Generate a procedural texture producing bricks";
ntype.enum_name_legacy = "TEX_BRICK";

View File

@@ -139,7 +139,7 @@ void register_node_type_sh_tex_checker()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexChecker", SH_NODE_TEX_CHECKER);
common_node_type_base(&ntype, "ShaderNodeTexChecker", SH_NODE_TEX_CHECKER);
ntype.ui_name = "Checker Texture";
ntype.ui_description = "Generate a checkerboard texture";
ntype.enum_name_legacy = "TEX_CHECKER";

View File

@@ -207,7 +207,7 @@ void register_node_type_sh_tex_gabor()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexGabor", SH_NODE_TEX_GABOR);
common_node_type_base(&ntype, "ShaderNodeTexGabor", SH_NODE_TEX_GABOR);
ntype.ui_name = "Gabor Texture";
ntype.ui_description = "Generate Gabor noise";
ntype.enum_name_legacy = "TEX_GABOR";

View File

@@ -197,7 +197,7 @@ void register_node_type_sh_tex_gradient()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexGradient", SH_NODE_TEX_GRADIENT);
common_node_type_base(&ntype, "ShaderNodeTexGradient", SH_NODE_TEX_GRADIENT);
ntype.ui_name = "Gradient Texture";
ntype.ui_description =
"Generate interpolated color and intensity values based on the input vector";

View File

@@ -183,7 +183,7 @@ void register_node_type_sh_tex_magic()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexMagic", SH_NODE_TEX_MAGIC);
common_node_type_base(&ntype, "ShaderNodeTexMagic", SH_NODE_TEX_MAGIC);
ntype.ui_name = "Magic Texture";
ntype.ui_description = "Generate a psychedelic color texture";
ntype.enum_name_legacy = "TEX_MAGIC";

View File

@@ -461,7 +461,7 @@ void register_node_type_sh_tex_noise()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexNoise", SH_NODE_TEX_NOISE);
common_node_type_base(&ntype, "ShaderNodeTexNoise", SH_NODE_TEX_NOISE);
ntype.ui_name = "Noise Texture";
ntype.ui_description = "Generate fractal Perlin noise";
ntype.enum_name_legacy = "TEX_NOISE";

View File

@@ -818,7 +818,7 @@ void register_node_type_sh_tex_voronoi()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexVoronoi", SH_NODE_TEX_VORONOI);
common_node_type_base(&ntype, "ShaderNodeTexVoronoi", SH_NODE_TEX_VORONOI);
ntype.ui_name = "Voronoi Texture";
ntype.ui_description =
"Generate Worley noise based on the distance to random points. Typically used to generate "

View File

@@ -335,7 +335,7 @@ void register_node_type_sh_tex_wave()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexWave", SH_NODE_TEX_WAVE);
common_node_type_base(&ntype, "ShaderNodeTexWave", SH_NODE_TEX_WAVE);
ntype.ui_name = "Wave Texture";
ntype.ui_description = "Generate procedural bands or rings with noise";
ntype.enum_name_legacy = "TEX_WAVE";

View File

@@ -260,7 +260,7 @@ void register_node_type_sh_tex_white_noise()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeTexWhiteNoise", SH_NODE_TEX_WHITE_NOISE);
common_node_type_base(&ntype, "ShaderNodeTexWhiteNoise", SH_NODE_TEX_WHITE_NOISE);
ntype.ui_name = "White Noise Texture";
ntype.ui_description = "Return a random value or color based on an input seed";
ntype.enum_name_legacy = "TEX_WHITE_NOISE";

View File

@@ -54,7 +54,7 @@ void register_node_type_sh_value()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeValue", SH_NODE_VALUE);
common_node_type_base(&ntype, "ShaderNodeValue", SH_NODE_VALUE);
ntype.ui_name = "Value";
ntype.ui_description = "Input numerical values to other nodes in the tree";
ntype.enum_name_legacy = "VALUE";

View File

@@ -556,7 +556,7 @@ void register_node_type_sh_vect_math()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeVectorMath", SH_NODE_VECTOR_MATH);
common_node_type_base(&ntype, "ShaderNodeVectorMath", SH_NODE_VECTOR_MATH);
ntype.ui_name = "Vector Math";
ntype.ui_description = "Perform vector math operation";
ntype.enum_name_legacy = "VECT_MATH";

View File

@@ -268,7 +268,7 @@ void register_node_type_sh_vector_rotate()
static blender::bke::bNodeType ntype;
sh_fn_node_type_base(&ntype, "ShaderNodeVectorRotate", SH_NODE_VECTOR_ROTATE);
common_node_type_base(&ntype, "ShaderNodeVectorRotate", SH_NODE_VECTOR_ROTATE);
ntype.ui_name = "Vector Rotate";
ntype.ui_description = "Rotate a vector around a pivot point (center)";
ntype.enum_name_legacy = "VECTOR_ROTATE";