[Bf-blender-cvs] [1010cdf421e] fracture_modifier: added option to only output verts, meta threshold max is 100 now

Martin Felke noreply at git.blender.org
Thu Dec 21 17:12:29 CET 2017


Commit: 1010cdf421ec32f4ea07418a1ef8e272bb764534
Author: Martin Felke
Date:   Thu Dec 21 17:12:17 2017 +0100
Branches: fracture_modifier
https://developer.blender.org/rB1010cdf421ec32f4ea07418a1ef8e272bb764534

added option to only output verts, meta threshold max is 100 now

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

M	release/scripts/startup/bl_ui/properties_physics_fracture.py
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_fracture.c
M	source/blender/makesrna/intern/rna_meta.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 ccb57c5bb8e..1266d81552e 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -283,9 +283,10 @@ class PHYSICS_PT_fracture_utilities(PhysicButtonsPanel, Panel):
         row.prop(md, "keep_distort")
         row.prop(md, "do_merge")
         row = layout.row()
-        row.prop(md, "fix_normals")
         row.prop(md, "use_centroids")
+        row.prop(md, "use_vertices")
         row = layout.row()
+        row.prop(md, "fix_normals")
         row.prop(md, "nor_range")
 
         col = layout.column(align=True)
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 85ffff5239a..1eb417e6e8f 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1797,6 +1797,7 @@ typedef struct FractureModifierData {
 	int deform_angle_weighted;
 	int deform_distance_weighted;
 	int use_centroids;
+	int use_vertices;
 
 	/* internal flags */
 	int use_experimental;
@@ -1819,7 +1820,7 @@ typedef struct FractureModifierData {
 	short mat_ofs_intersect;
 	short mat_ofs_difference;
 
-	//char pad[4];
+	char pad[4];
 } FractureModifierData;
 
 typedef struct DataTransferModifierData {
diff --git a/source/blender/makesrna/intern/rna_fracture.c b/source/blender/makesrna/intern/rna_fracture.c
index 86250bfd618..f320a8800c5 100644
--- a/source/blender/makesrna/intern/rna_fracture.c
+++ b/source/blender/makesrna/intern/rna_fracture.c
@@ -1418,5 +1418,10 @@ void RNA_def_fracture(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Use Centroids", "Only output the meshisland centroids as vertices");
 	//RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "use_vertices", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "use_vertices", false);
+	RNA_def_property_ui_text(prop, "Use Vertices", "Only output the meshisland vertices");
+	//RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	RNA_api_fracture(brna, srna);
 }
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c
index 91a65c7ccc5..bd309e0e325 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -337,7 +337,7 @@ static void rna_def_metaball(BlenderRNA *brna)
 	
 	prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "thresh");
-	RNA_def_property_range(prop, 0.0f, 5.0f);
+	RNA_def_property_range(prop, 0.0f, 100.0f);
 	RNA_def_property_ui_text(prop, "Threshold", "Influence of meta elements");
 	RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
 
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 412a7aa0116..8ad43b0a7de 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -255,6 +255,7 @@ static void initData(ModifierData *md)
 	fmd->grid_resolution[2] = 10;
 
 	fmd->use_centroids = false;
+	fmd->use_vertices = false;
 }
 
 //XXX TODO, freeing functionality should be in BKE too
@@ -1853,6 +1854,7 @@ static void copyData(ModifierData *md, ModifierData *target)
 
 	copy_v3_v3_int(trmd->grid_resolution, rmd->grid_resolution);
 	trmd->use_centroids = rmd->use_centroids;
+	trmd->use_vertices = rmd->use_vertices;
 }
 
 //XXXX TODO, is BB really useds still ? aint there exact volume calc now ?
@@ -3415,6 +3417,21 @@ static void optimize_automerge(FractureModifierData *fmd)
 	printf("remaining | removed groups: %d | %d\n", count, removed);
 }
 
+static void centroids_to_verts(FractureModifierData* fmd, BMesh* bm, Object* ob)
+{
+	MeshIsland *mi;
+	//only add verts where centroids are...
+	float imat[4][4];
+	invert_m4_m4(imat, ob->obmat);
+
+	for (mi = fmd->meshIslands.first; mi; mi = mi->next)
+	{
+		float co[3];
+		mul_v3_m4v3(co, imat, mi->rigidbody->pos);
+		BM_vert_create(bm, co, NULL, BM_CREATE_NOP);
+	}
+}
+
 static DerivedMesh *do_autoHide(FractureModifierData *fmd, DerivedMesh *dm, Object *ob)
 {
 	int totpoly = dm->getNumPolys(dm);
@@ -3425,19 +3442,9 @@ static DerivedMesh *do_autoHide(FractureModifierData *fmd, DerivedMesh *dm, Obje
 	int del_faces = 0;
 	bool do_merge = fmd->do_merge;
 
-	if (fmd->use_centroids)
+	if (fmd->use_centroids && !fmd->use_vertices)
 	{
-		MeshIsland *mi;
-		//only add verts where centroids are...
-		float imat[4][4];
-		invert_m4_m4(imat, ob->obmat);
-
-		for (mi = fmd->meshIslands.first; mi; mi = mi->next)
-		{
-			float co[3];
-			mul_v3_m4v3(co, imat, mi->rigidbody->pos);
-			BM_vert_create(bm, co, NULL, BM_CREATE_NOP);
-		}
+		centroids_to_verts(fmd, bm, ob);
 	}
 	else {
 		DM_to_bmesh_ex(dm, bm, true);
@@ -3502,6 +3509,16 @@ static DerivedMesh *do_autoHide(FractureModifierData *fmd, DerivedMesh *dm, Obje
 		BM_mesh_elem_hflag_enable_all(bm, BM_FACE | BM_EDGE | BM_VERT , BM_ELEM_SELECT, false);
 	}
 
+	if (fmd->use_vertices)
+	{	//only output verts
+		BMO_op_callf(bm, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "delete geom=%aef context=%i", DEL_EDGESFACES);
+
+		if (fmd->use_centroids)
+		{
+			centroids_to_verts(fmd, bm, ob);
+		}
+	}
+
 	if (fmd->automerge_dist > 0 && do_merge) {
 
 		//separate this, because it costs performance and might not work so well with thin objects, but its useful for smooth objects



More information about the Bf-blender-cvs mailing list