diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-05-11 17:57:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-05-11 18:00:43 +0300 |
commit | 63432f14247cec0ce263200b3a08e2a79b964271 (patch) | |
tree | 6bc5f99d3b046a2580ccc030c4f607fd3b1b9b23 /source | |
parent | 92774ff792a6c474df2a40c13204da4975de0c09 (diff) |
Fix crash snapping to mesh with no geometry
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/transform/transform_snap_object.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 17c77df58f2..d01513f2064 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -685,9 +685,24 @@ static bool snapDerivedMesh( { ARegion *ar = sctx->v3d_data.ar; bool retval = false; - int totvert = dm->getNumVerts(dm); - if (totvert > 0) { + if (snap_to == SCE_SNAP_MODE_FACE) { + if (dm->getNumPolys(dm) == 0) { + return retval; + } + } + if (snap_to == SCE_SNAP_MODE_EDGE) { + if (dm->getNumEdges(dm) == 0) { + return retval; + } + } + else { + if (dm->getNumVerts(dm) == 0) { + return retval; + } + } + + { const bool do_ray_start_correction = ( ELEM(snap_to, SCE_SNAP_MODE_FACE, SCE_SNAP_MODE_VERTEX) && (sctx->use_v3d && !((RegionView3D *)sctx->v3d_data.ar->regiondata)->is_persp)); @@ -953,9 +968,24 @@ static bool snapEditMesh( { ARegion *ar = sctx->v3d_data.ar; bool retval = false; - int totvert = em->bm->totvert; - if (totvert > 0) { + if (snap_to == SCE_SNAP_MODE_FACE) { + if (em->bm->totface == 0) { + return retval; + } + } + if (snap_to == SCE_SNAP_MODE_EDGE) { + if (em->bm->totedge == 0) { + return retval; + } + } + else { + if (em->bm->totvert == 0) { + return retval; + } + } + + { const bool do_ray_start_correction = ( ELEM(snap_to, SCE_SNAP_MODE_FACE, SCE_SNAP_MODE_VERTEX) && (sctx->use_v3d && !((RegionView3D *)sctx->v3d_data.ar->regiondata)->is_persp)); |