Blender V5.0
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 "DNA_mesh_types.h"
6
7#include "BKE_material.hh"
8#include "BKE_volume_grid.hh"
10
11#include "GEO_randomize.hh"
12
13#include "node_geometry_util.hh"
14
16
18{
19 b.add_input<decl::Float>("Grid").hide_value().structure_type(StructureType::Grid);
20 b.add_input<decl::Float>("Threshold")
21 .default_value(0.1f)
22 .description("Values larger than the threshold are inside the generated mesh");
23 b.add_input<decl::Float>("Adaptivity").min(0.0f).max(1.0f).subtype(PROP_FACTOR);
24 b.add_output<decl::Geometry>("Mesh");
25}
26
28{
29#ifdef WITH_OPENVDB
30 const bke::VolumeGrid<float> grid = params.extract_input<bke::VolumeGrid<float>>("Grid");
31 if (!grid) {
32 params.set_default_remaining_outputs();
33 return;
34 }
35 bke::VolumeTreeAccessToken tree_token;
36 Mesh *mesh = bke::volume_grid_to_mesh(grid.get().grid(tree_token),
37 params.extract_input<float>("Threshold"),
38 params.extract_input<float>("Adaptivity"));
41 params.set_output("Mesh", GeometrySet::from_mesh(mesh));
42#else
44#endif
45}
46
47static void node_register()
48{
49 static blender::bke::bNodeType ntype;
50
51 geo_node_type_base(&ntype, "GeometryNodeGridToMesh", GEO_NODE_GRID_TO_MESH);
52 ntype.ui_name = "Grid to Mesh";
53 ntype.ui_description = "Generate a mesh on the \"surface\" of a volume grid";
54 ntype.enum_name_legacy = "GRID_TO_MESH";
56 ntype.declare = node_declare;
59}
61
62} // namespace blender::nodes::node_geo_grid_to_mesh_cc
General operations, lookup, etc. for materials.
void BKE_id_material_eval_ensure_default_slot(ID *id)
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:461
#define GEO_NODE_GRID_TO_MESH
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_FACTOR
Definition RNA_types.hh:251
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void debug_randomize_mesh_order(Mesh *mesh)
Definition randomize.cc:288
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams &params)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
#define min(a, b)
Definition sort.cc:36
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)