Page MenuHome

Fix T92649: Incorrect copying of anonymous attributes in many places.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Nov 3 2021, 11:46 AM.

Details

Summary

Many modifiers and other places use CustomData_copy_data to copy data between different meshes. This function assumes that assumes that the source and destination CustomData objects are "compatible" in some way. Usually modifiers use CustomData_copy to create a compatible new CustomData on the new mesh. The issue was that the optimization I added for anonymous attributes broke this compatibility. It avoided copying some attributes when they are no longer used.

This lead to attributes being copied incorrectly.

The real solution would be to not depend on this kind of compatibility in CustomData_copy_data. However, changing that in a way that does not cause significant performance regressions in other parts of Blender is too risky for 3.0 (the issue is that CustomData_copy_data is often called for single elements, we don't want to compare all attribute names for all elements). Possible solutions for the future are:

  • Preprocess the mapping between two CustomData so that corresponding layers don't have to be found for every element.
  • Separate computing which indices are copied to which other indices from actually copying the data. Once the index mapping (e.g. in form of an integer array) is generated, one can process the CustomData layer by layer, reducing overhead significantly.

For now I just removed the optimization.

The viewer node had an affect on the behavior, because when the geometry was viewed, the captured anonymous attribute was still needed and therefore wasn't removed.

Diff Detail

Repository
rB Blender
Branch
T92649 (branched from master)
Build Status
Buildable 18425
Build 18425: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Nov 3 2021, 11:46 AM
Jacques Lucke (JacquesLucke) created this revision.

Since new code ideally doesn't use this method of copying attributes one index at a time, I don't think removing this optimization is such a big deal.

This revision is now accepted and ready to land.Nov 3 2021, 8:03 PM

Note, this optimization affected mesh copying etc. It was not just used when copying attributes one index at a time.