diff options
author | Hans Goudey <h.goudey@me.com> | 2021-01-11 21:06:52 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-01-11 21:06:52 +0300 |
commit | ecdbd83a8d30b982c4280f0dbd8ed821c657fa25 (patch) | |
tree | 9ecb883d232d9b18d44af4451b20aacb3fda7207 /source/blender/editors/space_node | |
parent | 5bd822dc46f60da4b7de125f2d559fa16d781787 (diff) |
Geometry Nodes: Attribute Vector Math Node
This patch implements the same operations and interface as the regular
vector math node, but it runs for every element of the attribute. This
should expand what's possible with geometry nodes quite a bit.
Differential Revision: https://developer.blender.org/D9914
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 4b5ba2af050..74ce0d713bf 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3228,6 +3228,35 @@ static void node_geometry_buts_attribute_math(uiLayout *layout, uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE); } +static void node_geometry_buts_attribute_vector_math(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + NodeAttributeVectorMath *node_storage = (NodeAttributeVectorMath *)node->storage; + + uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE); + uiItemR(layout, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE); + + /* These "use input b / c" checks are copied from the node's code. They could be deduplicated if + * the drawing code was moved to the node's file. */ + if (!ELEM(node_storage->operation, + NODE_VECTOR_MATH_NORMALIZE, + NODE_VECTOR_MATH_FLOOR, + NODE_VECTOR_MATH_CEIL, + NODE_VECTOR_MATH_FRACTION, + NODE_VECTOR_MATH_ABSOLUTE, + NODE_VECTOR_MATH_SINE, + NODE_VECTOR_MATH_COSINE, + NODE_VECTOR_MATH_TANGENT, + NODE_VECTOR_MATH_LENGTH)) { + uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE); + } + if (ELEM(node_storage->operation, NODE_VECTOR_MATH_WRAP)) { + uiItemR(layout, ptr, "input_type_c", DEFAULT_FLAGS, IFACE_("Type C"), ICON_NONE); + } +} + static void node_geometry_buts_point_instance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -3320,6 +3349,9 @@ static void node_geometry_set_butfunc(bNodeType *ntype) case GEO_NODE_ATTRIBUTE_MIX: ntype->draw_buttons = node_geometry_buts_attribute_mix; break; + case GEO_NODE_ATTRIBUTE_VECTOR_MATH: + ntype->draw_buttons = node_geometry_buts_attribute_vector_math; + break; case GEO_NODE_POINT_DISTRIBUTE: ntype->draw_buttons = node_geometry_buts_attribute_point_distribute; break; |