Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/attribute_access.cc
| Show First 20 Lines • Show All 520 Lines • ▼ Show 20 Lines | if (layer.name != nullptr && layer.name == attribute_name) { | ||||
| return std::make_unique<ArrayReadAttribute<int>>( | return std::make_unique<ArrayReadAttribute<int>>( | ||||
| domain, Span(static_cast<int *>(layer.data), size)); | domain, Span(static_cast<int *>(layer.data), size)); | ||||
| case CD_PROP_COLOR: | case CD_PROP_COLOR: | ||||
| return std::make_unique<ArrayReadAttribute<Color4f>>( | return std::make_unique<ArrayReadAttribute<Color4f>>( | ||||
| domain, Span(static_cast<Color4f *>(layer.data), size)); | domain, Span(static_cast<Color4f *>(layer.data), size)); | ||||
| case CD_PROP_BOOL: | case CD_PROP_BOOL: | ||||
| return std::make_unique<ArrayReadAttribute<bool>>( | return std::make_unique<ArrayReadAttribute<bool>>( | ||||
| domain, Span(static_cast<bool *>(layer.data), size)); | domain, Span(static_cast<bool *>(layer.data), size)); | ||||
| case CD_MLOOPUV: | |||||
| auto get_uv = [](const MLoopUV &uv) { return float2(uv.uv); }; | |||||
| return std::make_unique<DerivedArrayReadAttribute<MLoopUV, float2, decltype(get_uv)>>( | |||||
| domain, Span(static_cast<MLoopUV *>(layer.data), size), get_uv); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| static WriteAttributePtr write_attribute_from_custom_data( | static WriteAttributePtr write_attribute_from_custom_data( | ||||
| CustomData &custom_data, | CustomData &custom_data, | ||||
| Show All 28 Lines | if (layer.name != nullptr && layer.name == attribute_name) { | ||||
| return std::make_unique<ArrayWriteAttribute<int>>( | return std::make_unique<ArrayWriteAttribute<int>>( | ||||
| domain, MutableSpan(static_cast<int *>(layer.data), size)); | domain, MutableSpan(static_cast<int *>(layer.data), size)); | ||||
| case CD_PROP_COLOR: | case CD_PROP_COLOR: | ||||
| return std::make_unique<ArrayWriteAttribute<Color4f>>( | return std::make_unique<ArrayWriteAttribute<Color4f>>( | ||||
| domain, MutableSpan(static_cast<Color4f *>(layer.data), size)); | domain, MutableSpan(static_cast<Color4f *>(layer.data), size)); | ||||
| case CD_PROP_BOOL: | case CD_PROP_BOOL: | ||||
| return std::make_unique<ArrayWriteAttribute<bool>>( | return std::make_unique<ArrayWriteAttribute<bool>>( | ||||
| domain, MutableSpan(static_cast<bool *>(layer.data), size)); | domain, MutableSpan(static_cast<bool *>(layer.data), size)); | ||||
| case CD_MLOOPUV: | |||||
| auto get_uv = [](const MLoopUV &uv) { return float2(uv.uv); }; | |||||
| auto set_uv = [](MLoopUV &uv, const float2 value) { copy_v2_v2(uv.uv, value); }; | |||||
| return std::make_unique< | |||||
| DerivedArrayWriteAttribute<MLoopUV, float2, decltype(get_uv), decltype(set_uv)>>( | |||||
| domain, MutableSpan(static_cast<MLoopUV *>(layer.data), size), get_uv, set_uv); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| /* Returns true when the layer was found and is deleted. */ | /* Returns true when the layer was found and is deleted. */ | ||||
| static bool delete_named_custom_data_layer(CustomData &custom_data, | static bool delete_named_custom_data_layer(CustomData &custom_data, | ||||
| Show All 11 Lines | |||||
| } | } | ||||
| static void get_custom_data_layer_attribute_names(const CustomData &custom_data, | static void get_custom_data_layer_attribute_names(const CustomData &custom_data, | ||||
| const GeometryComponent &component, | const GeometryComponent &component, | ||||
| const AttributeDomain domain, | const AttributeDomain domain, | ||||
| Set<std::string> &r_names) | Set<std::string> &r_names) | ||||
| { | { | ||||
| for (const CustomDataLayer &layer : blender::Span(custom_data.layers, custom_data.totlayer)) { | for (const CustomDataLayer &layer : blender::Span(custom_data.layers, custom_data.totlayer)) { | ||||
| if (component.attribute_domain_with_type_supported(domain, | const CustomDataType data_type = static_cast<CustomDataType>(layer.type); | ||||
| static_cast<CustomDataType>(layer.type))) { | if (component.attribute_domain_with_type_supported(domain, data_type) || | ||||
| ELEM(data_type, CD_MLOOPUV)) { | |||||
| r_names.add(layer.name); | r_names.add(layer.name); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 712 Lines • ▼ Show 20 Lines | if (mesh_ == nullptr) { | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| Set<std::string> names; | Set<std::string> names; | ||||
| names.add("position"); | names.add("position"); | ||||
| for (StringRef name : vertex_group_names_.keys()) { | for (StringRef name : vertex_group_names_.keys()) { | ||||
| names.add(name); | names.add(name); | ||||
| } | } | ||||
| get_custom_data_layer_attribute_names(mesh_->pdata, *this, ATTR_DOMAIN_CORNER, names); | get_custom_data_layer_attribute_names(mesh_->ldata, *this, ATTR_DOMAIN_CORNER, names); | ||||
| get_custom_data_layer_attribute_names(mesh_->vdata, *this, ATTR_DOMAIN_POINT, names); | get_custom_data_layer_attribute_names(mesh_->vdata, *this, ATTR_DOMAIN_POINT, names); | ||||
| get_custom_data_layer_attribute_names(mesh_->edata, *this, ATTR_DOMAIN_EDGE, names); | get_custom_data_layer_attribute_names(mesh_->edata, *this, ATTR_DOMAIN_EDGE, names); | ||||
| get_custom_data_layer_attribute_names(mesh_->pdata, *this, ATTR_DOMAIN_POLYGON, names); | get_custom_data_layer_attribute_names(mesh_->pdata, *this, ATTR_DOMAIN_POLYGON, names); | ||||
| return names; | return names; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||