[Bf-blender-cvs] [05179a0ba48] blender-v2.92-release: Volumes: fix calling BKE_volume_load from multiple threads
Jacques Lucke
noreply at git.blender.org
Tue Jan 19 18:02:21 CET 2021
Commit: 05179a0ba4898c716a4b9b2d5e169c09b57e84fb
Author: Jacques Lucke
Date: Tue Jan 19 18:01:22 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rB05179a0ba4898c716a4b9b2d5e169c09b57e84fb
Volumes: fix calling BKE_volume_load from multiple threads
`BKE_volume_is_loaded` uses `grids.filepath` to determine if the
grids are already loaded. The issue was that `grids.filepath` was
set before the grids were loaded, resulting in incorrect early
returns for other threads.
Differential Revision: https://developer.blender.org/D10150
===================================================================
M source/blender/blenkernel/intern/volume.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index eadb01c43fc..9e7a3736141 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -783,21 +783,22 @@ bool BKE_volume_load(Volume *volume, Main *bmain)
/* Get absolute file path at current frame. */
const char *volume_name = volume->id.name + 2;
- volume_filepath_get(bmain, volume, grids.filepath);
+ char filepath[FILE_MAX];
+ volume_filepath_get(bmain, volume, filepath);
- CLOG_INFO(&LOG, 1, "Volume %s: load %s", volume_name, grids.filepath);
+ CLOG_INFO(&LOG, 1, "Volume %s: load %s", volume_name, filepath);
/* Test if file exists. */
- if (!BLI_exists(grids.filepath)) {
+ if (!BLI_exists(filepath)) {
char filename[FILE_MAX];
- BLI_split_file_part(grids.filepath, filename, sizeof(filename));
+ BLI_split_file_part(filepath, filename, sizeof(filename));
grids.error_msg = filename + std::string(" not found");
CLOG_INFO(&LOG, 1, "Volume %s: %s", volume_name, grids.error_msg.c_str());
return false;
}
/* Open OpenVDB file. */
- openvdb::io::File file(grids.filepath);
+ openvdb::io::File file(filepath);
openvdb::GridPtrVec vdb_grids;
try {
@@ -814,11 +815,13 @@ bool BKE_volume_load(Volume *volume, Main *bmain)
/* Add grids read from file to own vector, filtering out any NULL pointers. */
for (const openvdb::GridBase::Ptr &vdb_grid : vdb_grids) {
if (vdb_grid) {
- VolumeFileCache::Entry template_entry(grids.filepath, vdb_grid);
+ VolumeFileCache::Entry template_entry(filepath, vdb_grid);
grids.emplace_back(template_entry, volume->runtime.default_simplify_level);
}
}
+ BLI_strncpy(grids.filepath, filepath, FILE_MAX);
+
return grids.error_msg.empty();
#else
UNUSED_VARS(bmain, volume);
More information about the Bf-blender-cvs
mailing list