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-02-23 01:37:58 +0300
committerHans Goudey <h.goudey@me.com>2022-02-23 01:37:58 +0300
commit5b4732f81ca8a159e937336fba7c8eb3220216de (patch)
tree4c0ab34fda202c209cbc99934a5355feec26af49 /source/blender/blenkernel/intern
parent0b9cc6725cca193ec20868caf266ea35c173b956 (diff)
Cleanup: Use new enum for CurveEval handle types
This will make the transition to the new curves data structure a bit simple, since the handle types can be copied directly between the two. The change to CurveEval is simple because it is runtime-only.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/curve_eval.cc20
-rw-r--r--source/blender/blenkernel/intern/spline_bezier.cc46
2 files changed, 33 insertions, 33 deletions
diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc
index 7fb833e67f8..49010caef24 100644
--- a/source/blender/blenkernel/intern/curve_eval.cc
+++ b/source/blender/blenkernel/intern/curve_eval.cc
@@ -160,24 +160,24 @@ void CurveEval::mark_cache_invalid()
}
}
-static BezierSpline::HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_type)
+static HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_type)
{
switch (dna_handle_type) {
case HD_FREE:
- return BezierSpline::HandleType::Free;
+ return BEZIER_HANDLE_FREE;
case HD_AUTO:
- return BezierSpline::HandleType::Auto;
+ return BEZIER_HANDLE_AUTO;
case HD_VECT:
- return BezierSpline::HandleType::Vector;
+ return BEZIER_HANDLE_VECTOR;
case HD_ALIGN:
- return BezierSpline::HandleType::Align;
+ return BEZIER_HANDLE_ALIGN;
case HD_AUTO_ANIM:
- return BezierSpline::HandleType::Auto;
+ return BEZIER_HANDLE_AUTO;
case HD_ALIGN_DOUBLESIDE:
- return BezierSpline::HandleType::Align;
+ return BEZIER_HANDLE_ALIGN;
}
BLI_assert_unreachable();
- return BezierSpline::HandleType::Auto;
+ return BEZIER_HANDLE_AUTO;
}
static Spline::NormalCalculationMode normal_mode_from_dna_curve(const int twist_mode)
@@ -220,8 +220,8 @@ static SplinePtr spline_from_dna_bezier(const Nurb &nurb)
MutableSpan<float3> positions = spline->positions();
MutableSpan<float3> handle_positions_left = spline->handle_positions_left(true);
MutableSpan<float3> handle_positions_right = spline->handle_positions_right(true);
- MutableSpan<BezierSpline::HandleType> handle_types_left = spline->handle_types_left();
- MutableSpan<BezierSpline::HandleType> handle_types_right = spline->handle_types_right();
+ MutableSpan<int8_t> handle_types_left = spline->handle_types_left();
+ MutableSpan<int8_t> handle_types_right = spline->handle_types_right();
MutableSpan<float> radii = spline->radii();
MutableSpan<float> tilts = spline->tilts();
diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc
index 57f1d73d55e..3c2ac1dae9c 100644
--- a/source/blender/blenkernel/intern/spline_bezier.cc
+++ b/source/blender/blenkernel/intern/spline_bezier.cc
@@ -93,11 +93,11 @@ Span<float> BezierSpline::tilts() const
{
return tilts_;
}
-Span<BezierSpline::HandleType> BezierSpline::handle_types_left() const
+Span<int8_t> BezierSpline::handle_types_left() const
{
return handle_types_left_;
}
-MutableSpan<BezierSpline::HandleType> BezierSpline::handle_types_left()
+MutableSpan<int8_t> BezierSpline::handle_types_left()
{
return handle_types_left_;
}
@@ -114,11 +114,11 @@ MutableSpan<float3> BezierSpline::handle_positions_left(const bool write_only)
return handle_positions_left_;
}
-Span<BezierSpline::HandleType> BezierSpline::handle_types_right() const
+Span<int8_t> BezierSpline::handle_types_right() const
{
return handle_types_right_;
}
-MutableSpan<BezierSpline::HandleType> BezierSpline::handle_types_right()
+MutableSpan<int8_t> BezierSpline::handle_types_right()
{
return handle_types_right_;
}
@@ -187,7 +187,7 @@ void BezierSpline::ensure_auto_handles() const
for (const int i : IndexRange(this->size())) {
using namespace blender;
- if (ELEM(HandleType::Auto, handle_types_left_[i], handle_types_right_[i])) {
+ if (ELEM(BEZIER_HANDLE_AUTO, handle_types_left_[i], handle_types_right_[i])) {
const float3 prev_diff = positions_[i] - previous_position(positions_, is_cyclic_, i);
const float3 next_diff = next_position(positions_, is_cyclic_, i) - positions_[i];
float prev_len = math::length(prev_diff);
@@ -203,23 +203,23 @@ void BezierSpline::ensure_auto_handles() const
/* This magic number is unfortunate, but comes from elsewhere in Blender. */
const float len = math::length(dir) * 2.5614f;
if (len != 0.0f) {
- if (handle_types_left_[i] == HandleType::Auto) {
+ if (handle_types_left_[i] == BEZIER_HANDLE_AUTO) {
const float prev_len_clamped = std::min(prev_len, next_len * 5.0f);
handle_positions_left_[i] = positions_[i] + dir * -(prev_len_clamped / len);
}
- if (handle_types_right_[i] == HandleType::Auto) {
+ if (handle_types_right_[i] == BEZIER_HANDLE_AUTO) {
const float next_len_clamped = std::min(next_len, prev_len * 5.0f);
handle_positions_right_[i] = positions_[i] + dir * (next_len_clamped / len);
}
}
}
- if (handle_types_left_[i] == HandleType::Vector) {
+ if (handle_types_left_[i] == BEZIER_HANDLE_VECTOR) {
const float3 prev = previous_position(positions_, is_cyclic_, i);
handle_positions_left_[i] = math::interpolate(positions_[i], prev, 1.0f / 3.0f);
}
- if (handle_types_right_[i] == HandleType::Vector) {
+ if (handle_types_right_[i] == BEZIER_HANDLE_VECTOR) {
const float3 next = next_position(positions_, is_cyclic_, i);
handle_positions_right_[i] = math::interpolate(positions_[i], next, 1.0f / 3.0f);
}
@@ -257,8 +257,8 @@ void BezierSpline::transform(const blender::float4x4 &matrix)
}
static void set_handle_position(const float3 &position,
- const BezierSpline::HandleType type,
- const BezierSpline::HandleType type_other,
+ const HandleType type,
+ const HandleType type_other,
const float3 &new_value,
float3 &handle,
float3 &handle_other)
@@ -266,12 +266,12 @@ static void set_handle_position(const float3 &position,
using namespace blender::math;
/* Don't bother when the handle positions are calculated automatically anyway. */
- if (ELEM(type, BezierSpline::HandleType::Auto, BezierSpline::HandleType::Vector)) {
+ if (ELEM(type, BEZIER_HANDLE_AUTO, BEZIER_HANDLE_VECTOR)) {
return;
}
handle = new_value;
- if (type_other == BezierSpline::HandleType::Align) {
+ if (type_other == BEZIER_HANDLE_ALIGN) {
/* Keep track of the old length of the opposite handle. */
const float length = distance(handle_other, position);
/* Set the other handle to directly opposite from the current handle. */
@@ -283,8 +283,8 @@ static void set_handle_position(const float3 &position,
void BezierSpline::set_handle_position_right(const int index, const blender::float3 &value)
{
set_handle_position(positions_[index],
- handle_types_right_[index],
- handle_types_left_[index],
+ static_cast<HandleType>(handle_types_right_[index]),
+ static_cast<HandleType>(handle_types_left_[index]),
value,
handle_positions_right_[index],
handle_positions_left_[index]);
@@ -293,8 +293,8 @@ void BezierSpline::set_handle_position_right(const int index, const blender::flo
void BezierSpline::set_handle_position_left(const int index, const blender::float3 &value)
{
set_handle_position(positions_[index],
- handle_types_left_[index],
- handle_types_right_[index],
+ static_cast<HandleType>(handle_types_right_[index]),
+ static_cast<HandleType>(handle_types_left_[index]),
value,
handle_positions_left_[index],
handle_positions_right_[index]);
@@ -302,8 +302,8 @@ void BezierSpline::set_handle_position_left(const int index, const blender::floa
bool BezierSpline::point_is_sharp(const int index) const
{
- return ELEM(handle_types_left_[index], HandleType::Vector, HandleType::Free) ||
- ELEM(handle_types_right_[index], HandleType::Vector, HandleType::Free);
+ return ELEM(handle_types_left_[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE) ||
+ ELEM(handle_types_right_[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE);
}
bool BezierSpline::segment_is_vector(const int index) const
@@ -313,15 +313,15 @@ bool BezierSpline::segment_is_vector(const int index) const
if (index == this->size() - 1) {
if (is_cyclic_) {
- return handle_types_right_.last() == HandleType::Vector &&
- handle_types_left_.first() == HandleType::Vector;
+ return handle_types_right_.last() == BEZIER_HANDLE_VECTOR &&
+ handle_types_left_.first() == BEZIER_HANDLE_VECTOR;
}
/* There is actually no segment in this case, but it's nice to avoid
* having a special case for the last segment in calling code. */
return true;
}
- return handle_types_right_[index] == HandleType::Vector &&
- handle_types_left_[index + 1] == HandleType::Vector;
+ return handle_types_right_[index] == BEZIER_HANDLE_VECTOR &&
+ handle_types_left_[index + 1] == BEZIER_HANDLE_VECTOR;
}
void BezierSpline::mark_cache_invalid()