6# include <openvdb/openvdb.h>
7# include <openvdb/tools/LevelSetUtil.h>
8# include <openvdb/tools/ParticlesToLevelSet.h>
25static void gather_point_data_from_component(
Field<float> radius_field,
38 r_positions.
resize(r_positions.
size() + domain_num);
47static float compute_voxel_size_from_amount(
const float voxel_amount,
55 if (voxel_amount <= 1) {
63 const float extended_diagonal = diagonal + 2.0f * radius;
64 const float voxel_size = extended_diagonal / voxel_amount;
80 GeometryComponent::Type::PointCloud,
81 GeometryComponent::Type::Curve})
83 if (r_geometry_set.
has(type)) {
84 gather_point_data_from_component(
85 radius_field, *r_geometry_set.
get_component(type), positions, radii);
96 float voxel_size = 0.0f;
98 voxel_size =
params.get_input<
float>(
"Voxel Size");
101 const float voxel_amount =
params.get_input<
float>(
"Voxel Amount");
102 const float max_radius = *std::max_element(radii.
begin(), radii.
end());
103 voxel_size = compute_voxel_size_from_amount(voxel_amount, positions, max_radius);
115 const float density =
params.get_input<
float>(
"Density");
116 blender::geometry::fog_volume_grid_add_from_points(
117 volume,
"density", positions, radii, voxel_size, density);
119 r_geometry_set.
keep_only({GeometryComponent::Type::Volume, GeometryComponent::Type::Edit});
132 N_(
"Specify the approximate number of voxels along the diagonal")},
138 N_(
"Specify the voxel side length")},
139 {0,
nullptr, 0,
nullptr,
nullptr},
145 "Points which are converted to a volume");
146 b.add_input<
decl::Float>(
"Density").default_value(1.0f).min(0.0f);
150 .description(
"How the voxel size is specified")
158 .default_value(64.0f)
180 initialize_volume_component_from_points(
params, geometry_set);
182 params.set_output(
"Volume", std::move(geometry_set));
193 ntype.
ui_name =
"Points to Volume";
194 ntype.
ui_description =
"Generate a fog volume sphere around every point";
void * BKE_id_new_nomain(short type, const char *name)
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_POINTS_TO_VOLUME
bool BKE_volume_voxel_size_valid(const blender::float3 &voxel_size)
#define BLI_assert_msg(a, msg)
#define CTX_N_(context, msgid)
#define BLT_I18NCONTEXT_ID_ID
#define BLT_I18NCONTEXT_COUNTABLE
GeometryNodePointsToVolumeResolutionMode
@ GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT
@ GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_SIZE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr bool is_empty() const
void materialize(MutableSpan< T > r_span) const
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
int attribute_domain_size(AttrDomain domain) const
virtual std::optional< AttributeAccessor > attributes() const
virtual bool is_empty() const
int add_with_destination(GField field, GVMutableArray dst)
void * MEM_callocN(size_t len, const char *str)
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
std::optional< Bounds< T > > min_max(const std::optional< Bounds< T > > &a, const T &b)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
T distance(const T &a, const T &b)
static EnumPropertyItem resolution_mode_items[]
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *, bNode *node)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void replace_volume(Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void keep_only(Span< GeometryComponent::Type > component_types)
bool has(const GeometryComponent::Type component_type) const
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
NodeDeclareFunction declare