[Bf-blender-cvs] [be6d3df] fracture_modifier: made threading optional via a checkbox

Martin Felke noreply at git.blender.org
Mon Aug 8 14:07:43 CEST 2016


Commit: be6d3df29be5c6edb52c2f20087fc8ef8c84e699
Author: Martin Felke
Date:   Mon Aug 8 14:07:30 2016 +0200
Branches: fracture_modifier
https://developer.blender.org/rBbe6d3df29be5c6edb52c2f20087fc8ef8c84e699

made threading optional via a checkbox

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

M	source/blender/blenkernel/BKE_fracture.h
M	source/blender/blenkernel/intern/fracture.c
M	source/blender/editors/object/object_modifier.c
M	source/blender/makesrna/intern/rna_modifier.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 0094bb3..514845a 100644
--- a/source/blender/blenkernel/BKE_fracture.h
+++ b/source/blender/blenkernel/BKE_fracture.h
@@ -92,7 +92,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[]);
+                                  int num_settings, char uv_layer[], bool threaded);
 
 /* 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 fb52fa6..5e99ad4 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -1591,7 +1591,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 reset, int active_setting, int num_settings, char uv_layer[64], bool threaded)
 {
 	int n_size = 8;
 	
@@ -1663,7 +1663,7 @@ void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *p
 	container_compute_cells(voro_container, voro_cells);
 
 	/*Disable for fast bisect/fill, dynamic and mousebased for now -> errors and crashes */
-	if (mode != MOD_FRACTURE_DYNAMIC && reset == true && algorithm != MOD_FRACTURE_BISECT_FAST && algorithm != MOD_FRACTURE_BISECT_FAST_FILL) {
+	if (mode != MOD_FRACTURE_DYNAMIC && reset == true && algorithm != MOD_FRACTURE_BISECT_FAST && algorithm != MOD_FRACTURE_BISECT_FAST_FILL && threaded == true) {
 		/*segment cells, give each thread a chunk to work on */
 		pool = BLI_task_pool_create(scheduler, NULL);
 		num = BLI_task_scheduler_num_threads(scheduler);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 6c3a30e..3f057e2 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -911,14 +911,14 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
 	int mode_orig = ob->mode;
 
 	//if we have a running fracture job, dont remove the modifier
-	if (md && md->type == eModifierType_Fracture)
+	/*if (md && md->type == eModifierType_Fracture)
 	{
 		FractureModifierData* fmd = (FractureModifierData*)md;
 		if (fmd->execute_threaded && fmd->frac_mesh && fmd->frac_mesh->running == 1)
 		{
 			return OPERATOR_CANCELLED;
 		}
-	}
+	}*/
 	
 	if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
 		return OPERATOR_CANCELLED;
@@ -2475,7 +2475,7 @@ static int fracture_refresh_exec(bContext *C, wmOperator *op)
 	WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
 	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, NULL);
 	
-	if (!rmd->execute_threaded) {
+	/*if (!rmd->execute_threaded)*/ {
 #if 0
 		float vec[3] = {0.0f, 0.0f, 0.0f};
 		if (rv3d != NULL)
@@ -2492,6 +2492,7 @@ static int fracture_refresh_exec(bContext *C, wmOperator *op)
 		DAG_id_tag_update(&obact->id, OB_RECALC_DATA);
 		WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obact);
 	}
+#if 0
 	else {
 		/* job stuff */
 		int factor, verts, shardprogress, halvingprogress, totalprogress;
@@ -2528,6 +2529,7 @@ static int fracture_refresh_exec(bContext *C, wmOperator *op)
 
 		WM_jobs_start(CTX_wm_manager(C), wm_job);
 	}
+#endif
 
 	return OPERATOR_FINISHED;
 }
