From 47ec0394ca3d03e07c07a67e8f8d1625aedd39dd Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 18 Jun 2014 18:40:11 +0300 Subject: Fix T40679. Cleanest way here is not do bounding box collision for editmeshes at all. Decision is taken because: * Usually we want to do the snapping to the edited mesh anyway (when we don't the mesh is skipped completely, so we don't need to worry for extra checks) * Bounding box is calculated from derived mesh. This means that for subsurfed meshes for instance, the bounding box may be significantly smaller than the size of the edit mesh. --- source/blender/editors/transform/transform_snap.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/transform') diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index b116721868e..451837fd311 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -507,7 +507,6 @@ static void initSnappingMode(TransInfo *t) if (t->tsnap.applySnap != NULL && // A snapping function actually exist (obedit != NULL && ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs { - BoundBox *bb_init; /* Exclude editmesh if using proportional edit */ if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) { t->tsnap.modeSelect = SNAP_NOT_OBEDIT; @@ -1490,13 +1489,12 @@ static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4], const float ray_start[3], const float ray_normal[3], const float ray_origin[3], - const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth) + const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth, bool do_bb) { bool retval = false; int totvert = dm->getNumVerts(dm); if (totvert > 0) { - BoundBox *bb; float imat[4][4]; float timat[3][3]; /* transpose inverse matrix for normals */ float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = TRANSFORM_DIST_MAX_RAY; @@ -1514,9 +1512,11 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes /* local scale in normal direction */ local_scale = normalize_v3(ray_normal_local); - bb = BKE_object_boundbox_get(ob); - if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) { - return retval; + if (do_bb) { + BoundBox *bb = BKE_object_boundbox_get(ob); + if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) { + return retval; + } } switch (snap_mode) { @@ -1814,17 +1814,19 @@ static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, f if (ob->type == OB_MESH) { BMEditMesh *em; DerivedMesh *dm; + bool do_bb = true; if (use_obedit) { em = BKE_editmesh_from_object(ob); dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH); + do_bb = false; } else { em = NULL; dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); } - retval = snapDerivedMesh(snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_depth); + retval = snapDerivedMesh(snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_depth, do_bb); dm->release(dm); } -- cgit v1.2.3