Camera tracking integration
===========================
- glog should no flood into logs files now.
- Request from Francois - changes in sliding:
* Anchor point is for sliding the whole marker.
* Square on pattern moves pattern and search relative
to anchor point.
* Square on search moves search only.
- Bundles in 3d viewport are colored by track custom color.
This commit is contained in:
6
extern/libmv/libmv-capi.cpp
vendored
6
extern/libmv/libmv-capi.cpp
vendored
@@ -70,9 +70,10 @@ typedef struct libmv_RegionTracker {
|
||||
void libmv_initLogging(const char *argv0)
|
||||
{
|
||||
google::InitGoogleLogging(argv0);
|
||||
google::SetCommandLineOption("logtostderr", "0");
|
||||
google::SetCommandLineOption("logtostderr", "1");
|
||||
google::SetCommandLineOption("v", "0");
|
||||
google::SetCommandLineOption("stderrthreshold", "7");
|
||||
google::SetCommandLineOption("minloglevel", "7");
|
||||
V3D::optimizerVerbosenessLevel = 0;
|
||||
}
|
||||
|
||||
@@ -80,7 +81,8 @@ void libmv_startDebugLogging(void)
|
||||
{
|
||||
google::SetCommandLineOption("logtostderr", "1");
|
||||
google::SetCommandLineOption("v", "0");
|
||||
google::SetCommandLineOption("stderrthreshold", "2");
|
||||
google::SetCommandLineOption("stderrthreshold", "1");
|
||||
google::SetCommandLineOption("minloglevel", "0");
|
||||
V3D::optimizerVerbosenessLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_movieclip.h"
|
||||
#include "BKE_tracking.h"
|
||||
@@ -171,6 +172,10 @@ static void do_tracking_marker(bContext *C, void *UNUSED(arg), int event)
|
||||
marker->pos[0]= sc->marker_pos[0]/width;
|
||||
marker->pos[1]= sc->marker_pos[1]/height;
|
||||
|
||||
/* to update position of "parented" objects */
|
||||
DAG_id_tag_update(&clip->id, 0);
|
||||
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
else if(event==B_MARKER_PAT_DIM) {
|
||||
@@ -238,6 +243,10 @@ static void do_tracking_marker(bContext *C, void *UNUSED(arg), int event)
|
||||
track->offset[0]= sc->track_offset[0]/width;
|
||||
track->offset[1]= sc->track_offset[1]/height;
|
||||
|
||||
/* to update position of "parented" objects */
|
||||
DAG_id_tag_update(&clip->id, 0);
|
||||
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack *
|
||||
break;
|
||||
|
||||
if(marker->framenr==i) {
|
||||
copy_v2_v2(path[--a], marker->pos);
|
||||
add_v2_v2v2(path[--a], marker->pos, track->offset);
|
||||
|
||||
if(marker->framenr==sc->user.framenr)
|
||||
curindex= a;
|
||||
@@ -220,7 +220,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack *
|
||||
if(marker->framenr==sc->user.framenr)
|
||||
curindex= b;
|
||||
|
||||
copy_v2_v2(path[b++], marker->pos);
|
||||
add_v2_v2v2(path[b++], marker->pos, track->offset);
|
||||
} else
|
||||
break;
|
||||
|
||||
@@ -498,7 +498,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int outline, int act, int width, int height)
|
||||
static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int outline, int sel, int act, int width, int height)
|
||||
{
|
||||
float x, y, dx, dy, patdx, patdy, searchdx, searchdy, tdx, tdy;
|
||||
int tiny= sc->flag&SC_SHOW_TINY_MARKER;
|
||||
@@ -523,38 +523,25 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
||||
dx= 6.0f/width/sc->zoom;
|
||||
dy= 6.0f/height/sc->zoom;
|
||||
|
||||
patdx= MIN2(dx, (track->pat_max[0]-track->pat_min[0])/6.f);
|
||||
patdy= MIN2(dy, (track->pat_max[1]-track->pat_min[1])/6.f);
|
||||
patdx= MIN2(dx*2.f/3.f, (track->pat_max[0]-track->pat_min[0])/6.f);
|
||||
patdy= MIN2(dy*2.f/3.f, (track->pat_max[1]-track->pat_min[1])/6.f);
|
||||
|
||||
searchdx= MIN2(dx, (track->search_max[0]-track->search_min[0])/6.f);
|
||||
searchdy= MIN2(dy, (track->search_max[1]-track->search_min[1])/6.f);
|
||||
|
||||
/* position square */
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH || sc->flag&SC_SHOW_MARKER_PATTERN) {
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH) {
|
||||
if(!outline) {
|
||||
if(track->search_flag&SELECT) glColor3fv(scol);
|
||||
else glColor3fv(col);
|
||||
}
|
||||
|
||||
x= track->search_min[0];
|
||||
y= track->search_max[1];
|
||||
|
||||
tdx= searchdx;
|
||||
tdy= searchdy;
|
||||
} else {
|
||||
if(!outline) {
|
||||
if(track->pat_flag&SELECT) glColor3fv(scol);
|
||||
else glColor3fv(col);
|
||||
}
|
||||
|
||||
x= track->pat_min[0];
|
||||
y= track->pat_max[1];
|
||||
|
||||
tdx= patdx;
|
||||
tdy= patdy;
|
||||
if((sc->flag&SC_SHOW_MARKER_SEARCH) && ((track->search_flag&SELECT)==sel || outline)) {
|
||||
if(!outline) {
|
||||
if(track->search_flag&SELECT) glColor3fv(scol);
|
||||
else glColor3fv(col);
|
||||
}
|
||||
|
||||
/* search offset square */
|
||||
x= track->search_min[0];
|
||||
y= track->search_max[1];
|
||||
|
||||
tdx= searchdx;
|
||||
tdy= searchdy;
|
||||
|
||||
if(outline) {
|
||||
tdx+= 1.0f/sc->zoom/width;
|
||||
tdy+= 1.0f/sc->zoom/height;
|
||||
@@ -566,15 +553,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
||||
glVertex3f(x+tdx, y-tdy, 0);
|
||||
glVertex3f(x-tdx, y-tdy, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/* search resizing triangle */
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH) {
|
||||
if(!outline) {
|
||||
if(track->search_flag&SELECT) glColor3fv(scol);
|
||||
else glColor3fv(col);
|
||||
}
|
||||
|
||||
/* search resizing triangle */
|
||||
x= track->search_max[0];
|
||||
y= track->search_min[1];
|
||||
|
||||
@@ -582,8 +562,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
||||
tdy= searchdy*2.f;
|
||||
|
||||
if(outline) {
|
||||
tdx+= 2.0f/sc->zoom/width;
|
||||
tdy+= 2.0f/sc->zoom/height;
|
||||
tdx+= 1.0f/sc->zoom/width;
|
||||
tdy+= 1.0f/sc->zoom/height;
|
||||
}
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
@@ -593,13 +573,32 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/* pattern resizing triangle */
|
||||
if(sc->flag&SC_SHOW_MARKER_PATTERN) {
|
||||
if((sc->flag&SC_SHOW_MARKER_PATTERN) && ((track->pat_flag&SELECT)==sel || outline)) {
|
||||
if(!outline) {
|
||||
if(track->pat_flag&SELECT) glColor3fv(scol);
|
||||
else glColor3fv(col);
|
||||
}
|
||||
|
||||
/* pattern offset square */
|
||||
x= track->pat_min[0];
|
||||
y= track->pat_max[1];
|
||||
|
||||
tdx= patdx;
|
||||
tdy= patdy;
|
||||
|
||||
if(outline) {
|
||||
tdx+= 1.0f/sc->zoom/width;
|
||||
tdy+= 1.0f/sc->zoom/height;
|
||||
}
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(x-tdx, y+tdy, 0);
|
||||
glVertex3f(x+tdx, y+tdy, 0);
|
||||
glVertex3f(x+tdx, y-tdy, 0);
|
||||
glVertex3f(x-tdx, y-tdy, 0);
|
||||
glEnd();
|
||||
|
||||
/* pattern resizing triangle */
|
||||
x= track->pat_max[0];
|
||||
y= track->pat_min[1];
|
||||
|
||||
@@ -607,8 +606,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
||||
tdy= patdy*2.f;
|
||||
|
||||
if(outline) {
|
||||
tdx+= 2.0f/sc->zoom/width;
|
||||
tdy+= 2.0f/sc->zoom/height;
|
||||
tdx+= 1.0f/sc->zoom/width;
|
||||
tdy+= 1.0f/sc->zoom/height;
|
||||
}
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
@@ -772,7 +771,8 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
|
||||
if(MARKER_VISIBLE(sc, marker)) {
|
||||
draw_marker_outline(sc, track, marker, width, height);
|
||||
draw_marker_areas(sc, track, marker, width, height, 0, 0);
|
||||
draw_marker_slide_zones(sc, track, marker, 1, 0, width, height);
|
||||
draw_marker_slide_zones(sc, track, marker, 1, 0, 0, width, height);
|
||||
draw_marker_slide_zones(sc, track, marker, 0, 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,7 +791,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
|
||||
|
||||
if(MARKER_VISIBLE(sc, marker)) {
|
||||
draw_marker_areas(sc, track, marker, width, height, 0, 1);
|
||||
draw_marker_slide_zones(sc, track, marker, 0, 0, width, height);
|
||||
draw_marker_slide_zones(sc, track, marker, 0, 1, 0, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -806,7 +806,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
|
||||
|
||||
if(MARKER_VISIBLE(sc, marker)) {
|
||||
draw_marker_areas(sc, sel, marker, width, height, 1, 1);
|
||||
draw_marker_slide_zones(sc, sel, marker, 0, 1, width, height);
|
||||
draw_marker_slide_zones(sc, sel, marker, 0, 1, 1, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +156,8 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
|
||||
if(marker) {
|
||||
float pos[2];
|
||||
|
||||
pos[0]= marker->pos[0]*width;
|
||||
pos[1]= marker->pos[1]*height;
|
||||
pos[0]= (marker->pos[0]+track->offset[0])*width;
|
||||
pos[1]= (marker->pos[1]+track->offset[1])*height;
|
||||
|
||||
DO_MINMAX2(pos, min, max);
|
||||
|
||||
|
||||
@@ -356,14 +356,21 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
|
||||
copy_v2_v2(data->spos, marker->pos);
|
||||
copy_v2_v2(data->soff, track->offset);
|
||||
} else if(area==TRACK_AREA_PAT) {
|
||||
data->min= track->pat_min;
|
||||
data->max= track->pat_max;
|
||||
if(action==SLIDE_ACTION_SIZE) {
|
||||
data->min= track->pat_min;
|
||||
data->max= track->pat_max;
|
||||
} else {
|
||||
data->pos= marker->pos;
|
||||
data->offset= track->offset;
|
||||
copy_v2_v2(data->spos, marker->pos);
|
||||
copy_v2_v2(data->soff, track->offset);
|
||||
}
|
||||
} else if(area==TRACK_AREA_SEARCH) {
|
||||
data->min= track->search_min;
|
||||
data->max= track->search_max;
|
||||
}
|
||||
|
||||
if(ELEM(area, TRACK_AREA_PAT, TRACK_AREA_SEARCH)) {
|
||||
if(area==TRACK_AREA_SEARCH || (area==TRACK_AREA_PAT && action!=SLIDE_ACTION_OFFSET)) {
|
||||
copy_v2_v2(data->smin, data->min);
|
||||
copy_v2_v2(data->smax, data->max);
|
||||
}
|
||||
@@ -482,15 +489,14 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
|
||||
if((marker->flag&MARKER_DISABLED)==0) {
|
||||
if(sc->flag&SC_SHOW_MARKER_SEARCH) {
|
||||
if(mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height))
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height);
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_OFFSET, width, height);
|
||||
else if(mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height))
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_SIZE, width, height);
|
||||
}
|
||||
|
||||
if(!customdata && sc->flag&SC_SHOW_MARKER_PATTERN) {
|
||||
if((sc->flag&SC_SHOW_MARKER_SEARCH)==0)
|
||||
if(mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height))
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height);
|
||||
if(mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height))
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_OFFSET, width, height);
|
||||
|
||||
if(!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height))
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height);
|
||||
@@ -498,7 +504,7 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
|
||||
|
||||
if(!customdata)
|
||||
if(mouse_on_offset(sc, track, marker, co, width, height))
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_OFFSET, width, height);
|
||||
customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height);
|
||||
|
||||
if(customdata)
|
||||
break;
|
||||
@@ -529,19 +535,15 @@ static void cancel_mouse_slide(SlideMarkerData *data)
|
||||
{
|
||||
/* cancel sliding */
|
||||
if(data->area == TRACK_AREA_POINT) {
|
||||
if(data->action==SLIDE_ACTION_OFFSET) {
|
||||
data->offset[0]= data->soff[0];
|
||||
data->offset[1]= data->soff[1];
|
||||
} else {
|
||||
data->pos[0]= data->spos[0];
|
||||
data->pos[1]= data->spos[1];
|
||||
}
|
||||
if(data->action==SLIDE_ACTION_OFFSET)
|
||||
copy_v2_v2(data->offset, data->soff);
|
||||
else
|
||||
copy_v2_v2(data->pos, data->spos);
|
||||
} else {
|
||||
data->min[0]= data->smin[0];
|
||||
data->max[0]= data->smax[0];
|
||||
|
||||
data->min[1]= data->smin[1];
|
||||
data->max[1]= data->smax[1];
|
||||
if(data->action==SLIDE_ACTION_SIZE) {
|
||||
copy_v2_v2(data->min, data->smin);
|
||||
copy_v2_v2(data->max, data->smax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,14 +595,31 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
DAG_id_tag_update(&sc->clip->id, 0);
|
||||
} else {
|
||||
data->min[0]= data->smin[0]-dx;
|
||||
data->max[0]= data->smax[0]+dx;
|
||||
if(data->action==SLIDE_ACTION_SIZE) {
|
||||
data->min[0]= data->smin[0]-dx;
|
||||
data->max[0]= data->smax[0]+dx;
|
||||
|
||||
data->min[1]= data->smin[1]+dy;
|
||||
data->max[1]= data->smax[1]-dy;
|
||||
data->min[1]= data->smin[1]+dy;
|
||||
data->max[1]= data->smax[1]-dy;
|
||||
|
||||
if(data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_DIM);
|
||||
else BKE_tracking_clamp_track(data->track, CLAMP_PAT_DIM);
|
||||
if(data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_DIM);
|
||||
else BKE_tracking_clamp_track(data->track, CLAMP_PAT_DIM);
|
||||
} else {
|
||||
float d[2]={dx, dy};
|
||||
|
||||
if(data->area==TRACK_AREA_SEARCH) {
|
||||
add_v2_v2v2(data->min, data->smin, d);
|
||||
add_v2_v2v2(data->max, data->smax, d);
|
||||
} else {
|
||||
add_v2_v2v2(data->pos, data->spos, d);
|
||||
add_v2_v2v2(data->pos, data->spos, d);
|
||||
|
||||
sub_v2_v2v2(data->offset, data->soff, d);
|
||||
}
|
||||
|
||||
if(data->area==TRACK_AREA_SEARCH)
|
||||
BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_POS);
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL);
|
||||
|
||||
@@ -1455,7 +1455,10 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
|
||||
if(selected) {
|
||||
if(base==BASACT) UI_ThemeColor(TH_ACTIVE);
|
||||
else UI_ThemeColor(TH_SELECT);
|
||||
} else UI_ThemeColor(TH_WIRE);
|
||||
} else {
|
||||
if(track->flag&TRACK_CUSTOMCOLOR) glColor3fv(track->color);
|
||||
else UI_ThemeColor(TH_WIRE);
|
||||
}
|
||||
|
||||
drawaxes(0.05f, v3d->bundle_drawtype);
|
||||
|
||||
@@ -1481,7 +1484,9 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
|
||||
glDepthMask(1);
|
||||
}
|
||||
|
||||
UI_ThemeColor(TH_BUNDLE_SOLID);
|
||||
if(track->flag&TRACK_CUSTOMCOLOR) glColor3fv(track->color);
|
||||
else UI_ThemeColor(TH_BUNDLE_SOLID);
|
||||
|
||||
draw_bundle_sphere();
|
||||
} else {
|
||||
glDisable(GL_LIGHTING);
|
||||
@@ -1490,7 +1495,10 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
|
||||
if(selected) {
|
||||
if(base==BASACT) UI_ThemeColor(TH_ACTIVE);
|
||||
else UI_ThemeColor(TH_SELECT);
|
||||
} else UI_ThemeColor(TH_WIRE);
|
||||
} else {
|
||||
if(track->flag&TRACK_CUSTOMCOLOR) glColor3fv(track->color);
|
||||
else UI_ThemeColor(TH_WIRE);
|
||||
}
|
||||
|
||||
drawaxes(0.05f, v3d->bundle_drawtype);
|
||||
|
||||
|
||||
@@ -738,6 +738,10 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* same as above */
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
case NC_MOVIECLIP:
|
||||
if(wmn->data==ND_DISPLAY)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
case NC_SPACE:
|
||||
if(wmn->data == ND_SPACE_VIEW3D) {
|
||||
if (wmn->subtype == NS_VIEW3D_GPU) {
|
||||
|
||||
Reference in New Issue
Block a user