diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2021-07-18 14:14:23 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2021-07-18 14:14:23 +0300 |
commit | ca50a1f762703d477ee84cf494dec601fd540299 (patch) | |
tree | fbd86a77e77015d7cc6becc1255a63e436a45b2a /intern/cycles/util | |
parent | d35969a74ff7a71fc0ca233ae65a2f1c47eb9a25 (diff) | |
parent | e82c5c660778b3805f50f3f2901923692c17db2a (diff) |
Merge branch 'master' into geometry-nodes-unnamed-attributesgeometry-nodes-unnamed-attributes
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_openvdb.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/intern/cycles/util/util_openvdb.h b/intern/cycles/util/util_openvdb.h index a3ebb03e5a4..ae5326e3199 100644 --- a/intern/cycles/util/util_openvdb.h +++ b/intern/cycles/util/util_openvdb.h @@ -25,6 +25,42 @@ namespace openvdb { using Vec4fTree = tree::Tree4<Vec4f, 5, 4, 3>::Type; using Vec4fGrid = Grid<Vec4fTree>; +/* Apply operation to known grid types. */ +template<typename OpType> +bool grid_type_operation(const openvdb::GridBase::ConstPtr &grid, OpType &&op) +{ + if (grid->isType<openvdb::FloatGrid>()) { + return op.template operator()<openvdb::FloatGrid, openvdb::FloatGrid, float, 1>(grid); + } + else if (grid->isType<openvdb::Vec3fGrid>()) { + return op.template operator()<openvdb::Vec3fGrid, openvdb::Vec3fGrid, openvdb::Vec3f, 3>(grid); + } + else if (grid->isType<openvdb::BoolGrid>()) { + return op.template operator()<openvdb::BoolGrid, openvdb::FloatGrid, float, 1>(grid); + } + else if (grid->isType<openvdb::DoubleGrid>()) { + return op.template operator()<openvdb::DoubleGrid, openvdb::FloatGrid, float, 1>(grid); + } + else if (grid->isType<openvdb::Int32Grid>()) { + return op.template operator()<openvdb::Int32Grid, openvdb::FloatGrid, float, 1>(grid); + } + else if (grid->isType<openvdb::Int64Grid>()) { + return op.template operator()<openvdb::Int64Grid, openvdb::FloatGrid, float, 1>(grid); + } + else if (grid->isType<openvdb::Vec3IGrid>()) { + return op.template operator()<openvdb::Vec3IGrid, openvdb::Vec3fGrid, openvdb::Vec3f, 3>(grid); + } + else if (grid->isType<openvdb::Vec3dGrid>()) { + return op.template operator()<openvdb::Vec3dGrid, openvdb::Vec3fGrid, openvdb::Vec3f, 3>(grid); + } + else if (grid->isType<openvdb::MaskGrid>()) { + return op.template operator()<openvdb::MaskGrid, openvdb::FloatGrid, float, 1>(grid); + } + else { + return false; + } +} + }; // namespace openvdb #endif |