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-03-15 17:32:30 +0300
committerJacques Lucke <jacques@blender.org>2021-03-15 17:38:57 +0300
commit3618948df85f18f6ab5d33e10139520b4c3dd092 (patch)
tree647a84cf35c6c1e131898ab8b93d960cf9cd6de1 /source/blender/blenkernel/intern/geometry_component_mesh.cc
parent992abd4734a04b493e32ed900d4c7a786fd71549 (diff)
Geometry Nodes: expose builtin crease attribute
This exposes the `crease` attribute, that is used by the Subdivide Smooth node. It is also the first attribute on the edge domain. Domain interpolations for the edge domain have not been implemented yet. Ref T86397. Differential Revision: https://developer.blender.org/D10660
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_component_mesh.cc')
-rw-r--r--source/blender/blenkernel/intern/geometry_component_mesh.cc36
1 files changed, 35 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index d0c1929816f..b376a9dd083 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -604,6 +604,28 @@ static WriteAttributePtr make_vertex_color_write_attribute(void *data, const int
ATTR_DOMAIN_CORNER, MutableSpan((MLoopCol *)data, domain_size));
}
+static float get_crease(const MEdge &edge)
+{
+ return edge.crease / 255.0f;
+}
+
+static void set_crease(MEdge &edge, const float &value)
+{
+ edge.crease = round_fl_to_uchar_clamp(value * 255.0f);
+}
+
+static ReadAttributePtr make_crease_read_attribute(const void *data, const int domain_size)
+{
+ return std::make_unique<DerivedArrayReadAttribute<MEdge, float, get_crease>>(
+ ATTR_DOMAIN_EDGE, Span((const MEdge *)data, domain_size));
+}
+
+static WriteAttributePtr make_crease_write_attribute(void *data, const int domain_size)
+{
+ return std::make_unique<DerivedArrayWriteAttribute<MEdge, float, get_crease, set_crease>>(
+ ATTR_DOMAIN_EDGE, MutableSpan((MEdge *)data, domain_size));
+}
+
class VertexWeightWriteAttribute final : public WriteAttribute {
private:
MDeformVert *dverts_;
@@ -903,6 +925,18 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
make_shade_smooth_write_attribute,
nullptr);
+ static BuiltinCustomDataLayerProvider crease("crease",
+ ATTR_DOMAIN_EDGE,
+ CD_PROP_FLOAT,
+ CD_MEDGE,
+ BuiltinAttributeProvider::NonCreatable,
+ BuiltinAttributeProvider::Writable,
+ BuiltinAttributeProvider::NonDeletable,
+ edge_access,
+ make_crease_read_attribute,
+ make_crease_write_attribute,
+ nullptr);
+
static NamedLegacyCustomDataProvider uvs(ATTR_DOMAIN_CORNER,
CD_PROP_FLOAT2,
CD_MLOOPUV,
@@ -923,7 +957,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
static CustomDataAttributeProvider edge_custom_data(ATTR_DOMAIN_EDGE, edge_access);
static CustomDataAttributeProvider polygon_custom_data(ATTR_DOMAIN_POLYGON, polygon_access);
- return ComponentAttributeProviders({&position, &material_index, &shade_smooth, &normal},
+ return ComponentAttributeProviders({&position, &material_index, &shade_smooth, &normal, &crease},
{&uvs,
&vertex_colors,
&corner_custom_data,