[Bf-blender-cvs] [b7225df456b] geometry-nodes-level-set-nodes: Add volume grid "to_static_type" utility

Hans Goudey noreply at git.blender.org
Fri Aug 13 22:09:27 CEST 2021


Commit: b7225df456bf9daa1df19fef1e94601a58c016e5
Author: Hans Goudey
Date:   Thu Aug 5 23:52:52 2021 -0500
Branches: geometry-nodes-level-set-nodes
https://developer.blender.org/rBb7225df456bf9daa1df19fef1e94601a58c016e5

Add volume grid "to_static_type" utility

===================================================================

M	source/blender/blenkernel/BKE_volume.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h
index b53903af491..26e5b26ed87 100644
--- a/source/blender/blenkernel/BKE_volume.h
+++ b/source/blender/blenkernel/BKE_volume.h
@@ -187,6 +187,49 @@ openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *vo
 
 VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase &grid);
 
+namespace blender::bke::volume {
+
+template<typename Func>
+inline void to_static_type(const VolumeGridType data_type, const Func &func)
+{
+  switch (data_type) {
+    case VOLUME_GRID_FLOAT:
+      func(openvdb::FloatGrid());
+      break;
+    case VOLUME_GRID_VECTOR_FLOAT:
+      func(openvdb::Vec3fGrid());
+      break;
+    case VOLUME_GRID_BOOLEAN:
+      func(openvdb::BoolGrid());
+      break;
+    case VOLUME_GRID_DOUBLE:
+      func(openvdb::DoubleGrid());
+      break;
+    case VOLUME_GRID_INT:
+      func(openvdb::Int32Grid());
+      break;
+    case VOLUME_GRID_VECTOR_INT:
+      func(openvdb::Vec3IGrid());
+      break;
+    case VOLUME_GRID_VECTOR_DOUBLE:
+      func(openvdb::Vec3dGrid());
+      break;
+    case VOLUME_GRID_STRING:
+      func(openvdb::StringGrid());
+      break;
+    case VOLUME_GRID_MASK:
+      func(openvdb::MaskGrid());
+      break;
+    case VOLUME_GRID_POINTS:
+      func(openvdb::points::PointDataGrid());
+      break;
+    default:
+      BLI_assert_unreachable();
+      break;
+  }
+}
+}  // namespace blender::bke::volume
+
 template<typename OpType>
 auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op)
 {



More information about the Bf-blender-cvs mailing list