[Bf-blender-cvs] [479a1a9] fracture_modifier: separate autohide and automerge distances, autohide alone is ok for glass and is faster, while automerge is more useful in conjunction with smooth objects and fix normals, to hide the cracks better, also automerge caused errors with thin glass objects like window panes

Martin Felke noreply at git.blender.org
Sat Sep 26 17:47:50 CEST 2015


Commit: 479a1a9a1a5a45aad69cff55c2c005c0caca80d6
Author: Martin Felke
Date:   Sat Sep 26 17:47:18 2015 +0200
Branches: fracture_modifier
https://developer.blender.org/rB479a1a9a1a5a45aad69cff55c2c005c0caca80d6

separate autohide and automerge distances, autohide alone is ok for glass and is faster, while automerge is more useful in conjunction with smooth objects and fix normals, to hide the cracks better, also automerge caused errors with thin glass objects like window panes

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

M	release/scripts/startup/bl_ui/properties_physics_fracture.py
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_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index bc5205b..a6bc298 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -181,7 +181,9 @@ class PHYSICS_PT_fracture_utilities(PhysicButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
         md = context.fracture
-        layout.prop(md, "autohide_dist")
+        col = layout.column(align=True)
+        col.prop(md, "autohide_dist")
+        col.prop(md, "automerge_dist")
         row = layout.row()
         row.prop(md, "fix_normals")
         row.prop(md, "nor_range")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index de06329..178a039 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1594,7 +1594,9 @@ typedef struct FractureModifierData {
 	float origmat[4][4];
 	float breaking_threshold;
 	float cluster_breaking_threshold;
-	float contact_dist, autohide_dist;
+	float contact_dist;
+	float autohide_dist;
+	float automerge_dist;
 	float splinter_length;
 	float nor_range;
 	float fractal_amount;
@@ -1636,7 +1638,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 65d5581..cc51c78 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -894,6 +894,13 @@ static void rna_RigidBodyModifier_autohide_dist_set(PointerRNA *ptr, float value
 	rmd->refresh_autohide = true;
 }
 
+static void rna_RigidBodyModifier_automerge_dist_set(PointerRNA *ptr, float value)
+{
+	FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+	rmd->automerge_dist = value;
+	rmd->refresh_autohide = true;
+}
+
 static void rna_RigidBodyModifier_cluster_breaking_angle_set(PointerRNA *ptr, float value)
 {
 	FractureModifierData *rmd = (FractureModifierData*)ptr->data;
@@ -4887,6 +4894,14 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Autohide Distance", "Distance between faces below which both faces should be hidden");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "automerge_dist", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "automerge_dist");
+	RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyModifier_automerge_dist_set", NULL);
+	RNA_def_property_range(prop, 0.0f, 10.0f);
+	RNA_def_property_ui_text(prop, "Automerge Distance",
+ "Distance between faces below which vertices of both faces should be merged; (costs performance, use with smooth objects and fix normals to better hide cracks)");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	prop = RNA_def_property(srna, "breaking_percentage_weighted", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "breaking_percentage_weighted", false);
 	RNA_def_property_ui_text(prop, "Weighted Percentage", "Modify breaking percentage by threshold weights");
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index a6d6d06..a9d6219 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -160,6 +160,7 @@ static void initData(ModifierData *md)
 	fmd->auto_execute = false;
 	fmd->face_pairs = NULL;
 	fmd->autohide_dist = 0.0f;
+	fmd->automerge_dist = 0.0f;
 
 	fmd->breaking_percentage_weighted = false;
 	fmd->breaking_angle_weighted = false;
@@ -1351,6 +1352,7 @@ static void copyData(ModifierData *md, ModifierData *target)
 
 	trmd->auto_execute = rmd->auto_execute;
 	trmd->autohide_dist = rmd->autohide_dist;
+	trmd->automerge_dist = rmd->automerge_dist;
 
 	trmd->solver_iterations_override = rmd->solver_iterations_override;
 
@@ -2654,9 +2656,13 @@ static DerivedMesh *do_autoHide(FractureModifierData *fmd, DerivedMesh *dm)
 	}
 
 	BMO_op_callf(bm, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "delete_keep_normals geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES);
-	BMO_op_callf(bm, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
+
+	if (fmd->automerge_dist > 0) {
+		//separate this, because it costs performance and might not work so well with thin objects, but its useful for smooth objects
+		BMO_op_callf(bm, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
 	             "automerge_keep_normals verts=%hv dist=%f", BM_ELEM_SELECT,
-	             fmd->autohide_dist * 10); /*need to merge larger cracks*/
+	             fmd->automerge_dist); /*need to merge larger cracks*/
+	}
 
 	//dissolve sharp edges with limit dissolve
 	BMO_op_callf(bm, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "dissolve_limit_keep_normals "




More information about the Bf-blender-cvs mailing list