Geometry Nodes: Add 'Signed Distance' input node

Adds an input node Signed Distance that can
be used to refer to the distance-grid of an SDF volume.
Right now it's experimental and can be enabled by enabling
"New Volume Nodes" in the preferences.

It returns a float AttributeFieldInput called 'distance' which
can tell Volume nodes which grid to get.

See #103248.
This commit is contained in:
Erik Abrahamsson 2023-05-11 18:25:34 +02:00
parent 8a9f3b2a68
commit 36983fb5e4
7 changed files with 55 additions and 0 deletions

View File

@ -614,6 +614,7 @@ class NODE_MT_category_GEO_VOLUME(Menu):
node_add_menu.add_node_type(layout, "GeometryNodeMeanFilterSDFVolume")
node_add_menu.add_node_type(layout, "GeometryNodeOffsetSDFVolume")
node_add_menu.add_node_type(layout, "GeometryNodeSDFVolumeSphere")
node_add_menu.add_node_type(layout, "GeometryNodeInputSignedDistance")
node_add_menu.draw_assets_for_catalog(layout, self.bl_label)

View File

@ -1587,6 +1587,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
/* Function nodes use the range starting at 1200. */
#define GEO_NODE_SIMULATION_INPUT 2100
#define GEO_NODE_SIMULATION_OUTPUT 2101
#define GEO_NODE_INPUT_SIGNED_DISTANCE 2102
/** \} */

View File

@ -349,6 +349,7 @@ DefNode(GeometryNode, GEO_NODE_INPUT_RADIUS, 0, "INPUT_RADIUS", InputRadius, "Ra
DefNode(GeometryNode, GEO_NODE_INPUT_SCENE_TIME, 0, "INPUT_SCENE_TIME", InputSceneTime, "Scene Time", "Retrieve the current time in the scene's animation in units of seconds or frames")
DefNode(GeometryNode, GEO_NODE_INPUT_SHADE_SMOOTH, 0, "INPUT_SHADE_SMOOTH", InputShadeSmooth, "Is Shade Smooth", "Retrieve whether each face is marked for smooth shading")
DefNode(GeometryNode, GEO_NODE_INPUT_SHORTEST_EDGE_PATHS, 0, "SHORTEST_EDGE_PATHS", InputShortestEdgePaths, "Shortest Edge Paths", "")
DefNode(GeometryNode, GEO_NODE_INPUT_SIGNED_DISTANCE, 0, "SIGNED_DISTANCE", InputSignedDistance, "Signed Distance", "Retrieve the signed distance field grid called 'distance' from a volume")
DefNode(GeometryNode, GEO_NODE_INPUT_SPLINE_CYCLIC, 0, "INPUT_SPLINE_CYCLIC",InputSplineCyclic, "Is Spline Cyclic", "Retrieve whether each spline endpoint connects to the beginning")
DefNode(GeometryNode, GEO_NODE_INPUT_SPLINE_LENGTH, 0, "SPLINE_LENGTH", SplineLength, "Spline Length", "Retrieve the total length of each spline, as a distance or as a number of points")
DefNode(GeometryNode, GEO_NODE_INPUT_SPLINE_RESOLUTION, 0, "INPUT_SPLINE_RESOLUTION", InputSplineResolution, "Spline Resolution", "Retrieve the number of evaluated points that will be generated for every control point on curves")

View File

@ -102,6 +102,7 @@ set(SRC
nodes/node_geo_input_scene_time.cc
nodes/node_geo_input_shade_smooth.cc
nodes/node_geo_input_shortest_edge_paths.cc
nodes/node_geo_input_signed_distance.cc
nodes/node_geo_input_spline_cyclic.cc
nodes/node_geo_input_spline_length.cc
nodes/node_geo_input_spline_resolution.cc

View File

@ -86,6 +86,7 @@ void register_geometry_nodes()
register_node_type_geo_input_scene_time();
register_node_type_geo_input_shade_smooth();
register_node_type_geo_input_shortest_edge_paths();
register_node_type_geo_input_signed_distance();
register_node_type_geo_input_spline_cyclic();
register_node_type_geo_input_spline_length();
register_node_type_geo_input_spline_resolution();

View File

@ -83,6 +83,7 @@ void register_node_type_geo_input_radius();
void register_node_type_geo_input_scene_time();
void register_node_type_geo_input_shade_smooth();
void register_node_type_geo_input_shortest_edge_paths();
void register_node_type_geo_input_signed_distance();
void register_node_type_geo_input_spline_cyclic();
void register_node_type_geo_input_spline_length();
void register_node_type_geo_input_spline_resolution();

View File

@ -0,0 +1,49 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_input_signed_distance_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Float>(N_("Signed Distance")).field_source();
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_node_add_ops_for_basic_node(params);
}
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_link_ops_for_basic_node(params);
}
}
static void node_geo_exec(GeoNodeExecParams params)
{
Field<float> signed_distance_field{AttributeFieldInput::Create<float>("distance")};
params.set_output("Signed Distance", std::move(signed_distance_field));
}
} // namespace blender::nodes::node_geo_input_signed_distance_cc
void register_node_type_geo_input_signed_distance()
{
namespace file_ns = blender::nodes::node_geo_input_signed_distance_cc;
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_INPUT_SIGNED_DISTANCE, "Signed Distance", NODE_CLASS_INPUT);
ntype.geometry_node_execute = file_ns::node_geo_exec;
ntype.declare = file_ns::node_declare;
ntype.gather_add_node_search_ops = file_ns::search_node_add_ops;
ntype.gather_link_search_ops = file_ns::search_link_ops;
nodeRegisterType(&ntype);
}