[Bf-blender-cvs] [e253f9f66d6] master: Cleanup: Adjust naming in new curves code
Hans Goudey
noreply at git.blender.org
Thu Mar 24 05:05:54 CET 2022
Commit: e253f9f66d6f63592ffd97afe207ef7c72547d03
Author: Hans Goudey
Date: Wed Mar 23 23:01:02 2022 -0500
Branches: master
https://developer.blender.org/rBe253f9f66d6f63592ffd97afe207ef7c72547d03
Cleanup: Adjust naming in new curves code
Rename "size" variables and functions to use "num" instead,
based on T85728 (though this doesn't apply to simple C++
containers, it applies here). Rename "range" to "points" in
some functions, so be more specific.
Differential Revision: https://developer.blender.org/D14431
===================================================================
M source/blender/blenkernel/BKE_curves.hh
M source/blender/blenkernel/intern/curve_catmull_rom.cc
M source/blender/blenkernel/intern/curve_eval.cc
M source/blender/blenkernel/intern/curve_nurbs.cc
M source/blender/blenkernel/intern/curves.cc
M source/blender/blenkernel/intern/curves_geometry.cc
M source/blender/blenkernel/intern/curves_geometry_test.cc
M source/blender/blenkernel/intern/geometry_component_curves.cc
M source/blender/draw/intern/draw_cache_impl_curves.cc
M source/blender/editors/curves/intern/curves_add.cc
M source/blender/editors/sculpt_paint/curves_sculpt_3d_brush.cc
M source/blender/editors/sculpt_paint/curves_sculpt_add.cc
M source/blender/editors/sculpt_paint/curves_sculpt_comb.cc
M source/blender/editors/sculpt_paint/curves_sculpt_delete.cc
M source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc
M source/blender/geometry/intern/realize_instances.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc
M source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc
M source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index eb4f8f5d5c8..5039b6f0f57 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -122,14 +122,14 @@ class CurvesGeometry : public ::CurvesGeometry {
* Accessors.
*/
- int points_size() const;
- int curves_size() const;
+ int num_points() const;
+ int num_curves() const;
IndexRange points_range() const;
IndexRange curves_range() const;
/**
* The index of the first point in every curve. The size of this span is one larger than the
- * number of curves. Consider using #range_for_curve rather than using the offsets directly.
+ * number of curves. Consider using #points_for_curve rather than using the offsets directly.
*/
Span<int> offsets() const;
MutableSpan<int> offsets();
@@ -137,8 +137,8 @@ class CurvesGeometry : public ::CurvesGeometry {
/**
* Access a range of indices of point data for a specific curve.
*/
- IndexRange range_for_curve(int index) const;
- IndexRange range_for_curves(IndexRange curves) const;
+ IndexRange points_for_curve(int index) const;
+ IndexRange points_for_curves(IndexRange curves) const;
/** The type (#CurveType) of each curve, or potentially a single if all are the same type. */
VArray<int8_t> curve_types() const;
@@ -249,11 +249,11 @@ class CurvesGeometry : public ::CurvesGeometry {
* Access a range of indices of point data for a specific curve.
* Call #evaluated_offsets() first to ensure that the evaluated offsets cache is current.
*/
- IndexRange evaluated_range_for_curve(int index) const;
+ IndexRange evaluated_points_for_curve(int index) const;
/**
* The index of the first evaluated point for every curve. The size of this span is one larger
- * than the number of curves. Consider using #evaluated_range_for_curve rather than using the
+ * than the number of curves. Consider using #evaluated_points_for_curve rather than using the
* offsets directly.
*/
Span<int> evaluated_offsets() const;
@@ -275,7 +275,7 @@ class CurvesGeometry : public ::CurvesGeometry {
* Change the number of elements. New values for existing attributes should be properly
* initialized afterwards.
*/
- void resize(int point_size, int curve_size);
+ void resize(int num_points, int num_curves);
/** Call after deforming the position attribute. */
void tag_positions_changed();
@@ -314,9 +314,9 @@ namespace curves {
* and the fact that curves with two points cannot be cyclic. The logic is simple, but this
* function should be used to make intentions clearer.
*/
-inline int curve_segment_size(const int size, const bool cyclic)
+inline int curve_segment_size(const int num_points, const bool cyclic)
{
- return (cyclic && size > 2) ? size : size - 1;
+ return (cyclic && num_points > 2) ? num_points : num_points - 1;
}
namespace bezier {
@@ -381,10 +381,10 @@ namespace catmull_rom {
/**
* Calculate the number of evaluated points that #interpolate_to_evaluated is expected to produce.
- * \param size: The number of points in the curve.
+ * \param num_points: The number of points in the curve.
* \param resolution: The resolution for each segment.
*/
-int calculate_evaluated_size(int size, bool cyclic, int resolution);
+int calculate_evaluated_size(int num_points, bool cyclic, int resolution);
/**
* Evaluate the Catmull Rom curve. The length of the #dst span should be calculated with
@@ -399,7 +399,7 @@ namespace nurbs {
/**
* Checks the conditions that a NURBS curve needs to evaluate.
*/
-bool check_valid_size_and_order(int size, int8_t order, bool cyclic, KnotsMode knots_mode);
+bool check_valid_size_and_order(int num_points, int8_t order, bool cyclic, KnotsMode knots_mode);
/**
* Calculate the standard evaluated size for a NURBS curve, using the standard that
@@ -410,14 +410,14 @@ bool check_valid_size_and_order(int size, int8_t order, bool cyclic, KnotsMode k
* shared.
*/
int calculate_evaluated_size(
- int size, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode);
+ int num_points, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode);
/**
* Calculate the length of the knot vector for a NURBS curve with the given properties.
* The knots must be longer for a cyclic curve, for example, in order to provide weights for the
* last evaluated points that are also influenced by the first control points.
*/
-int knots_size(int size, int8_t order, bool cyclic);
+int knots_size(int num_points, int8_t order, bool cyclic);
/**
* Calculate the knots for a spline given its properties, based on built-in standards defined by
@@ -428,7 +428,7 @@ int knots_size(int size, int8_t order, bool cyclic);
* changes, and is generally more intuitive than defining the knot vector manually.
*/
void calculate_knots(
- int size, KnotsMode mode, int8_t order, bool cyclic, MutableSpan<float> knots);
+ int num_points, KnotsMode mode, int8_t order, bool cyclic, MutableSpan<float> knots);
/**
* Based on the knots, the order, and other properties of a NURBS curve, calculate a cache that can
@@ -436,7 +436,7 @@ void calculate_knots(
* two pieces of information for every evaluated point: the first control point that influences it,
* and a weight for each control point.
*/
-void calculate_basis_cache(int size,
+void calculate_basis_cache(int num_points,
int evaluated_size,
int8_t order,
bool cyclic,
@@ -461,11 +461,11 @@ void interpolate_to_evaluated(const BasisCache &basis_cache,
} // namespace curves
-Curves *curves_new_nomain(int point_size, int curves_size);
+Curves *curves_new_nomain(int num_points, int num_curves);
/**
* Create a new curves data-block containing a single curve with the given length and type.
*/
-Curves *curves_new_nomain_single(int point_size, CurveType type);
+Curves *curves_new_nomain_single(int num_points, CurveType type);
} // namespace blender::bke
diff --git a/source/blender/blenkernel/intern/curve_catmull_rom.cc b/source/blender/blenkernel/intern/curve_catmull_rom.cc
index 27687eb736f..5b6d0cac21f 100644
--- a/source/blender/blenkernel/intern/curve_catmull_rom.cc
+++ b/source/blender/blenkernel/intern/curve_catmull_rom.cc
@@ -9,11 +9,11 @@
namespace blender::bke::curves::catmull_rom {
-int calculate_evaluated_size(const int size, const bool cyclic, const int resolution)
+int calculate_evaluated_size(const int num_points, const bool cyclic, const int resolution)
{
- const int eval_size = resolution * curve_segment_size(size, cyclic);
+ const int eval_size = resolution * curve_segment_size(num_points, cyclic);
/* If the curve isn't cyclic, one last point is added to the final point. */
- return (cyclic && size > 2) ? eval_size : eval_size + 1;
+ return (cyclic && num_points > 2) ? eval_size : eval_size + 1;
}
/* Adapted from Cycles #catmull_rom_basis_eval function. */
diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc
index b2399f25638..2cf83b57881 100644
--- a/source/blender/blenkernel/intern/curve_eval.cc
+++ b/source/blender/blenkernel/intern/curve_eval.cc
@@ -398,7 +398,7 @@ std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves)
VArray<int8_t> curve_types = geometry.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.range_for_curve(curve_index);
+ const IndexRange point_range = geometry.points_for_curve(curve_index);
std::unique_ptr<Spline> spline;
switch (curve_types[curve_index]) {
@@ -489,7 +489,7 @@ 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();
- const IndexRange point_range = geometry.range_for_curve(curve_index);
+ const IndexRange point_range = geometry.points_for_curve(curve_index);
switch (spline.type()) {
case CURVE_TYPE_POLY:
diff --git a/source/blender/blenkernel/intern/curve_nurbs.cc b/source/blender/blenkernel/intern/curve_nurbs.cc
index a4cdbbca654..bd6bd222aa3 100644
--- a/source/blender/blenkernel/intern/curve_nurbs.cc
+++ b/source/blender/blenkernel/intern/curve_nurbs.cc
@@ -10,53 +10,53 @@
namespace blender::bke::curves::nurbs {
-bool check_valid_size_and_order(const int size,
+bool check_valid_size_and_order(const int num_points,
const int8_t order,
const bool cyclic,
const KnotsMode knots_mode)
{
- if (size < order) {
+ if (num_points < order) {
return false;
}
if (ELEM(knots_mode, NURBS_KNOT_MODE_BEZIER, NURBS_KNOT_MODE_ENDPOINT_BEZIER)) {
- if (knots_mode == NURBS_KNOT_MODE_BEZIER && size <= order) {
+ if (knots_mode == NURBS_KNOT_MODE_BEZIER && num_points <= order) {
return false;
}
- return (!cyclic || size % (order - 1) == 0);
+ return (!cyclic || num_points % (order - 1) == 0);
}
return true;
}
-int calculate_evaluated_size(const int size,
+int calculate_evaluated_size(const int num_points,
const int8_t order,
const bool cyclic,
const int resolution,
const KnotsMode knots_mode)
{
- if (!check_valid_size_and_order(size, order, cyclic, knots_mode)) {
+ if (!check_valid_size_and_order(num_points, order, cyclic, knots_mode)) {
return 0;
}
- return resolution * curve_segment_size(size, cyclic);
+ return resolution * curve_segment_size(num_points, cyclic);
}
-int knots_size(const int size, const int8_t order, const bool cyclic)
+int knots_size(const int num_points, const int8_t order, const bool cyclic)
{
if (cyclic) {
- return size + order * 2 - 1;
+ return num_points + order * 2 - 1;
}
- return size + order;
+ return num_points + order;
}
-void ca
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list