Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-10-31 01:26:18 +0300
committerHans Goudey <h.goudey@me.com>2021-10-31 01:26:18 +0300
commitae9052a33e646376b199be44eac26ca5dbe30e87 (patch)
treee9d433724514c0cd39ca54f2dc422454bfc54a91 /source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
parent9cfffe84681bfa4dd43d0d2338feabf2ad9cfd29 (diff)
Cleanup: Simplify logic for adding grid in points to volume node
Instead of creating a separate grid first and then merging the points to volume grid, use the recently added `BKE_volume_grid_add_vdb` helper function for this purpose.
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc10
1 files changed, 3 insertions, 7 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
index 312ea7df919..18d674a38a4 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
@@ -222,16 +222,12 @@ static void initialize_volume_component_from_points(GeoNodeExecParams &params,
Volume *volume = (Volume *)BKE_id_new_nomain(ID_VO, nullptr);
BKE_volume_init_grids(volume);
- VolumeGrid *c_density_grid = BKE_volume_grid_add(volume, "density", VOLUME_GRID_FLOAT);
- openvdb::FloatGrid::Ptr density_grid = openvdb::gridPtrCast<openvdb::FloatGrid>(
- BKE_volume_grid_openvdb_for_write(volume, c_density_grid, false));
-
const float density = params.get_input<float>("Density");
convert_to_grid_index_space(voxel_size, positions, radii);
openvdb::FloatGrid::Ptr new_grid = generate_volume_from_points(positions, radii, density);
- /* This merge is cheap, because the #density_grid is empty. */
- density_grid->merge(*new_grid);
- density_grid->transform().postScale(voxel_size);
+ new_grid->transform().postScale(voxel_size);
+ BKE_volume_grid_add_vdb(*volume, "density", std::move(new_grid));
+
r_geometry_set.keep_only({GEO_COMPONENT_TYPE_VOLUME, GEO_COMPONENT_TYPE_INSTANCES});
r_geometry_set.replace_volume(volume);
}