From 63a9f24b55d0b5d84d625bdbb44d498fb1f2ae01 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 20 Oct 2020 11:00:16 +0200 Subject: Volumes: simplify volumes in modifiers or on load This changes how the simplify volumes setting works. Before, it only affeted viewport rendering. This was an issue, because all internal computations would still have to happen on the high resolution volumes. With this patch, the simplify setting already affects file loading and procedural generation of volumes. Rendering does not have to care about the simplify option anymore, it just gets the correct simplified version from the depsgraph. Reviewers: brecht Differential Revision: https://developer.blender.org/D9176 --- source/blender/blenkernel/BKE_volume.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/BKE_volume.h') diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h index 2a272d06986..12c37ec56e0 100644 --- a/source/blender/blenkernel/BKE_volume.h +++ b/source/blender/blenkernel/BKE_volume.h @@ -140,6 +140,10 @@ struct VolumeGrid *BKE_volume_grid_add(struct Volume *volume, VolumeGridType type); void BKE_volume_grid_remove(struct Volume *volume, struct VolumeGrid *grid); +/* Simplify */ +int BKE_volume_simplify_level(const struct Depsgraph *depsgraph); +float BKE_volume_simplify_factor(const struct Depsgraph *depsgraph); + /* File Save */ bool BKE_volume_save(struct Volume *volume, struct Main *bmain, @@ -166,16 +170,7 @@ openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *vo struct VolumeGrid *grid, const bool clear); -template -typename GridType::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *volume, - struct VolumeGrid *grid, - const bool clear) -{ - openvdb::GridBase::Ptr openvdb_grid = BKE_volume_grid_openvdb_for_write(volume, grid, clear); - BLI_assert(openvdb_grid->isType()); - typename GridType::Ptr typed_openvdb_grid = openvdb::gridPtrCast(openvdb_grid); - return typed_openvdb_grid; -} +VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase::Ptr &grid); template auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op) @@ -212,4 +207,9 @@ auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op) return op.template operator()(); } +openvdb::GridBase::Ptr BKE_volume_grid_create_with_changed_resolution( + const VolumeGridType grid_type, + const openvdb::GridBase &old_grid, + const float resolution_factor); + #endif -- cgit v1.2.3