[Bf-blender-cvs] [d5bca52] master: Fix T44960: Crash with 'Shape Cut' in edit hair mode.

Bastien Montagne noreply at git.blender.org
Fri Jun 5 13:06:25 CEST 2015


Commit: d5bca524d55d929a9e725a51b373de4804e1fe2e
Author: Bastien Montagne
Date:   Fri Jun 5 12:56:56 2015 +0200
Branches: master
https://developer.blender.org/rBd5bca524d55d929a9e725a51b373de4804e1fe2e

Fix T44960: Crash with 'Shape Cut' in edit hair mode.

This is only supported for mesh objects so far.
Also, abort in case there are no faces in dm (instead of crashing on NULL BVH tree...).

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

M	source/blender/editors/physics/particle_edit.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 7abd6f4..f256799 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -414,18 +414,18 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
 	}
 }
 
-static void PE_create_shape_tree(PEData *data, Object *shapeob)
+static bool PE_create_shape_tree(PEData *data, Object *shapeob)
 {
 	DerivedMesh *dm = shapeob->derivedFinal;
 	
 	memset(&data->shape_bvh, 0, sizeof(data->shape_bvh));
 	
 	if (!dm) {
-		return;
+		return false;
 	}
 	
 	DM_ensure_tessface(dm);
-	bvhtree_from_mesh_faces(&data->shape_bvh, dm, 0.0f, 4, 8);
+	return bvhtree_from_mesh_faces(&data->shape_bvh, dm, 0.0f, 4, 8);
 }
 
 static void PE_free_shape_tree(PEData *data)
@@ -4059,11 +4059,12 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot)
 static int shape_cut_poll(bContext *C)
 {
 	if (PE_hair_poll(C)) {
-		Scene *scene= CTX_data_scene(C);
-		ParticleEditSettings *pset= PE_settings(scene);
+		Scene *scene = CTX_data_scene(C);
+		ParticleEditSettings *pset = PE_settings(scene);
 		
-		if (pset->shape_object)
+		if (pset->shape_object && (pset->shape_object->type == OB_MESH)) {
 			return true;
+		}
 	}
 	
 	return false;
@@ -4179,7 +4180,10 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
 		int removed;
 		
 		PE_set_data(C, &data);
-		PE_create_shape_tree(&data, shapeob);
+		if (!PE_create_shape_tree(&data, shapeob)) {
+			/* shapeob may not have faces... */
+			return OPERATOR_CANCELLED;
+		}
 		
 		if (selected)
 			foreach_selected_point(&data, shape_cut);
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index d5e99d4..7b30aa8 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -871,6 +871,7 @@ static void rna_def_particle_edit(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "shape_object", PROP_POINTER, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Shape Object", "Outer shape to use for tools");
+	RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll");
 	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo");
 
 	/* brush */




More information about the Bf-blender-cvs mailing list