Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intern/cycles/blender/blender_volume.cpp4
-rw-r--r--source/blender/blenkernel/BKE_volume.h19
-rw-r--r--source/blender/blenkernel/BKE_volume_render.h6
-rw-r--r--source/blender/blenkernel/intern/volume.cc82
-rw-r--r--source/blender/blenkernel/intern/volume_render.cc6
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c11
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c2
-rw-r--r--source/blender/draw/intern/draw_cache.h3
-rw-r--r--source/blender/draw/intern/draw_cache_impl_volume.c10
-rw-r--r--source/blender/makesrna/intern/rna_volume.c16
-rw-r--r--source/blender/modifiers/intern/MOD_volume_displace.cc2
-rw-r--r--source/blender/modifiers/intern/MOD_volume_to_mesh.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_transform.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc6
14 files changed, 107 insertions, 68 deletions
diff --git a/intern/cycles/blender/blender_volume.cpp b/intern/cycles/blender/blender_volume.cpp
index 0ff4de846e1..772ab9f5c8a 100644
--- a/intern/cycles/blender/blender_volume.cpp
+++ b/intern/cycles/blender/blender_volume.cpp
@@ -26,7 +26,7 @@
#ifdef WITH_OPENVDB
# include <openvdb/openvdb.h>
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const struct Volume *volume,
- struct VolumeGrid *grid);
+ const struct VolumeGrid *grid);
#endif
CCL_NAMESPACE_BEGIN
@@ -227,7 +227,7 @@ class BlenderVolumeLoader : public VDBImageLoader {
const bool unload = !b_volume_grid.is_loaded();
::Volume *volume = (::Volume *)b_volume.ptr.data;
- VolumeGrid *volume_grid = (VolumeGrid *)b_volume_grid.ptr.data;
+ const VolumeGrid *volume_grid = (VolumeGrid *)b_volume_grid.ptr.data;
grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
if (unload) {
diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h
index 53626dbeb1b..2b17cf26e0e 100644
--- a/source/blender/blenkernel/BKE_volume.h
+++ b/source/blender/blenkernel/BKE_volume.h
@@ -78,16 +78,17 @@ extern void (*BKE_volume_batch_cache_free_cb)(struct Volume *volume);
typedef struct VolumeGrid VolumeGrid;
-bool BKE_volume_load(struct Volume *volume, struct Main *bmain);
+bool BKE_volume_load(const struct Volume *volume, const struct Main *bmain);
void BKE_volume_unload(struct Volume *volume);
bool BKE_volume_is_loaded(const struct Volume *volume);
int BKE_volume_num_grids(const struct Volume *volume);
const char *BKE_volume_grids_error_msg(const struct Volume *volume);
const char *BKE_volume_grids_frame_filepath(const struct Volume *volume);
-VolumeGrid *BKE_volume_grid_get(const struct Volume *volume, int grid_index);
-VolumeGrid *BKE_volume_grid_active_get(const struct Volume *volume);
-VolumeGrid *BKE_volume_grid_find(const struct Volume *volume, const char *name);
+const VolumeGrid *BKE_volume_grid_get_for_read(const struct Volume *volume, int grid_index);
+VolumeGrid *BKE_volume_grid_get_for_write(struct Volume *volume, int grid_index);
+const VolumeGrid *BKE_volume_grid_active_get_for_read(const struct Volume *volume);
+const VolumeGrid *BKE_volume_grid_find_for_read(const struct Volume *volume, const char *name);
/* Grid
*
@@ -109,8 +110,8 @@ typedef enum VolumeGridType {
VOLUME_GRID_POINTS,
} VolumeGridType;
-bool BKE_volume_grid_load(const struct Volume *volume, struct VolumeGrid *grid);
-void BKE_volume_grid_unload(const struct Volume *volume, struct VolumeGrid *grid);
+bool BKE_volume_grid_load(const struct Volume *volume, const struct VolumeGrid *grid);
+void BKE_volume_grid_unload(const struct Volume *volume, const struct VolumeGrid *grid);
bool BKE_volume_grid_is_loaded(const struct VolumeGrid *grid);
/* Metadata */
@@ -145,8 +146,8 @@ int BKE_volume_simplify_level(const struct Depsgraph *depsgraph);
float BKE_volume_simplify_factor(const struct Depsgraph *depsgraph);
/* File Save */
-bool BKE_volume_save(struct Volume *volume,
- struct Main *bmain,
+bool BKE_volume_save(const struct Volume *volume,
+ const struct Main *bmain,
struct ReportList *reports,
const char *filepath);
@@ -165,7 +166,7 @@ bool BKE_volume_save(struct Volume *volume,
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);
+ const struct VolumeGrid *grid);
openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *volume,
struct VolumeGrid *grid,
const bool clear);
diff --git a/source/blender/blenkernel/BKE_volume_render.h b/source/blender/blenkernel/BKE_volume_render.h
index d7553ccb10b..907e3cf0880 100644
--- a/source/blender/blenkernel/BKE_volume_render.h
+++ b/source/blender/blenkernel/BKE_volume_render.h
@@ -43,7 +43,7 @@ typedef struct DenseFloatVolumeGrid {
} DenseFloatVolumeGrid;
bool BKE_volume_grid_dense_floats(const struct Volume *volume,
- struct VolumeGrid *volume_grid,
+ const struct VolumeGrid *volume_grid,
DenseFloatVolumeGrid *r_dense_grid);
void BKE_volume_dense_float_grid_clear(DenseFloatVolumeGrid *dense_grid);
@@ -53,7 +53,7 @@ typedef void (*BKE_volume_wireframe_cb)(
void *userdata, float (*verts)[3], int (*edges)[2], int totvert, int totedge);
void BKE_volume_grid_wireframe(const struct Volume *volume,
- struct VolumeGrid *volume_grid,
+ const struct VolumeGrid *volume_grid,
BKE_volume_wireframe_cb cb,
void *cb_userdata);
@@ -63,7 +63,7 @@ typedef void (*BKE_volume_selection_surface_cb)(
void *userdata, float (*verts)[3], int (*tris)[3], int totvert, int tottris);
void BKE_volume_grid_selection_surface(const struct Volume *volume,
- struct VolumeGrid *volume_grid,
+ const struct VolumeGrid *volume_grid,
BKE_volume_selection_surface_cb cb,
void *cb_userdata);
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 6c0d361a64c..a51828453ca 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -144,14 +144,14 @@ static struct VolumeFileCache {
blender::Map<int, openvdb::GridBase::Ptr> simplified_grids;
/* Has the grid tree been loaded? */
- bool is_loaded;
+ mutable bool is_loaded;
/* Error message if an error occurred while loading. */
std::string error_msg;
/* User counting. */
int num_metadata_users;
int num_tree_users;
/* Mutex for on-demand reading of tree. */
- std::mutex mutex;
+ mutable std::mutex mutex;
};
struct EntryHasher {
@@ -289,7 +289,7 @@ struct VolumeGrid {
}
}
- void load(const char *volume_name, const char *filepath)
+ void load(const char *volume_name, const char *filepath) const
{
/* If already loaded or not file-backed, nothing to do. */
if (is_loaded || entry == nullptr) {
@@ -331,7 +331,7 @@ struct VolumeGrid {
is_loaded = true;
}
- void unload(const char *volume_name)
+ void unload(const char *volume_name) const
{
/* Not loaded or not file-backed, nothing to do. */
if (!is_loaded || entry == nullptr) {
@@ -432,10 +432,14 @@ struct VolumeGrid {
int simplify_level = 0;
/* OpenVDB grid if it's not shared through the file cache. */
openvdb::GridBase::Ptr local_grid;
- /* Indicates if the tree has been loaded for this grid. Note that vdb.tree()
+ /**
+ * Indicates if the tree has been loaded for this grid. Note that vdb.tree()
* may actually be loaded by another user while this is false. But only after
- * calling load() and is_loaded changes to true is it safe to access. */
- bool is_loaded;
+ * calling load() and is_loaded changes to true is it safe to access.
+ *
+ * Const write access to this must be protected by `entry->mutex`.
+ */
+ mutable bool is_loaded;
};
/* Volume Grid Vector
@@ -468,14 +472,15 @@ struct VolumeGridVector : public std::list<VolumeGrid> {
metadata.reset();
}
+ /* Mutex for file loading of grids list. Const write access to the fields after this must be
+ * protected by locking with this mutex. */
+ mutable std::mutex mutex;
/* Absolute file path that grids have been loaded from. */
char filepath[FILE_MAX];
/* File loading error message. */
std::string error_msg;
/* File Metadata. */
openvdb::MetaMap::Ptr metadata;
- /* Mutex for file loading of grids list. */
- std::mutex mutex;
};
#endif
@@ -762,10 +767,10 @@ bool BKE_volume_is_loaded(const Volume *volume)
#endif
}
-bool BKE_volume_load(Volume *volume, Main *bmain)
+bool BKE_volume_load(const Volume *volume, const Main *bmain)
{
#ifdef WITH_OPENVDB
- VolumeGridVector &grids = *volume->runtime.grids;
+ const VolumeGridVector &const_grids = *volume->runtime.grids;
if (volume->runtime.frame == VOLUME_FRAME_NONE) {
/* Skip loading this frame, outside of sequence range. */
@@ -773,15 +778,19 @@ bool BKE_volume_load(Volume *volume, Main *bmain)
}
if (BKE_volume_is_loaded(volume)) {
- return grids.error_msg.empty();
+ return const_grids.error_msg.empty();
}
/* Double-checked lock. */
- std::lock_guard<std::mutex> lock(grids.mutex);
+ std::lock_guard<std::mutex> lock(const_grids.mutex);
if (BKE_volume_is_loaded(volume)) {
- return grids.error_msg.empty();
+ return const_grids.error_msg.empty();
}
+ /* Guarded by the lock, we can continue to access the grid vector,
+ * adding error messages or a new grid, etc. */
+ VolumeGridVector &grids = const_cast<VolumeGridVector &>(const_grids);
+
/* Get absolute file path at current frame. */
const char *volume_name = volume->id.name + 2;
char filepath[FILE_MAX];
@@ -846,7 +855,10 @@ void BKE_volume_unload(Volume *volume)
/* File Save */
-bool BKE_volume_save(Volume *volume, Main *bmain, ReportList *reports, const char *filepath)
+bool BKE_volume_save(const Volume *volume,
+ const Main *bmain,
+ ReportList *reports,
+ const char *filepath)
{
#ifdef WITH_OPENVDB
if (!BKE_volume_load(volume, bmain)) {
@@ -887,7 +899,7 @@ BoundBox *BKE_volume_boundbox_get(Object *ob)
}
if (ob->runtime.bb == nullptr) {
- Volume *volume = (Volume *)ob->data;
+ const Volume *volume = (const Volume *)ob->data;
ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "volume boundbox");
@@ -902,7 +914,7 @@ BoundBox *BKE_volume_boundbox_get(Object *ob)
const int num_grids = BKE_volume_num_grids(volume);
for (int i = 0; i < num_grids; i++) {
- VolumeGrid *grid = BKE_volume_grid_get(volume, i);
+ const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, i);
float grid_min[3], grid_max[3];
BKE_volume_grid_load(volume, grid);
@@ -953,7 +965,7 @@ bool BKE_volume_is_points_only(const Volume *volume)
}
for (int i = 0; i < num_grids; i++) {
- VolumeGrid *grid = BKE_volume_grid_get(volume, i);
+ const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, i);
if (BKE_volume_grid_type(grid) != VOLUME_GRID_POINTS) {
return false;
}
@@ -1140,7 +1152,23 @@ const char *BKE_volume_grids_frame_filepath(const Volume *volume)
#endif
}
-VolumeGrid *BKE_volume_grid_get(const Volume *volume, int grid_index)
+const VolumeGrid *BKE_volume_grid_get_for_read(const Volume *volume, int grid_index)
+{
+#ifdef WITH_OPENVDB
+ const VolumeGridVector &grids = *volume->runtime.grids;
+ for (const VolumeGrid &grid : grids) {
+ if (grid_index-- == 0) {
+ return &grid;
+ }
+ }
+ return nullptr;
+#else
+ UNUSED_VARS(volume, grid_index);
+ return nullptr;
+#endif
+}
+
+VolumeGrid *BKE_volume_grid_get_for_write(Volume *volume, int grid_index)
{
#ifdef WITH_OPENVDB
VolumeGridVector &grids = *volume->runtime.grids;
@@ -1156,7 +1184,7 @@ VolumeGrid *BKE_volume_grid_get(const Volume *volume, int grid_index)
#endif
}
-VolumeGrid *BKE_volume_grid_active_get(const Volume *volume)
+const VolumeGrid *BKE_volume_grid_active_get_for_read(const Volume *volume)
{
const int num_grids = BKE_volume_num_grids(volume);
if (num_grids == 0) {
@@ -1164,15 +1192,15 @@ VolumeGrid *BKE_volume_grid_active_get(const Volume *volume)
}
const int index = clamp_i(volume->active_grid, 0, num_grids - 1);
- return BKE_volume_grid_get(volume, index);
+ return BKE_volume_grid_get_for_read(volume, index);
}
/* Tries to find a grid with the given name. Make sure that that the volume has been loaded. */
-VolumeGrid *BKE_volume_grid_find(const Volume *volume, const char *name)
+const VolumeGrid *BKE_volume_grid_find_for_read(const Volume *volume, const char *name)
{
int num_grids = BKE_volume_num_grids(volume);
for (int i = 0; i < num_grids; i++) {
- VolumeGrid *grid = BKE_volume_grid_get(volume, i);
+ const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, i);
if (STREQ(BKE_volume_grid_name(grid), name)) {
return grid;
}
@@ -1183,7 +1211,7 @@ VolumeGrid *BKE_volume_grid_find(const Volume *volume, const char *name)
/* Grid Loading */
-bool BKE_volume_grid_load(const Volume *volume, VolumeGrid *grid)
+bool BKE_volume_grid_load(const Volume *volume, const VolumeGrid *grid)
{
#ifdef WITH_OPENVDB
VolumeGridVector &grids = *volume->runtime.grids;
@@ -1201,7 +1229,7 @@ bool BKE_volume_grid_load(const Volume *volume, VolumeGrid *grid)
#endif
}
-void BKE_volume_grid_unload(const Volume *volume, VolumeGrid *grid)
+void BKE_volume_grid_unload(const Volume *volume, const VolumeGrid *grid)
{
#ifdef WITH_OPENVDB
const char *volume_name = volume->id.name + 2;
@@ -1406,7 +1434,7 @@ VolumeGrid *BKE_volume_grid_add(Volume *volume, const char *name, VolumeGridType
{
#ifdef WITH_OPENVDB
VolumeGridVector &grids = *volume->runtime.grids;
- BLI_assert(BKE_volume_grid_find(volume, name) == nullptr);
+ BLI_assert(BKE_volume_grid_find_for_read(volume, name) == nullptr);
BLI_assert(type != VOLUME_GRID_UNKNOWN);
openvdb::GridBase::Ptr vdb_grid = BKE_volume_grid_type_operation(type, CreateGridOp{});
@@ -1474,7 +1502,7 @@ openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_metadata(const VolumeGri
}
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const Volume *volume,
- VolumeGrid *grid)
+ const VolumeGrid *grid)
{
BKE_volume_grid_load(volume, grid);
return grid->grid();
diff --git a/source/blender/blenkernel/intern/volume_render.cc b/source/blender/blenkernel/intern/volume_render.cc
index 5c71f1d7eca..6dc497bb616 100644
--- a/source/blender/blenkernel/intern/volume_render.cc
+++ b/source/blender/blenkernel/intern/volume_render.cc
@@ -104,7 +104,7 @@ static void create_texture_to_object_matrix(const openvdb::Mat4d &grid_transform
#endif
bool BKE_volume_grid_dense_floats(const Volume *volume,
- VolumeGrid *volume_grid,
+ const VolumeGrid *volume_grid,
DenseFloatVolumeGrid *r_dense_grid)
{
#ifdef WITH_OPENVDB
@@ -334,7 +334,7 @@ static void boxes_to_cube_mesh(blender::Span<openvdb::CoordBBox> boxes,
#endif
void BKE_volume_grid_wireframe(const Volume *volume,
- VolumeGrid *volume_grid,
+ const VolumeGrid *volume_grid,
BKE_volume_wireframe_cb cb,
void *cb_userdata)
{
@@ -411,7 +411,7 @@ static void grow_triangles(blender::MutableSpan<blender::float3> verts,
#endif /* WITH_OPENVDB */
void BKE_volume_grid_selection_surface(const Volume *volume,
- VolumeGrid *volume_grid,
+ const VolumeGrid *volume_grid,
BKE_volume_selection_surface_cb cb,
void *cb_userdata)
{
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index aee260a542e..2d84c87106c 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -332,7 +332,7 @@ static bool eevee_volume_object_grids_init(Object *ob, ListBase *gpu_grids, DRWS
bool multiple_transforms = true;
LISTBASE_FOREACH (GPUMaterialVolumeGrid *, gpu_grid, gpu_grids) {
- VolumeGrid *volume_grid = BKE_volume_grid_find(volume, gpu_grid->name);
+ const VolumeGrid *volume_grid = BKE_volume_grid_find_for_read(volume, gpu_grid->name);
DRWVolumeGrid *drw_grid = (volume_grid) ?
DRW_volume_batch_cache_get_grid(volume, volume_grid) :
NULL;
@@ -385,7 +385,7 @@ static bool eevee_volume_object_grids_init(Object *ob, ListBase *gpu_grids, DRWS
/* Bind volume grid textures. */
LISTBASE_FOREACH (GPUMaterialVolumeGrid *, gpu_grid, gpu_grids) {
- VolumeGrid *volume_grid = BKE_volume_grid_find(volume, gpu_grid->name);
+ const VolumeGrid *volume_grid = BKE_volume_grid_find_for_read(volume, gpu_grid->name);
DRWVolumeGrid *drw_grid = (volume_grid) ?
DRW_volume_batch_cache_get_grid(volume, volume_grid) :
NULL;
@@ -394,10 +394,9 @@ static bool eevee_volume_object_grids_init(Object *ob, ListBase *gpu_grids, DRWS
* - Grid exists and texture was loaded -> use texture.
* - Grid exists but has zero size or failed to load -> use zero.
* - Grid does not exist -> use default value. */
- GPUTexture *grid_tex = (drw_grid) ? drw_grid->texture :
- (volume_grid) ?
- e_data.dummy_zero :
- eevee_volume_default_texture(gpu_grid->default_value);
+ GPUTexture *grid_tex = (drw_grid) ? drw_grid->texture :
+ (volume_grid) ? e_data.dummy_zero :
+ eevee_volume_default_texture(gpu_grid->default_value);
DRW_shgroup_uniform_texture(grp, gpu_grid->sampler_name, grid_tex);
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
index c76f4a4c470..525a81b5581 100644
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -215,7 +215,7 @@ static void workbench_volume_object_cache_populate(WORKBENCH_Data *vedata,
/* Create 3D textures. */
Volume *volume = ob->data;
BKE_volume_load(volume, G.main);
- VolumeGrid *volume_grid = BKE_volume_grid_active_get(volume);
+ const VolumeGrid *volume_grid = BKE_volume_grid_active_get_for_read(volume);
if (volume_grid == NULL) {
return;
}
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index c15c246992d..c58dd85b6ed 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -244,7 +244,8 @@ typedef struct DRWVolumeGrid {
float bounds_to_texture[4][4];
} DRWVolumeGrid;
-DRWVolumeGrid *DRW_volume_batch_cache_get_grid(struct Volume *volume, struct VolumeGrid *grid);
+DRWVolumeGrid *DRW_volume_batch_cache_get_grid(struct Volume *volume,
+ const struct VolumeGrid *grid);
struct GPUBatch *DRW_cache_volume_face_wireframe_get(struct Object *ob);
struct GPUBatch *DRW_cache_volume_selection_surface_get(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c b/source/blender/draw/intern/draw_cache_impl_volume.c
index 7244dfd12c3..52ebf1b239e 100644
--- a/source/blender/draw/intern/draw_cache_impl_volume.c
+++ b/source/blender/draw/intern/draw_cache_impl_volume.c
@@ -225,7 +225,7 @@ GPUBatch *DRW_volume_batch_cache_get_wireframes_face(Volume *volume)
VolumeBatchCache *cache = volume_batch_cache_get(volume);
if (cache->face_wire.batch == NULL) {
- VolumeGrid *volume_grid = BKE_volume_grid_active_get(volume);
+ const VolumeGrid *volume_grid = BKE_volume_grid_active_get_for_read(volume);
if (volume_grid == NULL) {
return NULL;
}
@@ -274,7 +274,7 @@ GPUBatch *DRW_volume_batch_cache_get_selection_surface(Volume *volume)
{
VolumeBatchCache *cache = volume_batch_cache_get(volume);
if (cache->selection_surface == NULL) {
- VolumeGrid *volume_grid = BKE_volume_grid_active_get(volume);
+ const VolumeGrid *volume_grid = BKE_volume_grid_active_get_for_read(volume);
if (volume_grid == NULL) {
return NULL;
}
@@ -284,8 +284,8 @@ GPUBatch *DRW_volume_batch_cache_get_selection_surface(Volume *volume)
return cache->selection_surface;
}
-static DRWVolumeGrid *volume_grid_cache_get(Volume *volume,
- VolumeGrid *grid,
+static DRWVolumeGrid *volume_grid_cache_get(const Volume *volume,
+ const VolumeGrid *grid,
VolumeBatchCache *cache)
{
const char *name = BKE_volume_grid_name(grid);
@@ -351,7 +351,7 @@ static DRWVolumeGrid *volume_grid_cache_get(Volume *volume,
return cache_grid;
}
-DRWVolumeGrid *DRW_volume_batch_cache_get_grid(Volume *volume, VolumeGrid *volume_grid)
+DRWVolumeGrid *DRW_volume_batch_cache_get_grid(Volume *volume, const VolumeGrid *volume_grid)
{
VolumeBatchCache *cache = volume_batch_cache_get(volume);
DRWVolumeGrid *grid = volume_grid_cache_get(volume, volume_grid, cache);
diff --git a/source/blender/makesrna/intern/rna_volume.c b/source/blender/makesrna/intern/rna_volume.c
index 1bddd9152db..76db6f3e325 100644
--- a/source/blender/makesrna/intern/rna_volume.c
+++ b/source/blender/makesrna/intern/rna_volume.c
@@ -137,7 +137,7 @@ static void rna_Volume_grids_end(CollectionPropertyIterator *UNUSED(iter))
static PointerRNA rna_Volume_grids_get(CollectionPropertyIterator *iter)
{
Volume *volume = iter->internal.count.ptr;
- const VolumeGrid *grid = BKE_volume_grid_get(volume, iter->internal.count.item);
+ const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, iter->internal.count.item);
return rna_pointer_inherit_refine(&iter->parent, &RNA_VolumeGrid, (void *)grid);
}
@@ -207,6 +207,16 @@ static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr)
return strlen(BKE_volume_grids_frame_filepath(volume));
}
+static bool rna_Volume_load(Volume *volume, Main *bmain)
+{
+ return BKE_volume_load(volume, bmain);
+}
+
+static bool rna_Volume_save(Volume *volume, Main *bmain, ReportList *reports, const char *filepath)
+{
+ return BKE_volume_save(volume, bmain, reports, filepath);
+}
+
#else
static void rna_def_volume_grid(BlenderRNA *brna)
@@ -335,7 +345,7 @@ static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
PropertyRNA *parm;
- func = RNA_def_function(srna, "load", "BKE_volume_load");
+ func = RNA_def_function(srna, "load", "rna_Volume_load");
RNA_def_function_ui_description(func, "Load list of grids and metadata from file");
RNA_def_function_flag(func, FUNC_USE_MAIN);
parm = RNA_def_boolean(func, "success", 0, "", "True if grid list was successfully loaded");
@@ -344,7 +354,7 @@ static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "unload", "BKE_volume_unload");
RNA_def_function_ui_description(func, "Unload all grid and voxel data from memory");
- func = RNA_def_function(srna, "save", "BKE_volume_save");
+ func = RNA_def_function(srna, "save", "rna_Volume_save");
RNA_def_function_ui_description(func, "Save grids and metadata to file");
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
parm = RNA_def_string_file_path(func, "filepath", NULL, 0, "", "File path to save to");
diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc
index 745e089b8ff..e7c4004853e 100644
--- a/source/blender/modifiers/intern/MOD_volume_displace.cc
+++ b/source/blender/modifiers/intern/MOD_volume_displace.cc
@@ -293,7 +293,7 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
BKE_volume_load(volume, DEG_get_bmain(ctx->depsgraph));
const int grid_amount = BKE_volume_num_grids(volume);
for (int grid_index = 0; grid_index < grid_amount; grid_index++) {
- VolumeGrid *volume_grid = BKE_volume_grid_get(volume, grid_index);
+ VolumeGrid *volume_grid = BKE_volume_grid_get_for_write(volume, grid_index);
BLI_assert(volume_grid != nullptr);
openvdb::GridBase::Ptr grid = BKE_volume_grid_openvdb_for_write(volume, volume_grid, false);
diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
index 41ed7ae983a..3bf5cf6ab5b 100644
--- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
+++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
@@ -155,10 +155,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
return create_empty_mesh(input_mesh);
}
- Volume *volume = static_cast<Volume *>(vmmd->object->data);
+ const Volume *volume = static_cast<Volume *>(vmmd->object->data);
BKE_volume_load(volume, DEG_get_bmain(ctx->depsgraph));
- VolumeGrid *volume_grid = BKE_volume_grid_find(volume, vmmd->grid_name);
+ const VolumeGrid *volume_grid = BKE_volume_grid_find_for_read(volume, vmmd->grid_name);
if (volume_grid == nullptr) {
BKE_modifier_set_error(ctx->object, md, "Cannot find '%s' grid", vmmd->grid_name);
return create_empty_mesh(input_mesh);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform.cc b/source/blender/nodes/geometry/nodes/node_geo_transform.cc
index 2c05c98c9ba..d54982d16c2 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_transform.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_transform.cc
@@ -130,7 +130,7 @@ static void transform_volume(Volume *volume,
(scale.z == 0.0f) ? FLT_EPSILON : scale.z,
};
- Main *bmain = DEG_get_bmain(params.depsgraph());
+ const Main *bmain = DEG_get_bmain(params.depsgraph());
BKE_volume_load(volume, bmain);
const float4x4 matrix = float4x4::from_loc_eul_scale(translation, rotation, limited_scale);
@@ -141,7 +141,7 @@ static void transform_volume(Volume *volume,
const int num_grids = BKE_volume_num_grids(volume);
for (const int i : IndexRange(num_grids)) {
- VolumeGrid *volume_grid = BKE_volume_grid_get(volume, i);
+ VolumeGrid *volume_grid = BKE_volume_grid_get_for_write(volume, i);
openvdb::GridBase::Ptr grid = BKE_volume_grid_openvdb_for_write(volume, volume_grid, false);
openvdb::math::Transform &grid_transform = grid->transform();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
index 348ad453ddc..c6049787970 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
@@ -117,11 +117,11 @@ static void create_mesh_from_volume(GeometrySet &geometry_set_in,
return;
}
- Main *bmain = DEG_get_bmain(params.depsgraph());
- BKE_volume_load(const_cast<Volume *>(volume), bmain);
+ const Main *bmain = DEG_get_bmain(params.depsgraph());
+ BKE_volume_load(volume, bmain);
const std::string grid_name = params.get_input<std::string>("Density");
- VolumeGrid *volume_grid = BKE_volume_grid_find(volume, grid_name.c_str());
+ const VolumeGrid *volume_grid = BKE_volume_grid_find_for_read(volume, grid_name.c_str());
if (volume_grid == nullptr) {
return;
}