Animation: blend to infinity slider #106517
|
@ -491,7 +491,7 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor
|
|||
|
||||
/* ---------------- */
|
||||
|
||||
void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
||||
bool blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
||||
{
|
||||
const BezTriple *left_key = fcurve_segment_start_get(fcu, segment->start_index);
|
||||
const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length);
|
||||
|
@ -502,7 +502,7 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|||
if (factor >= 0) {
|
||||
/* Stop the function if there is no key beyond the the right neighboring one. */
|
||||
if (segment->start_index + segment->length >= fcu->totvert - 1) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
reference_key = right_key;
|
||||
beyond_key = fcu->bezt[segment->start_index + segment->length + 1];
|
||||
|
@ -510,7 +510,7 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|||
else {
|
||||
/* Stop the function if there is no key beyond the left neighboring one. */
|
||||
if (segment->start_index <= 1) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
reference_key = left_key;
|
||||
beyond_key = fcu->bezt[segment->start_index - 2];
|
||||
|
@ -523,7 +523,7 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|||
|
||||
/* Avoids dividing by 0. */
|
||||
if (x_delta == 0) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
||||
|
@ -538,6 +538,7 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|||
const float key_y_value = fcu->bezt[i].vec[1][1] + delta * fabs(factor);
|
||||
move_key(&fcu->bezt[i], key_y_value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ---------------- */
|
||||
|
|
|
@ -437,7 +437,7 @@ void smooth_fcurve_segment(struct FCurve *fcu,
|
|||
int kernel_size,
|
||||
double *kernel);
|
||||
void ease_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor);
|
||||
void blend_to_infinity_fcurve_segment(struct FCurve *fcu,
|
||||
bool blend_to_infinity_fcurve_segment(struct FCurve *fcu,
|
||||
struct FCurveSegment *segment,
|
||||
float factor);
|
||||
bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max);
|
||||
|
|
|
@ -1068,31 +1068,30 @@ static void blend_to_infinity_graph_keys(bAnimContext *ac, const float factor)
|
|||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
|
||||
bool all_segments_valid = true;
|
||||
|
||||
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
|
||||
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
ListBase segments = find_fcurve_segments(fcu);
|
||||
|
||||
LISTBASE_FOREACH (FCurveSegment *, segment, &segments) {
|
||||
if (factor >= 0){
|
||||
if (segment->start_index + segment->length >= fcu->totvert - 1) {
|
||||
WM_report(RPT_WARNING, "You need at least 2 keys to the right side of the selection.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (segment->start_index <= 1) {
|
||||
WM_report(RPT_WARNING, "You need at least 2 keys to the left side of the selection.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
blend_to_infinity_fcurve_segment(fcu, segment, factor);
|
||||
all_segments_valid = blend_to_infinity_fcurve_segment(fcu, segment, factor);
|
||||
}
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
BLI_freelistN(&segments);
|
||||
}
|
||||
|
||||
if(!all_segments_valid) {
|
||||
if (factor >= 0){
|
||||
WM_report(RPT_WARNING, "You need at least 2 keys to the right side of the selection.");
|
||||
}
|
||||
else {
|
||||
WM_report(RPT_WARNING, "You need at least 2 keys to the left side of the selection.");
|
||||
}
|
||||
}
|
||||
|
||||
ANIM_animdata_update(ac, &anim_data);
|
||||
ANIM_animdata_freelist(&anim_data);
|
||||
}
|
||||
|
@ -1190,12 +1189,12 @@ void GRAPH_OT_blend_to_infinity(wmOperatorType *ot)
|
|||
|
||||
RNA_def_float_factor(ot->srna,
|
||||
"factor",
|
||||
0.5f,
|
||||
0.0f,
|
||||
-FLT_MAX,
|
||||
FLT_MAX,
|
||||
"Curve Bend",
|
||||
"Control the bend of the curve",
|
||||
0.0f,
|
||||
-1.0f,
|
||||
1.0f);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue