From 1dfe8047d3a6c1b39b4e2e7d5b8ea6fb9515816c Mon Sep 17 00:00:00 2001 From: Weizhen Huang Date: Thu, 5 Jun 2025 20:53:48 +0200 Subject: [PATCH] Fix #105546: Cycles volume uninitialized when frame is beyond valid range Pull Request: https://projects.blender.org/blender/blender/pulls/139930 --- intern/cycles/blender/volume.cpp | 7 +++++++ intern/cycles/scene/volume.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/intern/cycles/blender/volume.cpp b/intern/cycles/blender/volume.cpp index ae815afbffb..4c50ddef792 100644 --- a/intern/cycles/blender/volume.cpp +++ b/intern/cycles/blender/volume.cpp @@ -200,6 +200,8 @@ static void sync_smoke_volume( ATTR_STD_VOLUME_VELOCITY, ATTR_STD_NONE}; + const Interval frame_interval = {b_domain.cache_frame_start(), b_domain.cache_frame_end()}; + for (int i = 0; attributes[i] != ATTR_STD_NONE; i++) { const AttributeStandard std = attributes[i]; if (!volume->need_attribute(scene, std)) { @@ -210,6 +212,11 @@ static void sync_smoke_volume( Attribute *attr = volume->attributes.add(std); + if (!frame_interval.contains(frame)) { + attr->data_voxel().clear(); + continue; + } + unique_ptr loader = make_unique(b_ob_info.real_object, std); ImageParams params; params.frame = frame; diff --git a/intern/cycles/scene/volume.cpp b/intern/cycles/scene/volume.cpp index 1c735c15265..f5742f7f0f4 100644 --- a/intern/cycles/scene/volume.cpp +++ b/intern/cycles/scene/volume.cpp @@ -677,6 +677,10 @@ void GeometryManager::create_volume_mesh(const Scene *scene, Volume *volume, Pro ImageHandle &handle = attr.data_voxel(); + if (handle.empty()) { + continue; + } + /* Try building from OpenVDB grid directly. */ VDBImageLoader *vdb_loader = handle.vdb_loader(); openvdb::GridBase::ConstPtr grid;