[Bf-blender-cvs] [e63c6cd345b] fracture_modifier: fix attempt for passive fakeparenting with dynamic/external, and first version of combined cuttergroup and procedural (boolean only) fracture

Martin Felke noreply at git.blender.org
Sat Mar 11 18:52:21 CET 2017


Commit: e63c6cd345b9bd804888fcf857a59cf2b1dde9a0
Author: Martin Felke
Date:   Sat Mar 11 18:52:01 2017 +0100
Branches: fracture_modifier
https://developer.blender.org/rBe63c6cd345b9bd804888fcf857a59cf2b1dde9a0

fix attempt for passive fakeparenting with dynamic/external, and first version of combined cuttergroup and procedural (boolean only) fracture

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

M	source/blender/blenkernel/BKE_fracture.h
M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/source/blender/blenkernel/BKE_fracture.h b/source/blender/blenkernel/BKE_fracture.h
index c2ac1d17964..f2268103f1c 100644
--- a/source/blender/blenkernel/BKE_fracture.h
+++ b/source/blender/blenkernel/BKE_fracture.h
@@ -93,7 +93,7 @@ struct DerivedMesh *BKE_shard_create_dm(struct Shard *s, bool doCustomData);
 void BKE_fracture_shard_by_points(struct FracMesh *fmesh, ShardID id, struct FracPointCloud *points, int algorithm,
                                   struct Object *obj, struct DerivedMesh *dm, short inner_material_index, float mat[4][4],
                                   int num_cuts, float fractal, bool smooth, int num_levels, int mode, bool reset, int active_setting,
-                                  int num_settings, char uv_layer[], bool threaded, int solver, float thresh, bool shards_to_islands);
+                                  int num_settings, char uv_layer[], bool threaded, int solver, float thresh, bool shards_to_islands, int override_count);
 
 /* create shards from a base mesh and a set of other objects / cutter planes */
 void BKE_fracture_shard_by_planes(struct FractureModifierData *fmd, struct Object *obj, short inner_material_index, float mat[4][4]);
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index a05c1d1d192..aa986e90647 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -712,7 +712,8 @@ static bool handle_boolean_bisect(FracMesh *fm, Object *obj, int expected_shards
 }
 
 static void do_prepare_cells(FracMesh *fm, cell *cells, int expected_shards, int algorithm, Shard *p, float (*centroid)[3],
-                             DerivedMesh **dm_parent, BMesh** bm_parent, Shard ***tempshards, Shard ***tempresults)
+                             DerivedMesh **dm_parent, BMesh** bm_parent, Shard ***tempshards, Shard ***tempresults, int override_count,
+                             FractureModifierData *fmd)
 {
 	int i;
 	Shard *s = NULL;
@@ -802,6 +803,8 @@ static void do_prepare_cells(FracMesh *fm, cell *cells, int expected_shards, int
 
 	//BLI_lock_thread(LOCK_CUSTOM1);
 	//skipping /deletion pass
+
+
 	for (i = 0; i < expected_shards; i++)
 	{
 		if (fm->cancel == 1) {
@@ -833,7 +836,8 @@ static void do_prepare_cells(FracMesh *fm, cell *cells, int expected_shards, int
 
 			if (!t)
 				continue;
-			if (true) //i < expected_shards)
+
+			if ((override_count == -1) || ((override_count > 0) && (i < override_count+1)))
 			{
 				printf("Deleting shard: %d %d %d\n", i, t->shard_id, t->setting_id);
 				BLI_remlink_safe(&fm->shard_map, t);
@@ -846,6 +850,15 @@ static void do_prepare_cells(FracMesh *fm, cell *cells, int expected_shards, int
 			}
 		}
 	}
+
+	if (override_count > -1) {
+		printf("Deleting island shards!\n");
+		while (fmd->islandShards.first) {
+			Shard *s = fmd->islandShards.first;
+			BLI_remlink_safe(&fmd->islandShards, s);
+			BKE_shard_free(s, false);
+		}
+	}
 	//BLI_unlock_thread(LOCK_CUSTOM1);
 
 	fm->last_expected_shards = expected_shards;
@@ -859,7 +872,7 @@ static void do_prepare_cells(FracMesh *fm, cell *cells, int expected_shards, int
 //static ThreadMutex prep_lock = BLI_MUTEX_INITIALIZER;
 static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, FracMesh *fm, int algorithm, Object *obj, DerivedMesh *dm,
                         short inner_material_index, float mat[4][4], int num_cuts, float fractal, bool smooth, int num_levels, int mode,
-                        bool reset, int active_setting, int num_settings, char uv_layer[64], bool threaded, int solver, float thresh)
+                        bool reset, int active_setting, int num_settings, char uv_layer[64], bool threaded, int solver, float thresh, int override_count)
 {
 	/*Parse voronoi raw data*/
 	int i = 0, j = 0, count = 0;
@@ -874,6 +887,7 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 	bool do_tree = (algorithm != MOD_FRACTURE_BISECT_FAST &&
 					algorithm != MOD_FRACTURE_BISECT_FAST_FILL &&
 					algorithm != MOD_FRACTURE_BOOLEAN_FRACTAL);
+	FractureModifierData *fmd = (FractureModifierData*) modifiers_findByType(obj, eModifierType_Fracture);
 
 	if (p == NULL || reset)
 	{
@@ -965,7 +979,7 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 
 	unit_m4(obmat);
 
-	do_prepare_cells(fm, cells, expected_shards, algorithm, p, &centroid, &dm_parent, &bm_parent, &tempshards, &tempresults);
+	do_prepare_cells(fm, cells, expected_shards, algorithm, p, &centroid, &dm_parent, &bm_parent, &tempshards, &tempresults, override_count, fmd);
 
 	if (fm->last_shard_tree)
 	{
@@ -1609,6 +1623,7 @@ typedef struct FractureData {
 	char uv_layer[64];
 	int solver;
 	float thresh;
+	int override_count;
 } FractureData;
 
 
@@ -1620,7 +1635,7 @@ static void compute_fracture(TaskPool *UNUSED(pool), void *taskdata, int UNUSED(
 	if (fd->totpoints > 0) {
 		parse_cells(fd->voro_cells, fd->totpoints, fd->id, fd->fmesh, fd->algorithm, fd->obj, fd->dm, fd->inner_material_index, fd->mat,
 	                fd->num_cuts, fd->fractal, fd->smooth, fd->num_levels,fd->mode, fd->reset, fd->active_setting, fd->num_settings, fd->uv_layer,
-		            true, fd->solver, fd->thresh);
+		            true, fd->solver, fd->thresh, fd->override_count);
 	}
 }
 
@@ -1628,7 +1643,7 @@ static void compute_fracture(TaskPool *UNUSED(pool), void *taskdata, int UNUSED(
 static FractureData segment_cells(cell *voro_cells, int startcell, int totcells, FracMesh *fmesh, ShardID id, FracPointCloud *pointcloud,
                     int algorithm, Object *obj, DerivedMesh *dm, short
                     inner_material_index, float mat[4][4], int num_cuts, float fractal, bool smooth, int num_levels, int mode,
-                    bool reset, int active_setting, int num_settings, char uv_layer[64], int solver, float thresh)
+                    bool reset, int active_setting, int num_settings, char uv_layer[64], int solver, float thresh, int override_count)
 {
 	FractureData fd;
 	fd.fmesh = fmesh;
@@ -1650,6 +1665,7 @@ static FractureData segment_cells(cell *voro_cells, int startcell, int totcells,
 	strncpy(fd.uv_layer, uv_layer, 64);
 	fd.solver = solver;
 	fd.thresh = thresh;
+	fd.override_count = override_count;
 
 	//cell start pointer, only take fd.totpoints cells out
 	fd.voro_cells = voro_cells + startcell;
@@ -1660,7 +1676,7 @@ static FractureData segment_cells(cell *voro_cells, int startcell, int totcells,
 void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *pointcloud, int algorithm, Object *obj, DerivedMesh *dm, short
                                   inner_material_index, float mat[4][4], int num_cuts, float fractal, bool smooth, int num_levels, int mode,
                                   bool reset, int active_setting, int num_settings, char uv_layer[64], bool threaded, int solver, float thresh,
-                                  bool shards_to_islands)
+                                  bool shards_to_islands, int override_count)
 {
 	int n_size = 8;
 	
@@ -1743,7 +1759,8 @@ void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *p
 			//give each task a segment of the shards...
 			int startcell = i * totcell;
 			FractureData fd = segment_cells(voro_cells, startcell, totcell, fmesh, id, pointcloud, algorithm, obj, dm, inner_material_index,
-											mat, num_cuts, fractal,smooth, num_levels, mode, reset, active_setting, num_settings, uv_layer, solver, thresh);
+											mat, num_cuts, fractal,smooth, num_levels, mode, reset, active_setting, num_settings, uv_layer,
+											solver, thresh, override_count);
 			fdata[i] = fd;
 		}
 
@@ -1754,7 +1771,8 @@ void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *p
 			int startcell = remainder_start;
 			printf("REMAINDER %d %d\n", startcell, remainder);
 			fdata[num] = segment_cells(voro_cells, startcell, remainder, fmesh, id, pointcloud, algorithm, obj, dm, inner_material_index,
-									   mat, num_cuts, fractal,smooth, num_levels, mode, reset, active_setting, num_settings, uv_layer, solver, thresh);
+										mat, num_cuts, fractal,smooth, num_levels, mode, reset, active_setting, num_settings, uv_layer,
+										solver, thresh, override_count);
 		}
 
 		for (i = 0; i < num+1; i++) {
@@ -1768,7 +1786,7 @@ void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *p
 	else {
 	/*Evaluate result*/
 	parse_cells(voro_cells, pointcloud->totpoints, id, fmesh, algorithm, obj, dm, inner_material_index, mat,
-	            num_cuts, fractal, smooth, num_levels, mode, reset, active_setting, num_settings, uv_layer, false, solver, thresh);
+	            num_cuts, fractal, smooth, num_levels, mode, reset, active_setting, num_settings, uv_layer, false, solver, thresh, override_count);
 	}
 
 	/*Free structs in C++ area of memory */
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 4e783602347..c6fbd288ddc 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -3953,11 +3953,12 @@ static bool do_update_modifier(Scene* scene, Object* ob, RigidBodyWorld *rbw, bo
 				BKE_rigidbody_update_ob_array(rbw, false);
 			}
 		}
-		else
+		//else
 		{
 			if (rebuild || is_zero_m4(fmd->passive_parent_mat))
 			{
 				copy_m4_m4(fmd->passive_parent_mat, ob->obmat);
+				print_m4("Passivemat: \n", fmd->passive_parent_mat);
 			}
 
 			//print_m4("Obmat: \n", ob->obmat);
@@ -4392,7 +4393,7 @@ static bool do_sync_modifier(ModifierData *md, Object *ob, RigidBodyWorld *rbw,
 		fmd = (FractureModifierData *)md;
 		bool mode = fmd->fracture_mode == MOD_FRACTURE_EXTERNAL;
 
-		exploOK = !fmd->explo_shared || (fmd->explo_shared && fmd->frac_mesh && fmd->dm) || mode;
+		exploOK = !fmd->explo_shared || (fmd->explo_shared && fmd->frac_mesh && fmd->dm) || mode || fmd->is_dynamic_external;
 
 		if (isModifierActive(fmd) && exploOK) {
 			modFound = true;
@@ -4418,6 +4419,13 @@ static bool do_sync_modifier(ModifierData *md, Object *ob, RigidBodyWorld *rbw,
 				}
 
 				if (ob->rigidbody_object->type == RBO_TYPE_ACTIVE

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list