diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 18:11:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 18:11:05 +0400 |
commit | b100f9d79de36900e24a21232621d38143f37786 (patch) | |
tree | 03aa3c6dcf601517f28c016b6528de22e5be7c86 /source/blender/editors | |
parent | 363bfdc46a05a5225bd4abc76b14ba2002f414af (diff) |
edit gp_stroke_convertcoords not to modify the mval passed to it & make some mval args const elsewhere too.
Diffstat (limited to 'source/blender/editors')
6 files changed, 19 insertions, 25 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index de989a1a292..c13feec5785 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -239,7 +239,7 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3], float *depth) { bGPdata *gpd= p->gpd; @@ -251,10 +251,10 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo */ } else { - const int mx=mval[0], my=mval[1]; + int mval_prj[2]; float rvec[3], dvec[3]; float mval_f[2]; - + /* Current method just converts each point in screen-coordinates to * 3D-coordinates using the 3D-cursor as reference. In general, this * works OK, but it could of course be improved. @@ -267,10 +267,9 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo gp_get_3d_reference(p, rvec); /* method taken from editview.c - mouse_cursor() */ - project_int_noclip(p->ar, rvec, mval); + project_int_noclip(p->ar, rvec, mval_prj); - mval_f[0]= mval[0] - mx; - mval_f[0]= mval[1] - my; + VECSUB2D(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec); sub_v3_v3v3(out, rvec, dvec); } @@ -278,12 +277,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo /* 2d - on 'canvas' (assume that p->v2d is set) */ else if ((gpd->sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) { - float x, y; - - UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &x, &y); - - out[0]= x; - out[1]= y; + UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]); } #if 0 diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index dbae9bcf1aa..2b0da72c2a1 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -3975,7 +3975,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), float *lastpos, f } -static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, int *UNUSED(prevmval_i), int *mval_i, double time, float pressure) +static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, const int UNUSED(prevmval_i[2]), const int mval_i[2], double time, float pressure) { /* Use mouse coords as floats for projection painting */ @@ -3994,7 +3994,7 @@ static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, i } -static int project_paint_stroke(ProjPaintState *ps, BrushPainter *painter, int *prevmval_i, int *mval_i, double time, float pressure) +static int project_paint_stroke(ProjPaintState *ps, BrushPainter *painter, const int prevmval_i[2], const int mval_i[2], double time, float pressure) { int a, redraw; @@ -4417,7 +4417,7 @@ static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, else return 0; } -static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPainter *painter, short texpaint, int *prevmval, int *mval, double time, float pressure) +static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPainter *painter, short texpaint, const int prevmval[2], const int mval[2], double time, float pressure) { Image *newimage = NULL; float fwuv[2], bkuv[2], newuv[2]; diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index ba7235a3161..b024f22e8dd 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -106,8 +106,8 @@ void PAINT_OT_image_from_view(struct wmOperatorType *ot); void projectf(struct bglMats *mats, const float v[3], float p[2]); float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius); float paint_get_tex_pixel(struct Brush* br, float u, float v); -int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index); -void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, int *xy, float *uv); +int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, const int mval[2], unsigned int *index); +void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]); void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y); void BRUSH_OT_curve_preset(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index aa84b8f2bb4..09f5c32bea0 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -148,7 +148,7 @@ static void imapaint_tri_weights(Object *ob, float *v1, float *v2, float *v3, fl } /* compute uv coordinates of mouse in face */ -void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, int *xy, float *uv) +void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2]) { DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); const int *index = dm->getFaceDataArray(dm, CD_ORIGINDEX); @@ -214,7 +214,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, int *xy, } ///* returns 0 if not found, otherwise 1 */ -int imapaint_pick_face(ViewContext *vc, Mesh *me, int *mval, unsigned int *index) +int imapaint_pick_face(ViewContext *vc, Mesh *me, const int mval[2], unsigned int *index) { if(!me || me->totface==0) return 0; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index f4fc004f413..692d33bd091 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -731,7 +731,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x return tot; } -static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, float *mval, float pressure) +static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, const float mval[2], float pressure) { Brush *brush = paint_brush(&vp->paint); float fac, fac_2, size, dx, dy; @@ -1724,7 +1724,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent return 1; } -static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index, float mval[2], float pressure, int UNUSED(flip)) +static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index, const float mval[2], float pressure, int UNUSED(flip)) { ViewContext *vc = &vpd->vc; Brush *brush = paint_brush(&vp->paint); diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 5810f750f19..037b1db56d6 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -2482,7 +2482,7 @@ static int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, return 0; } -static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, float *mval) +static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) { if(mval[1]>te->ys && mval[1]<te->ys+OL_H) { @@ -2628,7 +2628,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) /* *********** */ -static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, float *mval) +static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2]) { if(mval[1]>te->ys && mval[1]<te->ys+OL_H) { @@ -2693,7 +2693,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) /* ********************************************** */ -static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, float *mval) +static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) { if(mval[1]>te->ys && mval[1]<te->ys+OL_H) { @@ -3728,7 +3728,7 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot) /* ******************** */ -static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, float *mval) +static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, const float mval[2]) { if(mval[1]>te->ys && mval[1]<te->ys+OL_H) { |