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
path: root/source
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
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')
-rw-r--r--source/blender/blenkernel/intern/geometry_component_mesh.cc36
-rw-r--r--source/blender/blenkernel/intern/geometry_set_instances.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc2
3 files changed, 37 insertions, 3 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,
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc
index fc9d793c119..ce54ec7911f 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -381,7 +381,7 @@ static void join_instance_groups_mesh(Span<GeometryInstanceGroup> set_groups,
gather_attribute_info(attributes,
component_types,
set_groups,
- {"position", "material_index", "normal", "shade_smooth"});
+ {"position", "material_index", "normal", "shade_smooth", "crease"});
join_attributes(
set_groups, component_types, attributes, static_cast<GeometryComponent &>(dst_component));
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
index 54b0c07a0a0..52512769a47 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
@@ -224,7 +224,7 @@ static void join_components(Span<const MeshComponent *> src_components, Geometry
/* Don't copy attributes that are stored directly in the mesh data structs. */
join_attributes(to_base_components(src_components),
dst_component,
- {"position", "material_index", "normal", "shade_smooth"});
+ {"position", "material_index", "normal", "shade_smooth", "crease"});
}
static void join_components(Span<const PointCloudComponent *> src_components, GeometrySet &result)