Blender V5.3
mesh_topology_state.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "DNA_mesh_types.h"
10
11#include "BKE_attribute.hh"
13#include "BKE_mesh_types.hh"
14
15namespace blender::bke {
16
18{
19 if (!attr) {
20 return {};
21 }
22 return {attr.varray, attr.sharing_info};
23}
24
25template<typename T>
27 const AttributeReader<T> &attr)
28{
29 if (!attr) {
30 return array_state.is_empty();
31 }
32 return array_state.same_as(attr.varray, attr.sharing_info);
33}
34
36{
37 const AttributeAccessor attributes = mesh.attributes();
38 edge_verts_ = attribute_reader_to_array_state(attributes.lookup<int2>(".edge_verts"));
39 corner_verts_ = attribute_reader_to_array_state(attributes.lookup<int>(".corner_vert"));
40 corner_edges_ = attribute_reader_to_array_state(attributes.lookup<int>(".corner_edge"));
41 face_offset_indices_ = ArrayState<int>(VArray<int>::from_span(mesh.face_offsets()),
42 mesh.runtime->face_offsets_sharing_info);
43}
44
46{
47 const AttributeAccessor attributes = mesh.attributes();
48 if (!attribute_reader_matches_array_state(edge_verts_, attributes.lookup<int2>(".edge_verts"))) {
49 return false;
50 }
51 if (!attribute_reader_matches_array_state(corner_verts_, attributes.lookup<int>(".corner_vert")))
52 {
53 return false;
54 }
55 if (!attribute_reader_matches_array_state(corner_edges_, attributes.lookup<int>(".corner_edge")))
56 {
57 return false;
58 }
59 if (!face_offset_indices_.same_as(VArray<int>::from_span(mesh.face_offsets()),
60 mesh.runtime->face_offsets_sharing_info))
61 {
62 return false;
63 }
64 return true;
65}
66
67} // namespace blender::bke
bool same_as(const VArray< T > &other_values, const ImplicitSharingInfo *other_sharing_info) const
static VArray from_span(Span< T > values)
GAttributeReader lookup(const StringRef name) const
bool same_topology_as(const Mesh &mesh) const
ArrayState< T > attribute_reader_to_array_state(const AttributeReader< T > &attr)
bool attribute_reader_matches_array_state(const ArrayState< T > &array_state, const AttributeReader< T > &attr)
VecBase< int32_t, 2 > int2
const ImplicitSharingInfo * sharing_info