From 0710d9dfd17bc9dcc90ac4de2d9f652ae0714a2b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2014 14:13:03 +1000 Subject: Fix crash binding mdef with no faces --- source/blender/editors/armature/meshlaplacian.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/armature/meshlaplacian.c') diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index c2a54c6d9f8..56e7bde0081 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1209,7 +1209,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r } } -static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float *co1, float *co2) +static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, const float co1[3], const float co2[3]) { MDefBoundIsect *isect; BVHTreeRayHit hit; @@ -1218,14 +1218,23 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float void *data[3] = {mdb->cagedm->getTessFaceArray(mdb->cagedm), mdb, &isect_mdef}; MFace *mface1 = data[0], *mface; float vert[4][3], len, end[3]; - static float epsilon[3] = {0, 0, 0}; //1e-4, 1e-4, 1e-4}; + // static float epsilon[3] = {1e-4, 1e-4, 1e-4}; + + /* happens binding when a cage has no faces */ + if (UNLIKELY(mdb->bvhtree == NULL)) + return NULL; /* setup isec */ memset(&isect_mdef, 0, sizeof(isect_mdef)); isect_mdef.lambda = 1e10f; +#if 0 add_v3_v3v3(isect_mdef.start, co1, epsilon); add_v3_v3v3(end, co2, epsilon); +#else + copy_v3_v3(isect_mdef.start, co1); + copy_v3_v3(end, co2); +#endif sub_v3_v3v3(isect_mdef.vec, end, isect_mdef.start); hit.index = -1; -- cgit v1.2.3