[Bf-blender-cvs] [797331db861] geometry-nodes-curve-support: Geometry Nodes Curves: Make edges sharp in curve to mesh node
Hans Goudey
noreply at git.blender.org
Fri Apr 9 06:17:15 CEST 2021
Commit: 797331db86136d4f5b299ca55bdbab2046bc1b02
Author: Hans Goudey
Date: Thu Apr 8 23:17:09 2021 -0500
Branches: geometry-nodes-curve-support
https://developer.blender.org/rB797331db86136d4f5b299ca55bdbab2046bc1b02
Geometry Nodes Curves: Make edges sharp in curve to mesh node
===================================================================
M source/blender/blenkernel/BKE_derived_curve.hh
M source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_derived_curve.hh b/source/blender/blenkernel/BKE_derived_curve.hh
index 355e3881913..9f67de77afc 100644
--- a/source/blender/blenkernel/BKE_derived_curve.hh
+++ b/source/blender/blenkernel/BKE_derived_curve.hh
@@ -57,6 +57,12 @@ struct BezierPoint {
float radius;
/* User defined tilt in radians, added on top of the auto-calculated tilt. */
float tilt;
+
+ bool is_sharp() const
+ {
+ return ELEM(handle_type_a, HandleType::Vector, HandleType::Free) ||
+ ELEM(handle_type_b, HandleType::Vector, HandleType::Free);
+ }
};
/* TODO: Think about storing each data type from each control point separately. */
@@ -103,6 +109,11 @@ class Spline {
this->ensure_base_cache();
return evaluated_positions_cache_;
}
+ blender::Span<PointMapping> evaluated_mappings() const
+ {
+ this->ensure_base_cache();
+ return evaluated_mapping_cache_;
+ }
blender::Span<float> evaluated_length() const
{
this->ensure_length_cache();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
index e610203685a..90efaaaa48d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
@@ -193,17 +193,19 @@ static void spline_extrude_to_mesh_data(const Spline &spline,
}
/* Mark edge loops from sharp vector control points sharp. */
- // if (profile_spline.type == Spline::Bezier) {
- // const BezierSpline &bezier_spline = static_cast<const BezierSpline &>(profile_spline);
- // Span<PointMapping> mappings = bezier_spline.evaluated_mappings();
- // for (const int i_profile : mappings.index_range()) {
- // const int control_point_index = mappings[i_profile].control_point_index;
- // if (bezier_spline.control_points[control_point_index].is_sharp()) {
- // mark_edges_sharp(
- // edges.slice(spline_edges_start + spline_edge_len * i_profile, spline_edge_len));
- // }
- // }
- // }
+ if (profile_spline.type == Spline::Bezier) {
+ const BezierSpline &bezier_spline = static_cast<const BezierSpline &>(profile_spline);
+ Span<PointMapping> mappings = bezier_spline.evaluated_mappings();
+ for (const int i_profile : mappings.index_range()) {
+ const PointMapping &mapping = mappings[i_profile];
+ if (mapping.factor == 0.0f) {
+ if (bezier_spline.control_points[mapping.control_point_index].is_sharp()) {
+ mark_edges_sharp(
+ edges.slice(spline_edges_start + spline_edge_len * i_profile, spline_edge_len));
+ }
+ }
+ }
+ }
}
static Mesh *curve_to_mesh_calculate(const DCurve &curve, const DCurve &profile_curve)
@@ -244,8 +246,8 @@ static Mesh *curve_to_mesh_calculate(const DCurve &curve, const DCurve &profile_
MutableSpan<MEdge> edges{mesh->medge, mesh->totedge};
MutableSpan<MLoop> loops{mesh->mloop, mesh->totloop};
MutableSpan<MPoly> polys{mesh->mpoly, mesh->totpoly};
- // mesh->flag |= ME_AUTOSMOOTH;
- // mesh->smoothresh = DEG2RADF(180.0f);
+ mesh->flag |= ME_AUTOSMOOTH;
+ mesh->smoothresh = DEG2RADF(180.0f);
int vert_offset = 0;
int edge_offset = 0;
More information about the Bf-blender-cvs
mailing list