From a8a22d968c637a877210fc756e74731d9403f455 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 18 May 2012 09:36:32 +0000 Subject: [PATCH] mask: remove aspect arguments which are no longer needed. --- source/blender/blenkernel/BKE_mask.h | 11 ++--- source/blender/blenkernel/intern/mask.c | 48 +++++++------------ source/blender/editors/include/ED_mask.h | 2 +- source/blender/editors/mask/mask_draw.c | 43 +++++------------ source/blender/editors/mask/mask_ops.c | 24 +++++----- .../blender/editors/space_clip/space_clip.c | 2 +- .../editors/transform/transform_conversions.c | 2 +- source/blender/makesdna/DNA_mask_types.h | 12 ++--- 8 files changed, 55 insertions(+), 89 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 1c64e00630c..88934e4af84 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -54,21 +54,20 @@ void BKE_mask_shape_unique_name(struct Mask *mask, struct MaskShape *shape); struct MaskSpline *BKE_mask_spline_add(struct MaskShape *shape); int BKE_mask_spline_resolution(struct MaskSpline *spline); float *BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point); -float *BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, float aspx, - float aspy, int *tot_feather_point); -float *BKE_mask_spline_feather_points(struct MaskSpline *spline, float aspx, float aspy, int *tot_feather_point); +float *BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point); +float *BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point); /* point */ int BKE_mask_point_has_handle(struct MaskSplinePoint *point); -void BKE_mask_point_handle(struct MaskSplinePoint *point, float aspx, float aspy, float handle[2]); +void BKE_mask_point_handle(struct MaskSplinePoint *point, float handle[2]); void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], int keep_direction, float aspx, float aspy, float orig_handle[2], float orig_vec[3][3]); float *BKE_mask_point_segment_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, int *tot_diff_point); float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct MaskSplinePoint *point, - float aspx, float aspy, int *tot_feather_point); + int *tot_feather_point); void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]); void BKE_mask_point_normal(struct MaskSpline *spline, struct MaskSplinePoint *point, - float aspx, float aspy, float u, float n[2]); + float u, float n[2]); float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, float u); struct MaskSplinePointUW *BKE_mask_point_sort_uw(struct MaskSplinePoint *point, struct MaskSplinePointUW *uw); void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w); diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index ae8a6fa737c..863945e6baf 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -257,8 +257,7 @@ float *BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point) return diff_points; } -float *BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, float aspx, float aspy, - int *tot_feather_point) +float *BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point) { float *feather, *fp; int i, j, tot, resol = BKE_mask_spline_feather_resolution(spline); @@ -274,7 +273,7 @@ float *BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, float a float co[2], n[2]; BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, aspx, aspy, u, n); + BKE_mask_point_normal(spline, point, u, n); weight = BKE_mask_point_weight(spline, point, u); fp[0] = co[0] + n[0] * weight; @@ -287,7 +286,7 @@ float *BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, float a return feather; } -float *BKE_mask_spline_feather_points(MaskSpline *spline, float aspx, float aspy, int *tot_feather_point) +float *BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point) { int i, tot = 0; float *feather, *fp; @@ -308,7 +307,7 @@ float *BKE_mask_spline_feather_points(MaskSpline *spline, float aspx, float aspy float weight, n[2]; int j; - BKE_mask_point_normal(spline, point, aspx, aspy, 0.0f, n); + BKE_mask_point_normal(spline, point, 0.0f, n); weight = BKE_mask_point_weight(spline, point, 0.0f); fp[0] = bezt->vec[1][0] + n[0] * weight; @@ -320,7 +319,7 @@ float *BKE_mask_spline_feather_points(MaskSpline *spline, float aspx, float aspy float co[2]; BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, aspx, aspy, u, n); + BKE_mask_point_normal(spline, point, u, n); weight = BKE_mask_point_weight(spline, point, u); fp[0] = co[0] + n[0] * weight; @@ -344,17 +343,14 @@ int BKE_mask_point_has_handle(MaskSplinePoint *point) return bezt->h1 == HD_ALIGN; } -void BKE_mask_point_handle(MaskSplinePoint *point, float aspx, float aspy, float handle[2]) +void BKE_mask_point_handle(MaskSplinePoint *point, float handle[2]) { float vec[2]; sub_v2_v2v2(vec, point->bezt.vec[0], point->bezt.vec[1]); - vec[0] *= aspx; - vec[1] *= aspy; - - handle[0] = (point->bezt.vec[1][0] * aspx + vec[1]) / aspx; - handle[1] = (point->bezt.vec[1][1] * aspy - vec[0]) / aspy; + handle[0] = (point->bezt.vec[1][0] + vec[1]); + handle[1] = (point->bezt.vec[1][1] - vec[0]); } void BKE_mask_point_set_handle(MaskSplinePoint *point, float loc[2], int keep_direction, float aspx, float aspy, @@ -406,8 +402,7 @@ void BKE_mask_point_set_handle(MaskSplinePoint *point, float loc[2], int keep_di } } -float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint *point, float aspx, float aspy, - int *tot_feather_point) +float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint *point, int *tot_feather_point) { float *feather, *fp; int i, resol = BKE_mask_spline_feather_resolution(spline); @@ -419,7 +414,7 @@ float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint * float co[2], n[2]; BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, aspx, aspy, u, n); + BKE_mask_point_normal(spline, point, u, n); weight = BKE_mask_point_weight(spline, point, u); fp[0] = co[0] + n[0] * weight; @@ -493,7 +488,7 @@ void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float interp_v2_v2v2(co, r0, r1, u); } -void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float aspx, float aspy, float u, float n[2]) +void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u, float n[2]) { BezTriple *bezt = &point->bezt, *next; float q0[2], q1[2], q2[2], r0[2], r1[2], vec[2]; @@ -504,21 +499,15 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float asp else next = NULL; } - else next = &((point + 1))->bezt; + else { + next = &((point + 1))->bezt; + } if (!next) { - BKE_mask_point_handle(point, aspx, aspy, vec); + BKE_mask_point_handle(point, vec); sub_v2_v2v2(n, vec, bezt->vec[1]); - - n[0] *= aspx; - n[1] *= aspy; - normalize_v2(n); - - n[0] /= aspx; - n[1] /= aspy; - return; } @@ -531,13 +520,10 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float asp sub_v2_v2v2(vec, r1, r0); - n[0] = -vec[1] * aspy; - n[1] = vec[0] * aspx; + n[0] = -vec[1]; + n[1] = vec[0]; normalize_v2(n); - - n[0] /= aspx; - n[1] /= aspy; } float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, float u) diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 5df91b4032a..01495561912 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -39,6 +39,6 @@ void ED_keymap_mask(struct wmKeyConfig *keyconf); void ED_operatormacros_mask(void); /* mask_draw.c */ -void ED_mask_draw(bContext *C, int width, int height, float zoomx, float zoomy); +void ED_mask_draw(const bContext *C); #endif /* ED_TEXT_H */ diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index e3fe67df16b..152dc6d03da 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -49,12 +49,6 @@ #include "mask_intern.h" /* own include */ -typedef struct PixelSpaceContext { - int width, height; - float zoomx, zoomy; - float aspx, aspy; -} PixelSpaceContext; - static void set_spline_color(MaskShape *shape, MaskSpline *spline) { if (spline->flag & SELECT) { @@ -69,7 +63,7 @@ static void set_spline_color(MaskShape *shape, MaskSpline *spline) } /* return non-zero if spline is selected */ -static void draw_spline_points(MaskShape *shape, MaskSpline *spline, PixelSpaceContext *pixelspace) +static void draw_spline_points(MaskShape *shape, MaskSpline *spline) { int i, hsize, tot_feather_point; float *feather_points, *fp; @@ -82,7 +76,7 @@ static void draw_spline_points(MaskShape *shape, MaskSpline *spline, PixelSpaceC glPointSize(hsize); /* feather points */ - feather_points = fp = BKE_mask_spline_feather_points(spline, pixelspace->aspx, pixelspace->aspy, &tot_feather_point); + feather_points = fp = BKE_mask_spline_feather_points(spline, &tot_feather_point); for (i = 0; i < spline->tot_point; i++) { int j; MaskSplinePoint *point = &spline->points[i]; @@ -119,12 +113,11 @@ static void draw_spline_points(MaskShape *shape, MaskSpline *spline, PixelSpaceC /* control points */ for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - BezTriple *bezt = &point->bezt; - float vert[2], handle[2]; + float handle[2]; + float *vert = point->bezt.vec[1]; int has_handle = BKE_mask_point_has_handle(point); - copy_v2_v2(vert, bezt->vec[1]); - BKE_mask_point_handle(point, pixelspace->aspx, pixelspace->aspy, handle); + BKE_mask_point_handle(point, handle); /* draw handle segment */ if (has_handle) { @@ -196,7 +189,7 @@ static void draw_dashed_curve(MaskSpline *spline, float *points, int tot_point) glDisable(GL_LINE_STIPPLE); } -static void draw_spline_curve(MaskShape *shape, MaskSpline *spline, PixelSpaceContext *pixelspace) +static void draw_spline_curve(MaskShape *shape, MaskSpline *spline) { float *diff_points, *feather_points; int tot_diff_point, tot_feather_point; @@ -206,8 +199,7 @@ static void draw_spline_curve(MaskShape *shape, MaskSpline *spline, PixelSpaceCo if (!diff_points) return; - feather_points = BKE_mask_spline_feather_differentiated_points(spline, pixelspace->aspx, pixelspace->aspy, - &tot_feather_point); + feather_points = BKE_mask_spline_feather_differentiated_points(spline, &tot_feather_point); /* draw feather */ if (spline->flag & SELECT) @@ -224,7 +216,7 @@ static void draw_spline_curve(MaskShape *shape, MaskSpline *spline, PixelSpaceCo MEM_freeN(feather_points); } -static void draw_shapes(Mask *mask, PixelSpaceContext *pixelspace) +static void draw_shapes(Mask *mask) { MaskShape *shape = mask->shapes.first; @@ -233,10 +225,10 @@ static void draw_shapes(Mask *mask, PixelSpaceContext *pixelspace) while (spline) { /* draw curve itself first... */ - draw_spline_curve(shape, spline, pixelspace); + draw_spline_curve(shape, spline); /* ...and then handles over the curve so they're nicely visible */ - draw_spline_points(shape, spline, pixelspace); + draw_spline_points(shape, spline); spline = spline->next; } @@ -245,23 +237,12 @@ static void draw_shapes(Mask *mask, PixelSpaceContext *pixelspace) } } -void ED_mask_draw(bContext *C, int width, int height, float zoomx, float zoomy) +void ED_mask_draw(const bContext *C) { Mask *mask = CTX_data_edit_mask(C); - PixelSpaceContext pixelspace; - float aspx, aspy; if (!mask) return; - ED_mask_aspect(C, &aspx, &aspy); - - pixelspace.width = width; - pixelspace.height = height; - pixelspace.zoomx = zoomx; - pixelspace.zoomy = zoomy; - pixelspace.aspx = aspx; - pixelspace.aspy = aspy; - - draw_shapes(mask, &pixelspace); + draw_shapes(mask); } diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 5518fedf91a..16f201293d5 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -89,7 +89,7 @@ static void spline_point_select(MaskSplinePoint *point, int action) } -static float projection_on_spline(MaskSpline *spline, MaskSplinePoint *point, float aspx, float aspy, float start_u, const float co[2]) +static float projection_on_spline(MaskSpline *spline, MaskSplinePoint *point, float start_u, const float co[2]) { const float proj_eps = 1e-3; const float proj_eps_squared = proj_eps * proj_eps; @@ -104,7 +104,7 @@ static float projection_on_spline(MaskSpline *spline, MaskSplinePoint *point, fl if (u1 >= 0.0f) { BKE_mask_point_segment_co(spline, point, u1, co1); - BKE_mask_point_normal(spline, point, aspx, aspy, u1, n1); + BKE_mask_point_normal(spline, point, u1, n1); sub_v2_v2v2(v1, co, co1); if (len_squared_v2(v1) > proj_eps_squared) { @@ -125,7 +125,7 @@ static float projection_on_spline(MaskSpline *spline, MaskSplinePoint *point, fl if (u2 <= 1.0f) { BKE_mask_point_segment_co(spline, point, u2, co2); - BKE_mask_point_normal(spline, point, aspx, aspy, u2, n2); + BKE_mask_point_normal(spline, point, u2, n2); sub_v2_v2v2(v2, co, co2); if (len_squared_v2(v2) > proj_eps_squared) { @@ -249,7 +249,7 @@ static MaskSplinePoint *find_nearest_point(bContext *C, Mask *mask, float normal vec[1] = cur_point->bezt.vec[1][1] * scaley; if (BKE_mask_point_has_handle(cur_point)) { - BKE_mask_point_handle(cur_point, aspx, aspy, handle); + BKE_mask_point_handle(cur_point, handle); handle[0] *= scalex; handle[1] *= scaley; @@ -336,7 +336,7 @@ static int find_nearest_feather(bContext *C, Mask *mask, float normal_co[2], int int i, tot_feather_point; float *feather_points, *fp; - feather_points = fp = BKE_mask_spline_feather_points(spline, aspx, aspy, &tot_feather_point); + feather_points = fp = BKE_mask_spline_feather_points(spline, &tot_feather_point); for (i = 0; i < spline->tot_point; i++) { int j; @@ -444,7 +444,7 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, float normal_co[2], if (feather) { feather_points = BKE_mask_point_segment_feather_diff(spline, cur_point, - aspx, aspy, &tot_feather_point); + &tot_feather_point); points = feather_points; tot_point = tot_feather_point; @@ -502,7 +502,7 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, float normal_co[2], *point_r = point; if (u_r) { - u = projection_on_spline(point_spline, point, aspx, aspy, u, normal_co); + u = projection_on_spline(point_spline, point, u, normal_co); *u_r = u; } @@ -748,14 +748,14 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) customdata->weight = uw->w; BKE_mask_point_segment_co(spline, point, uw->u, co); - BKE_mask_point_normal(spline, point, customdata->aspx, customdata->aspy, uw->u, customdata->no); + BKE_mask_point_normal(spline, point, uw->u, customdata->no); customdata->feather[0] = co[0] + customdata->no[0] * uw->w; customdata->feather[1] = co[1] + customdata->no[1] * uw->w; } else { BezTriple *bezt = &point->bezt; - BKE_mask_point_normal(spline, point, customdata->aspx, customdata->aspy, 0.0f, customdata->no); + BKE_mask_point_normal(spline, point, 0.0f, customdata->no); customdata->feather[0] = bezt->vec[1][0] + customdata->no[0] * bezt->weight; customdata->feather[1] = bezt->vec[1][1] + customdata->no[1] * bezt->weight; @@ -763,7 +763,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->aspx, customdata->aspy, customdata->handle); + BKE_mask_point_handle(point, customdata->handle); ED_mask_mouse_pos(C, event, customdata->co); } @@ -882,14 +882,14 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) add_v2_v2v2(offco, data->feather, dco); if (data->uw) { - float u = projection_on_spline(data->spline, data->point, data->aspx, data->aspy, data->uw->u, offco); + float u = projection_on_spline(data->spline, data->point, data->uw->u, offco); if (u > 0.0f && u < 1.0f) data->uw->u = u; data->uw = BKE_mask_point_sort_uw(data->point, data->uw); weight = &data->uw->w; - BKE_mask_point_normal(data->spline, data->point, data->aspx, data->aspy, data->uw->u, no); + BKE_mask_point_normal(data->spline, data->point, data->uw->u, no); BKE_mask_point_segment_co(data->spline, data->point, data->uw->u, p); } else { diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 6ebcaf4ea16..8e92a9198b1 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1134,7 +1134,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) glScalef(maxdim * zoomx, maxdim * zoomy, 0); glMultMatrixf(sc->stabmat); - ED_mask_draw((bContext *)C, width*aspx, height*aspy, zoomx, zoomy); + ED_mask_draw((bContext *)C); glPopMatrix(); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 85d54c0d6e3..50d6beb0681 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5908,7 +5908,7 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, TransDat else { tdm->is_handle = TRUE; - BKE_mask_point_handle(point, aspx, aspy, tdm->handle); + BKE_mask_point_handle(point, tdm->handle); copy_v2_v2(tdm->orig_handle, tdm->handle); diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h index 7597a21fd03..dbdde515804 100644 --- a/source/blender/makesdna/DNA_mask_types.h +++ b/source/blender/makesdna/DNA_mask_types.h @@ -54,9 +54,9 @@ typedef struct MaskParent { ID *id; /* ID block of entity to which mask/spline is parented to * in case of parenting to movie tracking data set to MovieClip datablock */ char parent[64]; /* entity of parent to which parenting happened - * in case of parenting to movie tracking data contains name of object */ + * in case of parenting to movie tracking data contains name of object */ char sub_parent[64]; /* sub-entity of parent to which parenting happened - * in case of parenting to movie tracking data contains name of track */ + * in case of parenting to movie tracking data contains name of track */ float offset[2]; /* offset from parent position, so object/control point can be parented to a * motion track and also be animated (see ZanQdo's request below) */ } MaskParent; @@ -96,13 +96,13 @@ typedef struct MaskShape { } MaskShape; /* MaskParent->flag */ -#define MASK_PARENT_ACTIVE (1<<0) +#define MASK_PARENT_ACTIVE (1 << 0) /* MaskSpline->flag */ -#define MASK_SPLINE_CYCLIC (1<<1) +#define MASK_SPLINE_CYCLIC (1 << 1) /* MaskSpline->weight_interp */ -#define MASK_SPLINE_INTERP_LINEAR 1 -#define MASK_SPLINE_INTERP_EASE 2 +#define MASK_SPLINE_INTERP_LINEAR 1 +#define MASK_SPLINE_INTERP_EASE 2 #endif // __DNA_MASK_TYPES_H__