Cleanup: Use standard variable names for curves
This commit is contained in:
@@ -373,15 +373,15 @@ static void copy_attributes_between_components(const GeometryComponent &src_comp
|
||||
});
|
||||
}
|
||||
|
||||
std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves)
|
||||
std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves_id)
|
||||
{
|
||||
CurveComponent src_component;
|
||||
src_component.replace(&const_cast<Curves &>(curves), GeometryOwnershipType::ReadOnly);
|
||||
const blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap(
|
||||
curves.geometry);
|
||||
src_component.replace(&const_cast<Curves &>(curves_id), GeometryOwnershipType::ReadOnly);
|
||||
const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap(
|
||||
curves_id.geometry);
|
||||
|
||||
VArray<int> resolution = geometry.resolution();
|
||||
VArray<int8_t> normal_mode = geometry.normal_mode();
|
||||
VArray<int> resolution = curves.resolution();
|
||||
VArray<int8_t> normal_mode = curves.normal_mode();
|
||||
|
||||
VArray_Span<float> nurbs_weights{
|
||||
src_component.attribute_get_for_read<float>("nurbs_weight", ATTR_DOMAIN_POINT, 0.0f)};
|
||||
@@ -396,34 +396,34 @@ std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves)
|
||||
src_component.attribute_get_for_read<int8_t>("handle_type_left", ATTR_DOMAIN_POINT, 0)};
|
||||
|
||||
/* Create splines with the correct size and type. */
|
||||
VArray<int8_t> curve_types = geometry.curve_types();
|
||||
VArray<int8_t> curve_types = curves.curve_types();
|
||||
std::unique_ptr<CurveEval> curve_eval = std::make_unique<CurveEval>();
|
||||
for (const int curve_index : curve_types.index_range()) {
|
||||
const IndexRange point_range = geometry.points_for_curve(curve_index);
|
||||
const IndexRange points = curves.points_for_curve(curve_index);
|
||||
|
||||
std::unique_ptr<Spline> spline;
|
||||
/* #CurveEval does not support catmull rom curves, so convert those to poly splines. */
|
||||
switch (std::max<int8_t>(1, curve_types[curve_index])) {
|
||||
case CURVE_TYPE_POLY: {
|
||||
spline = std::make_unique<PolySpline>();
|
||||
spline->resize(point_range.size());
|
||||
spline->resize(points.size());
|
||||
break;
|
||||
}
|
||||
case CURVE_TYPE_BEZIER: {
|
||||
std::unique_ptr<BezierSpline> bezier_spline = std::make_unique<BezierSpline>();
|
||||
bezier_spline->resize(point_range.size());
|
||||
bezier_spline->resize(points.size());
|
||||
bezier_spline->set_resolution(resolution[curve_index]);
|
||||
bezier_spline->handle_types_left().copy_from(handle_types_left.slice(point_range));
|
||||
bezier_spline->handle_types_right().copy_from(handle_types_right.slice(point_range));
|
||||
bezier_spline->handle_types_left().copy_from(handle_types_left.slice(points));
|
||||
bezier_spline->handle_types_right().copy_from(handle_types_right.slice(points));
|
||||
|
||||
spline = std::move(bezier_spline);
|
||||
break;
|
||||
}
|
||||
case CURVE_TYPE_NURBS: {
|
||||
std::unique_ptr<NURBSpline> nurb_spline = std::make_unique<NURBSpline>();
|
||||
nurb_spline->resize(point_range.size());
|
||||
nurb_spline->resize(points.size());
|
||||
nurb_spline->set_resolution(resolution[curve_index]);
|
||||
nurb_spline->weights().copy_from(nurbs_weights.slice(point_range));
|
||||
nurb_spline->weights().copy_from(nurbs_weights.slice(points));
|
||||
nurb_spline->set_order(nurbs_orders[curve_index]);
|
||||
nurb_spline->knots_mode = static_cast<KnotsMode>(nurbs_knots_modes[curve_index]);
|
||||
|
||||
@@ -463,14 +463,14 @@ std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves)
|
||||
|
||||
Curves *curve_eval_to_curves(const CurveEval &curve_eval)
|
||||
{
|
||||
Curves *curves = blender::bke::curves_new_nomain(curve_eval.total_control_point_num(),
|
||||
curve_eval.splines().size());
|
||||
Curves *curves_id = blender::bke::curves_new_nomain(curve_eval.total_control_point_num(),
|
||||
curve_eval.splines().size());
|
||||
CurveComponent dst_component;
|
||||
dst_component.replace(curves, GeometryOwnershipType::Editable);
|
||||
dst_component.replace(curves_id, GeometryOwnershipType::Editable);
|
||||
|
||||
blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap(curves->geometry);
|
||||
geometry.offsets_for_write().copy_from(curve_eval.control_point_offsets());
|
||||
MutableSpan<int8_t> curve_types = geometry.curve_types_for_write();
|
||||
blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap(curves_id->geometry);
|
||||
curves.offsets_for_write().copy_from(curve_eval.control_point_offsets());
|
||||
MutableSpan<int8_t> curve_types = curves.curve_types_for_write();
|
||||
|
||||
OutputAttribute_Typed<int8_t> normal_mode =
|
||||
dst_component.attribute_try_get_for_output_only<int8_t>("normal_mode", ATTR_DOMAIN_CURVE);
|
||||
@@ -498,22 +498,22 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval)
|
||||
const Spline &spline = *curve_eval.splines()[curve_index];
|
||||
curve_types[curve_index] = curve_eval.splines()[curve_index]->type();
|
||||
normal_mode.as_span()[curve_index] = curve_eval.splines()[curve_index]->normal_mode;
|
||||
const IndexRange point_range = geometry.points_for_curve(curve_index);
|
||||
const IndexRange points = curves.points_for_curve(curve_index);
|
||||
|
||||
switch (spline.type()) {
|
||||
case CURVE_TYPE_POLY:
|
||||
break;
|
||||
case CURVE_TYPE_BEZIER: {
|
||||
const BezierSpline &src = static_cast<const BezierSpline &>(spline);
|
||||
handle_type_right.as_span().slice(point_range).copy_from(src.handle_types_right());
|
||||
handle_type_left.as_span().slice(point_range).copy_from(src.handle_types_left());
|
||||
handle_type_right.as_span().slice(points).copy_from(src.handle_types_right());
|
||||
handle_type_left.as_span().slice(points).copy_from(src.handle_types_left());
|
||||
break;
|
||||
}
|
||||
case CURVE_TYPE_NURBS: {
|
||||
const NURBSpline &src = static_cast<const NURBSpline &>(spline);
|
||||
nurbs_knots_mode.as_span()[curve_index] = static_cast<int8_t>(src.knots_mode);
|
||||
nurbs_order.as_span()[curve_index] = src.order();
|
||||
nurbs_weight.as_span().slice(point_range).copy_from(src.weights());
|
||||
nurbs_weight.as_span().slice(points).copy_from(src.weights());
|
||||
break;
|
||||
}
|
||||
case CURVE_TYPE_CATMULL_ROM: {
|
||||
@@ -523,7 +523,7 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval)
|
||||
}
|
||||
}
|
||||
|
||||
geometry.update_curve_types();
|
||||
curves.update_curve_types();
|
||||
|
||||
normal_mode.save();
|
||||
nurbs_weight.save();
|
||||
@@ -537,7 +537,7 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval)
|
||||
|
||||
copy_attributes_between_components(src_component, dst_component, {});
|
||||
|
||||
return curves;
|
||||
return curves_id;
|
||||
}
|
||||
|
||||
void CurveEval::assert_valid_point_attributes() const
|
||||
|
||||
Reference in New Issue
Block a user