From ee572a9642d5360f0ba852c17cc345f21ad1f985 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Jul 2012 21:22:42 +0000 Subject: [PATCH 1/9] code cleanup: minor edits for mask/transform --- source/blender/editors/include/ED_mask.h | 7 +++++ source/blender/editors/mask/mask_intern.h | 9 ------ source/blender/editors/transform/transform.c | 29 +++++++++++++++----- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 758fe6367bb..372d4665a73 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -34,12 +34,19 @@ struct wmKeyConfig; struct MaskLayer; struct MaskLayerShape; +struct wmEvent; /* mask_edit.c */ void ED_mask_size(const struct bContext *C, int *width, int *height); void ED_mask_zoom(const struct bContext *C, float *zoomx, float *zoomy); void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy); +void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley); +void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); + +void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr); + void ED_operatortypes_mask(void); void ED_keymap_mask(struct wmKeyConfig *keyconf); void ED_operatormacros_mask(void); diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index b4ff4bc5b31..ffd4afca182 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -99,15 +99,6 @@ void ED_mask_select_flush_all(struct Mask *mask); int ED_maskedit_poll(struct bContext *C); int ED_maskedit_mask_poll(struct bContext *C); -void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley); -void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); - -void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr); -void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr); - -void ED_mask_get_zoom(const bContext *C, float *zoomx, float *zoomy); -void ED_mask_get_size(const bContext *C, float *zoomx, float *zoomy); - /* mask_shapekey.c */ void MASK_OT_shape_key_insert(struct wmOperatorType *ot); void MASK_OT_shape_key_clear(struct wmOperatorType *ot); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 63161bc058f..4f26f563ac6 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -74,6 +74,7 @@ #include "ED_view3d.h" #include "ED_mesh.h" #include "ED_clip.h" +#include "ED_mask.h" #include "UI_view2d.h" #include "WM_types.h" @@ -225,13 +226,24 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) project_int_noclip(t->ar, vec, adr); } else if (t->spacetype == SPACE_IMAGE) { - float aspx, aspy, v[2]; +#if 0 + if (t->options & CTX_MASK) { + float v[2]; + ED_mask_point_pos__reverse(t->context, vec[0], vec[1], &v[0], &v[1]); + adr[0] = v[0]; + adr[1] = v[1]; + } + else +#endif + { + float aspx, aspy, v[2]; - ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); - v[0] = vec[0] / aspx; - v[1] = vec[1] / aspy; + ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); + v[0] = vec[0] / aspx; + v[1] = vec[1] / aspy; - UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1); + UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1); + } } else if (t->spacetype == SPACE_ACTION) { int out[2] = {0, 0}; @@ -272,10 +284,13 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) copy_v2_v2(v, vec); - if (t->options & CTX_MOVIECLIP) + if (t->options & CTX_MOVIECLIP) { ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); - else if (t->options & CTX_MASK) + } + else if (t->options & CTX_MASK) { + /* MASKTODO - not working as expected */ ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); + } v[0] /= aspx; v[1] /= aspy; From ff078d309e65d2383fa0829954c724fc49189492 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Jul 2012 22:41:40 +0000 Subject: [PATCH 2/9] change clip utility function arguments to take space data and region rather then the context. this allows a fix to be applied that corrects the helper line in the image view when transforming a mask. --- source/blender/editors/include/ED_clip.h | 12 ++--- source/blender/editors/include/ED_mask.h | 15 +++--- source/blender/editors/mask/mask_add.c | 24 ++++++--- source/blender/editors/mask/mask_draw.c | 6 ++- source/blender/editors/mask/mask_edit.c | 49 +++++++------------ source/blender/editors/mask/mask_ops.c | 34 +++++++++---- source/blender/editors/mask/mask_select.c | 31 +++++++++--- source/blender/editors/space_clip/clip_draw.c | 7 ++- .../blender/editors/space_clip/clip_editor.c | 46 +++++++---------- .../editors/space_clip/clip_graph_ops.c | 1 + .../blender/editors/space_clip/clip_intern.h | 4 +- source/blender/editors/space_clip/clip_ops.c | 29 ++++++++--- .../blender/editors/space_clip/clip_utils.c | 5 +- .../blender/editors/space_clip/space_clip.c | 7 +-- .../blender/editors/space_clip/tracking_ops.c | 29 +++++++---- .../editors/space_clip/tracking_select.c | 25 +++++++--- .../blender/editors/space_image/space_image.c | 2 +- .../editors/space_sequencer/sequencer_draw.c | 7 ++- source/blender/editors/transform/transform.c | 7 +-- .../editors/transform/transform_conversions.c | 4 +- 20 files changed, 201 insertions(+), 143 deletions(-) diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index f1b405c2c3e..8c4eb5c3879 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -52,9 +52,9 @@ int ED_space_clip_tracking_poll(struct bContext *C); int ED_space_clip_maskedit_poll(struct bContext *C); int ED_space_clip_maskedit_mask_poll(bContext *C); -void ED_space_clip_get_size(const struct bContext *C, int *width, int *height); -void ED_space_clip_get_size_fl(const struct bContext *C, float size[2]); -void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy); +void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height); +void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]); +void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *ar, float *zoomx, float *zoomy); void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy); void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); @@ -67,9 +67,9 @@ void ED_clip_update_frame(const struct Main *mainp, int cfra); int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit); void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2]); -void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr); -void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]); -void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); +void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, float y, float *xr, float *yr); +void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, const float co[2], float r_co[2]); +void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *ar, struct wmEvent *event, float co[2]); int ED_space_clip_check_show_trackedit(struct SpaceClip *sc); int ED_space_clip_check_show_maskedit(struct SpaceClip *sc); diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 372d4665a73..72be9cc2726 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -37,15 +37,16 @@ struct MaskLayerShape; struct wmEvent; /* mask_edit.c */ -void ED_mask_size(const struct bContext *C, int *width, int *height); -void ED_mask_zoom(const struct bContext *C, float *zoomx, float *zoomy); -void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy); +void ED_mask_get_size(struct ScrArea *sa, int *width, int *height); +void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *zoomy); +void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *ar, float *aspx, float *aspy); -void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley); -void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); +void ED_mask_pixelspace_factor(struct ScrArea *sa, struct ARegion *ar, float *scalex, float *scaley); +void ED_mask_mouse_pos(struct ScrArea *sa, struct ARegion *ar, struct wmEvent *event, float co[2]); -void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr); -void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_point_pos(struct ScrArea *sa, struct ARegion *ar, float x, float y, float *xr, float *yr); +void ED_mask_point_pos__reverse(struct ScrArea *sa, struct ARegion *ar, + float x, float y, float *xr, float *yr); void ED_operatortypes_mask(void); void ED_keymap_mask(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index c9f6dc0c5fb..48c81894b55 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -38,6 +38,7 @@ #include "BKE_mask.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "DNA_mask_types.h" #include "DNA_object_types.h" /* SELECT */ @@ -57,6 +58,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no float *u_r, float tangent[2], const short use_deform) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + MaskLayer *masklay, *point_masklay; MaskSpline *point_spline; MaskSplinePoint *point = NULL; @@ -65,9 +69,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no float u; float scalex, scaley, aspx, aspy; - ED_mask_size(C, &width, &height); - ED_mask_aspect(C, &aspx, &aspy); - ED_mask_pixelspace_factor(C, &scalex, &scaley); + ED_mask_get_size(sa, &width, &height); + ED_mask_get_aspect(sa, ar, &aspx, &aspy); + ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -180,6 +184,8 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline const float point_co[2], const float tangent[2], const float u, MaskSplinePoint *reference_point, const short reference_adjacent) { + ScrArea *sa = CTX_wm_area(C); + MaskSplinePoint *prev_point = NULL; MaskSplinePoint *next_point = NULL; BezTriple *bezt; @@ -190,7 +196,7 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline copy_v2_v2(co, point_co); co[2] = 0.0f; - ED_mask_size(C, &width, &height); + ED_mask_get_size(sa, &width, &height); /* point coordinate */ bezt = &new_point->bezt; @@ -610,9 +616,12 @@ static int add_vertex_exec(bContext *C, wmOperator *op) static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); RNA_float_set_array(op->ptr, "location", co); @@ -681,9 +690,12 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op) static int add_feather_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); RNA_float_set_array(op->ptr, "location", co); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index c79920eeb01..f416e31c1de 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -456,19 +456,21 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type) { + ScrArea *sa = CTX_wm_area(C); + Mask *mask = CTX_data_edit_mask(C); int width, height; if (!mask) return; - ED_mask_size(C, &width, &height); + ED_mask_get_size(sa, &width, &height); draw_masklays(mask, draw_flag, draw_type, width, height); } /* sets up the opengl context. - * width, height are to match the values from ED_mask_size() */ + * width, height are to match the values from ED_mask_get_size() */ void ED_mask_draw_region(Mask *mask, ARegion *ar, const char draw_flag, const char draw_type, int width, int height, diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 5c724d9e5a3..7b94cb83fe9 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -90,21 +90,19 @@ int ED_maskedit_mask_poll(bContext *C) /********************** registration *********************/ -void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) +void ED_mask_mouse_pos(ScrArea *sa, ARegion *ar, wmEvent *event, float co[2]) { - ScrArea *sa = CTX_wm_area(C); if (sa) { switch (sa->spacetype) { case SPACE_CLIP: { SpaceClip *sc = sa->spacedata.first; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co); break; } case SPACE_SEQ: { - ARegion *ar = CTX_wm_region(C); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); break; } @@ -112,7 +110,6 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) { float frame_size[2]; SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_size_fl(sima, frame_size); ED_image_mouse_pos(sima, ar, event, co); BKE_mask_coord_from_frame(co, co, frame_size); @@ -133,9 +130,8 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) /* input: x/y - mval space * output: xr/yr - mask point space */ -void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos(struct ScrArea *sa, struct ARegion *ar, float x, float y, float *xr, float *yr) { - ScrArea *sa = CTX_wm_area(C); float co[2]; if (sa) { @@ -143,7 +139,7 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr case SPACE_CLIP: { SpaceClip *sc = sa->spacedata.first; - ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]); + ED_clip_point_stable_pos(sc, ar, x, y, &co[0], &co[1]); BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co); break; } @@ -154,7 +150,6 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr { float frame_size[2]; SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_size_fl(sima, frame_size); ED_image_point_pos(sima, ar, x, y, &co[0], &co[1]); BKE_mask_coord_from_frame(co, co, frame_size); @@ -176,9 +171,8 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr *yr = co[1]; } -void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos__reverse(ScrArea *sa, ARegion *ar, float x, float y, float *xr, float *yr) { - ScrArea *sa = CTX_wm_area(C); float co[2]; if (sa) { @@ -189,7 +183,7 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, co[0] = x; co[1] = y; BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co); - ED_clip_point_stable_pos__reverse(C, co, co); + ED_clip_point_stable_pos__reverse(sc, ar, co, co); break; } case SPACE_SEQ: @@ -199,7 +193,6 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, { float frame_size[2]; SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_size_fl(sima, frame_size); co[0] = x; @@ -224,21 +217,21 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, *yr = co[1]; } -void ED_mask_size(const bContext *C, int *width, int *height) +void ED_mask_get_size(struct ScrArea *sa, int *width, int *height) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: { - ED_space_clip_get_size(C, width, height); + SpaceClip *sc = sa->spacedata.first; + ED_space_clip_get_size(sc, width, height); break; } case SPACE_SEQ: { - Scene *scene = CTX_data_scene(C); - *width = (scene->r.size * scene->r.xsch) / 100; - *height = (scene->r.size * scene->r.ysch) / 100; +// Scene *scene = CTX_data_scene(C); +// *width = (scene->r.size * scene->r.xsch) / 100; +// *height = (scene->r.size * scene->r.ysch) / 100; break; } case SPACE_IMAGE: @@ -262,14 +255,14 @@ void ED_mask_size(const bContext *C, int *width, int *height) } } -void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy) +void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *zoomy) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: { - ED_space_clip_get_zoom(C, zoomx, zoomy); + SpaceClip *sc = sa->spacedata.first; + ED_space_clip_get_zoom(sc, ar, zoomx, zoomy); break; } case SPACE_SEQ: @@ -280,7 +273,6 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy) case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_zoom(sima, ar, zoomx, zoomy); break; } @@ -297,9 +289,8 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy) } } -void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) +void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *UNUSED(ar), float *aspx, float *aspy) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: @@ -332,9 +323,8 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) } } -void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) +void ED_mask_pixelspace_factor(struct ScrArea *sa, struct ARegion *ar, float *scalex, float *scaley) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: @@ -343,8 +333,8 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) int width, height; float zoomx, zoomy, aspx, aspy; - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); ED_space_clip_get_aspect(sc, &aspx, &aspy); *scalex = ((float)width * aspx) * zoomx; @@ -359,7 +349,6 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); int width, height; float zoomx, zoomy, aspx, aspy; diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 99c46c38bfc..116c3dcede1 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -62,6 +62,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float MaskLayer **masklay_r, MaskSpline **spline_r, int *is_handle_r, float *score) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + MaskLayer *masklay; MaskLayer *point_masklay = NULL; MaskSpline *point_spline = NULL; @@ -70,9 +73,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float float len = FLT_MAX, scalex, scaley; int is_handle = FALSE, width, height; - ED_mask_size(C, &width, &height); - ED_mask_aspect(C, &aspx, &aspy); - ED_mask_pixelspace_factor(C, &scalex, &scaley); + ED_mask_get_size(sa, &width, &height); + ED_mask_get_aspect(sa, ar, &aspx, &aspy); + ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -158,6 +161,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[ MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, MaskSplinePointUW **uw_r, float *score) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + MaskLayer *masklay, *point_masklay = NULL; MaskSpline *point_spline = NULL; MaskSplinePoint *point = NULL; @@ -166,9 +172,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[ float scalex, scaley, aspx, aspy; int width, height; - ED_mask_size(C, &width, &height); - ED_mask_aspect(C, &aspx, &aspy); - ED_mask_pixelspace_factor(C, &scalex, &scaley); + ED_mask_get_size(sa, &width, &height); + ED_mask_get_aspect(sa, ar, &aspx, &aspy); + ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -426,6 +432,9 @@ static int slide_point_check_initial_feather(MaskSpline *spline) static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); SlidePointData *customdata = NULL; MaskLayer *masklay, *cv_masklay, *feather_masklay; @@ -437,8 +446,8 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) float co[2], cv_score, feather_score; const float threshold = 19; - ED_mask_mouse_pos(C, event, co); - ED_mask_size(C, &width, &height); + ED_mask_mouse_pos(sa, ar, event, co); + ED_mask_get_size(sa, &width, &height); cv_point = ED_mask_point_find_nearest(C, mask, co, threshold, &cv_masklay, &cv_spline, &is_handle, &cv_score); @@ -502,7 +511,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) copy_m3_m3(customdata->vec, point->bezt.vec); if (BKE_mask_point_has_handle(point)) BKE_mask_point_handle(point, customdata->handle); - ED_mask_mouse_pos(C, event, customdata->co); + ED_mask_mouse_pos(sa, ar, event, customdata->co); } return customdata; @@ -639,7 +648,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) /* no break! update CV position */ case MOUSEMOVE: - ED_mask_mouse_pos(C, event, co); + { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + + ED_mask_mouse_pos(sa, ar, event, co); sub_v2_v2v2(dco, co, data->co); if (data->action == SLIDE_ACTION_HANDLE) { @@ -768,6 +781,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) DAG_id_tag_update(&data->mask->id, 0); break; + } case LEFTMOUSE: if (event->val == KM_RELEASE) { diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 565beaf34ef..2f5fef1d59a 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -343,9 +343,12 @@ static int select_exec(bContext *C, wmOperator *op) static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); RNA_float_set_array(op->ptr, "location", co); @@ -380,6 +383,9 @@ void MASK_OT_select(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; int i; @@ -394,8 +400,8 @@ static int border_select_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - ED_mask_point_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); - ED_mask_point_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); + ED_mask_point_pos(sa, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); + ED_mask_point_pos(sa, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); mode = RNA_int_get(op->ptr, "gesture_mode"); extend = RNA_boolean_get(op->ptr, "extend"); @@ -465,6 +471,9 @@ void MASK_OT_select_border(wmOperatorType *ot) static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short select) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; int i; @@ -496,7 +505,7 @@ static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short float screen_co[2]; /* marker in screen coords */ - ED_mask_point_pos__reverse(C, + ED_mask_point_pos__reverse(sa, ar, point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1], &screen_co[0], &screen_co[1]); @@ -578,6 +587,9 @@ static int mask_spline_point_inside_ellipse(BezTriple *bezt, float offset[2], fl static int circle_select_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; int i; @@ -593,14 +605,14 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ - ED_mask_size(C, &width, &height); - ED_mask_zoom(C, &zoomx, &zoomy); + ED_mask_get_size(sa, &width, &height); + ED_mask_zoom(sa, ar, &zoomx, &zoomy); width = height = MAX2(width, height); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; - ED_mask_point_pos(C, x, y, &offset[0], &offset[1]); + ED_mask_point_pos(sa, ar, x, y, &offset[0], &offset[1]); /* do actual selection */ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { @@ -663,6 +675,9 @@ void MASK_OT_select_circle(wmOperatorType *ot) static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; MaskSpline *spline; @@ -674,7 +689,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent * const float threshold = 19; int change = FALSE; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); point = ED_mask_point_find_nearest(C, mask, co, threshold, &masklay, &spline, &is_handle, NULL); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 7734661aa96..d650ea7b61d 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1408,17 +1408,16 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); } -void clip_draw_main(const bContext *C, ARegion *ar) +void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) { - SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); ImBuf *ibuf; int width, height; float zoomx, zoomy; - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &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 (!clip) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 92fcbc2964d..c04cd864d2e 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -124,10 +124,8 @@ int ED_space_clip_maskedit_mask_poll(bContext *C) /* ******** common editing functions ******** */ -void ED_space_clip_get_size(const bContext *C, int *width, int *height) +void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height) { - SpaceClip *sc = CTX_wm_space_clip(C); - if (sc->clip) { BKE_movieclip_get_size(sc->clip, &sc->user, width, height); } @@ -136,20 +134,19 @@ void ED_space_clip_get_size(const bContext *C, int *width, int *height) } } -void ED_space_clip_get_size_fl(const bContext *C, float size[2]) +void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]) { int size_i[2]; - ED_space_clip_get_size(C, &size_i[0], &size_i[1]); + ED_space_clip_get_size(sc, &size_i[0], &size_i[1]); size[0] = size_i[0]; size[1] = size_i[1]; } -void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy) +void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *ar, float *zoomx, float *zoomy) { - ARegion *ar = CTX_wm_region(C); int width, height; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); @@ -273,9 +270,8 @@ void ED_clip_update_frame(const Main *mainp, int cfra) } } -static int selected_boundbox(const bContext *C, float min[2], float max[2]) +static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) { - SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height, ok = FALSE; @@ -284,7 +280,7 @@ static int selected_boundbox(const bContext *C, float min[2], float max[2]) INIT_MINMAX2(min, max); - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); track = tracksbase->first; while (track) { @@ -327,17 +323,17 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) int w, h, frame_width, frame_height; float min[2], max[2]; - ED_space_clip_get_size(C, &frame_width, &frame_height); + ED_space_clip_get_size(sc, &frame_width, &frame_height); if (frame_width == 0 || frame_height == 0) return FALSE; - if (!selected_boundbox(C, min, max)) + if (!selected_boundbox(sc, min, max)) return FALSE; /* center view */ - clip_view_center_to_point(C, (max[0] + min[0]) / (2 * frame_width), - (max[1] + min[1]) / (2 * frame_height)); + clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -385,15 +381,13 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ } } -void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, float *yr) +void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, float y, float *xr, float *yr) { - ARegion *ar = CTX_wm_region(C); - SpaceClip *sc = CTX_wm_space_clip(C); int sx, sy, width, height; float zoomx, zoomy, pos[3], imat[4][4]; - ED_space_clip_get_zoom(C, &zoomx, &zoomy); - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); @@ -424,18 +418,16 @@ void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, fl * \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords. * better name here? view_to_track / track_to_view or so? */ -void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], float r_co[2]) +void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, const float co[2], float r_co[2]) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float zoomx, zoomy; float pos[3]; int width, height; int sx, sy; UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); ED_clip_point_undistorted_pos(sc, co, pos); pos[2] = 0.0f; @@ -447,9 +439,9 @@ void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], flo r_co[1] = (pos[1] * height * zoomy) + (float)sy; } -void ED_clip_mouse_pos(const bContext *C, wmEvent *event, float co[2]) +void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *ar, wmEvent *event, float co[2]) { - ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]); + ED_clip_point_stable_pos(sc, ar, event->mval[0], event->mval[1], &co[0], &co[1]); } int ED_space_clip_check_show_trackedit(SpaceClip *sc) diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index abf7f416b9c..c0b11dda5c7 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -345,6 +345,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index c4652c2f04d..3422aacf264 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -69,7 +69,7 @@ void clip_draw_dopesheet_channels(const struct bContext *C, struct ARegion *ar); void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot); /* clip_draw.c */ -void clip_draw_main(const struct bContext *C, struct ARegion *ar); +void clip_draw_main(const struct bContext *C, struct SpaceClip *sc, struct ARegion *ar); void clip_draw_grease_pencil(struct bContext *C, int onlyv2d); void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y); @@ -125,7 +125,7 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int in void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track); void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker); -void clip_view_center_to_point(const struct bContext *C, float x, float y); +void clip_view_center_to_point(SpaceClip *sc, float x, float y); void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index ee799566970..1dabef75c21 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -74,6 +74,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); + float oldzoom = sc->zoom; int width, height; @@ -81,7 +82,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) if (sc->zoom < 0.1f || sc->zoom > 4.0f) { /* check zoom limits */ - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); width *= sc->zoom; height *= sc->zoom; @@ -95,7 +96,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) } if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; @@ -111,16 +112,20 @@ static void sclip_zoom_set_factor(const bContext *C, float zoomfac, float locati static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor) { + ARegion *ar = CTX_wm_region(C); + float location[2], *mpos = NULL; if (event) { - ED_clip_mouse_pos(C, event, location); + SpaceClip *sc = CTX_wm_space_clip(C); + + ED_clip_mouse_pos(sc, ar, event, location); mpos = location; } sclip_zoom_set_factor(C, factor, mpos); - ED_region_tag_redraw(CTX_wm_region(C)); + ED_region_tag_redraw(ar); } /******************** open clip operator ********************/ @@ -466,6 +471,8 @@ typedef struct ViewZoomData { static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + ViewZoomData *vpd; op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData"); @@ -476,7 +483,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) vpd->zoom = sc->zoom; vpd->event_type = event->type; - ED_clip_mouse_pos(C, event, vpd->location); + ED_clip_mouse_pos(sc, ar, event, vpd->location); WM_event_add_modal_handler(C, op); } @@ -593,9 +600,12 @@ static int view_zoom_in_exec(bContext *C, wmOperator *op) static int view_zoom_in_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float location[2]; - ED_clip_mouse_pos(C, event, location); + ED_clip_mouse_pos(sc, ar, event, location); RNA_float_set_array(op->ptr, "location", location); return view_zoom_in_exec(C, op); @@ -633,9 +643,12 @@ static int view_zoom_out_exec(bContext *C, wmOperator *op) static int view_zoom_out_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float location[2]; - ED_clip_mouse_pos(C, event, location); + ED_clip_mouse_pos(sc, ar, event, location); RNA_float_set_array(op->ptr, "location", location); return view_zoom_out_exec(C, op); @@ -706,7 +719,7 @@ static int view_all_exec(bContext *C, wmOperator *op) sc = CTX_wm_space_clip(C); ar = CTX_wm_region(C); - ED_space_clip_get_size(C, &w, &h); + ED_space_clip_get_size(sc, &w, &h); ED_space_clip_get_aspect(sc, &aspx, &aspy); w = w * aspx; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index d9c9f63e4a3..9e93aed6df7 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -223,13 +223,12 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, } } -void clip_view_center_to_point(const bContext *C, float x, float y) +void clip_view_center_to_point(SpaceClip *sc, float x, float y) { - SpaceClip *sc = CTX_wm_space_clip(C); int width, height; float aspx, aspy; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); ED_space_clip_get_aspect(sc, &aspx, &aspy); sc->xof = (x - 0.5f) * width * aspx; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index bd7359e8bb0..3428c47ff43 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1024,7 +1024,7 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) float x1, y1, w, h; int width, height, winx, winy; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); w = width; h = height; @@ -1119,14 +1119,15 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) /* data... */ movieclip_main_area_set_view2d(C, ar); - clip_draw_main(C, ar); + clip_draw_main(C, sc, ar); if (sc->mode == SC_MODE_MASKEDIT) { Mask *mask = CTX_data_edit_mask(C); if (mask) { + ScrArea *sa = CTX_wm_area(C); int width, height; - ED_mask_size(C, &width, &height); + ED_mask_get_size(sa, &width, &height); ED_mask_draw_region(mask, ar, sc->mask_info.draw_flag, sc->mask_info.draw_type, width, height, diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 360a3f74130..28bb0f70611 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -91,7 +91,7 @@ static void add_marker(const bContext *C, float x, float y) int width, height; int framenr = ED_space_clip_get_clip_frame_number(sc); - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height); @@ -107,7 +107,7 @@ static int add_marker_exec(bContext *C, wmOperator *op) float pos[2]; int width, height; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); if (!width || !height) return OPERATOR_CANCELLED; @@ -127,9 +127,12 @@ static int add_marker_exec(bContext *C, wmOperator *op) static int add_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); RNA_float_set_array(op->ptr, "location", co); @@ -525,6 +528,8 @@ static void show_cursor(bContext *C) MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int *area_r, int *action_r, int *corner_r) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height; @@ -533,12 +538,12 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int int framenr = ED_space_clip_get_clip_frame_number(sc); int action = -1, area = 0, corner = -1; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); if (width == 0 || height == 0) return NULL; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); track = tracksbase->first; while (track) { @@ -622,6 +627,8 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int static void *slide_marker_customdata(bContext *C, wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieTrackingTrack *track; int width, height; float co[2]; @@ -629,12 +636,12 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) int framenr = ED_space_clip_get_clip_frame_number(sc); int area, action, corner; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); if (width == 0 || height == 0) return NULL; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); track = tracking_marker_check_slide(C, event, &area, &action, &corner); if (track) { @@ -700,6 +707,8 @@ static void free_slide_data(SlideMarkerData *data) static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + SlideMarkerData *data = (SlideMarkerData *)op->customdata; float dx, dy, mdelta[2]; @@ -751,7 +760,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) float start[2], end[2]; float scale; - ED_clip_point_stable_pos(C, data->mval[0], data->mval[1], &start[0], &start[1]); + ED_clip_point_stable_pos(sc, ar, data->mval[0], data->mval[1], &start[0], &start[1]); sub_v2_v2(start, data->old_pos); @@ -767,7 +776,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) mval[1] = event->mval[1]; } - ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]); + ED_clip_point_stable_pos(sc, ar, mval[0], mval[1], &end[0], &end[1]); sub_v2_v2(end, data->old_pos); @@ -825,7 +834,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) sub_v2_v2v2(start, data->spos, data->old_pos); - ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]); + ED_clip_point_stable_pos(sc, ar, mval[0], mval[1], &end[0], &end[1]); sub_v2_v2(end, data->old_pos); if (len_v2(start) > 0.0f) { diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 0d933c1dff3..26a596ead07 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -119,7 +119,7 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack * float epsx, epsy; int width, height; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); @@ -281,6 +281,9 @@ static int select_exec(bContext *C, wmOperator *op) static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; int extend = RNA_boolean_get(op->ptr, "extend"); @@ -299,7 +302,7 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); RNA_float_set_array(op->ptr, "location", co); return select_exec(C, op); @@ -333,6 +336,8 @@ void CLIP_OT_select(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; @@ -348,8 +353,8 @@ static int border_select_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - ED_clip_point_stable_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); - ED_clip_point_stable_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); + ED_clip_point_stable_pos(sc, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); + ED_clip_point_stable_pos(sc, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); mode = RNA_int_get(op->ptr, "gesture_mode"); extend = RNA_boolean_get(op->ptr, "extend"); @@ -414,6 +419,8 @@ void CLIP_OT_select_border(wmOperatorType *ot) static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; @@ -435,7 +442,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho float screen_co[2]; /* marker in screen coords */ - ED_clip_point_stable_pos__reverse(C, marker->pos, screen_co); + ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co); if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) @@ -519,6 +526,8 @@ static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], f static int circle_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; @@ -535,13 +544,13 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; - ED_clip_point_stable_pos(C, x, y, &offset[0], &offset[1]); + ED_clip_point_stable_pos(sc, ar, x, y, &offset[0], &offset[1]); /* do selection */ track = tracksbase->first; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 55e22a999bc..1ef319c45e2 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -636,7 +636,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) if (mask) { int width, height; - ED_mask_size(C, &width, &height); + ED_space_image_get_size(sima, &width, &height); ED_mask_draw_region(mask, ar, sima->mask_info.draw_flag, sima->mask_info.draw_type, width, height, diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index ac2f8a7a34c..f90b2cf4deb 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -996,7 +996,12 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (mask) { int width, height; - ED_mask_size(C, &width, &height); + // ED_mask_get_size(C, &width, &height); + + //Scene *scene = CTX_data_scene(C); + width = (scene->r.size * scene->r.xsch) / 100; + height = (scene->r.size * scene->r.ysch) / 100; + ED_mask_draw_region(mask, ar, 0, 0, /* TODO */ width, height, diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4f26f563ac6..a49fa895e99 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -226,16 +226,13 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) project_int_noclip(t->ar, vec, adr); } else if (t->spacetype == SPACE_IMAGE) { -#if 0 if (t->options & CTX_MASK) { float v[2]; - ED_mask_point_pos__reverse(t->context, vec[0], vec[1], &v[0], &v[1]); + ED_mask_point_pos__reverse(t->sa, t->ar, vec[0], vec[1], &v[0], &v[1]); adr[0] = v[0]; adr[1] = v[1]; } - else -#endif - { + else { float aspx, aspy, v[2]; ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 597be0fd33b..02101b9d02d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6230,7 +6230,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) return; } - ED_mask_aspect(C, &asp[0], &asp[1]); + ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]); t->total = (propmode) ? count : countsel; td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mask Editing)"); @@ -6281,7 +6281,7 @@ void flushTransMasking(TransInfo *t) int a; float asp[2], inv[2]; - ED_mask_aspect(t->context, &asp[0], &asp[1]); + ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]); inv[0] = 1.0f / asp[0]; inv[1] = 1.0f / asp[1]; From 61469d2e3e1319c1242f07e604c822c8b310d772 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Jul 2012 22:47:05 +0000 Subject: [PATCH 3/9] code cleanup: remove unneeded 'struct' qualifiers --- source/blender/blenkernel/intern/screen.c | 2 +- .../blender/editors/interface/interface_templates.c | 6 +++--- source/blender/editors/mask/mask_edit.c | 10 +++++----- source/blender/editors/space_clip/clip_editor.c | 12 ++++++------ source/blender/editors/space_console/console_draw.c | 8 ++++---- source/blender/editors/space_file/file_ops.c | 4 ++-- source/blender/editors/space_file/filesel.c | 6 +++--- source/blender/editors/space_image/image_buttons.c | 2 +- source/blender/editors/space_info/info_draw.c | 8 ++++---- source/blender/editors/space_node/space_node.c | 2 +- source/blender/editors/space_view3d/space_view3d.c | 2 +- source/blender/editors/space_view3d/view3d_edit.c | 8 ++++---- source/blender/editors/space_view3d/view3d_fly.c | 2 +- source/blender/editors/transform/transform.c | 8 ++++---- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 4dfa9f7e12e..56fddfdaa2b 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -356,7 +356,7 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) /* note, using this function is generally a last resort, you really want to be * using the context when you can - campbell * -1 for any type */ -struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min) +ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short min) { ScrArea *sa, *big = NULL; int size, maxsize = 0; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 63b201e4cf7..2620fc46e74 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1635,7 +1635,7 @@ static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) } /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ -static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cumap_v) +static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) { CurveMapping *cumap = cumap_v; uiBlock *block; @@ -1696,7 +1696,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) ED_region_tag_redraw(CTX_wm_region(C)); } -static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) +static uiBlock *curvemap_tools_func(bContext *C, ARegion *ar, void *cumap_v) { uiBlock *block; short yco = 0, menuwidth = 10 * UI_UNIT_X; @@ -1718,7 +1718,7 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap return block; } -static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) +static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_v) { uiBlock *block; short yco = 0, menuwidth = 10 * UI_UNIT_X; diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 7b94cb83fe9..9ff959c14c1 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -130,7 +130,7 @@ void ED_mask_mouse_pos(ScrArea *sa, ARegion *ar, wmEvent *event, float co[2]) /* input: x/y - mval space * output: xr/yr - mask point space */ -void ED_mask_point_pos(struct ScrArea *sa, struct ARegion *ar, float x, float y, float *xr, float *yr) +void ED_mask_point_pos(ScrArea *sa, ARegion *ar, float x, float y, float *xr, float *yr) { float co[2]; @@ -217,7 +217,7 @@ void ED_mask_point_pos__reverse(ScrArea *sa, ARegion *ar, float x, float y, floa *yr = co[1]; } -void ED_mask_get_size(struct ScrArea *sa, int *width, int *height) +void ED_mask_get_size(ScrArea *sa, int *width, int *height) { if (sa && sa->spacedata.first) { switch (sa->spacetype) { @@ -255,7 +255,7 @@ void ED_mask_get_size(struct ScrArea *sa, int *width, int *height) } } -void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *zoomy) +void ED_mask_zoom(ScrArea *sa, ARegion *ar, float *zoomx, float *zoomy) { if (sa && sa->spacedata.first) { switch (sa->spacetype) { @@ -289,7 +289,7 @@ void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *z } } -void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *UNUSED(ar), float *aspx, float *aspy) +void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(ar), float *aspx, float *aspy) { if (sa && sa->spacedata.first) { switch (sa->spacetype) { @@ -323,7 +323,7 @@ void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *UNUSED(ar), float *a } } -void ED_mask_pixelspace_factor(struct ScrArea *sa, struct ARegion *ar, float *scalex, float *scaley) +void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *scaley) { if (sa && sa->spacedata.first) { switch (sa->spacetype) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index c04cd864d2e..1cde271e599 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -124,7 +124,7 @@ int ED_space_clip_maskedit_mask_poll(bContext *C) /* ******** common editing functions ******** */ -void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height) +void ED_space_clip_get_size(SpaceClip *sc, int *width, int *height) { if (sc->clip) { BKE_movieclip_get_size(sc->clip, &sc->user, width, height); @@ -134,7 +134,7 @@ void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height) } } -void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]) +void ED_space_clip_get_size_fl(SpaceClip *sc, float size[2]) { int size_i[2]; ED_space_clip_get_size(sc, &size_i[0], &size_i[1]); @@ -142,7 +142,7 @@ void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]) size[1] = size_i[1]; } -void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *ar, float *zoomx, float *zoomy) +void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) { int width, height; @@ -381,7 +381,7 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ } } -void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, float y, float *xr, float *yr) +void ED_clip_point_stable_pos(SpaceClip *sc, ARegion *ar, float x, float y, float *xr, float *yr) { int sx, sy, width, height; float zoomx, zoomy, pos[3], imat[4][4]; @@ -418,7 +418,7 @@ void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, * \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords. * better name here? view_to_track / track_to_view or so? */ -void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, const float co[2], float r_co[2]) +void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2]) { float zoomx, zoomy; float pos[3]; @@ -439,7 +439,7 @@ void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, r_co[1] = (pos[1] * height * zoomy) + (float)sy; } -void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *ar, wmEvent *event, float co[2]) +void ED_clip_mouse_pos(SpaceClip *sc, ARegion *ar, wmEvent *event, float co[2]) { ED_clip_point_stable_pos(sc, ar, event->mval[0], event->mval[1], &co[0], &co[1]); } diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 2897c5d7d67..4c2f0ac73d4 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -191,7 +191,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha } -static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick) +static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick) { ConsoleLine cl_dummy = {NULL}; int ret = 0; @@ -226,19 +226,19 @@ static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegi } -void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar) +void console_textview_main(struct SpaceConsole *sc, ARegion *ar) { int mval[2] = {INT_MAX, INT_MAX}; console_textview_main__internal(sc, ar, 1, mval, NULL, NULL); } -int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar) +int console_textview_height(struct SpaceConsole *sc, ARegion *ar) { int mval[2] = {INT_MAX, INT_MAX}; return console_textview_main__internal(sc, ar, 0, mval, NULL, NULL); } -int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, int mval[2]) +int console_char_pick(struct SpaceConsole *sc, ARegion *ar, int mval[2]) { int pos_pick = 0; void *mouse_pick = NULL; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 6856ce996e7..7630143acd1 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -70,7 +70,7 @@ #define INACTIVATE 2 /* ---------- FILE SELECTION ------------ */ -static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion *ar, const rcti *rect) +static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect) { FileSelection sel; float fxmin, fymin, fxmax, fymax; @@ -1277,7 +1277,7 @@ void FILE_OT_hidedot(struct wmOperatorType *ot) ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ } -struct ARegion *file_buttons_region(struct ScrArea *sa) +ARegion *file_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index ef3e150b034..34f16c11537 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -265,7 +265,7 @@ void ED_fileselect_reset_params(SpaceFile *sfile) sfile->params->title[0] = '\0'; } -int ED_fileselect_layout_numfiles(FileLayout *layout, struct ARegion *ar) +int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar) { int numfiles; @@ -472,7 +472,7 @@ static void column_widths(struct FileList *files, struct FileLayout *layout) } } -void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) +void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) { FileSelectParams *params = ED_fileselect_get_params(sfile); FileLayout *layout = NULL; @@ -559,7 +559,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->dirty = FALSE; } -FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) +FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, ARegion *ar) { if (!sfile->layout) { ED_fileselect_init_layout(sfile, ar); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 0acead3808e..a736cc4cb73 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -258,7 +258,7 @@ void image_preview_event(int event) /* nothing drawn here, we use it to store values */ -static void preview_cb(struct ScrArea *sa, struct uiBlock *block) +static void preview_cb(ScrArea *sa, struct uiBlock *block) { SpaceImage *sima = sa->spacedata.first; rctf dispf; diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 329917a9f7e..35e19bcce38 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -249,7 +249,7 @@ static int report_textview_line_color(struct TextViewContext *tvc, unsigned char #undef USE_INFO_NEWLINE -static int info_textview_main__internal(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick) +static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick) { int ret = 0; @@ -279,7 +279,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, struct ARegion return ret; } -void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int mouse_y) +void *info_text_pick(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, int mouse_y) { void *mouse_pick = NULL; int mval[2]; @@ -292,13 +292,13 @@ void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *re } -int info_textview_height(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports) +int info_textview_height(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports) { int mval[2] = {INT_MAX, INT_MAX}; return info_textview_main__internal(sinfo, ar, reports, 0, mval, NULL, NULL); } -void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports) +void info_textview_main(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports) { int mval[2] = {INT_MAX, INT_MAX}; info_textview_main__internal(sinfo, ar, reports, 1, mval, NULL, NULL); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index ce187c46625..bfc83018dbb 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -263,7 +263,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) } } -static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) +static void node_area_refresh(const struct bContext *C, ScrArea *sa) { /* default now: refresh node is starting preview */ SpaceNode *snode = sa->spacedata.first; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 88d08d937be..1e371cb074d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -984,7 +984,7 @@ static void view3d_props_area_listener(ARegion *ar, wmNotifier *wmn) } /*area (not region) level listener*/ -static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) +static void space_view3d_listener(ScrArea *sa, struct wmNotifier *wmn) { View3D *v3d = sa->spacedata.first; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 6fbe75fb876..440f7344616 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3648,7 +3648,7 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl return 1; } -int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth) +int ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float *depth) { *depth = view_autodist_depth_margin(ar, mval, margin); @@ -3657,7 +3657,7 @@ int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, static int depth_segment_cb(int x, int y, void *userData) { - struct { struct ARegion *ar; int margin; float depth; } *data = userData; + struct { ARegion *ar; int margin; float depth; } *data = userData; int mval[2]; float depth; @@ -3675,10 +3675,10 @@ static int depth_segment_cb(int x, int y, void *userData) } } -int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], +int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth) { - struct { struct ARegion *ar; int margin; float depth; } data = {NULL}; + struct { ARegion *ar; int margin; float depth; } data = {NULL}; int p1[2]; int p2[2]; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 15e32ea2de4..3efd7c252fe 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -219,7 +219,7 @@ typedef struct FlyInfo { } FlyInfo; -static void drawFlyPixel(const struct bContext *UNUSED(C), struct ARegion *UNUSED(ar), void *arg) +static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) { FlyInfo *fly = arg; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index a49fa895e99..f7fbc7002a2 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -94,7 +94,7 @@ #include -static void drawTransformApply(const struct bContext *C, struct ARegion *ar, void *arg); +static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg); static int doEdgeSlide(TransInfo *t, float perc); /* ************************** SPACE DEPENDANT CODE **************************** */ @@ -1497,7 +1497,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) } } -static void drawTransformView(const struct bContext *C, struct ARegion *UNUSED(ar), void *arg) +static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), void *arg) { TransInfo *t = arg; @@ -1508,7 +1508,7 @@ static void drawTransformView(const struct bContext *C, struct ARegion *UNUSED(a } #if 0 -static void drawTransformPixel(const struct bContext *UNUSED(C), struct ARegion *UNUSED(ar), void *UNUSED(arg)) +static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *UNUSED(arg)) { // TransInfo *t = arg; // @@ -1949,7 +1949,7 @@ void transformApply(bContext *C, TransInfo *t) t->context = NULL; } -static void drawTransformApply(const bContext *C, struct ARegion *UNUSED(ar), void *arg) +static void drawTransformApply(const bContext *C, ARegion *UNUSED(ar), void *arg) { TransInfo *t = arg; From c42b23030b8d25805214dacac78d8d22818db2a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 27 Jul 2012 08:18:11 +0000 Subject: [PATCH 4/9] copy support for mask datablocks --- source/blender/blenkernel/BKE_mask.h | 2 + source/blender/blenkernel/intern/library.c | 2 + source/blender/blenkernel/intern/mask.c | 43 ++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 98cab2e4062..76b6d25ceed 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -122,6 +122,8 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, const short /* general */ struct Mask *BKE_mask_new(const char *name); +struct Mask *BKE_mask_copy_nolib(struct Mask *mask); +struct Mask *BKE_mask_copy(struct Mask *mask); void BKE_mask_free(struct Mask *mask); void BKE_mask_unlink(struct Main *bmain, struct Mask *mask); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f3ef01425dd..98133b936d5 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -360,6 +360,8 @@ int id_copy(ID *id, ID **newid, int test) return 0; /* can't be copied from here */ case ID_GD: return 0; /* not implemented */ + case ID_MSK: + if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id); } return 0; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index d963d46569a..801c431265a 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1330,6 +1330,49 @@ Mask *BKE_mask_new(const char *name) return mask; } +Mask *BKE_mask_copy_nolib(Mask *mask) +{ + Mask *mask_new; + + mask_new = MEM_dupallocN(mask); + + /*take care here! - we may want to copy anim data */ + mask_new->adt = NULL; + + mask_new->masklayers.first = NULL; + mask_new->masklayers.last = NULL; + + BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers); + + /* enable fake user by default */ + if (!(mask_new->id.flag & LIB_FAKEUSER)) { + mask_new->id.flag |= LIB_FAKEUSER; + mask_new->id.us++; + } + + return mask_new; +} + +Mask *BKE_mask_copy(Mask *mask) +{ + Mask *mask_new; + + mask_new = BKE_libblock_copy(&mask->id); + + mask_new->masklayers.first = NULL; + mask_new->masklayers.last = NULL; + + BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers); + + /* enable fake user by default */ + if (!(mask_new->id.flag & LIB_FAKEUSER)) { + mask_new->id.flag |= LIB_FAKEUSER; + mask_new->id.us++; + } + + return mask_new; +} + void BKE_mask_point_free(MaskSplinePoint *point) { if (point->uw) From 1543a713a855f15786ac896aa47c23f2092a4438 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 27 Jul 2012 08:36:48 +0000 Subject: [PATCH 5/9] copying a mask now copies its animation data too --- source/blender/blenkernel/intern/mask.c | 44 ++++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 801c431265a..a2a63f67a62 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -188,28 +188,48 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay) BLI_uniquename(&mask->masklayers, masklay, "MaskLayer", '.', offsetof(MaskLayer, name), sizeof(masklay->name)); } -MaskLayer *BKE_mask_layer_copy(MaskLayer *layer) +MaskLayer *BKE_mask_layer_copy(MaskLayer *masklay) { - MaskLayer *layer_new; + MaskLayer *masklay_new; MaskSpline *spline; - layer_new = MEM_callocN(sizeof(MaskLayer), "new mask layer"); + masklay_new = MEM_callocN(sizeof(MaskLayer), "new mask layer"); - BLI_strncpy(layer_new->name, layer->name, sizeof(layer_new->name)); + BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name)); - layer_new->alpha = layer->alpha; - layer_new->blend = layer->blend; - layer_new->blend_flag = layer->blend_flag; - layer_new->flag = layer->flag; - layer_new->restrictflag = layer->restrictflag; + masklay_new->alpha = masklay->alpha; + masklay_new->blend = masklay->blend; + masklay_new->blend_flag = masklay->blend_flag; + masklay_new->flag = masklay->flag; + masklay_new->restrictflag = masklay->restrictflag; - for (spline = layer->splines.first; spline; spline = spline->next) { + for (spline = masklay->splines.first; spline; spline = spline->next) { MaskSpline *spline_new = BKE_mask_spline_copy(spline); - BLI_addtail(&layer_new->splines, spline_new); + BLI_addtail(&masklay_new->splines, spline_new); } - return layer_new; + /* correct animation */ + if (masklay->splines_shapes.first) { + MaskLayerShape *masklay_shape; + MaskLayerShape *masklay_shape_new; + + for (masklay_shape = masklay->splines_shapes.first; + masklay_shape; + masklay_shape = masklay_shape->next) + { + masklay_shape_new = MEM_callocN(sizeof(MaskLayerShape), "new mask layer shape"); + + masklay_shape_new->data = MEM_dupallocN(masklay_shape->data); + masklay_shape_new->tot_vert = masklay_shape->tot_vert; + masklay_shape_new->flag = masklay_shape->flag; + masklay_shape_new->frame = masklay_shape->frame; + + BLI_addtail(&masklay_new->splines_shapes, masklay_shape_new); + } + } + + return masklay_new; } void BKE_mask_layer_copy_list(ListBase *masklayers_new, ListBase *masklayers) From 93c29aaeb1b0021bac6cb09da1f0cfc7ca90809e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Jul 2012 08:58:34 +0000 Subject: [PATCH 6/9] Fix #32187: OpenGL preview does not take into account overwrite option --- source/blender/editors/render/render_opengl.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 538b4b3884a..12f1e09f5be 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -476,6 +476,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) int ok = 0; const short view_context = (oglrender->v3d != NULL); Object *camera = NULL; + int is_movie; /* go to next frame */ if (CFRA < oglrender->nfra) @@ -490,6 +491,21 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) CFRA++; } + is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype); + + if (!is_movie) { + BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); + + if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) { + printf("skipping existing frame \"%s\"\n", name); + + /* go to next frame */ + oglrender->nfra += scene->r.frame_step; + + return 1; + } + } + /* update animated image textures for gpu, etc, * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ ED_image_update_frame(bmain, CFRA); @@ -538,7 +554,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) ibuf = ibuf_cpy; } - if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (is_movie) { ok = oglrender->mh->append_movie(&scene->r, SFRA, CFRA, (int *)ibuf->rect, oglrender->sizex, oglrender->sizey, oglrender->reports); if (ok) { @@ -547,7 +563,6 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } } else { - BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format); if (ok == 0) { From b10a35a9a9128531347e60be530631b39386dcb2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 27 Jul 2012 09:32:47 +0000 Subject: [PATCH 7/9] motion blur for mask node: TODO - add shutter speed option - add blur option --- .../blender/compositor/nodes/COM_MaskNode.cpp | 4 + .../operations/COM_MaskOperation.cpp | 88 ++++++++++++++++--- .../compositor/operations/COM_MaskOperation.h | 4 +- source/blender/editors/space_node/drawnode.c | 16 ++-- source/blender/makesdna/DNA_node_types.h | 5 +- source/blender/makesrna/intern/rna_nodetree.c | 11 +++ 6 files changed, 106 insertions(+), 22 deletions(-) diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index 2620f84cfae..71a7191a35e 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -69,5 +69,9 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0); operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); + if (editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) { + operation->setMotionBlurSamples(editorNode->custom2); + } + graph->addOperation(operation); } diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 5e68142bda3..a4e548d47ac 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -137,28 +137,74 @@ MaskOperation::MaskOperation() : NodeOperation() this->m_mask = NULL; this->m_maskWidth = 0; this->m_maskHeight = 0; + this->m_maskWidthInv = 0.0f; + this->m_maskHeightInv = 0.0f; this->m_framenumber = 0; - this->m_rasterMaskHandle = NULL; + this->m_rasterMaskHandleTot = 1; + memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles)); } void MaskOperation::initExecution() { - if (this->m_mask) { - if (this->m_rasterMaskHandle == NULL) { - this->m_rasterMaskHandle = BKE_maskrasterize_handle_new(); + if (this->m_mask && this->m_rasterMaskHandles[0] == NULL) { + if (this->m_rasterMaskHandleTot == 1) { + this->m_rasterMaskHandles[0] = BKE_maskrasterize_handle_new(); - BKE_maskrasterize_handle_init(this->m_rasterMaskHandle, this->m_mask, - this->m_maskWidth, this->m_maskHeight, - TRUE, this->m_do_smooth, this->m_do_feather); + BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[0], this->m_mask, + this->m_maskWidth, this->m_maskHeight, + TRUE, this->m_do_smooth, this->m_do_feather); + } + else { + /* make a throw away copy of the mask */ + const float frame_range = 1.0f; /* should be 1 max, could be configurable */ + const float frame = (float)this->m_framenumber - frame_range; + const float frame_step = (frame_range * 2.0f) / this->m_rasterMaskHandleTot; + float frame_iter = frame; + + Mask *mask_temp; + + mask_temp = BKE_mask_copy_nolib(this->m_mask); + + /* trick so we can get unkeyed edits to display */ + { + MaskLayer *masklay; + MaskLayerShape *masklay_shape; + + for (masklay = (MaskLayer *)mask_temp->masklayers.first; + masklay; + masklay = (MaskLayer *)masklay->next) + { + masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_framenumber); + BKE_mask_layer_shape_from_mask(masklay, masklay_shape); + } + } + + for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) { + this->m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new(); + + /* re-eval frame info */ + BKE_mask_evaluate(mask_temp, frame_iter, TRUE); + + BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[i], mask_temp, + this->m_maskWidth, this->m_maskHeight, + TRUE, this->m_do_smooth, this->m_do_feather); + + frame_iter += frame_step; + } + + BKE_mask_free(mask_temp); + MEM_freeN(mask_temp); } } } void MaskOperation::deinitExecution() { - if (this->m_rasterMaskHandle) { - BKE_maskrasterize_handle_free(this->m_rasterMaskHandle); - this->m_rasterMaskHandle = NULL; + for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) { + if (this->m_rasterMaskHandles[i]) { + BKE_maskrasterize_handle_free(this->m_rasterMaskHandles[i]); + this->m_rasterMaskHandles[i] = NULL; + } } } @@ -182,12 +228,28 @@ void MaskOperation::determineResolution(unsigned int resolution[], unsigned int void MaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler) { - if (this->m_rasterMaskHandle) { - const float xy[2] = {x * this->m_maskWidthInv, y * this->m_maskHeightInv}; - color[0] = BKE_maskrasterize_handle_sample(this->m_rasterMaskHandle, xy); + const float xy[2] = {x * this->m_maskWidthInv, y * this->m_maskHeightInv}; + + if (this->m_rasterMaskHandleTot == 1) { + if (this->m_rasterMaskHandles[0]) { + color[0] = BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[0], xy); + } + else { + color[0] = 0.0f; + } } else { + /* incase loop below fails */ color[0] = 0.0f; + + for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) { + if (this->m_rasterMaskHandles[i]) { + color[0] += BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[i], xy); + } + } + + /* until we get better falloff */ + color[0] /= this->m_rasterMaskHandleTot; } } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 59c84bdbb7b..a8c23b3bca1 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -64,7 +64,8 @@ protected: ListBase m_maskLayers; #else /* USE_RASKTER */ - struct MaskRasterHandle *m_rasterMaskHandle; + struct MaskRasterHandle *m_rasterMaskHandles[32]; + unsigned int m_rasterMaskHandleTot; #endif /* USE_RASKTER */ /** @@ -93,6 +94,7 @@ public: void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } void setSmooth(bool smooth) { this->m_do_smooth = smooth; } void setFeather(bool feather) { this->m_do_feather = feather; } + void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = max(1, samples); } #ifdef USE_RASKTER void *initializeTileData(rcti *rect); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 7e6e9b6bd4e..b7a51adc543 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2490,18 +2490,22 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr) { + bNode *node = ptr->data; + uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL); uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE); - { - bNode *node = ptr->data; - if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) { - uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE); - } + if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) { + uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE); + } + + uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE); + if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) { + uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE); } } diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index b06c9465c25..8d36b428aca 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -375,8 +375,9 @@ enum { }; enum { - CMP_NODEFLAG_MASK_AA = (1 << 0), - CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1), + CMP_NODEFLAG_MASK_AA = (1 << 0), + CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1), + CMP_NODEFLAG_MASK_MOTION_BLUR = (1 << 2), /* we may want multiple aspect options, exposed as an rna enum */ CMP_NODEFLAG_MASK_FIXED = (1 << 8), diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index fbb61ea23e5..da30b109efd 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3184,6 +3184,17 @@ static void def_cmp_mask(StructRNA *srna) RNA_def_property_ui_text(prop, "Feather", "Use feather information from the mask"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_MOTION_BLUR); + RNA_def_property_ui_text(prop, "Motion Blur", "Use feather information from the mask"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "custom2"); + RNA_def_property_range(prop, 1, 32); + RNA_def_property_ui_text(prop, "Samples", "Number of motion blur samples"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "size_source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, aspect_type_items); From 52aa7a4a4c07f915b634a56162c9093ef1fecb09 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Jul 2012 10:12:58 +0000 Subject: [PATCH 8/9] Added utility function to return marker's subframe position Used in mask parenting stuff. --- source/blender/blenkernel/BKE_tracking.h | 2 ++ source/blender/blenkernel/intern/mask.c | 3 +- source/blender/blenkernel/intern/tracking.c | 32 ++++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 2b30c845754..ea6034bd91b 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -110,6 +110,8 @@ struct MovieTrackingMarker *BKE_tracking_marker_ensure(struct MovieTrackingTrack void BKE_tracking_marker_pattern_minmax(const struct MovieTrackingMarker *marker, float min[2], float max[2]); +void BKE_tracking_marker_get_subframe_position(struct MovieTrackingTrack *track, float framenr, float pos[2]); + /* **** Object **** */ struct MovieTrackingObject *BKE_tracking_object_add(struct MovieTracking *tracking, const char *name); void BKE_tracking_object_delete(struct MovieTracking *tracking, struct MovieTrackingObject *object); diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index a2a63f67a62..3c008692cbb 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1635,9 +1635,8 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[ user.framenr = ctime; if (track) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr); float marker_pos_ofs[2]; - add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); + BKE_tracking_marker_get_subframe_position(track, clip_framenr, marker_pos_ofs); BKE_mask_coord_from_movieclip(clip, &user, r_co, marker_pos_ofs); return TRUE; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 35a688849e8..3c00397dfa5 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -916,7 +916,7 @@ void BKE_tracking_track_deselect(MovieTrackingTrack *track, int area) BKE_tracking_track_flag_clear(track, area, SELECT); } -/*********************** Marker *************************/ +/*********************** Marker *************************/ MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track, MovieTrackingMarker *marker) { @@ -1133,6 +1133,36 @@ void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float DO_MINMAX2(marker->pattern_corners[3], min, max); } +void BKE_tracking_marker_get_subframe_position(MovieTrackingTrack *track, float framenr, float pos[2]) +{ + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, (int) framenr); + MovieTrackingMarker *marker_last = track->markers + (track->markersnr - 1); + + if (marker != marker_last) { + MovieTrackingMarker *marker_next = marker + 1; + + if (marker_next->framenr == marker->framenr + 1) { + /* currently only do subframing inside tracked ranges, do not extrapolate tracked segments + * could be changed when / if mask parent would be interpolating position in-between + * tracked segments + */ + + float fac = (framenr - (int) framenr) / (marker_next->framenr - marker->framenr); + + interp_v2_v2v2(pos, marker->pos, marker_next->pos, fac); + } + else { + copy_v2_v2(pos, marker->pos); + } + } + else { + copy_v2_v2(pos, marker->pos); + } + + /* currently track offset is always wanted to be applied here, could be made an option later */ + add_v2_v2(pos, track->offset); +} + /*********************** Object *************************/ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char *name) From b8d96bc011d255fa06c1327999c199c417c89225 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 27 Jul 2012 10:20:36 +0000 Subject: [PATCH 9/9] mask motion blur shutter option --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenloader/intern/readfile.c | 25 +++++++++++++++++++ .../blender/compositor/nodes/COM_MaskNode.cpp | 21 ++++++++++------ .../operations/COM_MaskOperation.cpp | 10 ++++---- .../compositor/operations/COM_MaskOperation.h | 8 ++++-- source/blender/editors/space_node/drawnode.c | 1 + source/blender/makesdna/DNA_node_types.h | 4 +++ source/blender/makesrna/intern/rna_nodetree.c | 12 +++++++-- .../composite/nodes/node_composite_mask.c | 13 ++++++++++ 9 files changed, 78 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index c4f5100d649..0c09c24e709 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 16 +#define BLENDER_SUBVERSION 17 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 68252fd7e25..a0529271666 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7027,6 +7027,24 @@ static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id), } } +static void do_version_ntree_mask_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_MASK) { + if (node->storage == NULL) { + NodeMask *data = MEM_callocN(sizeof(NodeMask), __func__); + /* move settings into own struct */ + data->size_x = node->custom3; + data->size_y = node->custom4; + node->custom3 = 0.5f; /* default shutter */ + node->storage = data; + } + } + } +} + static void do_version_ntree_keying_despill_balance(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) { bNode *node; @@ -7863,6 +7881,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ntreetype->foreach_nodetree(main, NULL, do_version_ntree_keying_despill_balance); } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 17)) { + bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT); + + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_ntree_mask_264); + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index 71a7191a35e..8d549d09362 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -36,11 +36,12 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode) void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - const RenderData *data = context->getRenderData(); + const RenderData *rd = context->getRenderData(); OutputSocket *outputMask = this->getOutputSocket(0); bNode *editorNode = this->getbNode(); + NodeMask *data = (NodeMask *)editorNode->storage; Mask *mask = (Mask *)editorNode->id; // always connect the output image @@ -48,16 +49,16 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setbNode(editorNode); if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) { - operation->setMaskWidth(editorNode->custom3); - operation->setMaskHeight(editorNode->custom4); + operation->setMaskWidth(data->size_x); + operation->setMaskHeight(data->size_y); } else if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) { - operation->setMaskWidth(editorNode->custom3 * (data->size / 100.0f)); - operation->setMaskHeight(editorNode->custom4 * (data->size / 100.0f)); + operation->setMaskWidth(data->size_x * (rd->size / 100.0f)); + operation->setMaskHeight(data->size_y * (rd->size / 100.0f)); } else { - operation->setMaskWidth(data->xsch * data->size / 100.0f); - operation->setMaskHeight(data->ysch * data->size / 100.0f); + operation->setMaskWidth(rd->xsch * rd->size / 100.0f); + operation->setMaskHeight(rd->ysch * rd->size / 100.0f); } if (outputMask->isConnected()) { @@ -69,8 +70,12 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0); operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); - if (editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) { + if ((editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && + (editorNode->custom2 > 1) && + (editorNode->custom3 > FLT_EPSILON)) + { operation->setMotionBlurSamples(editorNode->custom2); + operation->setMotionBlurShutter(editorNode->custom3); } graph->addOperation(operation); diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index a4e548d47ac..a3326de0a30 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -139,7 +139,8 @@ MaskOperation::MaskOperation() : NodeOperation() this->m_maskHeight = 0; this->m_maskWidthInv = 0.0f; this->m_maskHeightInv = 0.0f; - this->m_framenumber = 0; + this->m_frame_shutter = 0.0f; + this->m_frame_number = 0; this->m_rasterMaskHandleTot = 1; memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles)); } @@ -156,9 +157,8 @@ void MaskOperation::initExecution() } else { /* make a throw away copy of the mask */ - const float frame_range = 1.0f; /* should be 1 max, could be configurable */ - const float frame = (float)this->m_framenumber - frame_range; - const float frame_step = (frame_range * 2.0f) / this->m_rasterMaskHandleTot; + const float frame = (float)this->m_frame_number - this->m_frame_shutter; + const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot; float frame_iter = frame; Mask *mask_temp; @@ -174,7 +174,7 @@ void MaskOperation::initExecution() masklay; masklay = (MaskLayer *)masklay->next) { - masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_framenumber); + masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_frame_number); BKE_mask_layer_shape_from_mask(masklay, masklay_shape); } } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index a8c23b3bca1..77d8e1148c2 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -54,7 +54,9 @@ protected: float m_maskWidthInv; /* 1 / m_maskWidth */ float m_maskHeightInv; /* 1 / m_maskHeight */ - int m_framenumber; + float m_frame_shutter; + int m_frame_number; + bool m_do_smooth; bool m_do_feather; @@ -91,10 +93,12 @@ public: this->m_maskHeight = height; this->m_maskHeightInv = 1.0f / (float)height; } - void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } + void setFramenumber(int frame_number) { this->m_frame_number = frame_number; } void setSmooth(bool smooth) { this->m_do_smooth = smooth; } void setFeather(bool feather) { this->m_do_feather = feather; } + void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = max(1, samples); } + void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; } #ifdef USE_RASKTER void *initializeTileData(rcti *rect); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index b7a51adc543..b3ae8d3e939 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2506,6 +2506,7 @@ static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *p uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE); if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) { uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE); } } diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 8d36b428aca..5b8445465a2 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -589,6 +589,10 @@ typedef struct NodeDilateErode { char pad[7]; } NodeDilateErode; +typedef struct NodeMask { + int size_x, size_y; +} NodeMask; + typedef struct NodeTexBase { TexMapping tex_mapping; ColorMapping color_mapping; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index da30b109efd..4f259e80f25 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3195,20 +3195,28 @@ static void def_cmp_mask(StructRNA *srna) RNA_def_property_ui_text(prop, "Samples", "Number of motion blur samples"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "custom3"); + RNA_def_property_range(prop, 0.0, 1.0f); + RNA_def_property_ui_text(prop, "Shutter", "Exposure for motion blur as a factor of FPS"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "size_source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, aspect_type_items); RNA_def_property_ui_text(prop, "Size Source", "Where to get the mask size from for aspect/size information"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "NodeMask", "storage"); + prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs(prop, "rna_Node_custom3_get_as_int", "rna_Node_custom3_set_as_int", NULL); RNA_def_property_range(prop, 1.0f, 10000.0f); RNA_def_property_ui_text(prop, "X", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "size_y", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs(prop, "rna_Node_custom4_get_as_int", "rna_Node_custom4_set_as_int", NULL); RNA_def_property_range(prop, 1.0f, 10000.0f); RNA_def_property_ui_text(prop, "Y", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index 3cd3a732829..5df8bdc0a85 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -82,6 +82,16 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** } } +static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +{ + NodeMask *data = MEM_callocN(sizeof(NodeMask), STRINGIFY(NodeMask)); + data->size_x = data->size_y = 256; + node->storage = data; + + node->custom2 = 16; /* samples */ + node->custom3 = 0.5f; /* shutter */ +} + void register_node_type_cmp_mask(bNodeTreeType *ttype) { static bNodeType ntype; @@ -89,7 +99,10 @@ void register_node_type_cmp_mask(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_MASK, "Mask", NODE_CLASS_INPUT, NODE_OPTIONS); node_type_socket_templates(&ntype, NULL, cmp_node_mask_out); node_type_size(&ntype, 140, 100, 320); + node_type_init(&ntype, node_composit_init_mask); node_type_exec(&ntype, exec); + node_type_storage(&ntype, "NodeMask", node_free_standard_storage, node_copy_standard_storage); + nodeRegisterType(ttype, &ntype); }