Changeset View
Standalone View
source/blender/editors/space_graph/graph_edit.c
| Show First 20 Lines • Show All 990 Lines • ▼ Show 20 Lines | |||||
| ot->invoke = WM_operator_confirm; /* FIXME */ | ot->invoke = WM_operator_confirm; /* FIXME */ | ||||
| ot->exec = graphkeys_bake_exec; | ot->exec = graphkeys_bake_exec; | ||||
| ot->poll = graphop_selected_fcurve_poll; | ot->poll = graphop_selected_fcurve_poll; | ||||
| /* Flags */ | /* Flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* TODO: add props for start/end frames (Joshua Leung 2009) */ | /* TODO: add props for start/end frames (Joshua Leung 2009) */ | ||||
| } | } | ||||
sybren: Sentences should end in a period. | |||||
| /* ******************** Un-Bake F-Curve Operator *********************** */ | |||||
Done Inline ActionsThis is exactly the opposite of what this function is doing. sybren: This is exactly the opposite of what this function is doing. | |||||
| /* This operator unbakes the data of the selected F-Points to F-Curves. */ | |||||
| /* Un-Bake F-Points into F-Curves. */ | |||||
| static void unbake_graph_curves(bAnimContext *ac, int start, int end) | |||||
| { | |||||
| ListBase anim_data = {NULL, NULL}; | |||||
| bAnimListElem *ale; | |||||
Done Inline Actionsfilter can be declared and initialised one the same line, and declared const. sybren: `filter` can be declared and initialised one the same line, and declared `const`. | |||||
| /* Filter data. */ | |||||
| const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | | |||||
| ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); | |||||
| ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); | |||||
| /* Loop through filtered data and add keys between selected keyframes on every frame. */ | |||||
| for (ale = anim_data.first; ale; ale = ale->next) { | |||||
| FCurve *fcu = (FCurve *)ale->key_data; | |||||
Done Inline ActionsNo need to repeat the function name in a comment. sybren: No need to repeat the function name in a comment. | |||||
| fcurve_samples_to_keyframes(fcu, start, end); | |||||
| ale->update |= ANIM_UPDATE_DEPS; | |||||
| } | |||||
| ANIM_animdata_update(ac, &anim_data); | |||||
| ANIM_animdata_freelist(&anim_data); | |||||
| } | |||||
| /* ------------------- */ | |||||
| static int graphkeys_unbake_exec(bContext *C, wmOperator *UNUSED(op)) | |||||
| { | |||||
| bAnimContext ac; | |||||
| Scene *scene = NULL; | |||||
| int start, end; | |||||
Done Inline ActionsComments should be full sentences (start with capital, end with period). sybren: Comments should be full sentences (start with capital, end with period). | |||||
| /* Get editor data. */ | |||||
| if (ANIM_animdata_get_context(C, &ac) == 0) { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| /* For now, init start/end from preview-range extents. */ | |||||
Done Inline ActionsTODOs should have the name of the person who knows more about this. sybren: TODOs should have the name of the person who knows more about this. | |||||
Done Inline ActionsNo C++ comments in C files. sybren: No C++ comments in C files. | |||||
| /* TODO: add properties for this. (Joshua Leung 2009) */ | |||||
Done Inline ActionsLet's not copy "For now" comments from 2009. sybren: Let's not copy "For now" comments from 2009. | |||||
| scene = ac.scene; | |||||
| start = PSFRA; | |||||
| end = PEFRA; | |||||
| /* Unbake keyframes. */ | |||||
| unbake_graph_curves(&ac, start, end); | |||||
| /* Set notifier that keyframes have changed. */ | |||||
Done Inline ActionsNo C++ comments in C files. sybren: No C++ comments in C files. | |||||
| /* NOTE: some distinction between order/number of keyframes and type should be made? */ | |||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| void GRAPH_OT_unbake(wmOperatorType *ot) | |||||
| { | |||||
| /* Identifiers */ | |||||
| ot->name = "Un-Bake Curve"; | |||||
| ot->idname = "GRAPH_OT_unbake"; | |||||
| ot->description = "Un-Bake selected F-Points to F-Curves"; | |||||
| /* API callbacks */ | |||||
| ot->invoke = WM_operator_confirm; /* FIXME... */ | |||||
Done Inline ActionsI just noted this one, and I think we can remove it. Un-baking is a lossless process (ignoring the start/end frame), and we have an undo system that people can use if they're not happy with the result. I don't see the need for a confirmation pop-up. sybren: I just noted this one, and I think we can remove it. Un-baking is a lossless process (ignoring… | |||||
| ot->exec = graphkeys_unbake_exec; | |||||
| ot->poll = graphop_selected_fcurve_poll; | |||||
| /* Flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
Done Inline ActionsTODOs should have a name (and be capitalised). sybren: TODOs should have a name (and be capitalised). | |||||
| /* TODO: add props for start/end frames (Joshua Leung 2009) */ | |||||
Done Inline ActionsThis is a new operator, so I don't see why it should have a TODO from 2009 in there. sybren: This is a new operator, so I don't see why it should have a TODO from 2009 in there. | |||||
Done Inline ActionsBut muh vintage code comments! D: zeddb: But muh vintage code comments! D: | |||||
| } | |||||
| #ifdef WITH_AUDASPACE | #ifdef WITH_AUDASPACE | ||||
| /* ******************** Sound Bake F-Curve Operator *********************** */ | /* ******************** Sound Bake F-Curve Operator *********************** */ | ||||
| /* This operator bakes the given sound to the selected F-Curves */ | /* This operator bakes the given sound to the selected F-Curves */ | ||||
| /* ------------------- */ | /* ------------------- */ | ||||
| /* Custom data storage passed to the F-Sample-ing function, | /* Custom data storage passed to the F-Sample-ing function, | ||||
| ▲ Show 20 Lines • Show All 992 Lines • Show Last 20 Lines | |||||
Sentences should end in a period.