Fix T82393: Volume to Mesh modifier with sequence fails during rendering

The issue was that the volume for the current frame
might not have been loaded already by the time the
modifier runs.

The solution is simply to make sure that the volume
is loaded. This is similar to the Volume Displace modifier.
This commit is contained in:
Jacques Lucke 2020-11-04 13:21:43 +01:00
parent ba6977cb8b
commit cfcdae5549
Notes: blender-bot 2023-02-14 04:10:15 +01:00
Referenced by issue #82393, Volume to Mesh modifier on vdb sequence fails when rendering (F12 or animation ctrl-F12)
2 changed files with 4 additions and 0 deletions

View File

@ -1154,6 +1154,7 @@ VolumeGrid *BKE_volume_grid_active_get(const Volume *volume)
return BKE_volume_grid_get(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)
{
int num_grids = BKE_volume_num_grids(volume);

View File

@ -45,6 +45,8 @@
#include "BLI_span.hh"
#include "BLI_timeit.hh"
#include "DEG_depsgraph_query.h"
#ifdef WITH_OPENVDB
# include <openvdb/tools/GridTransformer.h>
# include <openvdb/tools/VolumeToMesh.h>
@ -281,6 +283,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
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);
if (volume_grid == nullptr) {
BKE_modifier_set_error(md, "Cannot find '%s' grid", vmmd->grid_name);