diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-07 05:06:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-07 05:06:18 +0400 |
commit | f11d7a426f4ceaa914c76a120d4e420308801f3b (patch) | |
tree | 33d62f8065548503c169b9aa4fa42f4141dbc3dc | |
parent | 400a0297b0b10dbed6a4f5fe8fddd9cdc58914af (diff) |
fix for bug in ED_view3d_project_float that only effected the 'Rip' tool.
when the source and destination vectors were the same pointer, the X value would get overwritten.
now the rip tool uses the best side to grab as in trunk.
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 21 | ||||
-rw-r--r-- | source/blender/editors/mesh/knifetool.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 3 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 14 |
7 files changed, 27 insertions, 22 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index de4b964baf6..54e62cb9c1d 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -219,9 +219,9 @@ void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]); int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); -void ED_view3d_project_float(const struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short no_shift); -void ED_view3d_project_float_v3(struct ARegion *a, const float vec[3], float *adr, float mat[4][4]); +void ED_view3d_project_float_v2(const struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); +void ED_view3d_project_float_v3(struct ARegion *a, const float vec[3], float adr[3], float mat[4][4]); void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, float size_r[2]); /* drawobject.c iterators */ diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index d02fc5f51d5..88fb179e936 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -2319,8 +2319,8 @@ static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *c { float vec1[3], vec2[3], mvalf[2]; - ED_view3d_project_float(ar, co1, vec1, mat); - ED_view3d_project_float(ar, co2, vec2, mat); + ED_view3d_project_float_v2(ar, co1, vec1, mat); + ED_view3d_project_float_v2(ar, co2, vec2, mat); mvalf[0] = (float)mval[0]; mvalf[1] = (float)mval[1]; @@ -2345,7 +2345,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) BMOIter siter; BMIter iter, eiter; BMLoop *l; - BMEdge *e, *e2, *closest = NULL; + BMEdge *e, *e2; BMVert *v, *ripvert = NULL; int side = 0, i, singlesel = FALSE; float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]}; @@ -2469,7 +2469,10 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) for (i = 0; i < 2; i++) { BMO_ITER(e, &siter, bm, &bmop, i ? "edgeout2":"edgeout1", BM_EDGE) { - float cent[3] = {0, 0, 0}, mid[3], vec[3]; + float cent[3] = {0, 0, 0}, mid[3]; + float vec[3]; + BMVert *v1_other; + BMVert *v2_other; #ifdef USE_BVH_VISIBILITY if (!BMBVH_EdgeVisible(bvhtree, e, ar, v3d, obedit) || !e->l) @@ -2481,7 +2484,12 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) * for each edge: calculate face center, then made a vector * from edge midpoint to face center. offset edge midpoint * by a small amount along this vector. */ - BM_face_center_mean_calc(bm, e->l->f, cent); + + /* rather then the face center, get the middle of + * both edge verts connected to this one */ + v1_other = BM_face_other_vert_loop(e->l->f, e->v2, e->v1)->v; + v2_other = BM_face_other_vert_loop(e->l->f, e->v1, e->v2)->v; + mid_v3_v3v3(cent, v1_other->co, v2_other->co); mid_v3_v3v3(mid, e->v1->co, e->v2->co); sub_v3_v3v3(vec, cent, mid); @@ -2490,13 +2498,12 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) add_v3_v3v3(mid, mid, vec); /* We have our comparison point, now project it */ - ED_view3d_project_float(ar, mid, mid, projectMat); + ED_view3d_project_float_v2(ar, mid, mid, projectMat); d = len_squared_v2v2(fmval, mid); if (d < dist) { side = i; - closest = e; dist = d; } } diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c index fcf9effee4a..b026ddd19fb 100644 --- a/source/blender/editors/mesh/knifetool.c +++ b/source/blender/editors/mesh/knifetool.c @@ -177,7 +177,7 @@ static void knife_input_ray_cast(knifetool_opdata *kcd, const int mval_i[2], static void knife_project_v3(knifetool_opdata *kcd, const float co[3], float sco[3]) { - ED_view3d_project_float(kcd->ar, co, sco, kcd->projmat); + ED_view3d_project_float_v3(kcd->ar, co, sco, kcd->projmat); } static ListBase *knife_empty_list(knifetool_opdata *kcd) diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 610c49ef27f..dcd7554b7b8 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -97,8 +97,7 @@ int paint_convert_bb_to_rect(rcti *rect, vec[1] = j ? bb_min[1] : bb_max[1]; vec[2] = k ? bb_min[2] : bb_max[2]; /* convert corner to screen space */ - ED_view3d_project_float(ar, vec, proj, - projection_mat); + ED_view3d_project_float_v2(ar, vec, proj, projection_mat); /* expand 2D rectangle */ rect->xmin = MIN2(rect->xmin, proj[0]); rect->xmax = MAX2(rect->xmax, proj[0]); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9c78b6126e7..ec0064df13b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -662,8 +662,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], if (ss->cache->radial_symmetry_pass) mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point); - ED_view3d_project_float(ss->cache->vc->ar, symm_point, point_2d, - ss->cache->projection_mat); + ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat); /* if fixed mode, keep coordinates relative to mouse */ if(mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 98fc4105445..f72b15614f5 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1603,7 +1603,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) asp= ( (float)ibuf->y)/(float)ibuf->x; vec[0] = vec[1] = vec[2] = 0.0; - ED_view3d_project_float(ar, vec, sco, rv3d->persmat); + ED_view3d_project_float_v2(ar, vec, sco, rv3d->persmat); cx = sco[0]; cy = sco[1]; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 359bb8967eb..7a7a7e9920e 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -770,18 +770,18 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, } /* use view3d_get_object_project_mat to get projecting mat */ -void ED_view3d_project_float(const ARegion *ar, const float vec[3], float adr[2], float mat[4][4]) +void ED_view3d_project_float_v2(const ARegion *ar, const float vec[3], float adr[2], float mat[4][4]) { float vec4[4]; - adr[0]= IS_CLIPPED; copy_v3_v3(vec4, vec); vec4[3]= 1.0; + /* adr[0]= IS_CLIPPED; */ /* always overwritten */ 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]; + 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]; } else { @@ -790,17 +790,17 @@ void ED_view3d_project_float(const ARegion *ar, const float vec[3], float adr[2] } /* use view3d_get_object_project_mat to get projecting mat */ -void ED_view3d_project_float_v3(ARegion *ar, const float vec[3], float *adr, float mat[4][4]) +void ED_view3d_project_float_v3(ARegion *ar, const float vec[3], float adr[3], float mat[4][4]) { float vec4[4]; copy_v3_v3(vec4, vec); vec4[3]= 1.0; - adr[0]= IS_CLIPPED; + /* adr[0]= IS_CLIPPED; */ /* always overwritten */ mul_m4_v4(mat, vec4); - if ( vec4[3]>FLT_EPSILON ) { + 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]; |