Fix T102764: Slow change of active material slot

The issue is caused by the combination of the following factors:

- There is a driver from custom property to the subdivision surface
  modifier.
- Active material index tags the ID for the copy-on-write update.

Dependency graph currently does not fully distinguish between
copy-on-write tag and properties-update tag, so the copy-on-write tag
makes the dependency graph believe that it is property which actually
affects evaluation has been changed.

The simple solution is to treat the active material slot index as an
interface data which does not need to trigger copy-on-write tag.

The possible downside of this solution is that if someone has a driver
from this property the driver will stop working. Whether there is such
a real-life setup or not is not clear. Is not something advisable to do
anyway.

Possible alternative would be to introduce more granularity into the
way how property tagging is done. This is something that would be nice
to implement eventually, but it is a much bigger refactor.

Differential Revision: https://developer.blender.org/D16613
This commit is contained in:
Sergey Sharybin
2022-11-25 17:24:33 +01:00
parent d1c21d5673
commit f83aa1ae08

View File

@@ -3242,6 +3242,7 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "actcol");
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_funcs(prop,
"rna_Object_active_material_index_get",