Fix T85462: crash in render mode while removing instances

This crash is caused by accessing object data in the kernel at an out of bound index from a deleted instance.

Cycles represents instances as Object nodes sharing the same Geometry node, so we need to tag the GeometryManager for an update if some objects are added or removed as no geometry might have been added or removed in order to properly update the BVH and its associated data arrays.

Regression caused by rBbbe6d4492823.
This commit is contained in:
Kévin Dietrich 2021-02-11 11:54:29 +01:00
parent 69e191604b
commit 349c17cf54
Notes: blender-bot 2023-02-14 08:06:33 +01:00
Referenced by issue #85462, Crash in render mode while removing instances
1 changed files with 9 additions and 1 deletions

View File

@ -915,7 +915,15 @@ void ObjectManager::tag_update(Scene *scene, uint32_t flag)
/* avoid infinite loops if the geometry manager tagged us for an update */
if ((flag & GEOMETRY_MANAGER) == 0) {
scene->geometry_manager->tag_update(scene, GeometryManager::OBJECT_MANAGER);
uint32_t geometry_flag = GeometryManager::OBJECT_MANAGER;
/* Also notify in case added or removed objects were instances, as no Geometry might have been
* added or removed, but the BVH still needs to updated. */
if ((flag & (OBJECT_ADDED | OBJECT_REMOVED)) != 0) {
geometry_flag |= (GeometryManager::GEOMETRY_ADDED | GeometryManager::GEOMETRY_REMOVED);
}
scene->geometry_manager->tag_update(scene, geometry_flag);
}
scene->light_manager->tag_update(scene, LightManager::OBJECT_MANAGER);