Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-05-19 11:55:48 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-19 11:55:48 +0400
commit1dad9bf0bcf0ed94d6542088f1e217f29540ec8c (patch)
treec35a4772defd8d16c645473be5d28546cfa4c980 /source/blender/editors
parent31d3e8d2142ad19e0d43cfcce3f1aece55c5d86c (diff)
change window_to_3d to take screen coords as floats.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c17
-rw-r--r--source/blender/editors/include/ED_view3d.h6
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c6
4 files changed, 18 insertions, 15 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 68577cf4f0f..e5f39614c03 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -377,24 +377,27 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi
}
else {
float *fp= give_cursor(scene, v3d);
- int mx, my;
+ float mx, my;
/* get screen coordinate */
if (gps->flag & GP_STROKE_2DSPACE) {
+ int mxi, myi;
View2D *v2d= &ar->v2d;
- UI_view2d_view_to_region(v2d, pt->x, pt->y, &mx, &my);
+ UI_view2d_view_to_region(v2d, pt->x, pt->y, &mxi, &myi);
+ mx= mxi;
+ my= myi;
}
else {
if(subrect) {
- mx= (int)((pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
- my= (int)((pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
+ mx= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
+ my= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
}
else {
- mx= (int)(pt->x / 100 * ar->winx);
- my= (int)(pt->y / 100 * ar->winy);
+ mx= (float)pt->x / 100.0f * ar->winx;
+ my= (float)pt->y / 100.0f * ar->winy;
}
}
-
+
/* convert screen coordinate to 3d coordinates
* - method taken from editview.c - mouse_cursor()
*/
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 00fb6371d68..a9061ce1b80 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -80,9 +80,9 @@ typedef struct ViewDepths {
float *give_cursor(struct Scene *scene, struct View3D *v3d);
int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
-void window_to_3d(struct ARegion *ar, float out[3], const float depth_pt[3], const int mx, const int my);
-void window_to_3d_delta(struct ARegion *ar, float out[3], const int mx, const int my);
-void window_to_3d_vector(struct ARegion *ar, float out[3], const int mx, const int my);
+void window_to_3d(struct ARegion *ar, float out[3], const float depth_pt[3], const float mx, const float my);
+void window_to_3d_delta(struct ARegion *ar, float out[3], const float mx, const float my);
+void window_to_3d_vector(struct ARegion *ar, float out[3], const float mx, const float my);
void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);
/* Depth buffer */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 2bd2e4e497f..5e2b9fd5e3f 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1074,7 +1074,7 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
float tvec[3];
float tpos[3];
float new_dist;
- short vb[2], mouseloc[2];
+ int vb[2], mouseloc[2];
mouseloc[0]= mx - ar->winrct.xmin;
mouseloc[1]= my - ar->winrct.ymin;
@@ -1087,7 +1087,7 @@ 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]);
- window_to_3d_delta(ar, dvec, mouseloc[0]-vb[0]/2, mouseloc[1]-vb[1]/2);
+ window_to_3d_delta(ar, dvec, mouseloc[0]-vb[0]/2.0f, mouseloc[1]-vb[1]/2.0f);
/* Calculate view target position for dolly */
add_v3_v3v3(tvec, tpos, dvec);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 0e6ac2d9f04..dc8979e0bf3 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -598,7 +598,7 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z)
return flip;
}
-void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const int mx, const int my)
+void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const float mx, const float my)
{
RegionView3D *rv3d= ar->regiondata;
@@ -630,7 +630,7 @@ void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const int
/* always call initgrabz */
/* only to detect delta motion */
-void window_to_3d_delta(ARegion *ar, float out[3], const int mx, const int my)
+void window_to_3d_delta(ARegion *ar, float out[3], const float mx, const float my)
{
RegionView3D *rv3d= ar->regiondata;
float dx, dy;
@@ -646,7 +646,7 @@ void window_to_3d_delta(ARegion *ar, float out[3], const int mx, const int my)
/* doesn't rely on initgrabz */
/* for perspective view, get the vector direction to
* the mouse cursor as a normalized vector */
-void window_to_3d_vector(ARegion *ar, float out[3], const int mx, const int my)
+void window_to_3d_vector(ARegion *ar, float out[3], const float mx, const float my)
{
RegionView3D *rv3d= ar->regiondata;