Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/attribute_access.cc
| Show First 20 Lines • Show All 1,344 Lines • ▼ Show 20 Lines | |||||
| static WriteAttributePtr make_material_index_write_attribute(void *data, const int domain_size) | static WriteAttributePtr make_material_index_write_attribute(void *data, const int domain_size) | ||||
| { | { | ||||
| return std::make_unique< | return std::make_unique< | ||||
| DerivedArrayWriteAttribute<MPoly, int, get_material_index, set_material_index>>( | DerivedArrayWriteAttribute<MPoly, int, get_material_index, set_material_index>>( | ||||
| ATTR_DOMAIN_POLYGON, MutableSpan<MPoly>((MPoly *)data, domain_size)); | ATTR_DOMAIN_POLYGON, MutableSpan<MPoly>((MPoly *)data, domain_size)); | ||||
| } | } | ||||
| static bool get_shade_smooth(const MPoly &mpoly) | |||||
| { | |||||
| return mpoly.flag & ME_SMOOTH; | |||||
| } | |||||
| static void set_shade_smooth(MPoly &mpoly, const bool &value) | |||||
| { | |||||
| SET_FLAG_FROM_TEST(mpoly.flag, value, ME_SMOOTH); | |||||
| } | |||||
| static ReadAttributePtr make_shade_smooth_read_attribute(const void *data, const int domain_size) | |||||
| { | |||||
| return std::make_unique<DerivedArrayReadAttribute<MPoly, bool, get_shade_smooth>>( | |||||
| ATTR_DOMAIN_POLYGON, Span<MPoly>((const MPoly *)data, domain_size)); | |||||
| } | |||||
| static WriteAttributePtr make_shade_smooth_write_attribute(void *data, const int domain_size) | |||||
| { | |||||
| return std::make_unique< | |||||
| DerivedArrayWriteAttribute<MPoly, bool, get_shade_smooth, set_shade_smooth>>( | |||||
| ATTR_DOMAIN_POLYGON, MutableSpan<MPoly>((MPoly *)data, domain_size)); | |||||
| } | |||||
| static float2 get_loop_uv(const MLoopUV &uv) | static float2 get_loop_uv(const MLoopUV &uv) | ||||
| { | { | ||||
| return float2(uv.uv); | return float2(uv.uv); | ||||
| } | } | ||||
| static void set_loop_uv(MLoopUV &uv, const float2 &co) | static void set_loop_uv(MLoopUV &uv, const float2 &co) | ||||
| { | { | ||||
| copy_v2_v2(uv.uv, co); | copy_v2_v2(uv.uv, co); | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | static BuiltinCustomDataLayerProvider material_index("material_index", | ||||
| BuiltinAttributeProvider::NonCreatable, | BuiltinAttributeProvider::NonCreatable, | ||||
| BuiltinAttributeProvider::Writable, | BuiltinAttributeProvider::Writable, | ||||
| BuiltinAttributeProvider::NonDeletable, | BuiltinAttributeProvider::NonDeletable, | ||||
| polygon_access, | polygon_access, | ||||
| make_material_index_read_attribute, | make_material_index_read_attribute, | ||||
| make_material_index_write_attribute, | make_material_index_write_attribute, | ||||
| nullptr); | nullptr); | ||||
| static BuiltinCustomDataLayerProvider shade_smooth("shade_smooth", | |||||
| ATTR_DOMAIN_POLYGON, | |||||
| CD_PROP_BOOL, | |||||
| CD_MPOLY, | |||||
| BuiltinAttributeProvider::NonCreatable, | |||||
| BuiltinAttributeProvider::Writable, | |||||
| BuiltinAttributeProvider::NonDeletable, | |||||
| polygon_access, | |||||
| make_shade_smooth_read_attribute, | |||||
| make_shade_smooth_write_attribute, | |||||
| nullptr); | |||||
| static NamedLegacyCustomDataProvider uvs(ATTR_DOMAIN_CORNER, | static NamedLegacyCustomDataProvider uvs(ATTR_DOMAIN_CORNER, | ||||
| CD_PROP_FLOAT2, | CD_PROP_FLOAT2, | ||||
| CD_MLOOPUV, | CD_MLOOPUV, | ||||
| corner_access, | corner_access, | ||||
| make_uvs_read_attribute, | make_uvs_read_attribute, | ||||
| make_uvs_write_attribute); | make_uvs_write_attribute); | ||||
| static NamedLegacyCustomDataProvider vertex_colors(ATTR_DOMAIN_CORNER, | static NamedLegacyCustomDataProvider vertex_colors(ATTR_DOMAIN_CORNER, | ||||
| CD_PROP_COLOR, | CD_PROP_COLOR, | ||||
| CD_MLOOPCOL, | CD_MLOOPCOL, | ||||
| corner_access, | corner_access, | ||||
| make_vertex_color_read_attribute, | make_vertex_color_read_attribute, | ||||
| make_vertex_color_write_attribute); | make_vertex_color_write_attribute); | ||||
| 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 polygon_custom_data(ATTR_DOMAIN_POLYGON, polygon_access); | static CustomDataAttributeProvider polygon_custom_data(ATTR_DOMAIN_POLYGON, polygon_access); | ||||
| return ComponentAttributeProviders({&position, &material_index}, | return ComponentAttributeProviders({&position, &material_index, &shade_smooth}, | ||||
| {&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, | ||||
| &polygon_custom_data}); | &polygon_custom_data}); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 667 Lines • Show Last 20 Lines | |||||