[Bf-blender-cvs] [1e5c376] fracture_modifier: fix: crash when using fractal boolean with 1 shard and split shards and other misbehavior (boolean did not create valid rigidbodies, so objects were stuck in the air with 1 shard and fast bisect / fast bisect fill created 1 shard too much everytime)

Martin Felke noreply at git.blender.org
Thu May 7 19:53:47 CEST 2015


Commit: 1e5c376e0ff073a6fff787254b4c52ec445c4204
Author: Martin Felke
Date:   Thu May 7 19:52:26 2015 +0200
Branches: fracture_modifier
https://developer.blender.org/rB1e5c376e0ff073a6fff787254b4c52ec445c4204

fix: crash when using fractal boolean with 1 shard and split shards and other misbehavior (boolean did not create valid rigidbodies, so objects were stuck in the air with 1 shard and fast bisect / fast bisect fill created 1 shard too much everytime)

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

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

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

diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 556f1a2..01a5145 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -647,7 +647,18 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 		}
 	}
 	else {
-		handle_fast_bisect(fm, expected_shards, algorithm, &bm_parent, obmat, centroid, inner_material_index, parent_id, tempshards, &tempresults);
+
+		if (expected_shards == 1)
+		{
+			/* do not fracture case */
+			tempresults[0] = p;
+			p->shard_id = -1;
+		}
+		else
+		{
+			handle_fast_bisect(fm, expected_shards, algorithm, &bm_parent, obmat, centroid, inner_material_index, parent_id,
+			                   tempshards, &tempresults);
+		}
 	}
 
 	if (bm_parent != NULL) {
@@ -661,7 +672,8 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 		dm_parent = NULL;
 	}
 
-	if (dm_p != NULL) {
+	/*only used with fractal, and is doubly freed in case of 1 shard (doubled) */
+	if (dm_p != NULL && expected_shards > 2) {
 		dm_p->needsFree = 1;
 		dm_p->release(dm_p);
 		dm_p = NULL;
diff --git a/source/blender/blenkernel/intern/fracture_util.c b/source/blender/blenkernel/intern/fracture_util.c
index 459ed6d..0c7d9b1 100644
--- a/source/blender/blenkernel/intern/fracture_util.c
+++ b/source/blender/blenkernel/intern/fracture_util.c
@@ -543,8 +543,8 @@ Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard *ch
 	right_dm = dm_parent;
 	output_dm = NewBooleanDerivedMesh(right_dm, obj, left_dm, obj, 1); /*1 == intersection, 3 == difference*/
 
-	/*check for watertightness*/
-	if (do_check_watertight(&output_dm, &bm, &left_dm, right_dm, other, mat))
+	/*check for watertightness, but for fractal only*/
+	if (other != NULL && do_check_watertight(&output_dm, &bm, &left_dm, right_dm, other, mat))
 	{
 		return NULL;
 	}
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 104e9fc..196685a 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -1001,7 +1001,10 @@ static FracPointCloud get_points_global(FractureModifierData *emd, Object *ob, D
 		if (emd->frac_algorithm == MOD_FRACTURE_BISECT_FAST || emd->frac_algorithm == MOD_FRACTURE_BISECT_FAST_FILL ||
 		    emd->frac_algorithm == MOD_FRACTURE_BOOLEAN_FRACTAL) {
 			/* XXX need double amount of shards, because we create 2 islands at each cut... so this matches the input count */
-			count *= 2;
+			if ((count > 1) || emd->frac_algorithm == MOD_FRACTURE_BOOLEAN_FRACTAL) {
+				count--;
+				count *= 2;
+			}
 		}
 
 		BLI_srandom(emd->point_seed);




More information about the Bf-blender-cvs mailing list