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
This commit is contained in:
Jacques Lucke 2021-09-20 18:56:30 +02:00
parent a79c33e8f8
commit 32a4c7f188
2 changed files with 12 additions and 1 deletions

View File

@ -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);
}

View File

@ -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");
}