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>2021-12-23 02:39:35 +0300
committerHans Goudey <h.goudey@me.com>2021-12-23 02:39:35 +0300
commit60c59d7d611dfd72652d9f7ffef519f983703349 (patch)
tree2d5b51089820069ad2d9a4eaebfd931ea7ec8670 /source/blender/blenkernel
parentc593db5a2ffc2f0ad993e8d2a839f87404d2f4a6 (diff)
Cleanup: Remove spline add_point method, refactor mesh to curve node
It's better to calculate the size of a spline before creating it, and this should simplify refactoring to a data structure that stores all point attribute contiguously (see T94193). The mesh to curve conversion is simplified slightly now, it creates the curve output after gathering all of the result vertex indices. This should be more efficient too, since it only grows an index vector for each spline, not a whole spline.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_spline.hh24
-rw-r--r--source/blender/blenkernel/intern/curve_to_mesh_convert.cc5
-rw-r--r--source/blender/blenkernel/intern/spline_bezier.cc18
-rw-r--r--source/blender/blenkernel/intern/spline_nurbs.cc13
-rw-r--r--source/blender/blenkernel/intern/spline_poly.cc8
5 files changed, 4 insertions, 64 deletions
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh
index ebdc4a0ca0b..d66af092475 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -330,17 +330,6 @@ class BezierSpline final : public Spline {
int resolution() const;
void set_resolution(const int value);
- /**
- * \warning Call #reallocate on the spline's attributes after adding all points.
- */
- void add_point(const blender::float3 position,
- const HandleType handle_type_left,
- const blender::float3 handle_position_left,
- const HandleType handle_type_right,
- const blender::float3 handle_position_right,
- const float radius,
- const float tilt);
-
void resize(const int size) final;
blender::MutableSpan<blender::float3> positions() final;
blender::Span<blender::float3> positions() const final;
@@ -567,14 +556,6 @@ class NURBSpline final : public Spline {
uint8_t order() const;
void set_order(const uint8_t value);
- /**
- * \warning Call #reallocate on the spline's attributes after adding all points.
- */
- void add_point(const blender::float3 position,
- const float radius,
- const float tilt,
- const float weight);
-
bool check_valid_size_and_order() const;
int knots_size() const;
@@ -634,11 +615,6 @@ class PolySpline final : public Spline {
int size() const final;
- /**
- * \warning Call #reallocate on the spline's attributes after adding all points.
- */
- void add_point(const blender::float3 position, const float radius, const float tilt);
-
void resize(const int size) final;
blender::MutableSpan<blender::float3> positions() final;
blender::Span<blender::float3> positions() const final;
diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
index 8c256da44cd..073d9d18a04 100644
--- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
+++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
@@ -762,7 +762,10 @@ static CurveEval get_curve_single_vert()
{
CurveEval curve;
std::unique_ptr<PolySpline> spline = std::make_unique<PolySpline>();
- spline->add_point(float3(0), 0, 0.0f);
+ spline->resize(1.0f);
+ spline->positions().fill(float3(0));
+ spline->radii().fill(1.0f);
+ spline->tilts().fill(0.0f);
curve.add_spline(std::move(spline));
return curve;
diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc
index 9ce285cebb8..b24c8960857 100644
--- a/source/blender/blenkernel/intern/spline_bezier.cc
+++ b/source/blender/blenkernel/intern/spline_bezier.cc
@@ -70,24 +70,6 @@ void BezierSpline::set_resolution(const int value)
this->mark_cache_invalid();
}
-void BezierSpline::add_point(const float3 position,
- const HandleType handle_type_left,
- const float3 handle_position_left,
- const HandleType handle_type_right,
- const float3 handle_position_right,
- const float radius,
- const float tilt)
-{
- handle_types_left_.append(handle_type_left);
- handle_positions_left_.append(handle_position_left);
- positions_.append(position);
- handle_types_right_.append(handle_type_right);
- handle_positions_right_.append(handle_position_right);
- radii_.append(radius);
- tilts_.append(tilt);
- this->mark_cache_invalid();
-}
-
void BezierSpline::resize(const int size)
{
handle_types_left_.resize(size);
diff --git a/source/blender/blenkernel/intern/spline_nurbs.cc b/source/blender/blenkernel/intern/spline_nurbs.cc
index e9d4ba7c7ef..719ba4b7ecd 100644
--- a/source/blender/blenkernel/intern/spline_nurbs.cc
+++ b/source/blender/blenkernel/intern/spline_nurbs.cc
@@ -81,19 +81,6 @@ void NURBSpline::set_order(const uint8_t value)
this->mark_cache_invalid();
}
-void NURBSpline::add_point(const float3 position,
- const float radius,
- const float tilt,
- const float weight)
-{
- positions_.append(position);
- radii_.append(radius);
- tilts_.append(tilt);
- weights_.append(weight);
- knots_dirty_ = true;
- this->mark_cache_invalid();
-}
-
void NURBSpline::resize(const int size)
{
positions_.resize(size);
diff --git a/source/blender/blenkernel/intern/spline_poly.cc b/source/blender/blenkernel/intern/spline_poly.cc
index 4af68b5f270..480bbd1dfe8 100644
--- a/source/blender/blenkernel/intern/spline_poly.cc
+++ b/source/blender/blenkernel/intern/spline_poly.cc
@@ -45,14 +45,6 @@ int PolySpline::size() const
return size;
}
-void PolySpline::add_point(const float3 position, const float radius, const float tilt)
-{
- positions_.append(position);
- radii_.append(radius);
- tilts_.append(tilt);
- this->mark_cache_invalid();
-}
-
void PolySpline::resize(const int size)
{
positions_.resize(size);