Fix crash binding mdef with no faces
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user