Fix: Cycles assert when having volumes and objects with displacement

Delay calculation of volume step until bounds are known, avoiding access
to non-valid bounds and fixing assert in debug builds.

This seems to be an oversight from the #121042

Pull Request: https://projects.blender.org/blender/blender/pulls/122549
This commit is contained in:
Sergey Sharybin 2024-05-31 15:53:12 +02:00 committed by Sergey Sharybin
parent 42581be240
commit c4d413fdad

@ -882,11 +882,17 @@ void ObjectManager::device_update_flags(
bool has_volume_objects = false;
foreach (Object *object, scene->objects) {
if (object->geometry->has_volume) {
/* If the bounds are not valid it is not always possible to calculate the volume step, and
* the step size is not needed for the displacement. So, delay calculation of the volume
* step size until the final bounds are known. */
if (bounds_valid) {
volume_objects.push_back(object);
object_volume_step[object->index] = object->compute_volume_step_size();
}
else {
object_volume_step[object->index] = FLT_MAX;
}
has_volume_objects = true;
object_volume_step[object->index] = object->compute_volume_step_size();
}
else {
object_volume_step[object->index] = FLT_MAX;