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:
authorHans Goudey <h.goudey@me.com>2022-04-09 20:46:30 +0300
committerHans Goudey <h.goudey@me.com>2022-04-09 20:46:30 +0300
commitceed37fc5cbb466a04b4b4f7afba5dcd561fdd6a (patch)
tree83f515a54846d868d57a10f14854df69cf4c82fd /source/blender/blenkernel/intern/curve_eval.cc
parent69a4d113e8dd3f2f267536b2b93af2540f3a0978 (diff)
Curves: Port tangent and normal calculation to the new data-block
Port the "Normal" and "Curve Tangent" nodes to the new curves data-block to avoid the conversion to `CurveEval`. This should make them faster by avoiding all that copying, but otherwise nothing else has changed. This also includes a fix to move the normal mode as a built-in curve attribute when converting to and from `CurveEval`. The attribute is needed because the option is used implicitly in many nodes currently. Differential Revision: https://developer.blender.org/D14609
Diffstat (limited to 'source/blender/blenkernel/intern/curve_eval.cc')
-rw-r--r--source/blender/blenkernel/intern/curve_eval.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc
index 9b1fd510fa8..6e09d1e8f10 100644
--- a/source/blender/blenkernel/intern/curve_eval.cc
+++ b/source/blender/blenkernel/intern/curve_eval.cc
@@ -381,6 +381,7 @@ std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves)
curves.geometry);
VArray<int> resolution = geometry.resolution();
+ VArray<int8_t> normal_mode = geometry.normal_mode();
VArray_Span<float> nurbs_weights{
src_component.attribute_get_for_read<float>("nurbs_weight", ATTR_DOMAIN_POINT, 0.0f)};
@@ -436,6 +437,7 @@ std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves)
spline->positions().fill(float3(0));
spline->tilts().fill(0.0f);
spline->radii().fill(1.0f);
+ spline->normal_mode = static_cast<NormalMode>(normal_mode[curve_index]);
curve_eval->add_spline(std::move(spline));
}
@@ -448,6 +450,7 @@ std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves)
dst_component,
{"curve_type",
"resolution",
+ "normal_mode",
"nurbs_weight",
"nurbs_order",
"knots_mode",
@@ -468,6 +471,8 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval)
geometry.offsets_for_write().copy_from(curve_eval.control_point_offsets());
MutableSpan<int8_t> curve_types = geometry.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);
OutputAttribute_Typed<float> nurbs_weight;
OutputAttribute_Typed<int> nurbs_order;
OutputAttribute_Typed<int8_t> nurbs_knots_mode;
@@ -491,7 +496,7 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval)
for (const int curve_index : curve_eval.splines().index_range()) {
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);
switch (spline.type()) {
@@ -517,6 +522,7 @@ Curves *curve_eval_to_curves(const CurveEval &curve_eval)
}
}
+ normal_mode.save();
nurbs_weight.save();
nurbs_order.save();
nurbs_knots_mode.save();