@@ -3475,13 +3477,13 @@ static void convert_startjob(void *customdata, short *stop, short *do_update, fl
 
 static int rigidbody_convert_keyframes_exec(bContext *C, wmOperator *op)
 {
-	Object *obact = ED_object_active_context(C);
+	//Object *obact = ED_object_active_context(C);
 	Scene *scene = CTX_data_scene(C);
-	float cfra = BKE_scene_frame_get(scene);
+	//float cfra = BKE_scene_frame_get(scene);
 	Group *gr;
 	FractureModifierData *rmd;
-	FractureJob *fj;
-	wmJob* wm_job;
+	//FractureJob *fj;
+	//wmJob* wm_job;
 
 	bool convertable = true;
 
@@ -3528,6 +3530,7 @@ static int rigidbody_convert_keyframes_exec(bContext *C, wmOperator *op)
 
 				gr = BKE_group_add(G.main, "Converted");
 
+#if 0
 				if (rmd->execute_threaded)
 				{
 					PointerRNA *ptr;
@@ -3566,8 +3569,9 @@ static int rigidbody_convert_keyframes_exec(bContext *C, wmOperator *op)
 				}
 				else
 				{
+#endif
 					convert_modifier_to_keyframes(rmd, gr, selob, scene, start, end, threshold, clean_chan);
-				}
+//				}
 			}
 		}
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index c23ae79..f6a50d4 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5967,7 +5967,7 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "execute_threaded", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "execute_threaded", false);
-	RNA_def_property_ui_text(prop, "Execute as threaded job (WIP)", "Execute the fracture as threaded job, Warning: WIP, still may crash");
+	RNA_def_property_ui_text(prop, "Execute multithreaded (WIP)", "Execute the fracture with multiple threads, Warning: Only use on complex geometry, may produce errors on simple geometry!");
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index a42c92e..826b51b 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -1497,7 +1497,7 @@ static void do_fracture(FractureModifierData *fmd, ShardID id, Object *obj, Deri
 		if (points.totpoints > 0) {
 			BKE_fracture_shard_by_points(fmd->frac_mesh, id, &points, fmd->frac_algorithm, obj, dm, mat_index, mat,
 			                             fmd->fractal_cuts, fmd->fractal_amount, fmd->use_smooth, fmd->fractal_iterations,
-			                             fmd->fracture_mode, fmd->reset_shards, fmd->active_setting, num_settings, fmd->uvlayer_name);
+			                             fmd->fracture_mode, fmd->reset_shards, fmd->active_setting, num_settings, fmd->uvlayer_name, fmd->execute_threaded);
 		}
 
 		/*TODO, limit this to settings shards !*/
@@ -3421,10 +3421,13 @@ static void do_post_island_creation(FractureModifierData *fmd, Object *ob, Deriv
 	fmd->refresh_constraints = true;
 	fmd->refresh_autohide = true;
 
+#if 0
 	if (fmd->execute_threaded) {
 		/* job done */
 		fmd->frac_mesh->running = 0;
 	}
+#endif
+
 }
 
 static void do_refresh_constraints(FractureModifierData *fmd, Object *ob)
@@ -3597,8 +3600,8 @@ static DerivedMesh *doSimulate(FractureModifierData *fmd, Object *ob, DerivedMes
 		((fmd->fracture_mode == MOD_FRACTURE_DYNAMIC) &&
 		(fmd->current_mi_entry && fmd->current_mi_entry->is_new)))
 	{
-		if ((fmd->refresh) || (fmd->refresh_constraints && !fmd->execute_threaded) ||
-			(fmd->refresh_constraints && fmd->execute_threaded && fmd->frac_mesh && fmd->frac_mesh->running == 0))
+		if ((fmd->refresh) || (fmd->refresh_constraints /*&& !fmd->execute_threaded*/)) // ||
+			//(fmd->refresh_constraints && fmd->execute_threaded && fmd->frac_mesh && fmd->frac_mesh->running == 0))
 		{
 			/* if we changed the fracture parameters */
 			freeData_internal(fmd, fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED, true);
@@ -3887,10 +3890,10 @@ static void do_modifier(FractureModifierData *fmd, Object *ob, DerivedMesh *dm)
 			}
 
 			/*only in prefracture case... and not even working there... :S*/
-			if (fmd->execute_threaded && fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED)
+			/*if (fmd->execute_threaded && fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED)
 			{
 				fmd->frac_mesh->running = 1;
-			}
+			}*/
 		}
 
 		if (fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED)
@@ -4011,10 +4014,10 @@ static DerivedMesh *do_prefractured(FractureModifierData *fmd, Object *ob, Deriv
 	/* TODO_4, for proper threading / job support make sure to use locks, spinlocks, and if possible remove those running / cancel flags */
 	/* make this local data in job struct maybe, fracturing could perhaps run parallel, but assembling the shards to a derivedmesh not, since
 	* addition order matters */
-	if (fmd->frac_mesh != NULL && fmd->frac_mesh->running == 1 && fmd->execute_threaded) {
+//	if (fmd->frac_mesh != NULL && fmd->frac_mesh->running == 1 && fmd->execute_threaded) {
 		/* skip modifier execution when fracture job is running */
-		return final_dm;
-	}
+//		return final_dm;
+//	}
 
 	if (fmd->refresh)
 	{




More information about the Bf-blender-cvs mailing list