Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_clip/clip_buttons.c
| Show First 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | typedef struct { | ||||
| MovieClip *clip; | MovieClip *clip; | ||||
| /** user of clip */ | /** user of clip */ | ||||
| MovieClipUser *user; | MovieClipUser *user; | ||||
| MovieTrackingTrack *track; | MovieTrackingTrack *track; | ||||
| MovieTrackingMarker *marker; | MovieTrackingMarker *marker; | ||||
| /** current frame number */ | /** current frame number */ | ||||
| int framenr; | int clip_framenr; | ||||
| /** position of marker in pixel coords */ | /** position of marker in pixel coords */ | ||||
| float marker_pos[2]; | float marker_pos[2]; | ||||
| /** position and dimensions of marker pattern in pixel coords */ | /** position and dimensions of marker pattern in pixel coords */ | ||||
| float marker_pat[2]; | float marker_pat[2]; | ||||
| /** offset of "parenting" point */ | /** offset of "parenting" point */ | ||||
| float track_offset[2]; | float track_offset[2]; | ||||
| /** position and dimensions of marker search in pixel coords */ | /** position and dimensions of marker search in pixel coords */ | ||||
| float marker_search_pos[2], marker_search[2]; | float marker_search_pos[2], marker_search[2]; | ||||
| /** marker's flags */ | /** marker's flags */ | ||||
| int marker_flag; | int marker_flag; | ||||
| } MarkerUpdateCb; | } MarkerUpdateCb; | ||||
| static void to_pixel_space(float r[2], float a[2], int width, int height) | static void to_pixel_space(float r[2], float a[2], int width, int height) | ||||
| { | { | ||||
| copy_v2_v2(r, a); | copy_v2_v2(r, a); | ||||
| r[0] *= width; | r[0] *= width; | ||||
| r[1] *= height; | r[1] *= height; | ||||
| } | } | ||||
| static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) | static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) | ||||
| { | { | ||||
| MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb; | MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb; | ||||
| MovieTrackingMarker *marker; | |||||
| if (!cb->compact) { | if (!cb->compact) { | ||||
| return; | return; | ||||
| } | } | ||||
| marker = BKE_tracking_marker_ensure(cb->track, cb->framenr); | MovieTrackingMarker *marker = cb->marker; | ||||
| marker->flag = cb->marker_flag; | marker->flag = cb->marker_flag; | ||||
| WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); | ||||
| } | } | ||||
| static void marker_block_handler(bContext *C, void *arg_cb, int event) | static void marker_block_handler(bContext *C, void *arg_cb, int event) | ||||
| { | { | ||||
| MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb; | MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb; | ||||
| MovieTrackingMarker *marker; | |||||
| int width, height; | int width, height; | ||||
| bool ok = false; | bool ok = false; | ||||
| BKE_movieclip_get_size(cb->clip, cb->user, &width, &height); | BKE_movieclip_get_size(cb->clip, cb->user, &width, &height); | ||||
| marker = BKE_tracking_marker_ensure(cb->track, cb->framenr); | MovieTrackingMarker *marker = cb->marker; | ||||
| if (event == B_MARKER_POS) { | if (event == B_MARKER_POS) { | ||||
| marker->pos[0] = cb->marker_pos[0] / width; | marker->pos[0] = cb->marker_pos[0] / width; | ||||
| marker->pos[1] = cb->marker_pos[1] / height; | marker->pos[1] = cb->marker_pos[1] / height; | ||||
| /* to update position of "parented" objects */ | /* to update position of "parented" objects */ | ||||
| DEG_id_tag_update(&cb->clip->id, 0); | DEG_id_tag_update(&cb->clip->id, 0); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | if (RNA_property_type(prop) != PROP_POINTER) { | ||||
| return; | return; | ||||
| } | } | ||||
| clipptr = RNA_property_pointer_get(ptr, prop); | clipptr = RNA_property_pointer_get(ptr, prop); | ||||
| clip = (MovieClip *)clipptr.data; | clip = (MovieClip *)clipptr.data; | ||||
| user = userptr->data; | user = userptr->data; | ||||
| track = trackptr->data; | track = trackptr->data; | ||||
| marker = BKE_tracking_marker_get(track, user->framenr); | int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr); | ||||
| marker = BKE_tracking_marker_get(track, clip_framenr); | |||||
| cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb"); | cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb"); | ||||
| cb->compact = compact; | cb->compact = compact; | ||||
| cb->clip = clip; | cb->clip = clip; | ||||
| cb->user = user; | cb->user = user; | ||||
| cb->track = track; | cb->track = track; | ||||
| cb->marker = marker; | cb->marker = marker; | ||||
| cb->marker_flag = marker->flag; | cb->marker_flag = marker->flag; | ||||
| cb->framenr = user->framenr; | |||||
| if (compact) { | if (compact) { | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| if (cb->marker_flag & MARKER_DISABLED) { | if (cb->marker_flag & MARKER_DISABLED) { | ||||
| tip = TIP_("Marker is disabled at current frame"); | tip = TIP_("Marker is disabled at current frame"); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 421 Lines • Show Last 20 Lines | |||||