Blender V5.0
node_geo_input_voxel_index.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
6
8
10
12{
13 b.use_custom_socket_order();
14 b.allow_any_socket_order();
15 b.add_output<decl::Int>("X").field_source().description(
16 "X coordinate of the voxel in index space, or the minimum X coordinate of a tile");
17 b.add_output<decl::Int>("Y").field_source().description(
18 "Y coordinate of the voxel in index space, or the minimum Y coordinate of a tile");
19 b.add_output<decl::Int>("Z").field_source().description(
20 "Z coordinate of the voxel in index space, or the minimum Z coordinate of a tile");
21 auto &panel = b.add_panel("Tile").default_closed(true);
22 panel.add_output<decl::Bool>("Is Tile").field_source().description(
23 "True if the field is evaluated on a tile, i.e. on multiple voxels at once. If this is "
24 "false, the extent is always 1");
25 panel.add_output<decl::Int>("Extent X")
26 .field_source()
28 "Number of voxels in the X direction of the tile, or 1 if the field is evaluated on a "
29 "voxel");
30 panel.add_output<decl::Int>("Extent Y")
31 .field_source()
33 "Number of voxels in the Y direction of the tile, or 1 if the field is evaluated on a "
34 "voxel");
35 panel.add_output<decl::Int>("Extent Z")
36 .field_source()
38 "Number of voxels in the Z direction of the tile, or 1 if the field is evaluated on a "
39 "voxel");
40}
41
43{
44#ifdef WITH_OPENVDB
45 if (params.output_is_required("X")) {
46 params.set_output("X",
47 fn::GField(std::make_shared<bke::VoxelCoordinateFieldInput>(math::Axis::X)));
48 }
49 if (params.output_is_required("Y")) {
50 params.set_output("Y",
51 fn::GField(std::make_shared<bke::VoxelCoordinateFieldInput>(math::Axis::Y)));
52 }
53 if (params.output_is_required("Z")) {
54 params.set_output("Z",
55 fn::GField(std::make_shared<bke::VoxelCoordinateFieldInput>(math::Axis::Z)));
56 }
57 if (params.output_is_required("Is Tile")) {
58 params.set_output("Is Tile", fn::GField(std::make_shared<bke::IsTileFieldInput>()));
59 }
60 if (params.output_is_required("Extent X")) {
61 params.set_output("Extent X",
62 fn::GField(std::make_shared<bke::VoxelExtentFieldInput>(math::Axis::X)));
63 }
64 if (params.output_is_required("Extent Y")) {
65 params.set_output("Extent Y",
66 fn::GField(std::make_shared<bke::VoxelExtentFieldInput>(math::Axis::Y)));
67 }
68 if (params.output_is_required("Extent Z")) {
69 params.set_output("Extent Z",
70 fn::GField(std::make_shared<bke::VoxelExtentFieldInput>(math::Axis::Z)));
71 }
72#else
74#endif
75}
76
77static void node_register()
78{
79 static blender::bke::bNodeType ntype;
80
81 geo_node_type_base(&ntype, "GeometryNodeInputVoxelIndex");
82 ntype.ui_name = "Voxel Index";
83 ntype.ui_description =
84 "Retrieve the integer coordinates of the voxel that the field is evaluated on";
87 ntype.declare = node_declare;
89}
91
92} // namespace blender::nodes::node_geo_input_voxel_index_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static constexpr Value Z
static constexpr Value X
static constexpr Value Y
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