diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-20 19:56:30 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-20 19:56:30 +0300 |
commit | 32a4c7f188826d649b231b39baa1c1bcb7cbcbdc (patch) | |
tree | 7c1d2936c2ef0be17f202286db31c196aab6a691 /source | |
parent | a79c33e8f8f3cac25459b703f3ad21f4eabb4455 (diff) |
Geometry Nodes: implicit position input in Set Position node
This change makes the Set Position node do nothing by default.
Before, the geometry would always disappear, because it all points
would be moved to (0, 0, 0).
Differential Revision: https://developer.blender.org/D12553
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes_evaluator.cc | 11 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_set_position.cc | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc index f67f7f967c9..a215ad4d21a 100644 --- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc +++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc @@ -321,6 +321,17 @@ static const CPPType *get_socket_cpp_type(const DSocket socket) static void get_socket_value(const SocketRef &socket, void *r_value) { + const bNodeSocket &bsocket = *socket.bsocket(); + /* This is not supposed to be a long term solution. Eventually we want that nodes can specify + * more complex defaults (other than just single values) in their socket declarations. */ + if (bsocket.flag & SOCK_HIDE_VALUE) { + const bNode &bnode = *socket.bnode(); + if (bsocket.type == SOCK_VECTOR && bnode.type == GEO_NODE_SET_POSITION) { + new (r_value) Field<float3>( + std::make_shared<bke::AttributeFieldInput>("position", CPPType::get<float3>())); + return; + } + } const bNodeSocketType *typeinfo = socket.typeinfo(); typeinfo->get_geometry_nodes_cpp_value(*socket.bsocket(), r_value); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index 832db76e731..c5e10b788ac 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -23,7 +23,7 @@ namespace blender::nodes { static void geo_node_set_position_declare(NodeDeclarationBuilder &b) { b.add_input<decl::Geometry>("Geometry"); - b.add_input<decl::Vector>("Position"); + b.add_input<decl::Vector>("Position").hide_value(); b.add_input<decl::Bool>("Selection").default_value(true).hide_value(); b.add_output<decl::Geometry>("Geometry"); } |