From ed564d7cb7f39853b2c79ac09cc9e010bd371576 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 12 Aug 2012 12:15:23 +0000 Subject: [PATCH 1/3] NDOF navigation support for clip editor --- .../blender/editors/space_clip/clip_intern.h | 2 + source/blender/editors/space_clip/clip_ops.c | 59 +++++++++++++++++++ .../blender/editors/space_clip/space_clip.c | 4 ++ 3 files changed, 65 insertions(+) diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 392367f9071..d33f77c1064 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -102,6 +102,8 @@ void CLIP_OT_change_frame(wmOperatorType *ot); void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot); void CLIP_OT_mode_set(struct wmOperatorType *ot); +void CLIP_OT_view_ndof(struct wmOperatorType *ot); + /* clip_toolbar.c */ struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa); void CLIP_OT_tools(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index b8657f9e688..9b4f3fcdd68 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1111,6 +1111,65 @@ void CLIP_OT_mode_set(wmOperatorType *ot) RNA_def_enum(ot->srna, "mode", clip_editor_mode_items, SC_MODE_TRACKING, "Mode", ""); } +/********************** NDOF operator *********************/ + +/* Combined pan/zoom from a 3D mouse device. + * Z zooms, XY pans + * "view" (not "paper") control -- user moves the viewpoint, not the image being viewed + * that explains the negative signs in the code below + */ + +static int clip_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) +{ + if (event->type != NDOF_MOTION) + return OPERATOR_CANCELLED; + else { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; + + float dt = ndof->dt; + + /* tune these until it feels right */ + const float zoom_sensitivity = 0.5f; /* 50% per second (I think) */ + const float pan_sensitivity = 300.0f; /* screen pixels per second */ + + float pan_x = pan_sensitivity * dt * ndof->tvec[0] / sc->zoom; + float pan_y = pan_sensitivity * dt * ndof->tvec[1] / sc->zoom; + + /* "mouse zoom" factor = 1 + (dx + dy) / 300 + * what about "ndof zoom" factor? should behave like this: + * at rest -> factor = 1 + * move forward -> factor > 1 + * move backward -> factor < 1 + */ + float zoom_factor = 1.0f + zoom_sensitivity * dt * - ndof->tvec[2]; + + if (U.ndof_flag & NDOF_ZOOM_INVERT) + zoom_factor = -zoom_factor; + + sclip_zoom_set_factor(C, zoom_factor, NULL); + sc->xof += pan_x; + sc->yof += pan_y; + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; + } +} + +void CLIP_OT_view_ndof(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "NDOF Pan/Zoom"; + ot->idname = "CLIP_OT_view_ndof"; + ot->description = "Use a 3D mouse device to pan/zoom the view"; + + /* api callbacks */ + ot->invoke = clip_view_ndof_invoke; +} + /********************** macroses *********************/ void ED_operatormacros_clip(void) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 3428c47ff43..bf65429b9f4 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -438,6 +438,7 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_change_frame); WM_operatortype_append(CLIP_OT_rebuild_proxy); WM_operatortype_append(CLIP_OT_mode_set); + WM_operatortype_append(CLIP_OT_view_ndof); /* ** clip_toolbar.c ** */ WM_operatortype_append(CLIP_OT_tools); @@ -602,6 +603,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CLIP_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CLIP_OT_view_ndof", NDOF_MOTION, 0, 0, 0); + /* jump to special frame */ kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 0); From 51fafdee0c650b991ba9bd65f488cfeba0339cdf Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 12 Aug 2012 13:24:29 +0000 Subject: [PATCH 2/3] Sequencer: overlay display type options Before this overlay would happen only for defined rectangle area, now it's possible to show current / reference frames only, which makes it possible to do more real slit view involving even displaying frames on different monitors. Still some work need to be done to clean interface up and support displaying color information for reference shot. --- .../scripts/startup/bl_ui/space_sequencer.py | 3 ++ .../editors/space_sequencer/sequencer_draw.c | 32 ++++++++++++------- .../space_sequencer/sequencer_intern.h | 2 +- .../editors/space_sequencer/space_sequencer.c | 10 +++--- source/blender/makesdna/DNA_space_types.h | 9 +++++- source/blender/makesrna/intern/rna_space.c | 15 ++++++++- 6 files changed, 52 insertions(+), 19 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 7b0715f4b41..45814205d9c 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -75,6 +75,9 @@ class SEQUENCER_HT_header(Header): row.prop(ed, "overlay_frame", text="") row.prop(ed, "overlay_lock", text="", icon='LOCKED') + row = layout.row() + row.prop(st, "overlay_type", text="") + row = layout.row(align=True) props = row.operator("render.opengl", text="", icon='RENDER_STILL') props.sequencer = True diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 297aeb465a6..2a6538e175b 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -798,7 +798,7 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val) else special_seq_update = NULL; } -void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs) +void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay) { struct Main *bmain = CTX_data_main(C); struct ImBuf *ibuf = NULL; @@ -836,7 +836,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq viewrecty /= proxy_size / 100.0f; } - if (frame_ofs == 0) { + if (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) { UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -913,17 +913,25 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glBegin(GL_QUADS); - if (frame_ofs) { - rctf tot_clip; - tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin); - tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin); - tot_clip.xmax = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax); - tot_clip.ymax = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax); + if (draw_overlay) { + if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { + rctf tot_clip; + tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin); + tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin); + tot_clip.xmax = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax); + tot_clip.ymax = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax); - glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin); - glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax); - glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmax, tot_clip.ymax); - glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmax, tot_clip.ymin); + glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin); + glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax); + glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmax, tot_clip.ymax); + glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmax, tot_clip.ymin); + } + else if (sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) { + glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin); + glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax); + glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax); + glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin); + } } else { glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 14d2ccdbbbe..16cf929a832 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -51,7 +51,7 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); /* sequencer_draw.c */ void draw_timeline_seq(const struct bContext *C, struct ARegion *ar); -void draw_image_seq(const struct bContext* C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset); +void draw_image_seq(const struct bContext* C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay); void seq_reset_imageofs(struct SpaceSeq *sseq); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 34ca26a3176..f7362aab7aa 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -487,13 +487,15 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar) ScrArea *sa = CTX_wm_area(C); SpaceSeq *sseq = sa->spacedata.first; Scene *scene = CTX_data_scene(C); + int show_split = scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF; /* XXX temp fix for wrong setting in sseq->mainb */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF; - draw_image_seq(C, scene, ar, sseq, scene->r.cfra, 0); + if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE) + draw_image_seq(C, scene, ar, sseq, scene->r.cfra, 0, FALSE); - if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF) { + if (show_split && sseq->overlay_type != SEQ_DRAW_OVERLAY_CURRENT) { int over_cfra; if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) @@ -501,8 +503,8 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar) else over_cfra = scene->r.cfra + scene->ed->over_ofs; - if (over_cfra != scene->r.cfra) - draw_image_seq(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra); + if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT) + draw_image_seq(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, TRUE); } } diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 2ac85a0d16e..b828247c816 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -470,7 +470,7 @@ typedef struct SpaceSeq { int flag; float zoom DNA_DEPRECATED; /* deprecated, handled by View2D now */ int view; /* see SEQ_VIEW_* below */ - int pad; + int overlay_type; struct bGPdata *gpd; /* grease-pencil data */ } SpaceSeq; @@ -523,6 +523,13 @@ typedef struct MaskSpaceInfo char pad3[6]; } MaskSpaceInfo; +/* sseq->mainb */ +typedef enum eSpaceSeq_OverlayType { + SEQ_DRAW_OVERLAY_RECT = 0, + SEQ_DRAW_OVERLAY_REFERENCE = 1, + SEQ_DRAW_OVERLAY_CURRENT = 2 +} eSpaceSeq_OverlayType; + /* File Selector ========================================== */ /* Config and Input for File Selector */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e325619dc0c..456df187fff 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2126,7 +2126,14 @@ static void rna_def_space_sequencer(BlenderRNA *brna) {SEQ_PROXY_RENDER_SIZE_FULL, "FULL", 0, "No proxy, full render", ""}, {0, NULL, 0, NULL, NULL} }; - + + static EnumPropertyItem overlay_type_items[] = { + {SEQ_DRAW_OVERLAY_RECT, "RECTANGLE", 0, "Rectangle", "Show rectangle area overlay"}, + {SEQ_DRAW_OVERLAY_REFERENCE, "REFERENCE", 0, "Reference", "Show reference frame only"}, + {SEQ_DRAW_OVERLAY_CURRENT, "CURRENT", 0, "Current", "Show current frame only"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "SpaceSequenceEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceSeq"); RNA_def_struct_ui_text(srna, "Space Sequence Editor", "Sequence editor space data"); @@ -2204,6 +2211,12 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "overlay_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "overlay_type"); + RNA_def_property_enum_items(prop, overlay_type_items); + RNA_def_property_ui_text(prop, "Overlay Type", "Overlay draw type"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); } static void rna_def_space_text(BlenderRNA *brna) From 82688e61fc330022bd8685a5a137fca024a60b8a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 12 Aug 2012 13:29:57 +0000 Subject: [PATCH 3/3] Sequencer: free cache used by sequence when removing strip Before this removing and adding new strip could have been lead into situations when new sequence would use old cache. --- source/blender/blenkernel/intern/sequencer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 920588d9f47..45259b5dbc9 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -136,6 +136,8 @@ static void free_proxy_seq(Sequence *seq) IMB_free_anim(seq->strip->proxy->anim); seq->strip->proxy->anim = NULL; } + + BKE_sequencer_cache_cleanup_sequence(seq); } static void seq_free_strip(Strip *strip)