diff options
author | Jacques Lucke <jacques@blender.org> | 2020-10-05 11:29:34 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-10-05 11:29:34 +0300 |
commit | a4f8b2ad7653cac8a5f7821ce7ee9af44b13a758 (patch) | |
tree | 73c8a83d11ea4461546648602234b0626c11367d /source/blender/blenkernel/BKE_volume.h | |
parent | 3e101759b1b726e3cc16c69b2619cd1d82b00a8e (diff) |
Volumes: more generic way to handle different openvdb types
Reviewers: brecht
Differential Revision: https://developer.blender.org/D9093
Diffstat (limited to 'source/blender/blenkernel/BKE_volume.h')
-rw-r--r-- | source/blender/blenkernel/BKE_volume.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h index 4481c1b4332..8e192aa7741 100644 --- a/source/blender/blenkernel/BKE_volume.h +++ b/source/blender/blenkernel/BKE_volume.h @@ -151,6 +151,8 @@ void BKE_volume_grid_remove(struct Volume *volume, struct VolumeGrid *grid); #if defined(__cplusplus) && defined(WITH_OPENVDB) # include <openvdb/openvdb.h> +# include <openvdb/points/PointDataGrid.h> + openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_metadata(const struct VolumeGrid *grid); openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const struct Volume *volume, struct VolumeGrid *grid); @@ -169,4 +171,39 @@ typename GridType::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *vo return typed_openvdb_grid; } +template<typename OpType> +auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op) +{ + switch (grid_type) { + case VOLUME_GRID_FLOAT: + return op.template operator()<openvdb::FloatGrid>(); + case VOLUME_GRID_VECTOR_FLOAT: + return op.template operator()<openvdb::Vec3fGrid>(); + case VOLUME_GRID_BOOLEAN: + return op.template operator()<openvdb::BoolGrid>(); + case VOLUME_GRID_DOUBLE: + return op.template operator()<openvdb::DoubleGrid>(); + case VOLUME_GRID_INT: + return op.template operator()<openvdb::Int32Grid>(); + case VOLUME_GRID_INT64: + return op.template operator()<openvdb::Int64Grid>(); + case VOLUME_GRID_VECTOR_INT: + return op.template operator()<openvdb::Vec3IGrid>(); + case VOLUME_GRID_VECTOR_DOUBLE: + return op.template operator()<openvdb::Vec3dGrid>(); + case VOLUME_GRID_STRING: + return op.template operator()<openvdb::StringGrid>(); + case VOLUME_GRID_MASK: + return op.template operator()<openvdb::MaskGrid>(); + case VOLUME_GRID_POINTS: + return op.template operator()<openvdb::points::PointDataGrid>(); + case VOLUME_GRID_UNKNOWN: + break; + } + + /* Should never be called. */ + BLI_assert(!"should never be reached"); + return op.template operator()<openvdb::FloatGrid>(); +} + #endif |