Blender V5.0
node_geo_grid_curl.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_volume_grid.hh"
6
8
9#ifdef WITH_OPENVDB
10# include "openvdb/tools/GridOperators.h"
11#endif
12
14
16{
17 b.add_input<decl::Vector>("Grid").hide_value().structure_type(StructureType::Grid);
18 b.add_output<decl::Vector>("Curl").structure_type(StructureType::Grid);
19}
20
22{
23#ifdef WITH_OPENVDB
24 const bke::VolumeGrid<float3> grid = params.extract_input<bke::VolumeGrid<float3>>("Grid");
25 if (!grid) {
26 params.set_default_remaining_outputs();
27 return;
28 }
29 bke::VolumeTreeAccessToken tree_token;
30 const openvdb::Vec3SGrid &vdb_grid = grid.grid(tree_token);
31 openvdb::Vec3SGrid::Ptr curl_vdb_grid = openvdb::tools::curl(vdb_grid);
32 params.set_output("Curl", bke::VolumeGrid<float3>(std::move(curl_vdb_grid)));
33#else
35#endif
36}
37
38static void node_register()
39{
40 static blender::bke::bNodeType ntype;
41 geo_node_type_base(&ntype, "GeometryNodeGridCurl");
42 ntype.ui_name = "Grid Curl";
43 ntype.ui_description =
44 "Calculate the magnitude and direction of circulation of a directional vector grid";
46 ntype.declare = node_declare;
49}
51
52} // namespace blender::nodes::node_geo_grid_curl_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:461
#define NOD_REGISTER_NODE(REGISTER_FUNC)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
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)
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
NodeDeclareFunction declare
Definition BKE_node.hh:362