Blender V4.3
node_geo_mesh_to_sdf_grid.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_mesh.hh"
6#include "BKE_volume_grid.hh"
7
9
10#include "node_geometry_util.hh"
11
13
15{
16 b.add_input<decl::Geometry>("Mesh").supported_type(GeometryComponent::Type::Mesh);
17 b.add_input<decl::Float>("Voxel Size")
18 .default_value(0.3f)
19 .min(0.01f)
20 .max(FLT_MAX)
22 b.add_input<decl::Int>("Band Width")
23 .default_value(3)
24 .min(1)
25 .max(100)
26 .description("Width of the active voxel surface, in voxels");
27 b.add_output<decl::Float>("SDF Grid");
28}
29
31{
32#ifdef WITH_OPENVDB
33 const GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh");
34 const Mesh *mesh = geometry_set.get_mesh();
35 if (!mesh || mesh->faces_num == 0) {
36 params.set_default_remaining_outputs();
37 return;
38 }
39 bke::VolumeGrid<float> grid = geometry::mesh_to_sdf_grid(
40 mesh->vert_positions(),
41 mesh->corner_verts(),
42 mesh->corner_tris(),
43 params.extract_input<float>("Voxel Size"),
44 std::max(1, params.extract_input<int>("Band Width")));
45 params.set_output("SDF Grid", std::move(grid));
46#else
48#endif
49}
50
51static void node_register()
52{
53 static blender::bke::bNodeType ntype;
54
55 geo_node_type_base(&ntype, GEO_NODE_MESH_TO_SDF_GRID, "Mesh to SDF Grid", NODE_CLASS_GEOMETRY);
56 ntype.declare = node_declare;
60}
62
63} // namespace blender::nodes::node_geo_mesh_to_sdf_grid_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:418
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_DISTANCE
Definition RNA_types.hh:159
local_group_size(16, 16) .push_constant(Type b
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
void search_link_ops_for_volume_grid_node(GatherLinkSearchOpParams &params)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams &params)
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
#define FLT_MAX
Definition stdcycles.h:14
const Mesh * get_mesh() const
Defines a node type.
Definition BKE_node.hh:218
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:339
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:363
NodeDeclareFunction declare
Definition BKE_node.hh:347