[Bf-blender-cvs] [c6de033] master: Fix T38493: ray_cast causes runtime error with no faces

Campbell Barton noreply at git.blender.org
Thu May 22 09:12:02 CEST 2014


Commit: c6de033bf1e92dd94858e8998f154fdea2e6bee2
Author: Campbell Barton
Date:   Thu May 22 17:10:21 2014 +1000
https://developer.blender.org/rBc6de033bf1e92dd94858e8998f154fdea2e6bee2

Fix T38493: ray_cast causes runtime error with no faces

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

M	source/blender/makesrna/intern/rna_object_api.c

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

diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 0b6d6b3..4c5fa03 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -276,7 +276,6 @@ static int dm_tessface_to_poly_index(DerivedMesh *dm, int tessface_index)
 	return ORIGINDEX_NONE;
 }
 
-/* BMESH_TODO, return polygon index, not tessface */
 static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3],
                                 float r_location[3], float r_normal[3], int *index)
 {
@@ -290,11 +289,8 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start
 	/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
 	bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6);
 
-	if (treeData.tree == NULL) {
-		BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for ray casting", ob->id.name + 2);
-		return;
-	}
-	else {
+	/* may fail if the mesh has no faces, in that case the ray-cast misses */
+	if (treeData.tree != NULL) {
 		BVHTreeRayHit hit;
 		float ray_nor[3], dist;
 		sub_v3_v3v3(ray_nor, ray_end, ray_start);




More information about the Bf-blender-cvs mailing list