diff options
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index 578f0298a19..2b6d25b6bf3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -30,9 +30,9 @@ static void geo_node_curve_trim_declare(NodeDeclarationBuilder &b) { b.add_input<decl::Geometry>("Curve"); b.add_input<decl::Float>("Start").min(0.0f).max(1.0f).subtype(PROP_FACTOR); - b.add_input<decl::Float>("End").min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>("End").min(0.0f).max(1.0f).default_value(1.0f).subtype(PROP_FACTOR); b.add_input<decl::Float>("Start", "Start_001").min(0.0f).subtype(PROP_DISTANCE); - b.add_input<decl::Float>("End", "End_001").min(0.0f).subtype(PROP_DISTANCE); + b.add_input<decl::Float>("End", "End_001").min(0.0f).default_value(1.0f).subtype(PROP_DISTANCE); b.add_output<decl::Geometry>("Curve"); } @@ -46,25 +46,24 @@ static void geo_node_curve_trim_init(bNodeTree *UNUSED(tree), bNode *node) NodeGeometryCurveTrim *data = (NodeGeometryCurveTrim *)MEM_callocN(sizeof(NodeGeometryCurveTrim), __func__); - data->mode = GEO_NODE_CURVE_INTERPOLATE_FACTOR; + data->mode = GEO_NODE_CURVE_SAMPLE_FACTOR; node->storage = data; } static void geo_node_curve_trim_update(bNodeTree *UNUSED(ntree), bNode *node) { const NodeGeometryCurveTrim &node_storage = *(NodeGeometryCurveTrim *)node->storage; - const GeometryNodeCurveInterpolateMode mode = (GeometryNodeCurveInterpolateMode) - node_storage.mode; + const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)node_storage.mode; bNodeSocket *start_fac = ((bNodeSocket *)node->inputs.first)->next; bNodeSocket *end_fac = start_fac->next; bNodeSocket *start_len = end_fac->next; bNodeSocket *end_len = start_len->next; - nodeSetSocketAvailability(start_fac, mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR); - nodeSetSocketAvailability(end_fac, mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR); - nodeSetSocketAvailability(start_len, mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH); - nodeSetSocketAvailability(end_len, mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH); + nodeSetSocketAvailability(start_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); + nodeSetSocketAvailability(end_fac, mode == GEO_NODE_CURVE_SAMPLE_FACTOR); + nodeSetSocketAvailability(start_len, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); + nodeSetSocketAvailability(end_len, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); } struct TrimLocation { @@ -158,8 +157,8 @@ static void trim_poly_spline(Spline &spline, linear_trim_data<float>(start, end, spline.tilts()); spline.attributes.foreach_attribute( - [&](StringRefNull name, const AttributeMetaData &UNUSED(meta_data)) { - std::optional<GMutableSpan> src = spline.attributes.get_for_write(name); + [&](const AttributeIDRef &attribute_id, const AttributeMetaData &UNUSED(meta_data)) { + std::optional<GMutableSpan> src = spline.attributes.get_for_write(attribute_id); BLI_assert(src); attribute_math::convert_to_static_type(src->type(), [&](auto dummy) { using T = decltype(dummy); @@ -193,14 +192,14 @@ static PolySpline trim_nurbs_spline(const Spline &spline, /* Copy generic attribute data. */ spline.attributes.foreach_attribute( - [&](StringRefNull name, const AttributeMetaData &meta_data) { - std::optional<GSpan> src = spline.attributes.get_for_read(name); + [&](const AttributeIDRef &attribute_id, const AttributeMetaData &meta_data) { + std::optional<GSpan> src = spline.attributes.get_for_read(attribute_id); BLI_assert(src); - if (!new_spline.attributes.create(name, meta_data.data_type)) { + if (!new_spline.attributes.create(attribute_id, meta_data.data_type)) { BLI_assert_unreachable(); return false; } - std::optional<GMutableSpan> dst = new_spline.attributes.get_for_write(name); + std::optional<GMutableSpan> dst = new_spline.attributes.get_for_write(attribute_id); BLI_assert(dst); attribute_math::convert_to_static_type(src->type(), [&](auto dummy) { @@ -249,8 +248,8 @@ static void trim_bezier_spline(Spline &spline, linear_trim_data<float>(start, end, bezier_spline.radii()); linear_trim_data<float>(start, end, bezier_spline.tilts()); spline.attributes.foreach_attribute( - [&](StringRefNull name, const AttributeMetaData &UNUSED(meta_data)) { - std::optional<GMutableSpan> src = spline.attributes.get_for_write(name); + [&](const AttributeIDRef &attribute_id, const AttributeMetaData &UNUSED(meta_data)) { + std::optional<GMutableSpan> src = spline.attributes.get_for_write(attribute_id); BLI_assert(src); attribute_math::convert_to_static_type(src->type(), [&](auto dummy) { using T = decltype(dummy); @@ -324,8 +323,7 @@ static void trim_bezier_spline(Spline &spline, static void geo_node_curve_trim_exec(GeoNodeExecParams params) { const NodeGeometryCurveTrim &node_storage = *(NodeGeometryCurveTrim *)params.node().storage; - const GeometryNodeCurveInterpolateMode mode = (GeometryNodeCurveInterpolateMode) - node_storage.mode; + const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)node_storage.mode; GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve"); geometry_set = bke::geometry_set_realize_instances(geometry_set); @@ -338,12 +336,11 @@ static void geo_node_curve_trim_exec(GeoNodeExecParams params) CurveEval &curve = *curve_component.get_for_write(); MutableSpan<SplinePtr> splines = curve.splines(); - const float start = mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR ? + const float start = mode == GEO_NODE_CURVE_SAMPLE_FACTOR ? params.extract_input<float>("Start") : params.extract_input<float>("Start_001"); - const float end = mode == GEO_NODE_CURVE_INTERPOLATE_FACTOR ? - params.extract_input<float>("End") : - params.extract_input<float>("End_001"); + const float end = mode == GEO_NODE_CURVE_SAMPLE_FACTOR ? params.extract_input<float>("End") : + params.extract_input<float>("End_001"); threading::parallel_for(splines.index_range(), 128, [&](IndexRange range) { for (const int i : range) { @@ -362,11 +359,11 @@ static void geo_node_curve_trim_exec(GeoNodeExecParams params) } const Spline::LookupResult start_lookup = - (mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH) ? + (mode == GEO_NODE_CURVE_SAMPLE_LENGTH) ? spline.lookup_evaluated_length(std::clamp(start, 0.0f, spline.length())) : spline.lookup_evaluated_factor(std::clamp(start, 0.0f, 1.0f)); const Spline::LookupResult end_lookup = - (mode == GEO_NODE_CURVE_INTERPOLATE_LENGTH) ? + (mode == GEO_NODE_CURVE_SAMPLE_LENGTH) ? spline.lookup_evaluated_length(std::clamp(end, 0.0f, spline.length())) : spline.lookup_evaluated_factor(std::clamp(end, 0.0f, 1.0f)); |