Blender V4.3
node_geo_grid_to_mesh.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_material.h"
6#include "BKE_mesh.h"
7#include "BKE_volume_grid.hh"
9
10#include "GEO_randomize.hh"
11
12#include "node_geometry_util.hh"
13
15
17{
18 b.add_input<decl::Float>("Grid").hide_value();
19 b.add_input<decl::Float>("Threshold")
20 .default_value(0.1f)
21 .description("Values larger than the threshold are inside the generated mesh");
22 b.add_input<decl::Float>("Adaptivity").min(0.0f).max(1.0f).subtype(PROP_FACTOR);
23 b.add_output<decl::Geometry>("Mesh");
24}
25
27{
28#ifdef WITH_OPENVDB
29 const bke::VolumeGrid<float> grid = params.extract_input<bke::VolumeGrid<float>>("Grid");
30 if (!grid) {
31 params.set_default_remaining_outputs();
32 return;
33 }
34 bke::VolumeTreeAccessToken tree_token;
35 Mesh *mesh = bke::volume_grid_to_mesh(grid.get().grid(tree_token),
36 params.extract_input<float>("Threshold"),
37 params.extract_input<float>("Adaptivity"));
40 params.set_output("Mesh", GeometrySet::from_mesh(mesh));
41#else
43#endif
44}
45
46static void node_register()
47{
48 static blender::bke::bNodeType ntype;
49
50 geo_node_type_base(&ntype, GEO_NODE_GRID_TO_MESH, "Grid to Mesh", NODE_CLASS_GEOMETRY);
51 ntype.declare = node_declare;
55}
57
58} // namespace blender::nodes::node_geo_grid_to_mesh_cc
General operations, lookup, etc. for materials.
void BKE_id_material_eval_ensure_default_slot(struct ID *id)
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:418
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_FACTOR
Definition RNA_types.hh:154
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
void debug_randomize_mesh_order(Mesh *mesh)
Definition randomize.cc:220
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 min(a, b)
Definition sort.c:32
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
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