When allocating new CustomData layers, often we do redundant
initialization of arrays. For example, it's common that values are
allocated, set to their default value, and then set to some other
value. This is wasteful, and it negates the benefits of optimizations
to the allocator like D15082. There are two reasons for this. The
first is array-of-structs storage that makes it annoying to initialize
values manually, and the second is confusing options in the Custom Data
API. This patch addresses the latter.
The CustomData "alloc type" options are rearranged. Besides
the options that use existing layers, there are two remaining:
- CD_SET_DEFAULT sets the default value.
- Usually zeroes, but for colors this is white (how it was before).
- Should be used when you add the layer but don't set all values.
- CD_CONSTRUCT refers to the "default construct" C++ term.
- Only necessary or defined for non-trivial types like vertex groups.
- Doesn't do anything for trivial types like int or float3.
- Should be used every other time, when all values will be set.
The attribute API's AttributeInit types are updated as well.
The patch doesn't name any functional changes yet. Follow-up commits
will change code from CD_SET_DEFAULT to CD_CONSTRUCT where the
correctness is clear.