Camera tracking integration
=========================== - Fixed crash when transforming disabled marker. - Select Inverse wouldn't select hidden parts of markers. - Movie Clip display aspect ratio is now available on Display panel.
This commit is contained in:
@@ -341,6 +341,11 @@ class CLIP_PT_display(bpy.types.Panel):
|
||||
layout.prop(sc, "lock_selection")
|
||||
layout.prop(sc, "use_mute_footage")
|
||||
|
||||
clip = sc.clip
|
||||
if clip:
|
||||
layout.label(text="Display Aspect:")
|
||||
layout.prop(clip, "display_aspect", text="")
|
||||
|
||||
|
||||
class CLIP_PT_footage(bpy.types.Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
|
||||
@@ -11815,6 +11815,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
{
|
||||
bScreen *sc;
|
||||
Camera *cam;
|
||||
MovieClip *clip;
|
||||
|
||||
for (sc= main->screen.first; sc; sc= sc->id.next) {
|
||||
ScrArea *sa;
|
||||
@@ -11841,8 +11842,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
for (clip= main->movieclip.first; clip; clip= clip->id.next) {
|
||||
if(clip->aspx<1.0f) {
|
||||
clip->aspx= 1.0f;
|
||||
clip->aspy= 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
for(cam= main->camera.first; cam; cam= cam->id.next) {
|
||||
if (cam->sensor_x < 0.01) {
|
||||
if (cam->sensor_x < 0.01f) {
|
||||
cam->sensor_x = 32.f;
|
||||
cam->sensor_y = 18.f;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ void ED_space_clip_set(struct bContext *C, struct SpaceClip *sc, struct MovieCli
|
||||
struct MovieClip *ED_space_clip(struct SpaceClip *sc);
|
||||
void ED_space_clip_size(struct SpaceClip *sc, int *width, int *height);
|
||||
void ED_space_clip_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy);
|
||||
void ED_clip_aspect(struct MovieClip *clip, float *aspx, float *aspy);
|
||||
void ED_space_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
|
||||
|
||||
|
||||
struct ImBuf *ED_space_clip_acquire_buffer(struct SpaceClip *sc);
|
||||
|
||||
|
||||
@@ -102,6 +102,22 @@ void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy)
|
||||
*zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
|
||||
}
|
||||
|
||||
void ED_clip_aspect(MovieClip *clip, float *aspx, float *aspy)
|
||||
{
|
||||
*aspx= *aspy= 1.0;
|
||||
|
||||
if(clip == NULL || clip->aspx==0.0f || clip->aspy==0.0f)
|
||||
return;
|
||||
|
||||
/* x is always 1 */
|
||||
*aspy = clip->aspy/clip->aspx;
|
||||
}
|
||||
|
||||
void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy)
|
||||
{
|
||||
ED_clip_aspect(ED_space_clip(sc), aspx, aspy);
|
||||
}
|
||||
|
||||
void ED_clip_update_frame(const Main *mainp, int cfra)
|
||||
{
|
||||
wmWindowManager *wm;
|
||||
@@ -158,9 +174,10 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
|
||||
void ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit)
|
||||
{
|
||||
int w, h, width, height, frame_width, frame_height;
|
||||
float min[2], max[2];
|
||||
float min[2], max[2], aspx, aspy;
|
||||
|
||||
ED_space_clip_size(sc, &frame_width, &frame_height);
|
||||
ED_space_clip_aspect(sc, &aspx, &aspy);
|
||||
|
||||
if(frame_width==0 || frame_height==0) return;
|
||||
|
||||
@@ -173,8 +190,8 @@ void ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit)
|
||||
h= max[1]-min[1];
|
||||
|
||||
/* center view */
|
||||
sc->xof= ((float)(max[0]+min[0]-frame_width))/2;
|
||||
sc->yof= ((float)(max[1]+min[1]-frame_height))/2;
|
||||
sc->xof= ((float)(max[0]+min[0]-frame_width))/2*aspx;
|
||||
sc->yof= ((float)(max[1]+min[1]-frame_height))/2*aspy;
|
||||
|
||||
/* set zoom to see all selection */
|
||||
if(w>0 && h>0) {
|
||||
|
||||
@@ -632,12 +632,17 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
SpaceClip *sc;
|
||||
ARegion *ar;
|
||||
int w, h, width, height;
|
||||
float aspx, aspy;
|
||||
|
||||
/* retrieve state */
|
||||
sc= CTX_wm_space_clip(C);
|
||||
ar= CTX_wm_region(C);
|
||||
|
||||
ED_space_clip_size(sc, &w, &h);
|
||||
ED_space_clip_aspect(sc, &aspx, &aspy);
|
||||
|
||||
w= w*aspx;
|
||||
h= h*aspy;
|
||||
|
||||
/* check if the image will fit in the image with zoom==1 */
|
||||
width= ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
|
||||
@@ -379,6 +379,7 @@ static void clip_refresh(const bContext *C, ScrArea *UNUSED(sa))
|
||||
/* sets up the fields of the View2D from zoom and offset */
|
||||
static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
|
||||
{
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
float x1, y1, w, h;
|
||||
int width, height, winx, winy;
|
||||
|
||||
@@ -387,6 +388,9 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
|
||||
w= width;
|
||||
h= height;
|
||||
|
||||
if(clip)
|
||||
h*= clip->aspy/clip->aspx;
|
||||
|
||||
winx= ar->winrct.xmax - ar->winrct.xmin + 1;
|
||||
winy= ar->winrct.ymax - ar->winrct.ymin + 1;
|
||||
|
||||
|
||||
@@ -162,10 +162,14 @@ static void mouse_pos(bContext *C, wmEvent *event, float co[2])
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceClip *sc= CTX_wm_space_clip(C);
|
||||
int sx, sy;
|
||||
float zoomx, zoomy;
|
||||
|
||||
ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
|
||||
|
||||
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
|
||||
co[0]= ((float)event->mval[0]-sx)/sc->zoom;
|
||||
co[1]= ((float)event->mval[1]-sy)/sc->zoom;
|
||||
|
||||
co[0]= ((float)event->mval[0]-sx)/zoomx;
|
||||
co[1]= ((float)event->mval[1]-sy)/zoomy;
|
||||
}
|
||||
|
||||
static int add_marker_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
@@ -676,18 +680,18 @@ static int select_all_exec(bContext *C, wmOperator *op)
|
||||
switch (action) {
|
||||
case SEL_SELECT:
|
||||
track->flag|= SELECT;
|
||||
track->pat_flag|= SELECT;
|
||||
track->search_flag|= SELECT;
|
||||
if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag|= SELECT;
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag|= SELECT;
|
||||
break;
|
||||
case SEL_DESELECT:
|
||||
track->flag&= ~SELECT;
|
||||
track->pat_flag&= ~SELECT;
|
||||
track->search_flag&= ~SELECT;
|
||||
if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag&= ~SELECT;
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag&= ~SELECT;
|
||||
break;
|
||||
case SEL_INVERT:
|
||||
track->flag^= SELECT;
|
||||
track->pat_flag^= SELECT;
|
||||
track->search_flag^= SELECT;
|
||||
if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag^= SELECT;
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag^= SELECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5291,17 +5291,9 @@ static void createTransTrackingData(bContext *C, TransInfo *t)
|
||||
marker= BKE_tracking_get_marker(track, framenr);
|
||||
|
||||
if(marker) {
|
||||
if((marker->flag&MARKER_DISABLED)==0) {
|
||||
if(track->flag&SELECT) t->total++;
|
||||
if(track->pat_flag&SELECT) t->total+= 2;
|
||||
}
|
||||
|
||||
if(track->search_flag&SELECT) {
|
||||
t->total+= 2;
|
||||
|
||||
if(marker->flag&MARKER_DISABLED)
|
||||
t->total+= 3;
|
||||
}
|
||||
if(track->flag&SELECT) t->total++;
|
||||
if(track->pat_flag&SELECT) t->total+= 2;
|
||||
if(track->search_flag&SELECT) t->total+= 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ typedef struct MovieClip {
|
||||
int lastframe; /* last accessed frame number */
|
||||
int lastsize[2]; /* size of last accessed frame */
|
||||
|
||||
float aspx, aspy; /* display aspect */
|
||||
|
||||
struct anim *anim; /* movie source data */
|
||||
void *ibuf_cache; /* cache of ibufs, not in file */
|
||||
|
||||
|
||||
@@ -135,6 +135,13 @@ static void rna_def_movieclip(BlenderRNA *brna)
|
||||
prop= RNA_def_float_vector(srna, "resolution" , 2 , NULL , 0, 0, "Resolution" , "X/Y pixels per meter" , 0 , 0);
|
||||
RNA_def_property_float_funcs(prop, "rna_MovieClip_resolution_get", NULL, NULL);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
|
||||
RNA_def_property_float_sdna(prop, NULL, "aspx");
|
||||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_range(prop, 0.1f, 5000.0f);
|
||||
RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this clip, does not affect rendering");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
|
||||
}
|
||||
|
||||
void RNA_def_movieclip(BlenderRNA *brna)
|
||||
|
||||
Reference in New Issue
Block a user