Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-01-14 20:11:44 +0300
committerJacques Lucke <jacques@blender.org>2021-01-14 20:11:44 +0300
commit33a558bf21579b57f94329bc98d87f28e178c17a (patch)
treebeef56951bab7e40dd46d1d44a83e58a98173ec1 /source/blender
parent5c1b740f1ee254ba30be4c39d5222ad3eb8b0871 (diff)
Geometry Nodes: support accessing UV layers with attribute system
Note that uv layers still can't be accessed with nodes, because those only access attributes on the point domain currently, while uv data is stored per corner. Implicit domain conversion hasn't been implemented yet.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 6739294a2c4..b9ccee0dd4a 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -526,6 +526,10 @@ static ReadAttributePtr read_attribute_from_custom_data(const CustomData &custom
case CD_PROP_BOOL:
return std::make_unique<ArrayReadAttribute<bool>>(
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);
}
}
}
@@ -570,6 +574,12 @@ static WriteAttributePtr write_attribute_from_custom_data(
case CD_PROP_BOOL:
return std::make_unique<ArrayWriteAttribute<bool>>(
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);
}
}
}
@@ -597,8 +607,9 @@ static void get_custom_data_layer_attribute_names(const CustomData &custom_data,
Set<std::string> &r_names)
{
for (const CustomDataLayer &layer : blender::Span(custom_data.layers, custom_data.totlayer)) {
- if (component.attribute_domain_with_type_supported(domain,
- static_cast<CustomDataType>(layer.type))) {
+ const CustomDataType data_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);
}
}
@@ -1307,7 +1318,7 @@ Set<std::string> MeshComponent::attribute_names() const
for (StringRef name : vertex_group_names_.keys()) {
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_->edata, *this, ATTR_DOMAIN_EDGE, names);
get_custom_data_layer_attribute_names(mesh_->pdata, *this, ATTR_DOMAIN_POLYGON, names);