Fix #119873: Bake node crash with instanced light objects

4d0936c7d7 explicitly avoids turning non-geometry object
instances into geometry instances. This code is called to prepare
geometry sets for baking, and baking currently assumes that the baked
instances are always geometry sets.

To fix this, just check the instance type and serialize an empty
geometry set for the crashing object instance case. Compared to before
the crash causing commit, there is no change in behavior, since that
would have created empty geometry sets too.

Pull Request: https://projects.blender.org/blender/blender/pulls/119892
This commit is contained in:
Hans Goudey 2024-03-25 21:42:07 +01:00 committed by Hans Goudey
parent 6c74d4af15
commit 40a5e739e2
1 changed files with 8 additions and 3 deletions

View File

@ -968,9 +968,14 @@ static std::shared_ptr<DictionaryValue> serialize_geometry_set(const GeometrySet
auto io_references = io_instances->append_array("references");
for (const InstanceReference &reference : instances.references()) {
BLI_assert(reference.type() == InstanceReference::Type::GeometrySet);
io_references->append(
serialize_geometry_set(reference.geometry_set(), blob_writer, blob_sharing));
if (reference.type() == InstanceReference::Type::GeometrySet) {
const GeometrySet &geometry = reference.geometry_set();
io_references->append(serialize_geometry_set(geometry, blob_writer, blob_sharing));
}
else {
/* TODO: Support serializing object and collection references. */
io_references->append(serialize_geometry_set({}, blob_writer, blob_sharing));
}
}
io_instances->append(