Geometry Nodes: UI: Add dynamic node class to switch nodes #128241
@ -260,7 +260,7 @@ static void node_register()
|
|||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
|
|
||||||
fn_node_type_base(
|
fn_node_type_base(
|
||||||
&ntype, FN_NODE_ALIGN_EULER_TO_VECTOR, "Align Euler to Vector", NODE_CLASS_CONVERTER);
|
&ntype, FN_NODE_ALIGN_EULER_TO_VECTOR, "Align Euler to Vector", NODE_CLASS_OP_VECTOR);
|
||||||
ntype.declare = node_declare;
|
ntype.declare = node_declare;
|
||||||
ntype.draw_buttons = node_layout;
|
ntype.draw_buttons = node_layout;
|
||||||
ntype.build_multi_function = node_build_multi_function;
|
ntype.build_multi_function = node_build_multi_function;
|
||||||
|
@ -197,6 +197,14 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int node_ui_class(const bNode *node)
|
||||||
|
{
|
||||||
|
const NodeRandomValue &storage = node_storage(*node);
|
||||||
|
const eCustomDataType cd_type = static_cast<eCustomDataType>(storage.data_type);
|
||||||
|
eNodeSocketDatatype data_type = *bke::custom_data_type_to_socket_type(cd_type);
|
||||||
|
return node_ui_class_from_data_type(data_type);
|
||||||
|
}
|
||||||
|
|
||||||
static void node_register()
|
static void node_register()
|
||||||
{
|
{
|
||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
@ -204,6 +212,7 @@ static void node_register()
|
|||||||
fn_node_type_base(&ntype, FN_NODE_RANDOM_VALUE, "Random Value", NODE_CLASS_CONVERTER);
|
fn_node_type_base(&ntype, FN_NODE_RANDOM_VALUE, "Random Value", NODE_CLASS_CONVERTER);
|
||||||
ntype.initfunc = fn_node_random_value_init;
|
ntype.initfunc = fn_node_random_value_init;
|
||||||
ntype.updatefunc = fn_node_random_value_update;
|
ntype.updatefunc = fn_node_random_value_update;
|
||||||
|
ntype.ui_class = node_ui_class;
|
||||||
ntype.draw_buttons = node_layout;
|
ntype.draw_buttons = node_layout;
|
||||||
ntype.declare = node_declare;
|
ntype.declare = node_declare;
|
||||||
ntype.build_multi_function = node_build_multi_function;
|
ntype.build_multi_function = node_build_multi_function;
|
||||||
|
@ -27,7 +27,7 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
|
|||||||
static void node_register()
|
static void node_register()
|
||||||
{
|
{
|
||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
fn_node_type_base(&ntype, FN_NODE_ROTATE_VECTOR, "Rotate Vector", NODE_CLASS_CONVERTER);
|
fn_node_type_base(&ntype, FN_NODE_ROTATE_VECTOR, "Rotate Vector", NODE_CLASS_OP_VECTOR);
|
||||||
ntype.declare = node_declare;
|
ntype.declare = node_declare;
|
||||||
ntype.build_multi_function = node_build_multi_function;
|
ntype.build_multi_function = node_build_multi_function;
|
||||||
blender::bke::node_register_type(&ntype);
|
blender::bke::node_register_type(&ntype);
|
||||||
|
@ -29,7 +29,7 @@ static void node_register()
|
|||||||
{
|
{
|
||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
fn_node_type_base(
|
fn_node_type_base(
|
||||||
&ntype, FN_NODE_TRANSFORM_DIRECTION, "Transform Direction", NODE_CLASS_CONVERTER);
|
&ntype, FN_NODE_TRANSFORM_DIRECTION, "Transform Direction", NODE_CLASS_OP_VECTOR);
|
||||||
ntype.declare = node_declare;
|
ntype.declare = node_declare;
|
||||||
ntype.build_multi_function = node_build_multi_function;
|
ntype.build_multi_function = node_build_multi_function;
|
||||||
blender::bke::node_register_type(&ntype);
|
blender::bke::node_register_type(&ntype);
|
||||||
|
@ -366,6 +366,13 @@ static bool node_insert_link(bNodeTree *ntree, bNode *node, bNodeLink *link)
|
|||||||
*ntree, *node, *node, *link);
|
*ntree, *node, *node, *link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int node_ui_class(const bNode *node)
|
||||||
|
{
|
||||||
|
const NodeIndexSwitch &storage = node_storage(*node);
|
||||||
|
const eNodeSocketDatatype data_type = eNodeSocketDatatype(storage.data_type);
|
||||||
|
return node_ui_class_from_data_type(data_type);
|
||||||
|
}
|
||||||
|
|
||||||
static void register_node()
|
static void register_node()
|
||||||
{
|
{
|
||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
@ -373,6 +380,7 @@ static void register_node()
|
|||||||
geo_node_type_base(&ntype, GEO_NODE_INDEX_SWITCH, "Index Switch", NODE_CLASS_CONVERTER);
|
geo_node_type_base(&ntype, GEO_NODE_INDEX_SWITCH, "Index Switch", NODE_CLASS_CONVERTER);
|
||||||
ntype.declare = node_declare;
|
ntype.declare = node_declare;
|
||||||
ntype.initfunc = node_init;
|
ntype.initfunc = node_init;
|
||||||
|
ntype.ui_class = node_ui_class;
|
||||||
ntype.insert_link = node_insert_link;
|
ntype.insert_link = node_insert_link;
|
||||||
blender::bke::node_type_storage(&ntype, "NodeIndexSwitch", node_free_storage, node_copy_storage);
|
blender::bke::node_type_storage(&ntype, "NodeIndexSwitch", node_free_storage, node_copy_storage);
|
||||||
ntype.gather_link_search_ops = node_gather_link_searches;
|
ntype.gather_link_search_ops = node_gather_link_searches;
|
||||||
|
@ -483,6 +483,13 @@ static void node_rna(StructRNA *srna)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int node_ui_class(const bNode *node)
|
||||||
|
{
|
||||||
|
const NodeMenuSwitch &storage = node_storage(*node);
|
||||||
|
const eNodeSocketDatatype data_type = eNodeSocketDatatype(storage.data_type);
|
||||||
|
return node_ui_class_from_data_type(data_type);
|
||||||
|
}
|
||||||
|
|
||||||
static void register_node()
|
static void register_node()
|
||||||
{
|
{
|
||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
@ -490,6 +497,7 @@ static void register_node()
|
|||||||
geo_node_type_base(&ntype, GEO_NODE_MENU_SWITCH, "Menu Switch", NODE_CLASS_CONVERTER);
|
geo_node_type_base(&ntype, GEO_NODE_MENU_SWITCH, "Menu Switch", NODE_CLASS_CONVERTER);
|
||||||
ntype.declare = node_declare;
|
ntype.declare = node_declare;
|
||||||
ntype.initfunc = node_init;
|
ntype.initfunc = node_init;
|
||||||
|
ntype.ui_class = node_ui_class;
|
||||||
blender::bke::node_type_storage(&ntype, "NodeMenuSwitch", node_free_storage, node_copy_storage);
|
blender::bke::node_type_storage(&ntype, "NodeMenuSwitch", node_free_storage, node_copy_storage);
|
||||||
ntype.gather_link_search_ops = node_gather_link_searches;
|
ntype.gather_link_search_ops = node_gather_link_searches;
|
||||||
ntype.draw_buttons = node_layout;
|
ntype.draw_buttons = node_layout;
|
||||||
|
@ -242,6 +242,13 @@ static void node_rna(StructRNA *srna)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int node_ui_class(const bNode *node)
|
||||||
|
{
|
||||||
|
const NodeSwitch &storage = node_storage(*node);
|
||||||
|
const eNodeSocketDatatype socket_type = eNodeSocketDatatype(storage.input_type);
|
||||||
|
return node_ui_class_from_data_type(socket_type);
|
||||||
|
}
|
||||||
|
|
||||||
static void register_node()
|
static void register_node()
|
||||||
{
|
{
|
||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
@ -249,6 +256,7 @@ static void register_node()
|
|||||||
geo_node_type_base(&ntype, GEO_NODE_SWITCH, "Switch", NODE_CLASS_CONVERTER);
|
geo_node_type_base(&ntype, GEO_NODE_SWITCH, "Switch", NODE_CLASS_CONVERTER);
|
||||||
ntype.declare = node_declare;
|
ntype.declare = node_declare;
|
||||||
ntype.initfunc = node_init;
|
ntype.initfunc = node_init;
|
||||||
|
ntype.ui_class = node_ui_class;
|
||||||
blender::bke::node_type_storage(
|
blender::bke::node_type_storage(
|
||||||
&ntype, "NodeSwitch", node_free_standard_storage, node_copy_standard_storage);
|
&ntype, "NodeSwitch", node_free_standard_storage, node_copy_standard_storage);
|
||||||
ntype.gather_link_search_ops = node_gather_link_searches;
|
ntype.gather_link_search_ops = node_gather_link_searches;
|
||||||
|
@ -171,6 +171,20 @@ void node_math_update(bNodeTree *ntree, bNode *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int node_ui_class_from_data_type(const eNodeSocketDatatype type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case SOCK_VECTOR:
|
||||||
|
return NODE_CLASS_OP_VECTOR;
|
||||||
|
case SOCK_RGBA:
|
||||||
|
return NODE_CLASS_OP_COLOR;
|
||||||
|
case SOCK_GEOMETRY:
|
||||||
|
return NODE_CLASS_GEOMETRY;
|
||||||
|
default:
|
||||||
|
return NODE_CLASS_CONVERTER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
@ -38,6 +38,9 @@ void node_sock_label(bNodeSocket *sock, const char *name);
|
|||||||
void node_sock_label_clear(bNodeSocket *sock);
|
void node_sock_label_clear(bNodeSocket *sock);
|
||||||
void node_math_update(bNodeTree *ntree, bNode *node);
|
void node_math_update(bNodeTree *ntree, bNode *node);
|
||||||
|
|
||||||
|
/**** Node Class ****/
|
||||||
|
int node_ui_class_from_data_type(const eNodeSocketDatatype type);
|
||||||
|
|
||||||
/**** Labels ****/
|
/**** Labels ****/
|
||||||
void node_blend_label(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy);
|
void node_blend_label(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy);
|
||||||
void node_image_label(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy);
|
void node_image_label(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy);
|
||||||
|
@ -60,14 +60,12 @@ static void node_shader_buts_map_range(uiLayout *layout, bContext * /*C*/, Point
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int node_shader_map_range_ui_class(const bNode *node)
|
static int node_ui_class(const bNode *node)
|
||||||
{
|
{
|
||||||
const NodeMapRange &storage = node_storage(*node);
|
const NodeMapRange &storage = node_storage(*node);
|
||||||
const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type);
|
const eCustomDataType cd_type = static_cast<eCustomDataType>(storage.data_type);
|
||||||
if (data_type == CD_PROP_FLOAT3) {
|
eNodeSocketDatatype data_type = *bke::custom_data_type_to_socket_type(cd_type);
|
||||||
return NODE_CLASS_OP_VECTOR;
|
return node_ui_class_from_data_type(data_type);
|
||||||
}
|
|
||||||
return NODE_CLASS_CONVERTER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_shader_update_map_range(bNodeTree *ntree, bNode *node)
|
static void node_shader_update_map_range(bNodeTree *ntree, bNode *node)
|
||||||
@ -527,7 +525,7 @@ void register_node_type_sh_map_range()
|
|||||||
sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER);
|
sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER);
|
||||||
ntype.declare = file_ns::sh_node_map_range_declare;
|
ntype.declare = file_ns::sh_node_map_range_declare;
|
||||||
ntype.draw_buttons = file_ns::node_shader_buts_map_range;
|
ntype.draw_buttons = file_ns::node_shader_buts_map_range;
|
||||||
ntype.ui_class = file_ns::node_shader_map_range_ui_class;
|
ntype.ui_class = file_ns::node_ui_class;
|
||||||
ntype.initfunc = file_ns::node_shader_init_map_range;
|
ntype.initfunc = file_ns::node_shader_init_map_range;
|
||||||
blender::bke::node_type_storage(
|
blender::bke::node_type_storage(
|
||||||
&ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage);
|
&ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage);
|
||||||
|
@ -132,19 +132,11 @@ static void sh_node_mix_label(const bNodeTree * /*ntree*/,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sh_node_mix_ui_class(const bNode *node)
|
static int node_ui_class(const bNode *node)
|
||||||
{
|
{
|
||||||
const NodeShaderMix &storage = node_storage(*node);
|
const NodeShaderMix &storage = node_storage(*node);
|
||||||
const eNodeSocketDatatype data_type = static_cast<eNodeSocketDatatype>(storage.data_type);
|
const eNodeSocketDatatype data_type = static_cast<eNodeSocketDatatype>(storage.data_type);
|
||||||
|
return node_ui_class_from_data_type(data_type);
|
||||||
switch (data_type) {
|
|
||||||
case SOCK_VECTOR:
|
|
||||||
return NODE_CLASS_OP_VECTOR;
|
|
||||||
case SOCK_RGBA:
|
|
||||||
return NODE_CLASS_OP_COLOR;
|
|
||||||
default:
|
|
||||||
return NODE_CLASS_CONVERTER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sh_node_mix_update(bNodeTree *ntree, bNode *node)
|
static void sh_node_mix_update(bNodeTree *ntree, bNode *node)
|
||||||
@ -612,7 +604,7 @@ void register_node_type_sh_mix()
|
|||||||
static blender::bke::bNodeType ntype;
|
static blender::bke::bNodeType ntype;
|
||||||
sh_fn_node_type_base(&ntype, SH_NODE_MIX, "Mix", NODE_CLASS_CONVERTER);
|
sh_fn_node_type_base(&ntype, SH_NODE_MIX, "Mix", NODE_CLASS_CONVERTER);
|
||||||
ntype.declare = file_ns::sh_node_mix_declare;
|
ntype.declare = file_ns::sh_node_mix_declare;
|
||||||
ntype.ui_class = file_ns::sh_node_mix_ui_class;
|
ntype.ui_class = file_ns::node_ui_class;
|
||||||
ntype.gpu_fn = file_ns::gpu_shader_mix;
|
ntype.gpu_fn = file_ns::gpu_shader_mix;
|
||||||
ntype.updatefunc = file_ns::sh_node_mix_update;
|
ntype.updatefunc = file_ns::sh_node_mix_update;
|
||||||
ntype.initfunc = file_ns::node_mix_init;
|
ntype.initfunc = file_ns::node_mix_init;
|
||||||
|
Loading…
Reference in New Issue
Block a user