Attributes: Integrate implicit sharing with the attribute API

Add the ability to retrieve implicit sharing info directly from the
C++ attribute API, which simplifies memory usage and performance
optimizations making use of it. This commit uses the additions to
the API to avoid copies in a few places:
- The "rest_position" attribute in the mesh modifier stack
- Instance on Points node
- Instances to points node
- Mesh to points node
- Points to vertices node

Many files are affected because in order to include the new information
in the API's returned data, I had to switch a bunch of types from
`VArray` to `AttributeReader`. This generally makes sense anyway, since
it allows retrieving the domain, which wasn't possible before in some
cases. I overloaded the `*` deference operator for some syntactic sugar
to avoid the (very ugly) `.varray` that would be necessary otherwise.

Pull Request: https://projects.blender.org/blender/blender/pulls/107059
This commit is contained in:
Hans Goudey
2023-04-19 11:21:06 +02:00
committed by Jacques Lucke
parent 19ac02767c
commit e45ed69349
83 changed files with 488 additions and 366 deletions
+2 -2
View File
@@ -333,8 +333,8 @@ static void mesh_merge_transform(Mesh *result,
}
const bke::AttributeAccessor cap_attributes = cap_mesh->attributes();
if (const VArray<int> cap_material_indices = cap_attributes.lookup<int>("material_index",
ATTR_DOMAIN_FACE)) {
if (const VArray cap_material_indices = *cap_attributes.lookup<int>("material_index",
ATTR_DOMAIN_FACE)) {
bke::MutableAttributeAccessor result_attributes = result->attributes_for_write();
bke::SpanAttributeWriter<int> result_material_indices =
result_attributes.lookup_or_add_for_write_span<int>("material_index", ATTR_DOMAIN_FACE);