diff options
author | Hans Goudey <h.goudey@me.com> | 2021-02-09 00:09:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-02-09 00:09:49 +0300 |
commit | cfa48c84d06ca8197f86b6d3ceef8a2c7c311a82 (patch) | |
tree | b841d7d8c27a8811317fc069a8581953fef5b736 /source/blender/nodes | |
parent | 13299a73675028c1d9bf3143ec808f9231e78e75 (diff) |
Cleanup: Register node property layout callbacks in files
This commit moves the property layout callbacks for node types to their
implementation files from `drawnode.c`. This was proposed a while ago in
T75724.
**Benefits**
- Fewer files need to be changed when adding a new node.
- Makes it possible to reuse functions from the node's implementation
in the layout code.
- Except for RNA, all of the node "inputs" are in the same place.
- Code gets shorter overall, avoids the large switch statements.
**Downsides**
- Requires including two UI headers.
- Requires adding an editors dependency to the nodes folder.
This commit only changes function nodes and geometry nodes, more can be
moved later.
Differential Revision: https://developer.blender.org/D10352
Diffstat (limited to 'source/blender/nodes')
27 files changed, 351 insertions, 36 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index a209faa5d17..4656e2e5e4f 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -26,6 +26,7 @@ set(INC intern shader texture + ../editors/include ../blenkernel ../blenlib ../blentranslation diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc index 9148cef7805..7a83ff8e016 100644 --- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc +++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc @@ -19,6 +19,9 @@ #include "RNA_enum_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_function_util.hh" static bNodeSocketTemplate fn_node_boolean_math_in[] = { @@ -32,6 +35,11 @@ static bNodeSocketTemplate fn_node_boolean_math_out[] = { {-1, ""}, }; +static void fn_node_boolean_math_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); +} + static void node_boolean_math_update(bNodeTree *UNUSED(ntree), bNode *node) { bNodeSocket *sockB = (bNodeSocket *)BLI_findlink(&node->inputs, 1); @@ -86,5 +94,6 @@ void register_node_type_fn_boolean_math() node_type_label(&ntype, node_boolean_math_label); node_type_update(&ntype, node_boolean_math_update); ntype.expand_in_mf_network = node_boolean_expand_in_mf_network; + ntype.draw_buttons = fn_node_boolean_math_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/function/nodes/node_fn_float_compare.cc b/source/blender/nodes/function/nodes/node_fn_float_compare.cc index 93c79a48571..6c8df8f2ea0 100644 --- a/source/blender/nodes/function/nodes/node_fn_float_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_float_compare.cc @@ -21,6 +21,9 @@ #include "RNA_enum_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_function_util.hh" static bNodeSocketTemplate fn_node_float_compare_in[] = { @@ -35,6 +38,11 @@ static bNodeSocketTemplate fn_node_float_compare_out[] = { {-1, ""}, }; +static void geo_node_float_compare_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); +} + static void node_float_compare_update(bNodeTree *UNUSED(ntree), bNode *node) { bNodeSocket *sockEpsilon = (bNodeSocket *)BLI_findlink(&node->inputs, 2); @@ -105,5 +113,6 @@ void register_node_type_fn_float_compare() node_type_label(&ntype, node_float_compare_label); node_type_update(&ntype, node_float_compare_update); ntype.expand_in_mf_network = node_float_compare_expand_in_mf_network; + ntype.draw_buttons = geo_node_float_compare_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/function/nodes/node_fn_input_vector.cc b/source/blender/nodes/function/nodes/node_fn_input_vector.cc index c2707f6307a..2cd4eb1d9df 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_vector.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_vector.cc @@ -18,11 +18,20 @@ #include "BLI_hash.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate fn_node_input_vector_out[] = { {SOCK_VECTOR, N_("Vector")}, {-1, ""}, }; +static void fn_node_input_vector_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "vector", UI_ITEM_R_EXPAND, "", ICON_NONE); +} + static void fn_node_vector_input_expand_in_mf_network( blender::nodes::NodeMFNetworkBuilder &builder) { @@ -50,6 +59,6 @@ void register_node_type_fn_input_vector() node_type_storage( &ntype, "NodeInputVector", node_free_standard_storage, node_copy_standard_storage); ntype.expand_in_mf_network = fn_node_vector_input_expand_in_mf_network; - + ntype.draw_buttons = fn_node_input_vector_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/function/nodes/node_fn_switch.cc b/source/blender/nodes/function/nodes/node_fn_switch.cc index 281ddb05c76..5187decbbe5 100644 --- a/source/blender/nodes/function/nodes/node_fn_switch.cc +++ b/source/blender/nodes/function/nodes/node_fn_switch.cc @@ -15,8 +15,17 @@ */ #include "BLI_listbase.h" + +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_function_util.hh" +static void fn_node_switch_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); +} + static bNodeSocketTemplate fn_node_switch_in[] = { {SOCK_BOOLEAN, N_("Switch")}, @@ -72,5 +81,6 @@ void register_node_type_fn_switch() fn_node_type_base(&ntype, FN_NODE_SWITCH, "Switch", 0, 0); node_type_socket_templates(&ntype, fn_node_switch_in, fn_node_switch_out); node_type_update(&ntype, fn_node_switch_update); + ntype.draw_buttons = fn_node_switch_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc index bdec3599bfa..e592bd0bda8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc @@ -18,6 +18,9 @@ #include "BLI_math_rotation.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_align_rotation_to_vector_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Factor")}, @@ -32,6 +35,17 @@ static bNodeSocketTemplate geo_node_align_rotation_to_vector_out[] = { {-1, ""}, }; +static void geo_node_align_rotation_to_vector_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "pivot_axis", 0, IFACE_("Pivot"), ICON_NONE); + uiLayout *col = uiLayoutColumn(layout, false); + uiItemR(col, ptr, "input_type_factor", 0, IFACE_("Factor"), ICON_NONE); + uiItemR(col, ptr, "input_type_vector", 0, IFACE_("Vector"), ICON_NONE); +} + namespace blender::nodes { static void align_rotations_auto_pivot(const Float3ReadAttribute &vectors, @@ -202,5 +216,6 @@ void register_node_type_geo_align_rotation_to_vector() node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_align_rotation_to_vector_exec; + ntype.draw_buttons = geo_node_align_rotation_to_vector_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc index 9b0900e19ab..179e418214c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc @@ -18,6 +18,9 @@ #include "BKE_colorband.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_attribute_color_ramp_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Attribute")}, @@ -30,6 +33,13 @@ static bNodeSocketTemplate geo_node_attribute_color_ramp_out[] = { {-1, ""}, }; +static void geo_node_attribute_color_ramp_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiTemplateColorRamp(layout, ptr, "color_ramp", 0); +} + namespace blender::nodes { static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryComponent &component) @@ -104,5 +114,6 @@ void register_node_type_geo_attribute_color_ramp() node_type_init(&ntype, blender::nodes::geo_node_attribute_color_ramp_init); node_type_size_preset(&ntype, NODE_SIZE_LARGE); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_color_ramp_exec; + ntype.draw_buttons = geo_node_attribute_color_ramp_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc index 194b062021d..5e434a7f96d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc @@ -26,6 +26,9 @@ #include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "NOD_math_functions.hh" static bNodeSocketTemplate geo_node_attribute_compare_in[] = { @@ -48,6 +51,15 @@ static bNodeSocketTemplate geo_node_attribute_compare_out[] = { {-1, ""}, }; +static void geo_node_attribute_compare_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); + uiItemR(layout, ptr, "input_type_a", 0, IFACE_("Type A"), ICON_NONE); + uiItemR(layout, ptr, "input_type_b", 0, IFACE_("Type B"), ICON_NONE); +} + static void geo_node_attribute_compare_init(bNodeTree *UNUSED(tree), bNode *node) { NodeAttributeCompare *data = (NodeAttributeCompare *)MEM_callocN(sizeof(NodeAttributeCompare), @@ -327,6 +339,7 @@ void register_node_type_geo_attribute_compare() node_type_socket_templates( &ntype, geo_node_attribute_compare_in, geo_node_attribute_compare_out); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_compare_exec; + ntype.draw_buttons = geo_node_attribute_compare_layout; node_type_update(&ntype, blender::nodes::geo_node_attribute_compare_update); node_type_storage( &ntype, "NodeAttributeCompare", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc index 9cec4070f89..92b47769d1f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc @@ -21,6 +21,9 @@ #include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_attribute_fill_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Attribute")}, @@ -36,6 +39,12 @@ static bNodeSocketTemplate geo_node_attribute_fill_out[] = { {-1, ""}, }; +static void geo_node_attribute_fill_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); + // uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); +} + static void geo_node_attribute_fill_init(bNodeTree *UNUSED(tree), bNode *node) { node->custom1 = CD_PROP_FLOAT; @@ -131,5 +140,6 @@ void register_node_type_geo_attribute_fill() node_type_init(&ntype, geo_node_attribute_fill_init); node_type_update(&ntype, geo_node_attribute_fill_update); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_fill_exec; + ntype.draw_buttons = geo_node_attribute_fill_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc index f3fc45fc1be..5844edfbbb7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc @@ -26,6 +26,9 @@ #include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "NOD_math_functions.hh" static bNodeSocketTemplate geo_node_attribute_math_in[] = { @@ -45,18 +48,6 @@ static bNodeSocketTemplate geo_node_attribute_math_out[] = { {-1, ""}, }; -static void geo_node_attribute_math_init(bNodeTree *UNUSED(tree), bNode *node) -{ - NodeAttributeMath *data = (NodeAttributeMath *)MEM_callocN(sizeof(NodeAttributeMath), - "NodeAttributeMath"); - - data->operation = NODE_MATH_ADD; - data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; - data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; - data->input_type_c = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; - node->storage = data; -} - static bool operation_use_input_c(const NodeMathOperation operation) { return ELEM(operation, @@ -117,6 +108,34 @@ static bool operation_use_input_b(const NodeMathOperation operation) return false; } +static void geo_node_attribute_math_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + NodeAttributeMath *node_storage = (NodeAttributeMath *)node->storage; + NodeMathOperation operation = (NodeMathOperation)node_storage->operation; + + uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); + uiItemR(layout, ptr, "input_type_a", 0, IFACE_("Type A"), ICON_NONE); + + if (operation_use_input_b(operation)) { + uiItemR(layout, ptr, "input_type_b", 0, IFACE_("Type B"), ICON_NONE); + } + if (operation_use_input_c(operation)) { + uiItemR(layout, ptr, "input_type_c", 0, IFACE_("Type C"), ICON_NONE); + } +} + +static void geo_node_attribute_math_init(bNodeTree *UNUSED(tree), bNode *node) +{ + NodeAttributeMath *data = (NodeAttributeMath *)MEM_callocN(sizeof(NodeAttributeMath), __func__); + + data->operation = NODE_MATH_ADD; + data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; + data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; + data->input_type_c = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; + node->storage = data; +} + namespace blender::nodes { static void geo_node_attribute_math_update(bNodeTree *UNUSED(ntree), bNode *node) @@ -267,6 +286,7 @@ void register_node_type_geo_attribute_math() geo_node_type_base(&ntype, GEO_NODE_ATTRIBUTE_MATH, "Attribute Math", NODE_CLASS_ATTRIBUTE, 0); node_type_socket_templates(&ntype, geo_node_attribute_math_in, geo_node_attribute_math_out); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_math_exec; + ntype.draw_buttons = geo_node_attribute_math_layout; node_type_update(&ntype, blender::nodes::geo_node_attribute_math_update); node_type_init(&ntype, geo_node_attribute_math_init); node_type_storage( diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc index 58d67145e75..976970d06b1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc @@ -18,6 +18,9 @@ #include "DNA_material_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_geometry_util.hh" static bNodeSocketTemplate geo_node_attribute_mix_in[] = { @@ -41,6 +44,15 @@ static bNodeSocketTemplate geo_node_mix_attribute_out[] = { {-1, ""}, }; +static void geo_node_attribute_mix_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "blend_type", 0, "", ICON_NONE); + uiLayout *col = uiLayoutColumn(layout, false); + uiItemR(col, ptr, "input_type_factor", 0, IFACE_("Factor"), ICON_NONE); + uiItemR(col, ptr, "input_type_a", 0, IFACE_("A"), ICON_NONE); + uiItemR(col, ptr, "input_type_b", 0, IFACE_("B"), ICON_NONE); +} + namespace blender::nodes { static void do_mix_operation_float(const int blend_mode, @@ -204,6 +216,7 @@ void register_node_type_geo_attribute_mix() node_type_socket_templates(&ntype, geo_node_attribute_mix_in, geo_node_mix_attribute_out); node_type_init(&ntype, blender::nodes::geo_node_attribute_mix_init); node_type_update(&ntype, blender::nodes::geo_node_attribute_mix_update); + ntype.draw_buttons = geo_node_attribute_mix_layout; node_type_storage( &ntype, "NodeAttributeMix", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_mix_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc index 14b1c4e3a59..1067a1e8593 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc @@ -14,16 +14,19 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "BLI_kdopbvh.h" #include "BLI_kdtree.h" #include "BLI_task.hh" +#include "BLI_timeit.hh" + +#include "DNA_mesh_types.h" #include "BKE_bvhutils.h" -#include "BLI_kdopbvh.h" -#include "node_geometry_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" -#include "BLI_timeit.hh" -#include "DNA_mesh_types.h" +#include "node_geometry_util.hh" static bNodeSocketTemplate geo_node_attribute_proximity_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, @@ -37,6 +40,13 @@ static bNodeSocketTemplate geo_node_attribute_proximity_out[] = { {-1, ""}, }; +static void geo_node_attribute_proximity_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "target_geometry_element", 0, "", ICON_NONE); +} + static void geo_attribute_proximity_init(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryAttributeProximity *node_storage = (NodeGeometryAttributeProximity *)MEM_callocN( @@ -220,5 +230,6 @@ void register_node_type_geo_attribute_proximity() node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_proximity_exec; + ntype.draw_buttons = geo_node_attribute_proximity_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc index 3ee7df7fe72..f5765af83b3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc @@ -19,6 +19,9 @@ #include "BLI_hash.h" #include "BLI_rand.hh" +#include "UI_interface.h" +#include "UI_resources.h" + #include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" @@ -38,6 +41,13 @@ static bNodeSocketTemplate geo_node_attribute_randomize_out[] = { {-1, ""}, }; +static void geo_node_attribute_random_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); +} + static void geo_node_attribute_randomize_init(bNodeTree *UNUSED(tree), bNode *node) { node->custom1 = CD_PROP_FLOAT; @@ -215,5 +225,6 @@ void register_node_type_geo_attribute_randomize() node_type_init(&ntype, geo_node_attribute_randomize_init); node_type_update(&ntype, geo_node_attribute_randomize_update); ntype.geometry_node_execute = blender::nodes::geo_node_random_attribute_exec; + ntype.draw_buttons = geo_node_attribute_random_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc index 66495bfa53b..b6a960e5617 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc @@ -22,6 +22,9 @@ #include "RE_texture.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_geometry_util.hh" static bNodeSocketTemplate geo_node_attribute_sample_texture_in[] = { @@ -36,6 +39,13 @@ static bNodeSocketTemplate geo_node_attribute_sample_texture_out[] = { {-1, ""}, }; +static void geo_node_attribute_sample_texture_layout(uiLayout *layout, + bContext *C, + PointerRNA *ptr) +{ + uiTemplateID(layout, C, ptr, "texture", "texture.new", NULL, NULL, 0, ICON_NONE, NULL); +} + namespace blender::nodes { static void execute_on_component(GeometryComponent &component, const GeoNodeExecParams ¶ms) @@ -103,5 +113,6 @@ void register_node_type_geo_sample_texture() node_type_socket_templates( &ntype, geo_node_attribute_sample_texture_in, geo_node_attribute_sample_texture_out); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_sample_texture_exec; + ntype.draw_buttons = geo_node_attribute_sample_texture_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc index 529906a35e7..62a291e8506 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc @@ -26,6 +26,9 @@ #include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "NOD_math_functions.hh" static bNodeSocketTemplate geo_node_attribute_vector_math_in[] = { @@ -46,25 +49,6 @@ static bNodeSocketTemplate geo_node_attribute_vector_math_out[] = { {-1, ""}, }; -static void geo_node_attribute_vector_math_init(bNodeTree *UNUSED(tree), bNode *node) -{ - NodeAttributeVectorMath *data = (NodeAttributeVectorMath *)MEM_callocN( - sizeof(NodeAttributeVectorMath), __func__); - - data->operation = NODE_VECTOR_MATH_ADD; - data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; - data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; - node->storage = data; -} - -static CustomDataType operation_get_read_type_b(const NodeVectorMathOperation operation) -{ - if (operation == NODE_VECTOR_MATH_SCALE) { - return CD_PROP_FLOAT; - } - return CD_PROP_FLOAT3; -} - static bool operation_use_input_b(const NodeVectorMathOperation operation) { return !ELEM(operation, @@ -84,6 +68,44 @@ static bool operation_use_input_c(const NodeVectorMathOperation operation) return operation == NODE_VECTOR_MATH_WRAP; } +static void geo_node_attribute_vector_math_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + const NodeAttributeVectorMath &node_storage = *(NodeAttributeVectorMath *)node->storage; + const NodeVectorMathOperation operation = (const NodeVectorMathOperation)node_storage.operation; + + uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); + uiItemR(layout, ptr, "input_type_a", 0, IFACE_("Type A"), ICON_NONE); + + if (operation_use_input_b(operation)) { + uiItemR(layout, ptr, "input_type_b", 0, IFACE_("Type B"), ICON_NONE); + } + if (operation_use_input_c(operation)) { + uiItemR(layout, ptr, "input_type_c", 0, IFACE_("Type C"), ICON_NONE); + } +} + +static CustomDataType operation_get_read_type_b(const NodeVectorMathOperation operation) +{ + if (operation == NODE_VECTOR_MATH_SCALE) { + return CD_PROP_FLOAT; + } + return CD_PROP_FLOAT3; +} + +static void geo_node_attribute_vector_math_init(bNodeTree *UNUSED(tree), bNode *node) +{ + NodeAttributeVectorMath *data = (NodeAttributeVectorMath *)MEM_callocN( + sizeof(NodeAttributeVectorMath), __func__); + + data->operation = NODE_VECTOR_MATH_ADD; + data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; + data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE; + node->storage = data; +} + static CustomDataType operation_get_result_type(const NodeVectorMathOperation operation) { switch (operation) { @@ -419,6 +441,7 @@ void register_node_type_geo_attribute_vector_math() node_type_socket_templates( &ntype, geo_node_attribute_vector_math_in, geo_node_attribute_vector_math_out); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_vector_math_exec; + ntype.draw_buttons = geo_node_attribute_vector_math_layout; node_type_update(&ntype, blender::nodes::geo_node_attribute_vector_math_update); node_type_init(&ntype, geo_node_attribute_vector_math_init); node_type_storage( diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc index 19178546e40..403b74b2fef 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc @@ -24,6 +24,9 @@ #include "RNA_enum_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "BKE_mesh.h" #include "bmesh.h" @@ -42,6 +45,11 @@ static bNodeSocketTemplate geo_node_boolean_out[] = { {-1, ""}, }; +static void geo_node_boolean_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); +} + static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data)) { return BM_elem_flag_test(f, BM_ELEM_DRAW) ? 1 : 0; @@ -147,6 +155,7 @@ void register_node_type_geo_boolean() geo_node_type_base(&ntype, GEO_NODE_BOOLEAN, "Boolean", NODE_CLASS_GEOMETRY, 0); node_type_socket_templates(&ntype, geo_node_boolean_in, geo_node_boolean_out); + ntype.draw_buttons = geo_node_boolean_layout; ntype.geometry_node_execute = blender::nodes::geo_node_boolean_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index 637a117e2af..42ad434ffcd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -20,6 +20,9 @@ #include "DNA_collection_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_collection_info_in[] = { {SOCK_COLLECTION, N_("Collection")}, {-1, ""}, @@ -30,6 +33,11 @@ static bNodeSocketTemplate geo_node_collection_info_out[] = { {-1, ""}, }; +static void geo_node_collection_info_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "transform_space", 0, NULL, ICON_NONE); +} + namespace blender::nodes { static void geo_node_collection_info_exec(GeoNodeExecParams params) @@ -95,5 +103,6 @@ void register_node_type_geo_collection_info() node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_collection_info_exec; + ntype.draw_buttons = geo_node_collection_info_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc index d713c191d5d..4e26977b85a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc @@ -23,6 +23,9 @@ #include "BLI_math_matrix.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_object_info_in[] = { {SOCK_OBJECT, N_("Object")}, {-1, ""}, @@ -36,6 +39,11 @@ static bNodeSocketTemplate geo_node_object_info_out[] = { {-1, ""}, }; +static void geo_node_object_info_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "transform_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE); +} + namespace blender::nodes { static void geo_node_object_info_exec(GeoNodeExecParams params) { @@ -128,5 +136,6 @@ void register_node_type_geo_object_info() node_type_storage( &ntype, "NodeGeometryObjectInfo", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_object_info_exec; + ntype.draw_buttons = geo_node_object_info_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc index eaf13b94eb9..93abed7926e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc @@ -33,6 +33,9 @@ #include "BKE_mesh_runtime.h" #include "BKE_pointcloud.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_geometry_util.hh" static bNodeSocketTemplate geo_node_point_distribute_in[] = { @@ -49,6 +52,13 @@ static bNodeSocketTemplate geo_node_point_distribute_out[] = { {-1, ""}, }; +static void geo_node_point_distribute_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "distribute_method", 0, "", ICON_NONE); +} + static void node_point_distribute_update(bNodeTree *UNUSED(ntree), bNode *node) { bNodeSocket *sock_min_dist = (bNodeSocket *)BLI_findlink(&node->inputs, 1); @@ -485,5 +495,6 @@ void register_node_type_geo_point_distribute() node_type_socket_templates(&ntype, geo_node_point_distribute_in, geo_node_point_distribute_out); node_type_update(&ntype, node_point_distribute_update); ntype.geometry_node_execute = blender::nodes::geo_node_point_distribute_exec; + ntype.draw_buttons = geo_node_point_distribute_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc index 3bd8c355124..1e7cf21f921 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc @@ -24,6 +24,9 @@ #include "BLI_hash.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_geometry_util.hh" static bNodeSocketTemplate geo_node_point_instance_in[] = { @@ -39,6 +42,14 @@ static bNodeSocketTemplate geo_node_point_instance_out[] = { {-1, ""}, }; +static void geo_node_point_instance_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "instance_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + if (RNA_enum_get(ptr, "instance_type") == GEO_NODE_POINT_INSTANCE_TYPE_COLLECTION) { + uiItemR(layout, ptr, "use_whole_collection", 0, NULL, ICON_NONE); + } +} + namespace blender::nodes { static void geo_node_point_instance_update(bNodeTree *UNUSED(tree), bNode *node) @@ -216,6 +227,7 @@ void register_node_type_geo_point_instance() node_type_init(&ntype, blender::nodes::geo_node_point_instance_init); node_type_storage( &ntype, "NodeGeometryPointInstance", node_free_standard_storage, node_copy_standard_storage); + ntype.draw_buttons = geo_node_point_instance_layout; node_type_update(&ntype, blender::nodes::geo_node_point_instance_update); ntype.geometry_node_execute = blender::nodes::geo_node_point_instance_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc index b1451dfb89e..3ca898bfd83 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc @@ -18,6 +18,9 @@ #include "BLI_math_rotation.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_point_rotate_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Axis")}, @@ -34,6 +37,23 @@ static bNodeSocketTemplate geo_node_point_rotate_out[] = { {-1, ""}, }; +static void geo_node_point_rotate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + NodeGeometryRotatePoints *storage = (NodeGeometryRotatePoints *)((bNode *)ptr->data)->storage; + + uiItemR(layout, ptr, "type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "space", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + + uiLayout *col = uiLayoutColumn(layout, false); + if (storage->type == GEO_NODE_POINT_ROTATE_TYPE_AXIS_ANGLE) { + uiItemR(col, ptr, "input_type_axis", 0, IFACE_("Axis"), ICON_NONE); + uiItemR(col, ptr, "input_type_angle", 0, IFACE_("Angle"), ICON_NONE); + } + else { + uiItemR(col, ptr, "input_type_rotation", 0, IFACE_("Rotation"), ICON_NONE); + } +} + namespace blender::nodes { static void point_rotate__axis_angle__object_space(const int domain_size, @@ -202,5 +222,6 @@ void register_node_type_geo_point_rotate() node_type_storage( &ntype, "NodeGeometryRotatePoints", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_point_rotate_exec; + ntype.draw_buttons = geo_node_point_rotate_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc index 47fca93d2ab..78e23b783db 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc @@ -18,6 +18,9 @@ #include "BKE_colorband.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_point_scale_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Factor")}, @@ -30,6 +33,11 @@ static bNodeSocketTemplate geo_node_point_scale_out[] = { {-1, ""}, }; +static void geo_node_point_scale_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "input_type", 0, IFACE_("Type"), ICON_NONE); +} + namespace blender::nodes { static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component) @@ -96,5 +104,6 @@ void register_node_type_geo_point_scale() node_type_storage( &ntype, "NodeGeometryPointScale", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_point_scale_exec; + ntype.draw_buttons = geo_node_point_scale_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc index 72176b11fdb..f7f369f5d66 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc @@ -18,6 +18,9 @@ #include "BKE_colorband.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_point_translate_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Translation")}, @@ -30,6 +33,11 @@ static bNodeSocketTemplate geo_node_point_translate_out[] = { {-1, ""}, }; +static void geo_node_point_translate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "input_type", 0, IFACE_("Type"), ICON_NONE); +} + namespace blender::nodes { static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component) @@ -97,5 +105,6 @@ void register_node_type_geo_point_translate() node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_point_translate_exec; + ntype.draw_buttons = geo_node_point_translate_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index b90ef2034a8..428f129fb36 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -25,6 +25,9 @@ #include "BKE_lib_id.h" #include "BKE_volume.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_points_to_volume_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_FLOAT, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, @@ -40,6 +43,16 @@ static bNodeSocketTemplate geo_node_point_translate_out[] = { {-1, ""}, }; +static void geo_node_points_to_volume_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiLayoutSetPropSep(layout, true); + uiLayoutSetPropDecorate(layout, false); + uiItemR(layout, ptr, "resolution_mode", 0, IFACE_("Resolution"), ICON_NONE); + uiItemR(layout, ptr, "input_type_radius", 0, IFACE_("Radius"), ICON_NONE); +} + namespace blender::nodes { #ifdef WITH_OPENVDB @@ -255,5 +268,6 @@ void register_node_type_geo_points_to_volume() node_type_init(&ntype, blender::nodes::geo_node_points_to_volume_init); node_type_update(&ntype, blender::nodes::geo_node_points_to_volume_update); ntype.geometry_node_execute = blender::nodes::geo_node_points_to_volume_exec; + ntype.draw_buttons = geo_node_points_to_volume_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc index 543859aef3f..99f7339a1cc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc @@ -20,6 +20,9 @@ #include "BKE_subdiv.h" #include "BKE_subdiv_mesh.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_geometry_util.hh" static bNodeSocketTemplate geo_node_subdivision_surface_in[] = { @@ -36,6 +39,17 @@ static bNodeSocketTemplate geo_node_subdivision_surface_out[] = { {-1, ""}, }; +static void geo_node_subdivision_surface_layout(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *UNUSED(ptr)) +{ +#ifndef WITH_OPENSUBDIV + uiItemL(layout, IFACE_("Disabled, built without OpenSubdiv"), ICON_ERROR); +#else + UNUSED_VARS(layout); +#endif +} + namespace blender::nodes { static void geo_node_subdivision_surface_exec(GeoNodeExecParams params) { @@ -112,5 +126,6 @@ void register_node_type_geo_subdivision_surface() node_type_socket_templates( &ntype, geo_node_subdivision_surface_in, geo_node_subdivision_surface_out); ntype.geometry_node_execute = blender::nodes::geo_node_subdivision_surface_exec; + ntype.draw_buttons = geo_node_subdivision_surface_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc index c224731ad9f..32fa32a9f13 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc @@ -18,6 +18,9 @@ #include "RNA_enum_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "node_geometry_util.hh" extern "C" { @@ -39,6 +42,12 @@ static bNodeSocketTemplate geo_node_triangulate_out[] = { {-1, ""}, }; +static void geo_node_triangulate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "quad_method", 0, "", ICON_NONE); + uiItemR(layout, ptr, "ngon_method", 0, "", ICON_NONE); +} + static void geo_triangulate_init(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = GEO_NODE_TRIANGULATE_QUAD_SHORTEDGE; @@ -75,5 +84,6 @@ void register_node_type_geo_triangulate() node_type_socket_templates(&ntype, geo_node_triangulate_in, geo_node_triangulate_out); node_type_init(&ntype, geo_triangulate_init); ntype.geometry_node_execute = blender::nodes::geo_node_triangulate_exec; + ntype.draw_buttons = geo_node_triangulate_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index b1d1430bccd..54dccb613a1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -31,6 +31,9 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + static bNodeSocketTemplate geo_node_volume_to_mesh_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Grid")}, @@ -46,6 +49,13 @@ static bNodeSocketTemplate geo_node_volume_to_mesh_out[] = { {-1, ""}, }; +static void geo_node_volume_to_mesh_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayoutSetPropSep(layout, true); + uiLayoutSetPropDecorate(layout, false); + uiItemR(layout, ptr, "resolution_mode", 0, IFACE_("Resolution"), ICON_NONE); +} + namespace blender::nodes { static void geo_node_volume_to_mesh_init(bNodeTree *UNUSED(ntree), bNode *node) @@ -156,5 +166,6 @@ void register_node_type_geo_volume_to_mesh() node_type_init(&ntype, blender::nodes::geo_node_volume_to_mesh_init); node_type_update(&ntype, blender::nodes::geo_node_volume_to_mesh_update); ntype.geometry_node_execute = blender::nodes::geo_node_volume_to_mesh_exec; + ntype.draw_buttons = geo_node_volume_to_mesh_layout; nodeRegisterType(&ntype); } |