Blender V5.0
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
8
9#pragma once
10
11#ifdef WITH_OPENVDB
12
13# include <openvdb/openvdb.h> /* IWYU pragma: export */
14# include <openvdb/points/PointDataGrid.h> /* IWYU pragma: export */
15# include <optional>
16
17# include "BLI_bounds_types.hh"
21# include "BLI_string_ref.hh"
22
23# include "BKE_volume_enums.hh"
24# include "BKE_volume_grid_fwd.hh"
25
26# include "openvdb_fwd.hh"
27
28struct Volume;
29
30blender::bke::VolumeGridData *BKE_volume_grid_add_vdb(Volume &volume,
32 openvdb::GridBase::Ptr vdb_grid);
33
34void BKE_volume_metadata_set(Volume &volume, openvdb::MetaMap::Ptr metadata);
35
36std::optional<blender::Bounds<blender::float3>> BKE_volume_grid_bounds(
37 openvdb::GridBase::ConstPtr grid);
38
44openvdb::GridBase::ConstPtr BKE_volume_grid_shallow_transform(openvdb::GridBase::ConstPtr grid,
46
47blender::float4x4 BKE_volume_transform_to_blender(const openvdb::math::Transform &transform);
48openvdb::math::Transform BKE_volume_transform_to_openvdb(const blender::float4x4 &transform);
49
50template<typename OpType>
51auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op)
52{
53 switch (grid_type) {
55 return op.template operator()<openvdb::FloatGrid>();
57 return op.template operator()<openvdb::Vec3fGrid>();
59 return op.template operator()<openvdb::BoolGrid>();
61 return op.template operator()<openvdb::DoubleGrid>();
62 case VOLUME_GRID_INT:
63 return op.template operator()<openvdb::Int32Grid>();
65 return op.template operator()<openvdb::Int64Grid>();
67 return op.template operator()<openvdb::Vec3IGrid>();
69 return op.template operator()<openvdb::Vec3dGrid>();
71 return op.template operator()<openvdb::MaskGrid>();
73 return op.template operator()<openvdb::points::PointDataGrid>();
75 break;
76 }
77
78 /* Should never be called. */
79 BLI_assert_msg(0, "should never be reached");
80 return op.template operator()<openvdb::FloatGrid>();
81}
82
83template<typename Fn>
84void BKE_volume_grid_type_to_static_type(const VolumeGridType grid_type, Fn &&fn)
85{
86 switch (grid_type) {
95 case VOLUME_GRID_INT:
103 case VOLUME_GRID_MASK:
108 break;
109 }
111}
112
113openvdb::GridBase::Ptr BKE_volume_grid_create_with_changed_resolution(
114 const VolumeGridType grid_type, const openvdb::GridBase &old_grid, float resolution_factor);
115
116#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_unreachable()
Definition BLI_assert.h:93
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:53
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
MatBase< float, 4, 4 > float4x4
const char * name