Fix: remove materials from simulation state in all cases #108411
|
@ -131,17 +131,33 @@ const CPPType &get_simulation_item_cpp_type(const NodeSimulationItem &item)
|
|||
return get_simulation_item_cpp_type(eNodeSocketDatatype(item.socket_type));
|
||||
}
|
||||
|
||||
static void remove_materials(Material ***materials, short *materials_num)
|
||||
{
|
||||
MEM_SAFE_FREE(*materials);
|
||||
*materials_num = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removess parts of the geometry that can't be stored in the simulation state:
|
||||
* - Anonymous attributes can't be stored because it is not known which of them will or will not be
|
||||
* used in the future.
|
||||
* - Materials can't be stored directly, because they are linked ID data blocks that can't be
|
||||
* restored from baked data currently.
|
||||
*/
|
||||
static void cleanup_geometry_for_simulation_state(GeometrySet &main_geometry)
|
||||
{
|
||||
main_geometry.modify_geometry_sets([&](GeometrySet &geometry) {
|
||||
if (Mesh *mesh = geometry.get_mesh_for_write()) {
|
||||
mesh->attributes_for_write().remove_anonymous();
|
||||
remove_materials(&mesh->mat, &mesh->totcol);
|
||||
}
|
||||
if (Curves *curves = geometry.get_curves_for_write()) {
|
||||
curves->geometry.wrap().attributes_for_write().remove_anonymous();
|
||||
remove_materials(&curves->mat, &curves->totcol);
|
||||
}
|
||||
if (PointCloud *pointcloud = geometry.get_pointcloud_for_write()) {
|
||||
pointcloud->attributes_for_write().remove_anonymous();
|
||||
remove_materials(&pointcloud->mat, &pointcloud->totcol);
|
||||
}
|
||||
if (bke::Instances *instances = geometry.get_instances_for_write()) {
|
||||
instances->attributes_for_write().remove_anonymous();
|
||||
|
|
Loading…
Reference in New Issue