From 8247bf6fa68bec20a76e613f77f3b49c3194ace8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Sep 2011 11:10:53 +0000 Subject: [PATCH] svn merge ^/branches/bmesh/blender -r40512:40513 --- .../editors/space_view3d/view3d_view.c | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8227ba87021..df4f615e5f1 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -713,7 +713,7 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, } #endif -/* use above call to get projecting mat */ +/* use view3d_get_object_project_mat to get projecting mat */ void ED_view3d_project_float(ARegion *ar, const float vec[3], float adr[2], float mat[4][4]) { float vec4[4]; @@ -732,6 +732,26 @@ void ED_view3d_project_float(ARegion *ar, const float vec[3], float adr[2], floa } } +/* use view3d_get_object_project_mat to get projecting mat */ +void ED_view3d_project_float_v3(ARegion *ar, float *vec, float *adr, float mat[4][4]) +{ + float vec4[4]; + + copy_v3_v3(vec4, vec); + vec4[3]= 1.0; + adr[0]= IS_CLIPPED; + + mul_m4_v4(mat, vec4); + + if( vec4[3]>FLT_EPSILON ) { + adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; + adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3]; + adr[2] = vec4[2]/vec4[3]; + } else { + adr[0] = adr[1] = adr[2] = 0.0f; + } +} + int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb) { /* return 1: draw */ @@ -803,9 +823,9 @@ void project_int(ARegion *ar, const float vec[3], int adr[2]) RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; - adr[0]= (int)2140000000.0f; copy_v3_v3(vec4, vec); vec4[3]= 1.0; + adr[0]= (int)2140000000.0f; mul_m4_v4(rv3d->persmat, vec4); @@ -851,9 +871,9 @@ void project_short_noclip(ARegion *ar, const float vec[3], short adr[2]) RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; - adr[0]= IS_CLIPPED; copy_v3_v3(vec4, vec); vec4[3]= 1.0; + adr[0]= IS_CLIPPED; mul_m4_v4(rv3d->persmat, vec4); @@ -877,9 +897,9 @@ void project_float(ARegion *ar, const float vec[3], float adr[2]) RegionView3D *rv3d= ar->regiondata; float vec4[4]; - adr[0]= IS_CLIPPED; copy_v3_v3(vec4, vec); vec4[3]= 1.0; + adr[0]= IS_CLIPPED; mul_m4_v4(rv3d->persmat, vec4);