From 4f4e45540daf211a3531a81c464fa3a389ea8ede Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Feb 2013 11:29:27 +0000 Subject: fix for harmless glitch rotating the camera in camera mode, having the center point so close to the viewpoint caused the helper line to erratically move about because of float precision. --- source/blender/editors/transform/transform.c | 18 +++++++++++++----- source/blender/editors/transform/transform.h | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/transform') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 53142243f4f..c8874d13cac 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -239,11 +239,11 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) } } -void projectIntView(TransInfo *t, const float vec[3], int adr[2]) +void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DProjTest flag) { if (t->spacetype == SPACE_VIEW3D) { if (t->ar->regiontype == RGN_TYPE_WINDOW) { - if (ED_view3d_project_int_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { + if (ED_view3d_project_int_global(t->ar, vec, adr, flag) != V3D_PROJ_RET_OK) { adr[0] = (int)2140000000.0f; /* this is what was done in 2.64, perhaps we can be smarter? */ adr[1] = (int)2140000000.0f; } @@ -361,15 +361,19 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], adr, adr + 1); } } +void projectIntView(TransInfo *t, const float vec[3], int adr[2]) +{ + projectIntViewEx(t, vec, adr, V3D_PROJ_TEST_NOP); +} -void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) +void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV3DProjTest flag) { switch (t->spacetype) { case SPACE_VIEW3D: { if (t->ar->regiontype == RGN_TYPE_WINDOW) { /* allow points behind the view [#33643] */ - if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_global(t->ar, vec, adr, flag) != V3D_PROJ_RET_OK) { /* XXX, 2.64 and prior did this, weak! */ adr[0] = t->ar->winx / 2.0f; adr[1] = t->ar->winy / 2.0f; @@ -393,6 +397,10 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) zero_v2(adr); } +void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) +{ + projectFloatViewEx(t, vec, adr, V3D_PROJ_TEST_NOP); +} void applyAspectRatio(TransInfo *t, float vec[2]) { @@ -1543,7 +1551,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) if (ob) mul_m4_v3(ob->obmat, vecrot); } - projectFloatView(t, vecrot, cent); // no overflow in extreme cases + projectFloatViewEx(t, vecrot, cent, V3D_PROJ_TEST_CLIP_ZERO); glPushMatrix(); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 9c57c74a26d..dbf56f658ac 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -35,6 +35,7 @@ #include "ED_transform.h" #include "ED_numinput.h" +#include "ED_view3d.h" #include "DNA_listBase.h" @@ -481,7 +482,9 @@ int transformEnd(struct bContext *C, TransInfo *t); void setTransformViewMatrices(TransInfo *t); void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy); +void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DProjTest flag); void projectIntView(TransInfo *t, const float vec[3], int adr[2]); +void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV3DProjTest flag); void projectFloatView(TransInfo *t, const float vec[3], float adr[2]); void applyAspectRatio(TransInfo *t, float *vec); -- cgit v1.2.3