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-03-25 04:48:08 +0300
committerHans Goudey <h.goudey@me.com>2022-03-25 04:48:08 +0300
commit6e72e3fdb295fdfd3e252bd48be96e2d832e43f2 (patch)
tree70e439dfb872a2bb6dc2be33163f5fa13f82c434 /source/blender/blenkernel/intern
parentd3999683ff5ac8b42de74cb453b459096f76f542 (diff)
Cleanup: Further renaming in new curves code
A follow-up to e253f9f66d6f. Follow the policy from T85728 completely (using "num" as a prefix) and rename another function.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/curve_catmull_rom.cc6
-rw-r--r--source/blender/blenkernel/intern/curve_nurbs.cc40
-rw-r--r--source/blender/blenkernel/intern/curves.cc10
-rw-r--r--source/blender/blenkernel/intern/curves_geometry.cc60
-rw-r--r--source/blender/blenkernel/intern/curves_geometry_test.cc4
-rw-r--r--source/blender/blenkernel/intern/geometry_component_curves.cc4
6 files changed, 62 insertions, 62 deletions
diff --git a/source/blender/blenkernel/intern/curve_catmull_rom.cc b/source/blender/blenkernel/intern/curve_catmull_rom.cc
index 5b6d0cac21f..ea3672dd56b 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 num_points, const bool cyclic, const int resolution)
+int calculate_evaluated_size(const int points_num, const bool cyclic, const int resolution)
{
- const int eval_size = resolution * curve_segment_size(num_points, cyclic);
+ const int eval_size = resolution * curve_segment_size(points_num, cyclic);
/* If the curve isn't cyclic, one last point is added to the final point. */
- return (cyclic && num_points > 2) ? eval_size : eval_size + 1;
+ return (cyclic && points_num > 2) ? eval_size : eval_size + 1;
}
/* Adapted from Cycles #catmull_rom_basis_eval function. */
diff --git a/source/blender/blenkernel/intern/curve_nurbs.cc b/source/blender/blenkernel/intern/curve_nurbs.cc
index bd6bd222aa3..31fe5426b5b 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 num_points,
+bool check_valid_size_and_order(const int points_num,
const int8_t order,
const bool cyclic,
const KnotsMode knots_mode)
{
- if (num_points < order) {
+ if (points_num < order) {
return false;
}
if (ELEM(knots_mode, NURBS_KNOT_MODE_BEZIER, NURBS_KNOT_MODE_ENDPOINT_BEZIER)) {
- if (knots_mode == NURBS_KNOT_MODE_BEZIER && num_points <= order) {
+ if (knots_mode == NURBS_KNOT_MODE_BEZIER && points_num <= order) {
return false;
}
- return (!cyclic || num_points % (order - 1) == 0);
+ return (!cyclic || points_num % (order - 1) == 0);
}
return true;
}
-int calculate_evaluated_size(const int num_points,
+int calculate_evaluated_size(const int points_num,
const int8_t order,
const bool cyclic,
const int resolution,
const KnotsMode knots_mode)
{
- if (!check_valid_size_and_order(num_points, order, cyclic, knots_mode)) {
+ if (!check_valid_size_and_order(points_num, order, cyclic, knots_mode)) {
return 0;
}
- return resolution * curve_segment_size(num_points, cyclic);
+ return resolution * curve_segment_size(points_num, cyclic);
}
-int knots_size(const int num_points, const int8_t order, const bool cyclic)
+int knots_size(const int points_num, const int8_t order, const bool cyclic)
{
if (cyclic) {
- return num_points + order * 2 - 1;
+ return points_num + order * 2 - 1;
}
- return num_points + order;
+ return points_num + order;
}
-void calculate_knots(const int num_points,
+void calculate_knots(const int points_num,
const KnotsMode mode,
const int8_t order,
const bool cyclic,
MutableSpan<float> knots)
{
- BLI_assert(knots.size() == knots_size(num_points, order, cyclic));
- UNUSED_VARS_NDEBUG(num_points);
+ BLI_assert(knots.size() == knots_size(points_num, order, cyclic));
+ UNUSED_VARS_NDEBUG(points_num);
const bool is_bezier = ELEM(mode, NURBS_KNOT_MODE_BEZIER, NURBS_KNOT_MODE_ENDPOINT_BEZIER);
const bool is_end_point = ELEM(mode, NURBS_KNOT_MODE_ENDPOINT, NURBS_KNOT_MODE_ENDPOINT_BEZIER);
@@ -94,7 +94,7 @@ void calculate_knots(const int num_points,
}
static void calculate_basis_for_point(const float parameter,
- const int num_points,
+ const int points_num,
const int degree,
const Span<float> knots,
MutableSpan<float> r_weights,
@@ -104,7 +104,7 @@ static void calculate_basis_for_point(const float parameter,
int start = 0;
int end = 0;
- for (const int i : IndexRange(num_points + degree)) {
+ for (const int i : IndexRange(points_num + degree)) {
const bool knots_equal = knots[i] == knots[i + 1];
if (knots_equal || parameter < knots[i] || parameter > knots[i + 1]) {
continue;
@@ -121,7 +121,7 @@ static void calculate_basis_for_point(const float parameter,
for (const int i_order : IndexRange(2, degree)) {
if (end + i_order >= knots.size()) {
- end = num_points + degree - i_order;
+ end = points_num + degree - i_order;
}
for (const int i : IndexRange(end - start + 1)) {
const int knot_index = start + i;
@@ -146,14 +146,14 @@ static void calculate_basis_for_point(const float parameter,
r_start_index = start;
}
-void calculate_basis_cache(const int num_points,
+void calculate_basis_cache(const int points_num,
const int evaluated_size,
const int8_t order,
const bool cyclic,
const Span<float> knots,
BasisCache &basis_cache)
{
- BLI_assert(num_points > 0);
+ BLI_assert(points_num > 0);
BLI_assert(evaluated_size > 0);
const int8_t degree = order - 1;
@@ -168,7 +168,7 @@ void calculate_basis_cache(const int num_points,
MutableSpan<float> basis_weights(basis_cache.weights);
MutableSpan<int> basis_start_indices(basis_cache.start_indices);
- const int last_control_point_index = cyclic ? num_points + degree : num_points;
+ const int last_control_point_index = cyclic ? points_num + degree : points_num;
const int evaluated_segment_size = curve_segment_size(evaluated_size, cyclic);
const float start = knots[degree];
@@ -176,7 +176,7 @@ void calculate_basis_cache(const int num_points,
const float step = (end - start) / evaluated_segment_size;
for (const int i : IndexRange(evaluated_size)) {
/* Clamp parameter due to floating point inaccuracy. */
- const float parameter = std::clamp(start + step * i, knots[0], knots[num_points + degree]);
+ const float parameter = std::clamp(start + step * i, knots[0], knots[points_num + degree]);
MutableSpan<float> point_weights = basis_weights.slice(i * order, order);
diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc
index e88d25ae56a..82db1176759 100644
--- a/source/blender/blenkernel/intern/curves.cc
+++ b/source/blender/blenkernel/intern/curves.cc
@@ -366,19 +366,19 @@ void BKE_curves_batch_cache_free(Curves *curves)
namespace blender::bke {
-Curves *curves_new_nomain(const int num_points, const int num_curves)
+Curves *curves_new_nomain(const int points_num, const int curves_num)
{
Curves *curves = static_cast<Curves *>(BKE_id_new_nomain(ID_CV, nullptr));
CurvesGeometry &geometry = CurvesGeometry::wrap(curves->geometry);
- geometry.resize(num_points, num_curves);
+ geometry.resize(points_num, curves_num);
return curves;
}
-Curves *curves_new_nomain_single(const int num_points, const CurveType type)
+Curves *curves_new_nomain_single(const int points_num, const CurveType type)
{
- Curves *curves = curves_new_nomain(num_points, 1);
+ Curves *curves = curves_new_nomain(points_num, 1);
CurvesGeometry &geometry = CurvesGeometry::wrap(curves->geometry);
- geometry.offsets().last() = num_points;
+ geometry.offsets().last() = points_num;
geometry.curve_types().first() = type;
return curves;
}
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index f9c925b626d..a069176c6f3 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -149,21 +149,21 @@ CurvesGeometry::~CurvesGeometry()
/** \name Accessors
* \{ */
-int CurvesGeometry::num_points() const
+int CurvesGeometry::points_num() const
{
return this->point_size;
}
-int CurvesGeometry::num_curves() const
+int CurvesGeometry::curves_num() const
{
return this->curve_size;
}
IndexRange CurvesGeometry::points_range() const
{
- return IndexRange(this->num_points());
+ return IndexRange(this->points_num());
}
IndexRange CurvesGeometry::curves_range() const
{
- return IndexRange(this->num_curves());
+ return IndexRange(this->curves_num());
}
IndexRange CurvesGeometry::points_for_curve(const int index) const
@@ -186,7 +186,7 @@ IndexRange CurvesGeometry::points_for_curves(const IndexRange curves) const
static int domain_size(const CurvesGeometry &curves, const AttributeDomain domain)
{
- return domain == ATTR_DOMAIN_POINT ? curves.num_points() : curves.num_curves();
+ return domain == ATTR_DOMAIN_POINT ? curves.points_num() : curves.curves_num();
}
static CustomData &domain_custom_data(CurvesGeometry &curves, const AttributeDomain domain)
@@ -457,7 +457,7 @@ static void calculate_evaluated_offsets(const CurvesGeometry &curves,
});
}
-int CurvesGeometry::evaluated_points_size() const
+int CurvesGeometry::evaluated_points_num() const
{
/* This could avoid calculating offsets in the future in simple circumstances. */
return this->evaluated_offsets().last();
@@ -482,10 +482,10 @@ Span<int> CurvesGeometry::evaluated_offsets() const
}
threading::isolate_task([&]() {
- this->runtime->evaluated_offsets_cache.resize(this->num_curves() + 1);
+ this->runtime->evaluated_offsets_cache.resize(this->curves_num() + 1);
if (this->has_curve_with_type(CURVE_TYPE_BEZIER)) {
- this->runtime->bezier_evaluated_offsets.resize(this->num_points());
+ this->runtime->bezier_evaluated_offsets.resize(this->points_num());
}
else {
this->runtime->bezier_evaluated_offsets.clear_and_make_inline();
@@ -536,7 +536,7 @@ void CurvesGeometry::ensure_nurbs_basis_cache() const
return;
}
- this->runtime->nurbs_basis_cache.resize(this->num_curves());
+ this->runtime->nurbs_basis_cache.resize(this->curves_num());
MutableSpan<curves::nurbs::BasisCache> basis_caches(this->runtime->nurbs_basis_cache);
VArray<bool> cyclic = this->cyclic();
@@ -579,7 +579,7 @@ Span<float3> CurvesGeometry::evaluated_positions() const
}
threading::isolate_task([&]() {
- this->runtime->evaluated_position_cache.resize(this->evaluated_points_size());
+ this->runtime->evaluated_position_cache.resize(this->evaluated_points_num());
MutableSpan<float3> evaluated_positions = this->runtime->evaluated_position_cache;
VArray<int8_t> types = this->curve_types();
@@ -645,16 +645,16 @@ Span<float3> CurvesGeometry::evaluated_positions() const
/** \name Operations
* \{ */
-void CurvesGeometry::resize(const int num_points, const int num_curves)
+void CurvesGeometry::resize(const int points_num, const int curves_num)
{
- if (num_points != this->point_size) {
- CustomData_realloc(&this->point_data, num_points);
- this->point_size = num_points;
+ if (points_num != this->point_size) {
+ CustomData_realloc(&this->point_data, points_num);
+ this->point_size = points_num;
}
- if (num_curves != this->curve_size) {
- CustomData_realloc(&this->curve_data, num_curves);
- this->curve_size = num_curves;
- this->curve_offsets = (int *)MEM_reallocN(this->curve_offsets, sizeof(int) * (num_curves + 1));
+ if (curves_num != this->curve_size) {
+ CustomData_realloc(&this->curve_data, curves_num);
+ this->curve_size = curves_num;
+ this->curve_offsets = (int *)MEM_reallocN(this->curve_offsets, sizeof(int) * (curves_num + 1));
}
this->tag_topology_changed();
this->update_customdata_pointers();
@@ -727,7 +727,7 @@ static std::optional<bounds::MinMaxResult<float3>> curves_bounds(const CurvesGeo
{
Span<float3> positions = curves.positions();
if (curves.radius) {
- Span<float> radii{curves.radius, curves.num_points()};
+ Span<float> radii{curves.radius, curves.points_num()};
return bounds::min_max_with_radii(positions, radii);
}
return bounds::min_max(positions);
@@ -926,7 +926,7 @@ static bool layer_matches_name_and_type(const CustomDataLayer &layer,
void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse)
{
- CustomData_duplicate_referenced_layers(&this->point_data, this->num_points());
+ CustomData_duplicate_referenced_layers(&this->point_data, this->points_num());
/* Collect the Bezier handle attributes while iterating through the point custom data layers;
* they need special treatment later. */
@@ -940,22 +940,22 @@ void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse)
if (positions_left.is_empty() &&
layer_matches_name_and_type(layer, ATTR_HANDLE_POSITION_LEFT, CD_PROP_FLOAT3)) {
- positions_left = {static_cast<float3 *>(layer.data), this->num_points()};
+ positions_left = {static_cast<float3 *>(layer.data), this->points_num()};
continue;
}
if (positions_right.is_empty() &&
layer_matches_name_and_type(layer, ATTR_HANDLE_POSITION_RIGHT, CD_PROP_FLOAT3)) {
- positions_right = {static_cast<float3 *>(layer.data), this->num_points()};
+ positions_right = {static_cast<float3 *>(layer.data), this->points_num()};
continue;
}
if (types_left.is_empty() &&
layer_matches_name_and_type(layer, ATTR_HANDLE_TYPE_LEFT, CD_PROP_INT8)) {
- types_left = {static_cast<int8_t *>(layer.data), this->num_points()};
+ types_left = {static_cast<int8_t *>(layer.data), this->points_num()};
continue;
}
if (types_right.is_empty() &&
layer_matches_name_and_type(layer, ATTR_HANDLE_TYPE_RIGHT, CD_PROP_INT8)) {
- types_right = {static_cast<int8_t *>(layer.data), this->num_points()};
+ types_right = {static_cast<int8_t *>(layer.data), this->points_num()};
continue;
}
@@ -963,7 +963,7 @@ void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse)
attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
using T = decltype(dummy);
reverse_curve_point_data<T>(
- *this, curves_to_reverse, {static_cast<T *>(layer.data), this->num_points()});
+ *this, curves_to_reverse, {static_cast<T *>(layer.data), this->points_num()});
});
}
@@ -1001,7 +1001,7 @@ static void adapt_curve_domain_point_to_curve_impl(const CurvesGeometry &curves,
MutableSpan<T> r_values)
{
attribute_math::DefaultMixer<T> mixer(r_values);
- for (const int i_curve : IndexRange(curves.num_curves())) {
+ for (const int i_curve : IndexRange(curves.curves_num())) {
for (const int i_point : curves.points_for_curve(i_curve)) {
mixer.mix_in(i_curve, old_values[i_point]);
}
@@ -1022,7 +1022,7 @@ void adapt_curve_domain_point_to_curve_impl(const CurvesGeometry &curves,
MutableSpan<bool> r_values)
{
r_values.fill(true);
- for (const int i_curve : IndexRange(curves.num_curves())) {
+ for (const int i_curve : IndexRange(curves.curves_num())) {
for (const int i_point : curves.points_for_curve(i_curve)) {
if (!old_values[i_point]) {
r_values[i_curve] = false;
@@ -1039,7 +1039,7 @@ static GVArray adapt_curve_domain_point_to_curve(const CurvesGeometry &curves,
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) {
- Array<T> values(curves.num_curves());
+ Array<T> values(curves.curves_num());
adapt_curve_domain_point_to_curve_impl<T>(curves, varray.typed<T>(), values);
new_varray = VArray<T>::ForContainer(std::move(values));
}
@@ -1059,7 +1059,7 @@ static void adapt_curve_domain_curve_to_point_impl(const CurvesGeometry &curves,
const VArray<T> &old_values,
MutableSpan<T> r_values)
{
- for (const int i_curve : IndexRange(curves.num_curves())) {
+ for (const int i_curve : IndexRange(curves.curves_num())) {
r_values.slice(curves.points_for_curve(i_curve)).fill(old_values[i_curve]);
}
}
@@ -1070,7 +1070,7 @@ static GVArray adapt_curve_domain_curve_to_point(const CurvesGeometry &curves,
GVArray new_varray;
attribute_math::convert_to_static_type(varray.type(), [&](auto dummy) {
using T = decltype(dummy);
- Array<T> values(curves.num_points());
+ Array<T> values(curves.points_num());
adapt_curve_domain_curve_to_point_impl<T>(curves, varray.typed<T>(), values);
new_varray = VArray<T>::ForContainer(std::move(values));
});
diff --git a/source/blender/blenkernel/intern/curves_geometry_test.cc b/source/blender/blenkernel/intern/curves_geometry_test.cc
index fd994d5abf4..bc99785de1c 100644
--- a/source/blender/blenkernel/intern/curves_geometry_test.cc
+++ b/source/blender/blenkernel/intern/curves_geometry_test.cc
@@ -46,7 +46,7 @@ TEST(curves_geometry, Move)
CurvesGeometry other = std::move(curves);
/* The old curves should be empty, and the offsets are expected to be null. */
- EXPECT_EQ(curves.num_points(), 0); /* NOLINT: bugprone-use-after-move */
+ EXPECT_EQ(curves.points_num(), 0); /* NOLINT: bugprone-use-after-move */
EXPECT_EQ(curves.curve_offsets, nullptr); /* NOLINT: bugprone-use-after-move */
/* Just a basic check that the new curves work okay. */
@@ -206,7 +206,7 @@ TEST(curves_geometry, CatmullRomTwoPointCyclic)
/* The cyclic value should be ignored when there are only two control points. There should
* be 12 evaluated points for the single segment and an extra for the last point. */
- EXPECT_EQ(curves.evaluated_points_size(), 13);
+ EXPECT_EQ(curves.evaluated_points_num(), 13);
}
TEST(curves_geometry, BezierPositionEvaluation)
diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc
index 83b8e5fb262..27689d70c77 100644
--- a/source/blender/blenkernel/intern/geometry_component_curves.cc
+++ b/source/blender/blenkernel/intern/geometry_component_curves.cc
@@ -236,10 +236,10 @@ int CurveComponent::attribute_domain_size(const AttributeDomain domain) const
const blender::bke::CurvesGeometry &geometry = blender::bke::CurvesGeometry::wrap(
curves_->geometry);
if (domain == ATTR_DOMAIN_POINT) {
- return geometry.num_points();
+ return geometry.points_num();
}
if (domain == ATTR_DOMAIN_CURVE) {
- return geometry.num_curves();
+ return geometry.curves_num();
}
return 0;
}