[Bf-blender-cvs] [0710d9d] master: Fix crash binding mdef with no faces

Campbell Barton noreply at git.blender.org
Wed May 7 06:14:40 CEST 2014


Commit: 0710d9dfd17bc9dcc90ac4de2d9f652ae0714a2b
Author: Campbell Barton
Date:   Wed May 7 14:13:03 2014 +1000
https://developer.blender.org/rB0710d9dfd17bc9dcc90ac4de2d9f652ae0714a2b

Fix crash binding mdef with no faces

===================================================================

M	source/blender/editors/armature/meshlaplacian.c

===================================================================

diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index c2a54c6..56e7bde 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;




More information about the Bf-blender-cvs mailing list