Various fixes for camera tracking stuff
- Fixed tooltip displaying for track sequence forwards in clip editor - Corrected detection of 8 tracks so it wouldn't count tracks disabled on keyframes. - Scale track preview to actual track widget size instead of scaling the whole preview image with given zoom ratio, so no extra memory needed to store zoomed margin would be used. - Track's statistics text will fit pattern position instead of search if marker is disabled on current frame. - Fixed toggle selection operator if selected track is hidden due to "Hide Disabled" policy.
This commit is contained in:
@@ -172,6 +172,7 @@ class CLIP_PT_tools_tracking(Panel):
|
||||
props.backwards = True
|
||||
props.sequence = True
|
||||
props = row.operator("clip.track_markers", text="", icon='PLAY')
|
||||
props.backwards = False
|
||||
props.sequence = True
|
||||
row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ struct MovieTrackingMarker *BKE_tracking_get_marker(struct MovieTrackingTrack *t
|
||||
struct MovieTrackingMarker *BKE_tracking_ensure_marker(struct MovieTrackingTrack *track, int framenr);
|
||||
struct MovieTrackingMarker *BKE_tracking_exact_marker(struct MovieTrackingTrack *track, int framenr);
|
||||
int BKE_tracking_has_marker(struct MovieTrackingTrack *track, int framenr);
|
||||
int BKE_tracking_has_enabled_marker(struct MovieTrackingTrack *track, int framenr);
|
||||
|
||||
void BKE_tracking_free_track(struct MovieTrackingTrack *track);
|
||||
|
||||
|
||||
@@ -395,6 +395,13 @@ int BKE_tracking_has_marker(MovieTrackingTrack *track, int framenr)
|
||||
return BKE_tracking_exact_marker(track, framenr) != 0;
|
||||
}
|
||||
|
||||
int BKE_tracking_has_enabled_marker(MovieTrackingTrack *track, int framenr)
|
||||
{
|
||||
MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
|
||||
|
||||
return marker && (marker->flag & MARKER_DISABLED) == 0;
|
||||
}
|
||||
|
||||
void BKE_tracking_free_track(MovieTrackingTrack *track)
|
||||
{
|
||||
if(track->markers) MEM_freeN(track->markers);
|
||||
@@ -1741,8 +1748,8 @@ static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tra
|
||||
|
||||
track= tracksbase->first;
|
||||
while(track) {
|
||||
if(BKE_tracking_has_marker(track, frame1))
|
||||
if(BKE_tracking_has_marker(track, frame2))
|
||||
if(BKE_tracking_has_enabled_marker(track, frame1))
|
||||
if(BKE_tracking_has_enabled_marker(track, frame2))
|
||||
tot++;
|
||||
|
||||
track= track->next;
|
||||
@@ -1758,7 +1765,7 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o
|
||||
ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
|
||||
|
||||
if(count_tracks_on_both_keyframes(tracking, tracksbase)<8) {
|
||||
BLI_strncpy(error_msg, "At least 8 tracks on both of keyframes are needed for reconstruction", error_size);
|
||||
BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1461,19 +1461,21 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
|
||||
fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
||||
}
|
||||
|
||||
static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float zoomx, float zoomy)
|
||||
static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width, float height, int margin)
|
||||
{
|
||||
ImBuf *scaleibuf;
|
||||
int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy;
|
||||
const float scalex= 1.0f/zoomx;
|
||||
const float scaley= 1.0f/zoomy;
|
||||
const float scalex= ((float)ibuf->x-2*margin) / width;
|
||||
const float scaley= ((float)ibuf->y-2*margin) / height;
|
||||
float off_x= (int)track_pos[0]-track_pos[0]+0.5f;
|
||||
float off_y= (int)track_pos[1]-track_pos[1]+0.5f;
|
||||
int x, y;
|
||||
|
||||
scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect);
|
||||
scaleibuf= IMB_allocImBuf(width, height, 32, IB_rect);
|
||||
|
||||
for(y= 0; y<h; y++) {
|
||||
for (x= 0; x<w; x++) {
|
||||
float src_x= scalex*x;
|
||||
float src_y= scaley*y;
|
||||
for(y= 0; y<height; y++) {
|
||||
for (x= 0; x<width; x++) {
|
||||
float src_x= scalex*(x)+margin-off_x;
|
||||
float src_y= scaley*(y)+margin-off_y;
|
||||
|
||||
bicubic_interpolation(ibuf, scaleibuf, src_x, src_y, x, y);
|
||||
}
|
||||
@@ -1504,7 +1506,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
if(scopes->track_disabled) {
|
||||
glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
|
||||
uiSetRoundBox(15);
|
||||
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
|
||||
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
@@ -1512,8 +1514,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
/* additional margin around image */
|
||||
/* NOTE: should be kept in sync with value from BKE_movieclip_update_scopes */
|
||||
const int margin= 3;
|
||||
float zoomx, zoomy, track_pos[2], off_x, off_y, x0, y0;
|
||||
int a;
|
||||
float zoomx, zoomy, track_pos[2], off_x, off_y;
|
||||
int a, width, height;
|
||||
ImBuf *drawibuf;
|
||||
|
||||
glPushMatrix();
|
||||
@@ -1524,16 +1526,18 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
/* draw content of pattern area */
|
||||
glScissor(ar->winrct.xmin+rect.xmin, ar->winrct.ymin+rect.ymin, scissor[2], scissor[3]);
|
||||
|
||||
zoomx= (rect.xmax-rect.xmin) / (scopes->track_preview->x-2*margin);
|
||||
zoomy= (rect.ymax-rect.ymin) / (scopes->track_preview->y-2*margin);
|
||||
width= rect.xmax-rect.xmin+1;
|
||||
height = rect.ymax-rect.ymin;
|
||||
|
||||
zoomx= (float)width / (scopes->track_preview->x-2*margin);
|
||||
zoomy= (float)height / (scopes->track_preview->y-2*margin);
|
||||
|
||||
off_x= ((int)track_pos[0]-track_pos[0]+0.5)*zoomx;
|
||||
off_y= ((int)track_pos[1]-track_pos[1]+0.5)*zoomy;
|
||||
x0= (int)(off_x+rect.xmin-zoomx*(margin-0.5f))+1;
|
||||
y0= (int)(off_y+rect.ymin-zoomy*(margin-0.5f))+1;
|
||||
|
||||
drawibuf= scale_trackpreview_ibuf(scopes->track_preview, zoomx, zoomy);
|
||||
glaDrawPixelsSafe(x0, y0, rect.xmax-x0+1, rect.ymax-y0+1,
|
||||
drawibuf= scale_trackpreview_ibuf(scopes->track_preview, track_pos, width, height, margin);
|
||||
|
||||
glaDrawPixelsSafe(rect.xmin, rect.ymin+1, drawibuf->x, drawibuf->y,
|
||||
drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
|
||||
IMB_freeImBuf(drawibuf);
|
||||
|
||||
@@ -1568,7 +1572,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
if(!ok) {
|
||||
glColor4f(0.f, 0.f, 0.f, 0.3f);
|
||||
uiSetRoundBox(15);
|
||||
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
|
||||
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
|
||||
}
|
||||
|
||||
/* outline, scale gripper */
|
||||
|
||||
@@ -777,7 +777,9 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
else UI_ThemeColor(TH_SEL_MARKER);
|
||||
}
|
||||
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH) {
|
||||
if((sc->flag&SC_SHOW_MARKER_SEARCH) &&
|
||||
((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0))
|
||||
{
|
||||
dx= track->search_min[0];
|
||||
dy= track->search_min[1];
|
||||
} else if(sc->flag&SC_SHOW_MARKER_PATTERN) {
|
||||
|
||||
@@ -1014,6 +1014,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
MovieTrackingTrack *track= NULL; /* selected track */
|
||||
MovieTrackingMarker *marker;
|
||||
ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking);
|
||||
int action= RNA_enum_get(op->ptr, "action");
|
||||
int framenr= sc->user.framenr;
|
||||
@@ -1024,8 +1025,12 @@ static int select_all_exec(bContext *C, wmOperator *op)
|
||||
track= tracksbase->first;
|
||||
while(track) {
|
||||
if(TRACK_VIEW_SELECTED(sc, track)) {
|
||||
action= SEL_DESELECT;
|
||||
break;
|
||||
marker= BKE_tracking_get_marker(track, framenr);
|
||||
|
||||
if(MARKER_VISIBLE(sc, marker)) {
|
||||
action= SEL_DESELECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
track= track->next;
|
||||
@@ -1035,9 +1040,9 @@ static int select_all_exec(bContext *C, wmOperator *op)
|
||||
track= tracksbase->first;
|
||||
while(track) {
|
||||
if((track->flag&TRACK_HIDDEN)==0) {
|
||||
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
|
||||
marker= BKE_tracking_get_marker(track, framenr);
|
||||
|
||||
if(marker && MARKER_VISIBLE(sc, marker)) {
|
||||
if(MARKER_VISIBLE(sc, marker)) {
|
||||
switch (action) {
|
||||
case SEL_SELECT:
|
||||
track->flag|= SELECT;
|
||||
|
||||
Reference in New Issue
Block a user