Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_clip/tracking_ops_track.c
| Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | static void track_markers_freejob(void *tmv) | ||||
| tmj->clip->tracking_context = NULL; | tmj->clip->tracking_context = NULL; | ||||
| BKE_autotrack_context_free(tmj->context); | BKE_autotrack_context_free(tmj->context); | ||||
| MEM_freeN(tmj); | MEM_freeN(tmj); | ||||
| } | } | ||||
| static int track_markers(bContext *C, wmOperator *op, bool use_job) | static int track_markers(bContext *C, wmOperator *op, bool use_job) | ||||
| { | { | ||||
| TrackMarkersJob *tmj; | TrackMarkersJob *tmj; | ||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| SpaceClip *sc = CTX_wm_space_clip(C); | SpaceClip *sc = CTX_wm_space_clip(C); | ||||
| MovieClip *clip = ED_space_clip_get_clip(sc); | MovieClip *clip = ED_space_clip_get_clip(sc); | ||||
| wmJob *wm_job; | wmJob *wm_job; | ||||
| bool backwards = RNA_boolean_get(op->ptr, "backwards"); | bool backwards = RNA_boolean_get(op->ptr, "backwards"); | ||||
| bool sequence = RNA_boolean_get(op->ptr, "sequence"); | bool sequence = RNA_boolean_get(op->ptr, "sequence"); | ||||
| int framenr = ED_space_clip_get_clip_frame_number(sc); | int framenr = ED_space_clip_get_clip_frame_number(sc); | ||||
| if (WM_jobs_test(CTX_wm_manager(C), sa, WM_JOB_TYPE_ANY)) { | if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_ANY)) { | ||||
| /* Only one tracking is allowed at a time. */ | /* Only one tracking is allowed at a time. */ | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (clip->tracking_context) { | if (clip->tracking_context) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (track_count_markers(sc, clip, framenr) == 0) { | if (track_count_markers(sc, clip, framenr) == 0) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| tmj = MEM_callocN(sizeof(TrackMarkersJob), "TrackMarkersJob data"); | tmj = MEM_callocN(sizeof(TrackMarkersJob), "TrackMarkersJob data"); | ||||
| if (!track_markers_initjob(C, tmj, backwards, sequence)) { | if (!track_markers_initjob(C, tmj, backwards, sequence)) { | ||||
| track_markers_freejob(tmj); | track_markers_freejob(tmj); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* Setup job. */ | /* Setup job. */ | ||||
| if (use_job && sequence) { | if (use_job && sequence) { | ||||
| wm_job = WM_jobs_get(CTX_wm_manager(C), | wm_job = WM_jobs_get(CTX_wm_manager(C), | ||||
| CTX_wm_window(C), | CTX_wm_window(C), | ||||
| sa, | CTX_data_scene(C), | ||||
| "Track Markers", | "Track Markers", | ||||
| WM_JOB_PROGRESS, | WM_JOB_PROGRESS, | ||||
| WM_JOB_TYPE_CLIP_TRACK_MARKERS); | WM_JOB_TYPE_CLIP_TRACK_MARKERS); | ||||
| WM_jobs_customdata_set(wm_job, tmj, track_markers_freejob); | WM_jobs_customdata_set(wm_job, tmj, track_markers_freejob); | ||||
| /* If there's delay set in tracking job, tracking should happen | /* If there's delay set in tracking job, tracking should happen | ||||
| * with fixed FPS. To deal with editor refresh we have to synchronize | * with fixed FPS. To deal with editor refresh we have to synchronize | ||||
| * tracks from job and tracks in clip. Do this in timer callback | * tracks from job and tracks in clip. Do this in timer callback | ||||
| Show All 36 Lines | |||||
| static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| return track_markers(C, op, true); | return track_markers(C, op, true); | ||||
| } | } | ||||
| static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| { | { | ||||
| /* No running tracking, remove handler and pass through. */ | /* No running tracking, remove handler and pass through. */ | ||||
| if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) { | if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_ANY)) { | ||||
| return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; | return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; | ||||
| } | } | ||||
| /* Running tracking. */ | /* Running tracking. */ | ||||
| switch (event->type) { | switch (event->type) { | ||||
| case ESCKEY: | case ESCKEY: | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines | |||||