[Bf-blender-cvs] [3c8876c] fracture_modifier: new parameter "stability factor" (for constraints, compounds) and resetting all shards by default now on refracture, except in mousebased fracture (faster to keep unchanged shards there)

Martin Felke noreply at git.blender.org
Sun Oct 25 09:42:44 CET 2015


Commit: 3c8876c5a18a7cf2d84ead582a9c92a9facda04b
Author: Martin Felke
Date:   Sun Oct 25 09:27:37 2015 +0100
Branches: fracture_modifier
https://developer.blender.org/rB3c8876c5a18a7cf2d84ead582a9c92a9facda04b

new parameter "stability factor" (for constraints, compounds) and resetting all shards by default now on refracture, except in mousebased fracture (faster to keep unchanged shards there)

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

M	release/scripts/startup/bl_operators/presets.py
M	release/scripts/startup/bl_ui/properties_physics_fracture.py
M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/editors/object/object_modifier.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 06f8eac..1366948 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -672,7 +672,8 @@ class AddPresetFracture(AddPresetBase, Operator):
         "fracture.use_compounds",
         "fracture.impulse_dampening",
         "fracture.directional_factor",
-        "fracture.minimum_impulse"
+        "fracture.minimum_impulse",
+        "fracture.mass_threshold_factor"
     ]
 
     preset_subdir = "fracture"
diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index 615c100..1920f18 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -136,7 +136,7 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel):
             box.label("Inner Vertex Group:")
             box.prop_search(md, "inner_vertex_group", ob, "vertex_groups", text = "")
 
-        layout.operator("object.fracture_refresh", text="Execute Fracture", icon='MOD_EXPLODE')
+        layout.operator("object.fracture_refresh", text="Execute Fracture", icon='MOD_EXPLODE').reset = True
 
 class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel):
     bl_label = "Fracture Constraint Settings"
@@ -191,6 +191,7 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel):
         col.prop(md, "solver_iterations_override")
         col.prop(md, "cluster_solver_iterations_override")
         layout.prop(md, "use_mass_dependent_thresholds")
+        layout.prop(md, "mass_threshold_factor")
 
 class PHYSICS_PT_fracture_utilities(PhysicButtonsPanel, Panel):
     bl_label = "Fracture Utilities"
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 40ae349..41389d5 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -785,7 +785,7 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 					algorithm != MOD_FRACTURE_BISECT_FAST_FILL &&
 					algorithm != MOD_FRACTURE_BOOLEAN_FRACTAL);
 
-	if (p == NULL)
+	if (p == NULL || reset)
 	{
 		if (fm->last_shard_tree)
 		{
@@ -799,28 +799,22 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 			fm->last_shards = NULL;
 		}
 
-		return;
+		if (!p)
+			return;
 	}
 
-/*	if (mode == MOD_FRACTURE_PREFRACTURED && reset)
+	if (mode == MOD_FRACTURE_PREFRACTURED && reset)
 	{
-		Shard *t = fm->shard_map.first, *next = NULL;
-		while (t && t->next)
+		while (fm->shard_map.first)
 		{
-			next = t->next;
-
-			if (t != p)
-			{
-				BLI_remlink_safe(&fm->shard_map, t);
-				printf("Resetting shard: %d\n", t->shard_id);
-				BKE_shard_free(t, true);
-			}
-
-			t = next;
+			Shard *t = fm->shard_map.first;
+			BLI_remlink_safe(&fm->shard_map, t);
+			printf("Resetting shard: %d\n", t->shard_id);
+			BKE_shard_free(t, true);
 		}
-	}*/
+	}
 
-	if (mode == MOD_FRACTURE_PREFRACTURED /*&& !reset*/)
+	if (mode == MOD_FRACTURE_PREFRACTURED && !reset)
 	{
 		//rebuild tree
 		if (!fm->last_shard_tree && (fm->shard_count > 0) && mode == MOD_FRACTURE_PREFRACTURED)
@@ -2061,6 +2055,12 @@ void BKE_fracture_load_settings(FractureModifierData *fmd, FractureSetting *fs)
 	// add more constraint types, as in special ones (3x generic and so on)
 	fmd->cluster_constraint_type = fs->cluster_constraint_type;
 	fmd->constraint_target = fs->constraint_target;
+
+	fmd->impulse_dampening = fs->impulse_dampening;
+	fmd->minimum_impulse = fs->minimum_impulse;
+	fmd->directional_factor = fs->directional_factor;
+	fmd->mass_threshold_factor = fs->mass_threshold_factor;
+	fmd->use_compounds = fs->use_compounds;
 }
 
 void BKE_fracture_store_settings(FractureModifierData *fs, FractureSetting *fmd)
@@ -2131,4 +2131,10 @@ void BKE_fracture_store_settings(FractureModifierData *fs, FractureSetting *fmd)
 	// add more constraint types, as in special ones (3x generic and so on)
 	fmd->cluster_constraint_type = fs->cluster_constraint_type;
 	fmd->constraint_target = fs->constraint_target;
