diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-25 20:03:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-25 20:03:08 +0400 |
commit | f83ea3fa85ed79f85bdf5eda9a35b886a2d9159c (patch) | |
tree | 8f63706475def55835de77da94f45a3afc4ed6de /source | |
parent | c730125f3edeaab0276ae4c2d4ed2a5c5fbc72eb (diff) |
fix some crashes with mask/image transfor, a few more areas working now.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mask/mask_edit.c | 19 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 19 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 58 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 21 |
4 files changed, 86 insertions, 31 deletions
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 197e433eff4..ca5de41c392 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -48,6 +48,8 @@ #include "ED_sequencer.h" #include "ED_transform.h" +#include "UI_view2d.h" + #include "RNA_access.h" #include "mask_intern.h" /* own include */ @@ -101,11 +103,17 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) break; } case SPACE_SEQ: - zero_v2(co); /* MASKTODO */ + { + ARegion *ar = CTX_wm_region(C); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); break; + } case SPACE_IMAGE: - zero_v2(co); /* MASKTODO */ + { + ARegion *ar = CTX_wm_region(C); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); break; + } default: /* possible other spaces from which mask editing is available */ BLI_assert(0); @@ -139,8 +147,11 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr zero_v2(co); /* MASKTODO */ break; case SPACE_IMAGE: + { + //SpaceImage *sima = sa->spacedata.first; zero_v2(co); /* MASKTODO */ break; + } default: /* possible other spaces from which mask editing is available */ BLI_assert(0); @@ -251,8 +262,8 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) } case SPACE_IMAGE: { - // SpaceImage *sima = sa->spacedata.first; - *aspx = *aspy = 1.0f; /* MASKTODO - image aspect? */ + SpaceImage *sima = sa->spacedata.first; + ED_space_image_uv_aspect(sima, aspx, aspy); break; } default: diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 6aee12c4b41..b2bb33f19ea 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -145,6 +145,8 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) convertViewVec2D(t->view, r_vec, dx, dy); + /* MASKTODO - see clip clamp w/h */ + ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); r_vec[0] *= aspx; r_vec[1] *= aspy; @@ -406,10 +408,17 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL); } else if (t->spacetype == SPACE_IMAGE) { - // XXX how to deal with lock? - SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; - if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data); - else ED_area_tag_redraw(t->sa); + if (t->options & CTX_MASK) { + Mask *mask = CTX_data_edit_mask(C); + + WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); + } + else { + // XXX how to deal with lock? + SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; + if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data); + else ED_area_tag_redraw(t->sa); + } } else if (t->spacetype == SPACE_CLIP) { SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first; @@ -423,7 +432,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); } else if (ED_space_clip_check_show_maskedit(sc)) { - Mask *mask = ED_space_clip_get_mask(sc); + Mask *mask = CTX_data_edit_mask(C); WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 949266a0cc2..8ab6e5e68ce 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5009,7 +5009,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } } } - + + if (t->spacetype == SPACE_SEQ) { /* freeSeqData in transform_conversions.c does this * keep here so the else at the end wont run... */ @@ -5030,7 +5031,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ED_markers_post_apply_transform(&t->scene->markers, t->scene, TFM_TIME_EXTEND, t->values[0], t->frame_side); } } - + } + else if (t->spacetype == SPACE_IMAGE) { + /* prevent this passing through to final 'else' which assumes objects */ } else if (t->spacetype == SPACE_NODE) { SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; @@ -5356,6 +5359,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else { /* Objects */ int i, recalcObPaths = 0; + BLI_assert(t->flag & T_OBJECT); + for (i = 0; i < t->total; i++) { TransData *td = t->data + i; ListBase pidlist; @@ -6069,19 +6074,17 @@ typedef struct TransDataMasking { MaskSplinePoint *point; } TransDataMasking; -static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, - TransData *td, TransData2D *td2d, TransDataMasking *tdm, int propmode) +static void MaskPointToTransData(MaskSplinePoint *point, + TransData *td, TransData2D *td2d, TransDataMasking *tdm, + const int propmode, const float asp[2]) { BezTriple *bezt = &point->bezt; - float aspx, aspy; short is_sel_point = MASKPOINT_ISSEL_KNOT(point); short is_sel_any = MASKPOINT_ISSEL_ANY(point); tdm->point = point; copy_m3_m3(tdm->vec, bezt->vec); - ED_space_clip_get_aspect(sc, &aspx, &aspy); - if (propmode || is_sel_point) { int i; for (i = 0; i < 3; i++) { @@ -6089,8 +6092,8 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, * proportional editing to be consistent with the stretched CV coords * that are displayed. this also means that for display and numinput, * and when the the CV coords are flushed, these are converted each time */ - td2d->loc[0] = bezt->vec[i][0] * aspx; - td2d->loc[1] = bezt->vec[i][1] * aspy; + td2d->loc[0] = bezt->vec[i][0] * asp[0]; + td2d->loc[1] = bezt->vec[i][1] * asp[1]; td2d->loc[2] = 0.0f; td2d->loc2d = bezt->vec[i]; @@ -6132,8 +6135,8 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, copy_v2_v2(tdm->orig_handle, tdm->handle); - td2d->loc[0] = tdm->handle[0] * aspx; - td2d->loc[1] = tdm->handle[1] * aspy; + td2d->loc[0] = tdm->handle[0] * asp[0]; + td2d->loc[1] = tdm->handle[1] * asp[1]; td2d->loc[2] = 0.0f; td2d->loc2d = tdm->handle; @@ -6164,7 +6167,6 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, static void createTransMaskingData(bContext *C, TransInfo *t) { - SpaceClip *sc = CTX_wm_space_clip(C); Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; TransData *td = NULL; @@ -6172,6 +6174,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) TransDataMasking *tdm = NULL; int count = 0, countsel = 0; int propmode = t->flag & T_PROP_EDIT; + float asp[2]; t->total = 0; @@ -6206,7 +6209,11 @@ static void createTransMaskingData(bContext *C, TransInfo *t) } /* note: in prop mode we need at least 1 selected */ - if (countsel == 0) return; + if (countsel == 0) { + return; + } + + ED_mask_aspect(C, &asp[0], &asp[1]); t->total = (propmode) ? count : countsel; td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mask Editing)"); @@ -6232,7 +6239,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) MaskSplinePoint *point = &spline->points[i]; if (propmode || MASKPOINT_ISSEL_ANY(point)) { - MaskPointToTransData(sc, point, td, td2d, tdm, propmode); + MaskPointToTransData(point, td, td2d, tdm, propmode, asp); if (propmode || MASKPOINT_ISSEL_KNOT(point)) { td += 3; @@ -6297,11 +6304,23 @@ void createTransData(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_IMAGE) { t->flag |= T_POINTS | T_2D_EDIT; - createTransUVs(C, t); - if (t->data && (t->flag & T_PROP_EDIT)) { - sort_trans_data(t); // makes selected become first in array - set_prop_dist(t, 1); - sort_trans_data_dist(t); + if (t->options & CTX_MASK) { + /* copied from below */ + createTransMaskingData(C, t); + + if (t->data && (t->flag & T_PROP_EDIT)) { + sort_trans_data(t); // makes selected become first in array + set_prop_dist(t, TRUE); + sort_trans_data_dist(t); + } + } + else { + createTransUVs(C, t); + if (t->data && (t->flag & T_PROP_EDIT)) { + sort_trans_data(t); // makes selected become first in array + set_prop_dist(t, 1); + sort_trans_data_dist(t); + } } } else if (t->spacetype == SPACE_ACTION) { @@ -6342,6 +6361,7 @@ void createTransData(bContext *C, TransInfo *t) if (t->options & CTX_MOVIECLIP) createTransTrackingData(C, t); else if (t->options & CTX_MASK) { + /* copied from above */ createTransMaskingData(C, t); if (t->data && (t->flag & T_PROP_EDIT)) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index dba597d316d..a250c763dd1 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1099,6 +1099,16 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) // XXX for now, get View2D from the active region t->view = &ar->v2d; t->around = sima->around; + + if (t->obedit) { + /* UV transform */ + } + else if (sima->mode == SI_MODE_MASK) { + t->options |= CTX_MASK; + } + else { + BLI_assert(0); + } } else if (t->spacetype == SPACE_NODE) { // XXX for now, get View2D from the active region @@ -1280,9 +1290,14 @@ void postTrans(bContext *C, TransInfo *t) } if (t->spacetype == SPACE_IMAGE) { - SpaceImage *sima = t->sa->spacedata.first; - if (sima->flag & SI_LIVE_UNWRAP) - ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL); + if (t->options & CTX_MASK) { + /* pass */ + } + else { + SpaceImage *sima = t->sa->spacedata.first; + if (sima->flag & SI_LIVE_UNWRAP) + ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL); + } } else if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = t->sa->spacedata.first; |