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:
authorHans Goudey <h.goudey@me.com>2021-04-08 20:00:26 +0300
committerHans Goudey <h.goudey@me.com>2021-04-08 20:00:26 +0300
commitfd414b49068c011a1fd63a304ea95bbe420d6570 (patch)
treecb08572a2ec4db702d41b12efbf2f6e010296510 /source/blender/blenkernel/BKE_volume.h
parentb51562ed76d5428ed4d511cd248d1b059e341661 (diff)
Cleanup: Use const arguments for volume code
The problem was that you could getting write access to a grid from a `const Volume *` without breaking const correctness. I encountered this when working on support for volumes in the bounding box node. For geometry nodes there is an important distinction between getting data "for read" and "for write", with the former returning a `const` version of the data. Also, for volumes it was necessary to cast away const, since all of the relevant functions in `volume.cc` didn't have const versions. This patch adds `const` in these places, distinguising between "for read" and "for write" versions of functions where necessary. The downside is that loading and unloading in the global volume cache needs const write-access to some member variables. I see that as an inherent problem that comes up with caching that never has a beautiful solution anyway. Some of the const-ness could probably be propogated futher in EEVEE code, but I'll leave that out, since there is another level of caching. Differential Revision: https://developer.blender.org/D10916
Diffstat (limited to 'source/blender/blenkernel/BKE_volume.h')
-rw-r--r--source/blender/blenkernel/BKE_volume.h19
1 files changed, 10 insertions, 9 deletions
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);