diff options
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 5 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_sketch.c | 4 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 19 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 6 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 15 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 5 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 22 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 8 |
13 files changed, 87 insertions, 53 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 702c133ffc5..d5dce320a6b 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2489,7 +2489,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e ARegion *ar; View3D *v3d; RegionView3D *rv3d; - float *fp = NULL, tvec[3], oldcurs[3]; + float *fp = NULL, tvec[3], oldcurs[3], mval_f[2]; int retv; scene= CTX_data_scene(C); @@ -2501,7 +2501,8 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e copy_v3_v3(oldcurs, fp); - ED_view3d_win_to_3d(ar, fp, event->mval[0], event->mval[1], tvec); + VECCOPY2D(mval_f, event->mval); + ED_view3d_win_to_3d(ar, fp, mval_f, tvec); copy_v3_v3(fp, tvec); /* extrude to the where new cursor is and store the operation result */ diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 214f2dbccce..ccb9a45af37 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -1022,6 +1022,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr short cval[2]; float fp[3] = {0, 0, 0}; float dvec[3]; + float mval_f[2]; if (last != NULL) { @@ -1032,7 +1033,8 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr /* method taken from editview.c - mouse_cursor() */ project_short_noclip(ar, fp, cval); - ED_view3d_win_to_delta(ar, cval[0] - dd->mval[0], cval[1] - dd->mval[1], dvec); + VECSUB2D(mval_f, cval, dd->mval); + ED_view3d_win_to_delta(ar, mval_f, dvec); sub_v3_v3v3(vec, fp, dvec); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 74e9799e668..83dec47bf8b 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -377,31 +377,30 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi } else { float *fp= give_cursor(scene, v3d); - float mx, my; + float mvalf[2]; /* get screen coordinate */ if (gps->flag & GP_STROKE_2DSPACE) { - int mxi, myi; + int mvali[2]; View2D *v2d= &ar->v2d; - UI_view2d_view_to_region(v2d, pt->x, pt->y, &mxi, &myi); - mx= mxi; - my= myi; + UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali+1); + VECCOPY2D(mvalf, mvali); } else { if(subrect) { - mx= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; - my= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; + mvalf[0]= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; + mvalf[1]= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; } else { - mx= (float)pt->x / 100.0f * ar->winx; - my= (float)pt->y / 100.0f * ar->winy; + mvalf[0]= (float)pt->x / 100.0f * ar->winx; + mvalf[1]= (float)pt->y / 100.0f * ar->winy; } } /* convert screen coordinate to 3d coordinates * - method taken from editview.c - mouse_cursor() */ - ED_view3d_win_to_3d(ar, fp, mx, my, p3d); + ED_view3d_win_to_3d(ar, fp, mvalf, p3d); } } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index f84e770b8f2..de989a1a292 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -253,6 +253,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo else { const int mx=mval[0], my=mval[1]; 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 @@ -267,7 +268,10 @@ static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], flo /* method taken from editview.c - mouse_cursor() */ project_int_noclip(p->ar, rvec, mval); - ED_view3d_win_to_delta(p->ar, mval[0]-mx, mval[1]-my, dvec); + + mval_f[0]= mval[0] - mx; + mval_f[0]= mval[1] - my; + ED_view3d_win_to_delta(p->ar, mval_f, dvec); sub_v3_v3v3(out, rvec, dvec); } } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 1adf7c9000b..2f99cf16093 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -85,33 +85,30 @@ int initgrabz(struct RegionView3D *rv3d, float x, float y, float z); * Calculate a 3d location from 2d window coordinates. * @param ar The region (used for the window width and height). * @param depth_pt The reference location used to calculate the Z depth. - * @param mx The area relative X location (such as event->mval[0]). - * @param my The area relative Y location (such as event->mval[1]). + * @param mval The area relative location (such as event->mval converted to floats). * @param out The resulting world-space location. */ -void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mx, const float my, float out[3]); +void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); /** * Calculate a 3d difference vector from 2d window offset. * note that initgrabz() must be called first to determine * the depth used to calculate the delta. * @param ar The region (used for the window width and height). - * @param mx The area relative X difference (such as event->mval[0] - other_x). - * @param my The area relative Y difference (such as event->mval[1] - other_y). + * @param mval The area relative 2d difference (such as event->mval[0] - other_x). * @param out The resulting world-space delta. */ -void ED_view3d_win_to_delta(struct ARegion *ar, const float mx, const float my, float out[3]); +void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]); /** * Calculate a 3d direction vector from 2d window coordinates. * This direction vector starts and the view in the direction of the 2d window coordinates. * In orthographic view all window coordinates yield the same vector. * @param ar The region (used for the window width and height). - * @param mx The area relative X difference (such as event->mval[0]). - * @param my The area relative Y difference (such as event->mval[1]). + * @param mval The area relative 2d location (such as event->mval converted to floats). * @param out The resulting normalized world-space direction vector. */ -void ED_view3d_win_to_vector(struct ARegion *ar, const float mx, const float my, float out[3]); +void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]); /** * Calculate a 3d segment from 2d window coordinates. diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 7cb12fe243d..79d01e0a61d 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3501,6 +3501,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) switch(pset->brushtype) { case PE_BRUSH_COMB: { + float mval_f[2]; data.mval= mval; data.rad= (float)brush->size; @@ -3512,7 +3513,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) invert_m4_m4(ob->imat, ob->obmat); - ED_view3d_win_to_delta(ar, dx, dy, vec); + mval_f[0]= dx; + mval_f[1]= dy; + ED_view3d_win_to_delta(ar, mval_f, vec); data.dvec= vec; foreach_mouse_hit_key(&data, brush_comb, selected); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 86b946f6ee3..aa84b8f2bb4 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -58,11 +58,15 @@ float paint_calc_object_space_radius(ViewContext *vc, float center[3], { Object *ob = vc->obact; float delta[3], scale, loc[3]; + float mval_f[2]; mul_v3_m4v3(loc, ob->obmat, center); initgrabz(vc->rv3d, loc[0], loc[1], loc[2]); - ED_view3d_win_to_delta(vc->ar, pixel_radius, 0, delta); + + mval_f[0]= pixel_radius; + mval_f[1]= 0.0f; + ED_view3d_win_to_delta(vc->ar, mval_f, delta); scale= fabsf(mat4_to_scale(ob->obmat)); scale= (scale == 0.0f)? 1.0f: scale; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7b09736ca95..fa9f2fd340e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2994,7 +2994,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) cache->orig_grab_location[1], cache->orig_grab_location[2]); - ED_view3d_win_to_delta(cache->vc->ar, cache->mouse[0], cache->mouse[1], grab_location); + ED_view3d_win_to_delta(cache->vc->ar, cache->mouse, grab_location); /* compute delta to move verts by */ if(!cache->first_time) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e4511f60d8f..adce40f58ce 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1407,10 +1407,11 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) } else { float sco[2]; + const float mval_f[2]= {1.0f, 0.0f}; /* calc window coord */ initgrabz(rv3d, 0.0, 0.0, 0.0); - ED_view3d_win_to_delta(ar, 1, 0, vec); + ED_view3d_win_to_delta(ar, mval_f, vec); fac= MAX3( fabs(vec[0]), fabs(vec[1]), fabs(vec[1]) ); fac= 1.0f/fac; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index d9746dfc27d..2e181e65db7 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -418,8 +418,12 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) } } - /* for dolly */ - ED_view3d_win_to_vector(vod->ar, event->mval[0], event->mval[1], vod->mousevec); + { + /* for dolly */ + float mval_f[2]; + VECCOPY2D(mval_f, event->mval); + ED_view3d_win_to_vector(vod->ar, mval_f, vod->mousevec); + } /* lookup, we dont pass on v3d to prevent confusement */ vod->grid= vod->v3d->grid; @@ -928,8 +932,12 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) } else { float dvec[3]; + float mval_f[2]; + + mval_f[0]= x - vod->oldx; + mval_f[1]= y - vod->oldy; + ED_view3d_win_to_delta(vod->ar, mval_f, dvec); - ED_view3d_win_to_delta(vod->ar, x-vod->oldx, y-vod->oldy, dvec); add_v3_v3(vod->rv3d->ofs, dvec); if(vod->rv3d->viewlock & RV3D_BOXVIEW) @@ -1071,6 +1079,7 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) float dvec[3]; float tvec[3]; float tpos[3]; + float mval_f[2]; float new_dist; int vb[2], mouseloc[2]; @@ -1085,7 +1094,10 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) /* Project cursor position into 3D space */ initgrabz(rv3d, tpos[0], tpos[1], tpos[2]); - ED_view3d_win_to_delta(ar, mouseloc[0]-vb[0]/2.0f, mouseloc[1]-vb[1]/2.0f, dvec); + + mval_f[0]= (mouseloc[0] - vb[0]) / 2.0f; + mval_f[1]= (mouseloc[1] - vb[1]) / 2.0f; + ED_view3d_win_to_delta(ar, mval_f, dvec); /* Calculate view target position for dolly */ add_v3_v3v3(tvec, tpos, dvec); @@ -2070,13 +2082,17 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) new_ofs[0] = -p[0]; new_ofs[1] = -p[1]; new_ofs[2] = -p[2]; - } else { + } + else { + float mval_f[2]; /* We cant use the depth, fallback to the old way that dosnt set the center depth */ copy_v3_v3(new_ofs, rv3d->ofs); initgrabz(rv3d, -new_ofs[0], -new_ofs[1], -new_ofs[2]); - ED_view3d_win_to_delta(ar, (rect.xmin+rect.xmax-vb[0])/2, (rect.ymin+rect.ymax-vb[1])/2, dvec); + mval_f[0]= (rect.xmin + rect.xmax - vb[0]) / 2.0f; + mval_f[1]= (rect.ymin + rect.ymax - vb[1]) / 2.0f; + ED_view3d_win_to_delta(ar, mval_f, dvec); /* center the view to the center of the rectangle */ sub_v3_v3(new_ofs, dvec); } @@ -2479,15 +2495,16 @@ static int viewpan_exec(bContext *C, wmOperator *op) ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); float vec[3]; + float mval_f[2]= {0.0f, 0.0f}; int pandir; pandir = RNA_enum_get(op->ptr, "type"); initgrabz(rv3d, 0.0, 0.0, 0.0); - if(pandir == V3D_VIEW_PANRIGHT) ED_view3d_win_to_delta(ar, -32, 0, vec); - else if(pandir == V3D_VIEW_PANLEFT) ED_view3d_win_to_delta(ar, 32, 0, vec); - else if(pandir == V3D_VIEW_PANUP) ED_view3d_win_to_delta(ar, 0, -25, vec); - else if(pandir == V3D_VIEW_PANDOWN) ED_view3d_win_to_delta(ar, 0, 25, vec); + if(pandir == V3D_VIEW_PANRIGHT) { mval_f[0]= -32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } + else if(pandir == V3D_VIEW_PANLEFT) { mval_f[0]= 32.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } + else if(pandir == V3D_VIEW_PANUP) { mval_f[1]= -25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } + else if(pandir == V3D_VIEW_PANDOWN) { mval_f[1]= 25.0f; ED_view3d_win_to_delta(ar, mval_f, vec); } add_v3_v3(rv3d->ofs, vec); if(rv3d->viewlock & RV3D_BOXVIEW) @@ -2811,7 +2828,9 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve } if(depth_used==0) { - ED_view3d_win_to_delta(ar, mval[0]-event->mval[0], mval[1]-event->mval[1], dvec); + float mval_f[2]; + VECSUB(mval_f, mval, event->mval); + ED_view3d_win_to_delta(ar, mval_f, dvec); sub_v3_v3(fp, dvec); } } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 1bae23b70dd..0940734a8e9 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -106,7 +106,9 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); if(mval_cpy[0]!=IS_CLIPPED) { - ED_view3d_win_to_delta(vc->ar, mval_cpy[0]-mval[0], mval_cpy[1]-mval[1], dvec); + float mval_f[2]; + VECSUB2D(mval_f, mval_cpy, mval); + ED_view3d_win_to_delta(vc->ar, mval_f, dvec); sub_v3_v3(fp, dvec); return TRUE; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index b47bf9a08ce..678ffc09e39 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -508,7 +508,7 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2] if(rv3d->is_persp) { float vec[3]; - ED_view3d_win_to_vector(ar, mval[0], mval[1], vec); + ED_view3d_win_to_vector(ar, mval, vec); copy_v3_v3(ray_start, rv3d->viewinv[3]); VECADDFAC(ray_start, rv3d->viewinv[3], vec, v3d->near); @@ -592,7 +592,7 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z) return flip; } -void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mx, const float my, float out[3]) +void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]) { RegionView3D *rv3d= ar->regiondata; @@ -602,7 +602,7 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mx, c if(rv3d->is_persp) { float mousevec[3]; copy_v3_v3(line_sta, rv3d->viewinv[3]); - ED_view3d_win_to_vector(ar, mx, my, mousevec); + ED_view3d_win_to_vector(ar, mval, mousevec); add_v3_v3v3(line_end, line_sta, mousevec); if(isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) { @@ -611,8 +611,8 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mx, c } } else { - const float dx= (2.0f * (float)mx / (float)ar->winx) - 1.0f; - const float dy= (2.0f * (float)my / (float)ar->winy) - 1.0f; + const float dx= (2.0f * mval[0] / (float)ar->winx) - 1.0f; + const float dy= (2.0f * mval[1] / (float)ar->winy) - 1.0f; line_sta[0]= (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0]; line_sta[1]= (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1]; line_sta[2]= (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2]; @@ -624,13 +624,13 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mx, c /* always call initgrabz */ /* only to detect delta motion */ -void ED_view3d_win_to_delta(ARegion *ar, const float mx, const float my, float out[3]) +void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3]) { RegionView3D *rv3d= ar->regiondata; float dx, dy; - dx= 2.0f*mx*rv3d->zfac/ar->winx; - dy= 2.0f*my*rv3d->zfac/ar->winy; + dx= 2.0f*mval[0]*rv3d->zfac/ar->winx; + dy= 2.0f*mval[1]*rv3d->zfac/ar->winy; out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); @@ -640,13 +640,13 @@ void ED_view3d_win_to_delta(ARegion *ar, const float mx, const float my, float o /* doesn't rely on initgrabz */ /* for perspective view, get the vector direction to * the mouse cursor as a normalized vector */ -void ED_view3d_win_to_vector(ARegion *ar, const float mx, const float my, float out[3]) +void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3]) { RegionView3D *rv3d= ar->regiondata; if(rv3d->is_persp) { - out[0]= 2.0f * (mx / ar->winx) - 1.0f; - out[1]= 2.0f * (my / ar->winy) - 1.0f; + out[0]= 2.0f * (mval[0] / ar->winx) - 1.0f; + out[1]= 2.0f * (mval[1] / ar->winy) - 1.0f; out[2]= -0.5f; mul_project_m4_v3(rv3d->persinv, out); sub_v3_v3(out, rv3d->viewinv[3]); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 85404aa98e1..608ba3fc1f9 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -123,9 +123,11 @@ void setTransformViewMatrices(TransInfo *t) void convertViewVec(TransInfo *t, float *vec, int dx, int dy) { if (t->spacetype==SPACE_VIEW3D) { - if (t->ar->regiontype == RGN_TYPE_WINDOW) - { - ED_view3d_win_to_delta(t->ar, dx, dy, vec); + if (t->ar->regiontype == RGN_TYPE_WINDOW) { + float mval_f[2]; + mval_f[0]= dx; + mval_f[1]= dy; + ED_view3d_win_to_delta(t->ar, mval_f, vec); } } else if(t->spacetype==SPACE_IMAGE) { |