Blender V4.3
BKE_volume_openvdb.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#ifdef WITH_OPENVDB
8
9# include <openvdb/openvdb.h>
10# include <openvdb/points/PointDataGrid.h>
11# include <optional>
12
13# include "BLI_bounds_types.hh"
16# include "BLI_string_ref.hh"
17
18# include "BKE_volume_enums.hh"
19
20struct Volume;
21
22blender::bke::VolumeGridData *BKE_volume_grid_add_vdb(Volume &volume,
24 openvdb::GridBase::Ptr vdb_grid);
25
26std::optional<blender::Bounds<blender::float3>> BKE_volume_grid_bounds(
27 openvdb::GridBase::ConstPtr grid);
28
34openvdb::GridBase::ConstPtr BKE_volume_grid_shallow_transform(openvdb::GridBase::ConstPtr grid,
35 const blender::float4x4 &transform);
36
37template<typename OpType>
38auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op)
39{
40 switch (grid_type) {
42 return op.template operator()<openvdb::FloatGrid>();
44 return op.template operator()<openvdb::Vec3fGrid>();
46 return op.template operator()<openvdb::BoolGrid>();
48 return op.template operator()<openvdb::DoubleGrid>();
49 case VOLUME_GRID_INT:
50 return op.template operator()<openvdb::Int32Grid>();
52 return op.template operator()<openvdb::Int64Grid>();
54 return op.template operator()<openvdb::Vec3IGrid>();
56 return op.template operator()<openvdb::Vec3dGrid>();
58 return op.template operator()<openvdb::MaskGrid>();
60 return op.template operator()<openvdb::points::PointDataGrid>();
62 break;
63 }
64
65 /* Should never be called. */
66 BLI_assert_msg(0, "should never be reached");
67 return op.template operator()<openvdb::FloatGrid>();
68}
69
70openvdb::GridBase::Ptr BKE_volume_grid_create_with_changed_resolution(
71 const VolumeGridType grid_type, const openvdb::GridBase &old_grid, float resolution_factor);
72
73#endif
VolumeGridType
@ VOLUME_GRID_VECTOR_FLOAT
@ VOLUME_GRID_MASK
@ VOLUME_GRID_VECTOR_DOUBLE
@ VOLUME_GRID_VECTOR_INT
@ VOLUME_GRID_UNKNOWN
@ VOLUME_GRID_DOUBLE
@ VOLUME_GRID_BOOLEAN
@ VOLUME_GRID_INT
@ VOLUME_GRID_INT64
@ VOLUME_GRID_POINTS
@ VOLUME_GRID_FLOAT
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57