Geometry Nodes: Use multi-input socket in join geometry node

This updates the join node to use the new multi-input socket from D10067.
The change just requires slightly changing the arguments of the exec
function, and changing the socket input list.

Note that this commit does not contain the UI changes, it only allows for
more input links, and combines the two sockets into one. The UI changes
will come next.

Reviewed By: Hans Goudey

Differential Revision: https://developer.blender.org/D10069
This commit is contained in:
Fabian Schempp 2021-02-11 00:23:15 -06:00 committed by Hans Goudey
parent faad487b58
commit 9a9e19fdcc
3 changed files with 45 additions and 15 deletions

View File

@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 6
#define BLENDER_FILE_SUBVERSION 7
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file

View File

@ -735,6 +735,23 @@ static void version_node_socket_name(bNodeTree *ntree,
}
}
static void version_node_join_geometry_for_multi_input_socket(bNodeTree *ntree)
{
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
if (link->tonode->type == GEO_NODE_JOIN_GEOMETRY && !(link->tosock->flag & SOCK_MULTI_INPUT)) {
link->tosock = link->tonode->inputs.first;
}
}
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == GEO_NODE_JOIN_GEOMETRY) {
bNodeSocket *socket = node->inputs.first;
socket->flag |= SOCK_MULTI_INPUT;
socket->limit = 4095;
nodeRemoveSocket(ntree, node, socket->next);
}
}
}
/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
@ -1679,6 +1696,14 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 293, 7)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_GEOMETRY) {
version_node_join_geometry_for_multi_input_socket(ntree);
}
}
FOREACH_NODETREE_END;
}
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -24,8 +24,16 @@
#include "node_geometry_util.hh"
static bNodeSocketTemplate geo_node_join_geometry_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{SOCK_GEOMETRY, N_("Geometry")},
{SOCK_GEOMETRY,
N_("Geometry"),
0.0f,
0.0f,
0.0f,
1.0f,
-1.0f,
1.0f,
PROP_NONE,
SOCK_MULTI_INPUT},
{-1, ""},
};
@ -252,11 +260,11 @@ static void join_components(Span<const VolumeComponent *> src_components, Geomet
}
template<typename Component>
static void join_component_type(Span<const GeometrySet *> src_geometry_sets, GeometrySet &result)
static void join_component_type(Span<GeometrySet> src_geometry_sets, GeometrySet &result)
{
Vector<const Component *> components;
for (const GeometrySet *geometry_set : src_geometry_sets) {
const Component *component = geometry_set->get_component_for_read<Component>();
for (const GeometrySet &geometry_set : src_geometry_sets) {
const Component *component = geometry_set.get_component_for_read<Component>();
if (component != nullptr && !component->is_empty()) {
components.append(component);
}
@ -274,16 +282,13 @@ static void join_component_type(Span<const GeometrySet *> src_geometry_sets, Geo
static void geo_node_join_geometry_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set_a = params.extract_input<GeometrySet>("Geometry");
GeometrySet geometry_set_b = params.extract_input<GeometrySet>("Geometry_001");
Vector<GeometrySet> geometry_sets = params.extract_multi_input<GeometrySet>("Geometry");
GeometrySet geometry_set_result;
std::array<const GeometrySet *, 2> src_geometry_sets = {&geometry_set_a, &geometry_set_b};
join_component_type<MeshComponent>(src_geometry_sets, geometry_set_result);
join_component_type<PointCloudComponent>(src_geometry_sets, geometry_set_result);
join_component_type<InstancesComponent>(src_geometry_sets, geometry_set_result);
join_component_type<VolumeComponent>(src_geometry_sets, geometry_set_result);
join_component_type<MeshComponent>(geometry_sets, geometry_set_result);
join_component_type<PointCloudComponent>(geometry_sets, geometry_set_result);
join_component_type<InstancesComponent>(geometry_sets, geometry_set_result);
join_component_type<VolumeComponent>(geometry_sets, geometry_set_result);
params.set_output("Geometry", std::move(geometry_set_result));
}