[Bf-blender-cvs] [1bd9a91] fracture_modifier: crash fixes for greasepencil edge fracture

Martin Felke noreply at git.blender.org
Fri Aug 7 15:38:42 CEST 2015


Commit: 1bd9a911c48e49ceb6903dee82e836b73d720a50
Author: Martin Felke
Date:   Fri Aug 7 15:38:23 2015 +0200
Branches: fracture_modifier
https://developer.blender.org/rB1bd9a911c48e49ceb6903dee82e836b73d720a50

crash fixes for greasepencil edge fracture

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

M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/fracture_util.c

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

diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 74687ce..fca5cda 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -1295,12 +1295,32 @@ static void intersect_shards_by_dm(FractureModifierData *fmd, DerivedMesh *d, Ob
 	BKE_shard_free(t, true);
 }
 
+static void reset_shards(FractureModifierData *fmd)
+{
+	if (fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED && fmd->reset_shards)
+	{
+		FracMesh *fm = fmd->frac_mesh;
+		while (fm && fm->shard_map.first)
+		{
+			Shard *t = fm->shard_map.first;
+			BLI_remlink_safe(&fm->shard_map, t);
+			printf("Resetting shard (Greasepencil/Cutter Plane): %d\n", t->shard_id);
+			BKE_shard_free(t, true);
+		}
+		fm->shard_count = 0;
+		/* do not reset again afterwards, in case we have multiple point sources */
+		fmd->reset_shards = false;
+	}
+}
+
 void BKE_fracture_shard_by_greasepencil(FractureModifierData *fmd, Object *obj, short inner_material_index, float mat[4][4])
 {
 	bGPDlayer *gpl;
 	bGPDframe *gpf;
 	bGPDstroke *gps;
 
+	reset_shards(fmd);
+
 	if ((obj->gpd) && (obj->gpd->layers.first)) {
 
 		float imat[4][4];
@@ -1345,6 +1365,7 @@ void BKE_fracture_shard_by_planes(FractureModifierData *fmd, Object *obj, short
 		GroupObject* go;
 		float imat[4][4];
 
+		reset_shards(fmd);
 		invert_m4_m4(imat, obj->obmat);
 
 		for (go = fmd->cutter_group->gobject.first; go; go = go->next)
diff --git a/source/blender/blenkernel/intern/fracture_util.c b/source/blender/blenkernel/intern/fracture_util.c
index 05a6502..b23604a 100644
--- a/source/blender/blenkernel/intern/fracture_util.c
+++ b/source/blender/blenkernel/intern/fracture_util.c
@@ -559,8 +559,23 @@ Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard *ch
 		other_dm = NewBooleanDerivedMesh(left_dm, obj, right_dm, obj, 3);
 
 		/*check for watertightness again, true means do return NULL here*/
-		if (do_check_watertight_other(&other_dm, &output_dm, other, right_dm, &left_dm, mat))
+		if (!other_dm || do_check_watertight_other(&other_dm, &output_dm, other, right_dm, &left_dm, mat))
 		{
+			if (!other_dm) {
+				/* in case of failed boolean op, clean up other dms too before returning NULL */
+				if (left_dm) {
+					left_dm->needsFree = 1;
+					left_dm->release(left_dm);
+					left_dm = NULL;
+				}
+
+				if (output_dm) {
+					output_dm->needsFree = 1;
+					output_dm->release(left_dm);
+					output_dm = NULL;
+				}
+			}
+
 			return NULL;
 		}




More information about the Bf-blender-cvs mailing list