Merge remote-tracking branch 'origin/blender-v4.4-release'
This commit is contained in:
@@ -50,7 +50,17 @@ struct UndoCurve {
|
||||
ListBase nubase;
|
||||
int actvert;
|
||||
GHash *undoIndex;
|
||||
ListBase fcurves, drivers;
|
||||
|
||||
/* Historical note: Once upon a time, this code also made a backup of F-Curves, in an attempt to
|
||||
* enable undo of animation changes. This was very limited, as it only backed up the animation
|
||||
* of the curve ID; all the other IDs whose animation was shown in the dope sheet, timeline, etc.
|
||||
* was ignored. It also ignored the NLA, and deleted Action groups even when the animation was
|
||||
* not touched by the user.
|
||||
*
|
||||
* With the introduction of slotted Actions, a decision had to be made to either port this
|
||||
* behavior or remove it. The latter was chosen. For more information, see #135585. */
|
||||
ListBase drivers;
|
||||
|
||||
int actnu;
|
||||
int flag;
|
||||
|
||||
@@ -77,11 +87,6 @@ static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short
|
||||
}
|
||||
|
||||
if (ad) {
|
||||
if (ad->action) {
|
||||
BKE_fcurves_free(&ad->action->curves);
|
||||
BKE_fcurves_copy(&ad->action->curves, &ucu->fcurves);
|
||||
}
|
||||
|
||||
BKE_fcurves_free(&ad->drivers);
|
||||
BKE_fcurves_copy(&ad->drivers, &ucu->drivers);
|
||||
}
|
||||
@@ -111,7 +116,7 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
|
||||
EditNurb *editnurb = cu->editnurb, tmpEditnurb;
|
||||
AnimData *ad = BKE_animdata_from_id(&cu->id);
|
||||
|
||||
/* TODO: include size of fcurve & undoIndex */
|
||||
/* TODO: include size of drivers & undoIndex */
|
||||
// ucu->undo_size = 0;
|
||||
|
||||
if (editnurb->keyindex) {
|
||||
@@ -120,10 +125,6 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
|
||||
}
|
||||
|
||||
if (ad) {
|
||||
if (ad->action) {
|
||||
BKE_fcurves_copy(&ucu->fcurves, &ad->action->curves);
|
||||
}
|
||||
|
||||
BKE_fcurves_copy(&ucu->drivers, &ad->drivers);
|
||||
}
|
||||
|
||||
@@ -156,7 +157,6 @@ static void undocurve_free_data(UndoCurve *uc)
|
||||
|
||||
BKE_curve_editNurb_keyIndex_free(&uc->undoIndex);
|
||||
|
||||
BKE_fcurves_free(&uc->fcurves);
|
||||
BKE_fcurves_free(&uc->drivers);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
|
||||
namespace blender::geometry {
|
||||
|
||||
static void extend_curves_straight(const float used_percent_length,
|
||||
const float new_size,
|
||||
const Span<int> start_points,
|
||||
const Span<int> end_points,
|
||||
const int curve,
|
||||
const IndexRange new_curve,
|
||||
const Span<float> use_start_lengths,
|
||||
const Span<float> use_end_lengths,
|
||||
MutableSpan<float3> positions)
|
||||
static void extend_curve_straight(const float used_percent_length,
|
||||
const float new_size,
|
||||
const Span<int> start_points,
|
||||
const Span<int> end_points,
|
||||
const int curve,
|
||||
const IndexRange new_curve,
|
||||
const Span<float> use_start_lengths,
|
||||
const Span<float> use_end_lengths,
|
||||
MutableSpan<float3> positions)
|
||||
{
|
||||
float overshoot_point_param = used_percent_length * (new_size - 1);
|
||||
if (start_points[curve]) {
|
||||
@@ -69,18 +69,18 @@ static void extend_curves_straight(const float used_percent_length,
|
||||
}
|
||||
}
|
||||
|
||||
static void extend_curves_curved(const float used_percent_length,
|
||||
const Span<int> start_points,
|
||||
const Span<int> end_points,
|
||||
const OffsetIndices<int> points_by_curve,
|
||||
const int curve,
|
||||
const IndexRange new_curve,
|
||||
const Span<float> use_start_lengths,
|
||||
const Span<float> use_end_lengths,
|
||||
const float max_angle,
|
||||
const float segment_influence,
|
||||
const bool invert_curvature,
|
||||
MutableSpan<float3> positions)
|
||||
static void extend_curve_curved(const float used_percent_length,
|
||||
const Span<int> start_points,
|
||||
const Span<int> end_points,
|
||||
const OffsetIndices<int> points_by_curve,
|
||||
const int curve,
|
||||
const IndexRange new_curve,
|
||||
const Span<float> use_start_lengths,
|
||||
const Span<float> use_end_lengths,
|
||||
const float max_angle,
|
||||
const float segment_influence,
|
||||
const bool invert_curvature,
|
||||
MutableSpan<float3> positions)
|
||||
{
|
||||
/* Curvature calculation. */
|
||||
const int first_old_index = start_points[curve] ? start_points[curve] : 0;
|
||||
@@ -217,8 +217,13 @@ bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves,
|
||||
}
|
||||
|
||||
const int src_curves_num = src_curves.curves_num();
|
||||
|
||||
/* Extra point count at the start/end of extended strokes. For straight extension, or for strokes
|
||||
* with only 2 points (thus unable to curve), the value of their respective index should be set
|
||||
* to 1 to allow #extend_curves_straight() to identify strokes to work on. */
|
||||
Array<int> start_points(src_curves_num, 0);
|
||||
Array<int> end_points(src_curves_num, 0);
|
||||
|
||||
Array<float> use_start_lengths(src_curves_num);
|
||||
Array<float> use_end_lengths(src_curves_num);
|
||||
|
||||
@@ -232,16 +237,17 @@ bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves,
|
||||
float total_length = src_curves.evaluated_length_total_for_curve(curve, false);
|
||||
use_start_lengths[curve] *= total_length;
|
||||
use_end_lengths[curve] *= total_length;
|
||||
start_points[curve] = 1;
|
||||
end_points[curve] = 1;
|
||||
}
|
||||
});
|
||||
|
||||
bke::CurvesGeometry dst_curves;
|
||||
|
||||
/* Use the old curves when extending straight when no new points are added. */
|
||||
if (!follow_curvature) {
|
||||
/* Use the old curves when extending straight when no new points are added. */
|
||||
dst_curves = std::move(src_curves);
|
||||
/* Enable affected curves for #extend_curves_straight(). */
|
||||
index_mask::masked_fill<int>(start_points, 1, selection);
|
||||
index_mask::masked_fill<int>(end_points, 1, selection);
|
||||
}
|
||||
else {
|
||||
/* Copy only curves domain since we are not changing the number of curves here. */
|
||||
@@ -251,10 +257,10 @@ bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves,
|
||||
selection.foreach_index([&](const int curve) {
|
||||
int point_count = points_by_curve[curve].size();
|
||||
dst_points_by_curve[curve] = point_count;
|
||||
/* Curve not suitable for stretching... */
|
||||
if (point_count <= 2) {
|
||||
start_points[curve] = 0;
|
||||
end_points[curve] = 0;
|
||||
/* Can't make a curve, set start/end points to 1 to allow straight extension. */
|
||||
start_points[curve] = 1;
|
||||
end_points[curve] = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -286,12 +292,10 @@ bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves,
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (start_points[curve] > 0) {
|
||||
if (follow_curvature) {
|
||||
MutableSpan<int> starts = new_points_by_curve.slice(0, start_points[curve]);
|
||||
starts.fill(points_by_curve[curve].first());
|
||||
local_front = start_points[curve];
|
||||
}
|
||||
if (end_points[curve] > 0) {
|
||||
MutableSpan<int> ends = new_points_by_curve.slice(
|
||||
new_points_by_curve.size() - end_points[curve], end_points[curve]);
|
||||
ends.fill(points_by_curve[curve].last());
|
||||
@@ -329,29 +333,29 @@ bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves,
|
||||
isfinite(overshoot_fac) ? overshoot_fac : 0.1f, 1e-4f, 1.0f);
|
||||
|
||||
if (!follow_curvature || new_size == 2) {
|
||||
extend_curves_straight(used_percent_length,
|
||||
new_size,
|
||||
{1},
|
||||
{1},
|
||||
curve,
|
||||
new_curve,
|
||||
use_start_lengths.as_span(),
|
||||
use_end_lengths.as_span(),
|
||||
positions);
|
||||
extend_curve_straight(used_percent_length,
|
||||
new_size,
|
||||
start_points.as_span(),
|
||||
end_points.as_span(),
|
||||
curve,
|
||||
new_curve,
|
||||
use_start_lengths.as_span(),
|
||||
use_end_lengths.as_span(),
|
||||
positions);
|
||||
}
|
||||
else if (start_points[curve] > 0 || end_points[curve] > 0) {
|
||||
extend_curves_curved(used_percent_length,
|
||||
start_points.as_span(),
|
||||
end_points.as_span(),
|
||||
points_by_curve,
|
||||
curve,
|
||||
new_curve,
|
||||
use_start_lengths.as_span(),
|
||||
use_end_lengths.as_span(),
|
||||
max_angle,
|
||||
segment_influence,
|
||||
invert_curvature,
|
||||
positions);
|
||||
extend_curve_curved(used_percent_length,
|
||||
start_points.as_span(),
|
||||
end_points.as_span(),
|
||||
points_by_curve,
|
||||
curve,
|
||||
new_curve,
|
||||
use_start_lengths.as_span(),
|
||||
use_end_lengths.as_span(),
|
||||
max_angle,
|
||||
segment_influence,
|
||||
invert_curvature,
|
||||
positions);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user