Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/geometry_component_mesh.cc
| Show First 20 Lines • Show All 906 Lines • ▼ Show 20 Lines | template<typename StructT, | ||||
| ElemT (*GetFunc)(const StructT &), | ElemT (*GetFunc)(const StructT &), | ||||
| void (*SetFunc)(StructT &, ElemT)> | void (*SetFunc)(StructT &, ElemT)> | ||||
| static GVMutableArrayPtr make_derived_write_attribute(void *data, const int domain_size) | static GVMutableArrayPtr make_derived_write_attribute(void *data, const int domain_size) | ||||
| { | { | ||||
| return std::make_unique<fn::GVMutableArray_For_DerivedSpan<StructT, ElemT, GetFunc, SetFunc>>( | return std::make_unique<fn::GVMutableArray_For_DerivedSpan<StructT, ElemT, GetFunc, SetFunc>>( | ||||
| MutableSpan<StructT>((StructT *)data, domain_size)); | MutableSpan<StructT>((StructT *)data, domain_size)); | ||||
| } | } | ||||
| template<typename T> | |||||
| static GVArrayPtr make_array_read_attribute(const void *data, const int domain_size) | |||||
| { | |||||
| return std::make_unique<fn::GVArray_For_Span<T>>(Span<T>((const T *)data, domain_size)); | |||||
| } | |||||
| template<typename T> | |||||
| static GVMutableArrayPtr make_array_write_attribute(void *data, const int domain_size) | |||||
| { | |||||
| return std::make_unique<fn::GVMutableArray_For_MutableSpan<T>>( | |||||
| MutableSpan<T>((T *)data, domain_size)); | |||||
| } | |||||
| static float3 get_vertex_position(const MVert &vert) | static float3 get_vertex_position(const MVert &vert) | ||||
| { | { | ||||
| return float3(vert.co); | return float3(vert.co); | ||||
| } | } | ||||
| static void set_vertex_position(MVert &vert, float3 position) | static void set_vertex_position(MVert &vert, float3 position) | ||||
| { | { | ||||
| copy_v3_v3(vert.co, position); | copy_v3_v3(vert.co, position); | ||||
| ▲ Show 20 Lines • Show All 346 Lines • ▼ Show 20 Lines | static BuiltinCustomDataLayerProvider position( | ||||
| BuiltinAttributeProvider::NonDeletable, | BuiltinAttributeProvider::NonDeletable, | ||||
| point_access, | point_access, | ||||
| make_derived_read_attribute<MVert, float3, get_vertex_position>, | make_derived_read_attribute<MVert, float3, get_vertex_position>, | ||||
| make_derived_write_attribute<MVert, float3, get_vertex_position, set_vertex_position>, | make_derived_write_attribute<MVert, float3, get_vertex_position, set_vertex_position>, | ||||
| tag_normals_dirty_when_writing_position); | tag_normals_dirty_when_writing_position); | ||||
| static NormalAttributeProvider normal; | static NormalAttributeProvider normal; | ||||
| static BuiltinCustomDataLayerProvider random_point_id("random_point_id", | |||||
| ATTR_DOMAIN_POINT, | |||||
| CD_PROP_INT32, | |||||
| CD_PROP_INT32, | |||||
| BuiltinAttributeProvider::Creatable, | |||||
| BuiltinAttributeProvider::Writable, | |||||
| BuiltinAttributeProvider::Deletable, | |||||
| point_access, | |||||
| make_array_read_attribute<int>, | |||||
| make_array_write_attribute<int>, | |||||
| nullptr); | |||||
| static BuiltinCustomDataLayerProvider material_index( | static BuiltinCustomDataLayerProvider material_index( | ||||
| "material_index", | "material_index", | ||||
| ATTR_DOMAIN_FACE, | ATTR_DOMAIN_FACE, | ||||
| CD_PROP_INT32, | CD_PROP_INT32, | ||||
| CD_MPOLY, | CD_MPOLY, | ||||
| BuiltinAttributeProvider::NonCreatable, | BuiltinAttributeProvider::NonCreatable, | ||||
| BuiltinAttributeProvider::Writable, | BuiltinAttributeProvider::Writable, | ||||
JacquesLucke: `edge_access` | |||||
| BuiltinAttributeProvider::NonDeletable, | BuiltinAttributeProvider::NonDeletable, | ||||
| face_access, | face_access, | ||||
| make_derived_read_attribute<MPoly, int, get_material_index>, | make_derived_read_attribute<MPoly, int, get_material_index>, | ||||
| make_derived_write_attribute<MPoly, int, get_material_index, set_material_index>, | make_derived_write_attribute<MPoly, int, get_material_index, set_material_index>, | ||||
| nullptr); | nullptr); | ||||
| static BuiltinCustomDataLayerProvider shade_smooth( | static BuiltinCustomDataLayerProvider shade_smooth( | ||||
| "shade_smooth", | "shade_smooth", | ||||
| ATTR_DOMAIN_FACE, | ATTR_DOMAIN_FACE, | ||||
| CD_PROP_BOOL, | CD_PROP_BOOL, | ||||
| CD_MPOLY, | CD_MPOLY, | ||||
Done Inline Actionsface_access JacquesLucke: `face_access` | |||||
| BuiltinAttributeProvider::NonCreatable, | BuiltinAttributeProvider::NonCreatable, | ||||
| BuiltinAttributeProvider::Writable, | BuiltinAttributeProvider::Writable, | ||||
| BuiltinAttributeProvider::NonDeletable, | BuiltinAttributeProvider::NonDeletable, | ||||
| face_access, | face_access, | ||||
| make_derived_read_attribute<MPoly, bool, get_shade_smooth>, | make_derived_read_attribute<MPoly, bool, get_shade_smooth>, | ||||
| make_derived_write_attribute<MPoly, bool, get_shade_smooth, set_shade_smooth>, | make_derived_write_attribute<MPoly, bool, get_shade_smooth, set_shade_smooth>, | ||||
| nullptr); | nullptr); | ||||
| Show All 27 Lines | static NamedLegacyCustomDataProvider vertex_colors( | ||||
| make_derived_write_attribute<MLoopCol, ColorGeometry4f, get_loop_color, set_loop_color>); | make_derived_write_attribute<MLoopCol, ColorGeometry4f, get_loop_color, set_loop_color>); | ||||
| static VertexGroupsAttributeProvider vertex_groups; | static VertexGroupsAttributeProvider vertex_groups; | ||||
| static CustomDataAttributeProvider corner_custom_data(ATTR_DOMAIN_CORNER, corner_access); | static CustomDataAttributeProvider corner_custom_data(ATTR_DOMAIN_CORNER, corner_access); | ||||
| static CustomDataAttributeProvider point_custom_data(ATTR_DOMAIN_POINT, point_access); | static CustomDataAttributeProvider point_custom_data(ATTR_DOMAIN_POINT, point_access); | ||||
| static CustomDataAttributeProvider edge_custom_data(ATTR_DOMAIN_EDGE, edge_access); | static CustomDataAttributeProvider edge_custom_data(ATTR_DOMAIN_EDGE, edge_access); | ||||
| static CustomDataAttributeProvider face_custom_data(ATTR_DOMAIN_FACE, face_access); | static CustomDataAttributeProvider face_custom_data(ATTR_DOMAIN_FACE, face_access); | ||||
| return ComponentAttributeProviders({&position, &material_index, &shade_smooth, &normal, &crease}, | return ComponentAttributeProviders( | ||||
| {&position, &random_point_id, &material_index, &shade_smooth, &normal, &crease}, | |||||
| {&uvs, | {&uvs, | ||||
| &vertex_colors, | &vertex_colors, | ||||
| &corner_custom_data, | &corner_custom_data, | ||||
| &vertex_groups, | &vertex_groups, | ||||
| &point_custom_data, | &point_custom_data, | ||||
| &edge_custom_data, | &edge_custom_data, | ||||
| &face_custom_data}); | &face_custom_data}); | ||||
| } | } | ||||
| } // namespace blender::bke | } // namespace blender::bke | ||||
| const blender::bke::ComponentAttributeProviders *MeshComponent::get_attribute_providers() const | const blender::bke::ComponentAttributeProviders *MeshComponent::get_attribute_providers() const | ||||
| { | { | ||||
| static blender::bke::ComponentAttributeProviders providers = | static blender::bke::ComponentAttributeProviders providers = | ||||
| blender::bke::create_attribute_providers_for_mesh(); | blender::bke::create_attribute_providers_for_mesh(); | ||||
| return &providers; | return &providers; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
edge_access