+
+	fmd->impulse_dampening = fs->impulse_dampening;
+	fmd->minimum_impulse = fs->minimum_impulse;
+	fmd->directional_factor = fs->directional_factor;
+	fmd->mass_threshold_factor = fs->mass_threshold_factor;
+	fmd->use_compounds = fs->use_compounds;
 }
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index a3996faa..fd86064 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -189,7 +189,7 @@ void BKE_rigidbody_calc_threshold(float max_con_mass, FractureModifierData *rmd,
 		return;
 	}
 
-	max_thresh = rmd->breaking_threshold;
+	max_thresh = thresh = rmd->breaking_threshold;
 	if ((con->mi1->rigidbody != NULL) && (con->mi2->rigidbody != NULL)) {
 		con_mass = con->mi1->rigidbody->mass + con->mi2->rigidbody->mass;
 
@@ -198,6 +198,11 @@ void BKE_rigidbody_calc_threshold(float max_con_mass, FractureModifierData *rmd,
 			thresh = (con_mass / max_con_mass) * max_thresh;
 		}
 
+		if (rmd->mass_threshold_factor > 0.0f)
+		{
+			thresh = thresh * con_mass * rmd->mass_threshold_factor;
+		}
+
 		con->breaking_threshold = thresh;
 	}
 }
@@ -3096,7 +3101,7 @@ static bool do_update_modifier(Scene* scene, Object* ob, RigidBodyWorld *rbw, bo
 				rbsc->num_solver_iterations = iterations;
 			}
 
-			if ((fmd->use_mass_dependent_thresholds)) {
+			if ((fmd->use_mass_dependent_thresholds || fmd->mass_threshold_factor > 0.0f)) {
 				BKE_rigidbody_calc_threshold(max_con_mass, fmd, rbsc);
 			}
 
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 01278ca..fbc81a2 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2420,7 +2420,7 @@ static int fracture_poll(bContext *C)
 	return edit_modifier_poll_generic(C, &RNA_FractureModifier, 0);
 }
 
-static int fracture_refresh_exec(bContext *C, wmOperator *UNUSED(op))
+static int fracture_refresh_exec(bContext *C, wmOperator *op)
 {
 	Object *obact = ED_object_active_context(C);
 	Scene *scene = CTX_data_scene(C);
@@ -2432,6 +2432,7 @@ static int fracture_refresh_exec(bContext *C, wmOperator *UNUSED(op))
 	//RegionView3D *rv3d = CTX_wm_region_view3d(C);
 
 	rmd = (FractureModifierData *)modifiers_findByType(obact, eModifierType_Fracture);
+	rmd->reset_shards = RNA_boolean_get(op->ptr, "reset");
 
 	if (scene->rigidbody_world != NULL)
 	{
@@ -2563,6 +2564,8 @@ void OBJECT_OT_fracture_refresh(wmOperatorType *ot)
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 	edit_modifier_properties(ot);
+
+	RNA_def_boolean(ot->srna, "reset", false, "Reset Shards", "Reset all shards in next refracture, instead of keeping similar ones");
 }
 
 /****************** rigidbody constraint refresh operator *********************/
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index aa928b3..9c01795 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1587,6 +1587,11 @@ typedef struct FractureSetting {
 	float physics_mesh_scale;
 	float grease_offset;
 
+	float impulse_dampening;
+	float minimum_impulse;
+	float directional_factor;
+	float mass_threshold_factor;
+
 	int use_constraints;
 	int use_compounds;
 	int use_mass_dependent_thresholds;
@@ -1681,6 +1686,7 @@ typedef struct FractureModifierData {
 	float impulse_dampening;
 	float minimum_impulse;
 	float directional_factor;
+	float mass_threshold_factor;
 
 	/* flags */
 	int refresh;
@@ -1718,7 +1724,7 @@ typedef struct FractureModifierData {
 	float max_vol;
 	int last_frame;
 
-	char pad[4];
+	//char pad[4];
 } FractureModifierData;
 
 typedef struct DataTransferModifierData {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 096b38f..5a0f813 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5207,6 +5207,14 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
 	                         "Determines how strong the remaining impulse must be for continuing damage propagation");
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "mass_threshold_factor", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "mass_threshold_factor");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Stability Factor",
+	                         "Determines how 'stable' an object is, by multiplying threshold * mass * this factor, 0 means disabled, 1 means highest mass					                          dependent stability");
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 static void rna_def_modifier_datatransfer(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 2bc767d..ada9788 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -134,7 +134,6 @@ static void initData(ModifierData *md)
 	zero_m4(fmd->origmat);
 	fmd->breaking_threshold = 10.0f;
 	fmd->use_constraints = false;
-	fmd->use_compounds = false;
 	fmd->contact_dist = 1.0f;
 	fmd->use_mass_dependent_thresholds = false;
 	fmd->explo_shared = false;
@@ -207,9 +206,11 @@ static void initData(ModifierData *md)
 	fmd->reset_shards = false;
 	fmd->active_setting = -1;
 
+	fmd->use_compounds = false;
 	fmd->impulse_dampening = 0.05f;
 	fmd->directional_factor = 0.0f;
 	fmd->minimum_impulse = 0.1f;
+	fmd->mass_threshold_factor = 0.0f;
 }
 
 static void freeMeshIsland(FractureModifierData *rmd, MeshIsland *mi, bool remove_rigidbody)
@@ -1449,6 +1450,8 @@ static void copyData(ModifierData *md, ModifierData *target)
 	trmd->impulse_dampening = 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list