Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTianwei Shen <shentianweipku@gmail.com>2016-07-22 06:43:50 +0300
committerTianwei Shen <shentianweipku@gmail.com>2016-07-22 06:43:50 +0300
commit929e9694f4e4740e2301e1e996d9c466d24da58c (patch)
tree0c56ddfcc489ffcd7c940959a595aaeaedb0465e /source/blender/editors/space_clip
parentd572da5b12cda9489c2ff787b79d79d60a9ba0f0 (diff)
trying to shift window for secondary clip
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r--source/blender/editors/space_clip/clip_draw.c64
-rw-r--r--source/blender/editors/space_clip/space_clip.c57
2 files changed, 117 insertions, 4 deletions
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 455afb76cb9..99e12021382 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -1750,7 +1750,71 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
void clip_draw_secondary_clip(const bContext *C, SpaceClip *sc, ARegion *ar)
{
+ MovieClip *sclip = ED_space_clip_get_secondary_clip(sc);
+ Scene *scene = CTX_data_scene(C);
+ ImBuf *ibuf = NULL;
+ int width, height;
+ float zoomx, zoomy;
+
+ ED_space_clip_get_size(sc, &width, &height);
+ ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
+
+ /* if no clip, nothing to do */
+ if (!sclip) {
+ ED_region_grid_draw(ar, zoomx, zoomy);
+ return;
+ }
+
+ if (sc->flag & SC_SHOW_STABLE) {
+ float translation[2];
+ float aspect = sclip->tracking.camera.pixel_aspect;
+ float smat[4][4], ismat[4][4];
+
+ if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
+ ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc,
+ &sc->scale, &sc->angle);
+ }
+ if (ibuf != NULL && width != ibuf->x)
+ mul_v2_v2fl(translation, sc->loc, (float)width / ibuf->x);
+ else
+ copy_v2_v2(translation, sc->loc);
+
+ BKE_tracking_stabilization_data_to_mat4(width, height, aspect, translation,
+ sc->scale, sc->angle, sc->stabmat);
+
+ unit_m4(smat);
+ smat[0][0] = 1.0f / width;
+ smat[1][1] = 1.0f / height;
+ invert_m4_m4(ismat, smat);
+
+ mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat);
+ }
+ else if ((sc->flag & SC_MUTE_FOOTAGE) == 0) {
+ ibuf = ED_space_clip_get_buffer(sc);
+
+ zero_v2(sc->loc);
+ sc->scale = 1.0f;
+ unit_m4(sc->stabmat);
+ unit_m4(sc->unistabmat);
+ }
+
+ if (ibuf) {
+ draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy);
+ IMB_freeImBuf(ibuf);
+ }
+ else if (sc->flag & SC_MUTE_FOOTAGE) {
+ draw_movieclip_muted(ar, width, height, zoomx, zoomy);
+ }
+ else {
+ ED_region_grid_draw(ar, zoomx, zoomy);
+ }
+
+ if (width && height) {
+ draw_stabilization_border(sc, ar, width, height, zoomx, zoomy);
+ draw_tracking_tracks(sc, scene, ar, sclip, width, height, zoomx, zoomy);
+ draw_distortion(sc, ar, sclip, width, height, zoomx, zoomy);
+ }
}
void clip_draw_cache_and_notes(const bContext *C, SpaceClip *sc, ARegion *ar)
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index bf36cbb2950..8189494a3a1 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -1143,6 +1143,53 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar)
ar->v2d.cur.ymax /= h;
}
+/* sets up the fields of the View2D from zoom and offset for secondary clip in correspondence mode*/
+static void movieclip_secondary_clip_set_view2d(const bContext *C, ARegion *ar)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ float x1, y1, w, h, aspx, aspy;
+ int width, height, winx, winy;
+
+ ED_space_clip_get_size(sc, &width, &height);
+ ED_space_clip_get_aspect(sc, &aspx, &aspy);
+
+ w = width * aspx;
+ h = height * aspy;
+
+ winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ winy = BLI_rcti_size_y(&ar->winrct) + 1;
+
+ ar->v2d.tot.xmin = 0;
+ ar->v2d.tot.ymin = 0;
+ ar->v2d.tot.xmax = w;
+ ar->v2d.tot.ymax = h;
+
+ ar->v2d.mask.xmin = ar->v2d.mask.ymin = 0;
+ ar->v2d.mask.xmax = winx;
+ ar->v2d.mask.ymax = winy;
+
+ /* which part of the image space do we see? */
+ x1 = ar->winrct.xmin + (winx - sc->zoom * w) / 2.0f;
+ y1 = ar->winrct.ymin + (winy - sc->zoom * h) / 2.0f;
+
+ x1 -= sc->zoom * sc->xof;
+ y1 -= sc->zoom * sc->yof;
+
+ /* relative display right */
+ ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / sc->zoom;
+ ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sc->zoom);
+
+ /* relative display left */
+ ar->v2d.cur.ymin = (ar->winrct.ymin - (float)y1) / sc->zoom;
+ ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sc->zoom);
+
+ /* normalize 0.0..1.0 */
+ ar->v2d.cur.xmin /= w;
+ ar->v2d.cur.xmax /= w;
+ ar->v2d.cur.ymin /= h;
+ ar->v2d.cur.ymax /= h;
+}
+
/* add handlers, stuff you only do once or on area/region changes */
static void clip_main_region_init(wmWindowManager *wm, ARegion *ar)
{
@@ -1200,10 +1247,6 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
movieclip_main_area_set_view2d(C, ar);
clip_draw_main(C, sc, ar);
- if (sc->mode == SC_MODE_CORRESPONDENCE) {
- //TODO(tianwei): draw correspondence related code
- clip_draw_secondary_clip(C, sc, ar);
- }
/* TODO(sergey): would be nice to find a way to de-duplicate all this space conversions */
UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
@@ -1248,6 +1291,12 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
clip_draw_grease_pencil((bContext *)C, true);
}
+ /* draw secondary clip in Correspondence mode */
+ if (sc->mode == SC_MODE_CORRESPONDENCE) {
+ //movieclip_secondary_clip_set_view2d(C, ar);
+ clip_draw_secondary_clip(C, sc, ar);
+ }
+
/* reset view matrix */
UI_view2d_view_restore(C);