Cleanup: move code in graph_slider_ops
Future operators can use the same code, so it is moved up to disassociate it from decimate No functional changes Reviewed by: Sybren A. Stüvel Differential Revision: https://developer.blender.org/D12489 Ref: D12489
This commit is contained in:
parent
6986b43b3d
commit
3364a5bea6
Notes:
blender-bot
2023-02-14 03:13:26 +01:00
Referenced by issue #92450, Cycles Transparent Shading BUG Referenced by issue #81785, Implementation: Modal Key Manipulation Operators
|
@ -53,7 +53,10 @@
|
|||
(ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | \
|
||||
ANIMFILTER_NODUPLIS)
|
||||
|
||||
/* ------------------- */
|
||||
/* ******************** GRAPH SLIDER OPERATORS ************************* */
|
||||
/* This file contains a collection of operators to modify keyframes in the graph editor. All
|
||||
* operators are modal and use a slider that allows the user to define a percentage to modify the
|
||||
* operator. */
|
||||
|
||||
/* This data type is only used for modal operation. */
|
||||
typedef struct tGraphSliderOp {
|
||||
|
@ -78,16 +81,6 @@ typedef struct tBeztCopyData {
|
|||
BezTriple *bezt;
|
||||
} tBeztCopyData;
|
||||
|
||||
typedef enum tDecimModes {
|
||||
DECIM_RATIO = 1,
|
||||
DECIM_ERROR,
|
||||
} tDecimModes;
|
||||
|
||||
/* ******************** GRAPH SLIDER OPERATORS ************************* */
|
||||
/* This file contains a collection of operators to modify keyframes in the graph editor. All
|
||||
* operators are modal and use a slider that allows the user to define a percentage to modify the
|
||||
* operator. */
|
||||
|
||||
/* ******************** Utility Functions ************************* */
|
||||
|
||||
/* Construct a list with the original bezt arrays so we can restore them during modal operation.
|
||||
|
@ -130,30 +123,6 @@ static void store_original_bezt_arrays(tGraphSliderOp *gso)
|
|||
ANIM_animdata_freelist(&anim_data);
|
||||
}
|
||||
|
||||
/* ******************** Decimate Keyframes Operator ************************* */
|
||||
|
||||
static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float error_sq_max)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
|
||||
/* Filter data. */
|
||||
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
|
||||
|
||||
/* Loop through filtered data and clean curves. */
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
if (!decimate_fcurve(ale, remove_ratio, error_sq_max)) {
|
||||
/* The selection contains unsupported keyframe types! */
|
||||
WM_report(RPT_WARNING, "Decimate: Skipping non linear/bezier keyframes!");
|
||||
}
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
}
|
||||
|
||||
ANIM_animdata_update(ac, &anim_data);
|
||||
ANIM_animdata_freelist(&anim_data);
|
||||
}
|
||||
|
||||
/* Overwrite the current bezts arrays with the original data. */
|
||||
static void reset_bezts(tGraphSliderOp *gso)
|
||||
{
|
||||
|
@ -192,6 +161,35 @@ static void reset_bezts(tGraphSliderOp *gso)
|
|||
ANIM_animdata_freelist(&anim_data);
|
||||
}
|
||||
|
||||
/* ******************** Decimate Keyframes Operator ************************* */
|
||||
|
||||
typedef enum tDecimModes {
|
||||
DECIM_RATIO = 1,
|
||||
DECIM_ERROR,
|
||||
} tDecimModes;
|
||||
|
||||
static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float error_sq_max)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
|
||||
/* Filter data. */
|
||||
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
|
||||
|
||||
/* Loop through filtered data and clean curves. */
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
if (!decimate_fcurve(ale, remove_ratio, error_sq_max)) {
|
||||
/* The selection contains unsupported keyframe types! */
|
||||
WM_report(RPT_WARNING, "Decimate: Skipping non linear/bezier keyframes!");
|
||||
}
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
}
|
||||
|
||||
ANIM_animdata_update(ac, &anim_data);
|
||||
ANIM_animdata_freelist(&anim_data);
|
||||
}
|
||||
|
||||
static void decimate_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
tGraphSliderOp *gso = op->customdata;
|
||||
|
|
Loading…
Reference in New Issue