[Bf-blender-cvs] [192a18a] fracture_modifier: added new bmesh boolean solver to fracture modifier as well

Martin Felke noreply at git.blender.org
Wed Sep 28 00:03:48 CEST 2016


Commit: 192a18a99d17b2d1ea6fc9bf7ee2d6b3606356f2
Author: Martin Felke
Date:   Wed Sep 28 00:01:28 2016 +0200
Branches: fracture_modifier
https://developer.blender.org/rB192a18a99d17b2d1ea6fc9bf7ee2d6b3606356f2

added new bmesh boolean solver to fracture modifier as well

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

M	release/scripts/startup/bl_ui/properties_physics_fracture.py
M	source/blender/blenkernel/BKE_fracture.h
M	source/blender/blenkernel/BKE_fracture_util.h
M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/fracture_util.c
M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/intern/MOD_boolean.c
M	source/blender/modifiers/intern/MOD_boolean_util.h
A	source/blender/modifiers/intern/MOD_boolean_util_bmesh.c
R100	source/blender/modifiers/intern/MOD_boolean_util.c	source/blender/modifiers/intern/MOD_boolean_util_carve.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 e151343..297529a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -96,6 +96,12 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel):
             layout.prop(md, "limit_impact")
 
         layout.prop(md, "frac_algorithm")
+        if md.frac_algorithm in {'BOOLEAN', 'BOOLEAN_FRACTAL'}:
+            col = layout.column(align=True)
+            col.label(text="Boolean Solver:")
+            col.prop(md, "boolean_solver", text="")
+            if md.boolean_solver == 'BMESH':
+                col.prop(md, "boolean_double_threshold")
         col = layout.column(align=True)
         col.prop(md, "shard_count")
         col.prop(md, "cluster_count")
diff --git a/source/blender/blenkernel/BKE_fracture.h b/source/blender/blenkernel/BKE_fracture.h
index 514845a..77c005e 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[], bool threaded);
+                                  int num_settings, char uv_layer[], bool threaded, int solver, float thresh);
 
 /* 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/BKE_fracture_util.h b/source/blender/blenkernel/BKE_fracture_util.h
index 6b769f7..4736e4b 100644
--- a/source/blender/blenkernel/BKE_fracture_util.h
+++ b/source/blender/blenkernel/BKE_fracture_util.h
@@ -35,7 +35,8 @@
 
 #include "DNA_fracture_types.h"
 
-Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard* child, short inner_material_index, int num_cuts, float fractal, Shard **other, float mat[4][4], float radius, bool use_smooth_inner, int num_levels, char uv_layer[]);
+Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard* child, short inner_material_index, int num_cuts, float fractal,
+                                  Shard **other, float mat[4][4], float radius, bool use_smooth_inner, int num_levels, char uv_layer[], int solver, float thresh);
 Shard *BKE_fracture_shard_bisect(struct BMesh *bm_orig, Shard* child, float obmat[4][4], bool use_fill,
                                  bool clear_inner, bool clear_outer, int cutlimit, float centroid[],
                                  short inner_mat_index, char uv_layer[], struct KDTree *preselect_tree);
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 595b486..de88b68 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -116,8 +116,9 @@ static BMesh *shard_to_bmesh(Shard *s)
 	BMIter iter;
 	BMFace *f;
 
+	bm_parent = BM_mesh_create(&bm_mesh_allocsize_default,  &((struct BMeshCreateParams){.use_toolflags = true,}));
 	dm_parent = BKE_shard_create_dm(s, true);
-	bm_parent = DM_to_bmesh(dm_parent, true);
+	DM_to_bmesh_ex(dm_parent, bm_parent, true);
 	BM_mesh_elem_table_ensure(bm_parent, BM_VERT | BM_FACE);
 
 	BM_ITER_MESH (f, &iter, bm_parent, BM_FACES_OF_MESH)
@@ -512,7 +513,7 @@ static void handle_fast_bisect(FracMesh *fm, int expected_shards, int algorithm,
 
 static void handle_boolean_fractal(Shard* s, Shard* t, int expected_shards, DerivedMesh* dm_parent, Object *obj, short inner_material_index,
                                    int num_cuts, float fractal, int num_levels, bool smooth,int parent_id, int* i, Shard ***tempresults,
-                                   DerivedMesh **dm_p, char uv_layer[64])
+                                   DerivedMesh **dm_p, char uv_layer[64], int solver, int thresh)
 {
 	/* physics shard and fractalized shard, so we need to booleanize twice */
 	/* and we need both halves, so twice again */
@@ -551,7 +552,7 @@ static void handle_boolean_fractal(Shard* s, Shard* t, int expected_shards, Deri
 		loc_eul_size_to_mat4(matrix, loc, eul, one);
 
 		/*visual shards next, fractalized cuts */
-		s = BKE_fracture_shard_boolean(obj, *dm_p, t, inner_material_index, num_cuts,fractal, &s2, matrix, radius, smooth, num_levels, uv_layer);
+		s = BKE_fracture_shard_boolean(obj, *dm_p, t, inner_material_index, num_cuts,fractal, &s2, matrix, radius, smooth, num_levels, uv_layer, solver, thresh);
 
 		if (index < max_retries)
 		{
@@ -604,7 +605,7 @@ static void handle_boolean_fractal(Shard* s, Shard* t, int expected_shards, Deri
 static bool handle_boolean_bisect(FracMesh *fm, Object *obj, int expected_shards, int algorithm, int parent_id, Shard **tempshards,
                                   DerivedMesh *dm_parent, BMesh* bm_parent, float obmat[4][4], short inner_material_index, int num_cuts,
                                   int num_levels, float fractal, int *i, bool smooth, Shard*** tempresults, DerivedMesh **dm_p, char uv_layer[64],
-                                  KDTree *preselect_tree)
+                                  KDTree *preselect_tree, int solver, int thresh)
 {
 	Shard *s = NULL, *t = NULL;
 	if (fm->cancel == 1)
@@ -626,11 +627,11 @@ static bool handle_boolean_bisect(FracMesh *fm, Object *obj, int expected_shards
 
 	/* XXX TODO, need object for material as well, or atleast a material index... */
 	if (algorithm == MOD_FRACTURE_BOOLEAN) {
-		s = BKE_fracture_shard_boolean(obj, dm_parent, t, inner_material_index, 0, 0.0f, NULL, NULL, 0.0f, false, 0, uv_layer);
+		s = BKE_fracture_shard_boolean(obj, dm_parent, t, inner_material_index, 0, 0.0f, NULL, NULL, 0.0f, false, 0, uv_layer, solver, thresh);
 	}
 	else if (algorithm == MOD_FRACTURE_BOOLEAN_FRACTAL) {
 		handle_boolean_fractal(s, t, expected_shards, dm_parent, obj, inner_material_index, num_cuts, fractal,
-		                       num_levels, smooth, parent_id, i, tempresults, dm_p, uv_layer);
+		                       num_levels, smooth, parent_id, i, tempresults, dm_p, uv_layer, solver, thresh);
 	}
 	else if (algorithm == MOD_FRACTURE_BISECT || algorithm == MOD_FRACTURE_BISECT_FILL) {
 		float co[3] = {0, 0, 0};
@@ -806,7 +807,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)
+                        bool reset, int active_setting, int num_settings, char uv_layer[64], bool threaded, int solver, float thresh)
 {
 	/*Parse voronoi raw data*/
 	int i = 0, j = 0, count = 0;
@@ -940,7 +941,7 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 		for (i = 0; i < expected_shards; i++)	{
 			bool stop = handle_boolean_bisect(fm, obj, expected_shards, algorithm, parent_id, tempshards, dm_parent,
 			                      bm_parent, obmat, inner_material_index, num_cuts, num_levels, fractal,
-			                      &i, smooth, &tempresults, &dm_p, uv_layer, preselect_tree);
+			                      &i, smooth, &tempresults, &dm_p, uv_layer, preselect_tree, solver, thresh);
 			//if (stop)
 			//	break;
 		}
@@ -1243,7 +1244,7 @@ static void stroke_to_faces(FractureModifierData *fmd, BMesh** bm, bGPDstroke *g
 
 static void do_intersect(FractureModifierData *fmd, Object* ob, Shard *t, short inner_mat_index,
                          bool is_zero, float mat[4][4], int **shard_counts, int* count,
-                         int k, DerivedMesh **dm_parent, bool keep_other_shard)
+                         int k, DerivedMesh **dm_parent, bool keep_other_shard, int solver, float thresh)
 {
 	/*just keep appending items at the end here */
 	MPoly *mpoly, *mp;
@@ -1266,11 +1267,11 @@ static void do_intersect(FractureModifierData *fmd, Object* ob, Shard *t, short
 
 	if (keep_other_shard)
 	{
-		s = BKE_fracture_shard_boolean(ob, *dm_parent, t, inner_mat_index, 0, 0.0f, &s2, NULL, 0.0f, false, 0, fmd->uvlayer_name);
+		s = BKE_fracture_shard_boolean(ob, *dm_parent, t, inner_mat_index, 0, 0.0f, &s2, NULL, 0.0f, false, 0, fmd->uvlayer_name, solver, thresh);
 	}
 	else
 	{
-		s = BKE_fracture_shard_boolean(ob, *dm_parent, t, inner_mat_index, 0, 0.0f, NULL, NULL, 0.0f, false, 0, fmd->uvlayer_name);
+		s = BKE_fracture_shard_boolean(ob, *dm_parent, t, inner_mat_index, 0, 0.0f, NULL, NULL, 0.0f, false, 0, fmd->uvlayer_name, solver, thresh);
 	}
 
 	//printf("Fractured: %d\n", k);
@@ -1313,7 +1314,7 @@ static void do_intersect(FractureModifierData *fmd, Object* ob, Shard *t, short
 
 
 static void intersect_shards_by_dm(FractureModifierData *fmd, DerivedMesh *d, Object *ob, Object *ob2, short inner_mat_index, float mat[4][4],
-                                   bool keep_other_shard)
+                                   bool keep_other_shard, int solver, float thresh)
 {
 	Shard *t = NULL;
 	int i = 0, count = 0, k = 0;
@@ -1355,7 +1356,7 @@ static void intersect_shards_by_dm(FractureModifierData *fmd, DerivedMesh *d, Ob
 	shard_counts = MEM_mallocN(sizeof(int) * count, "shard_counts");
 
 	for (k = 0; k < count; k++) {
-		do_intersect(fmd, ob, t, inner_mat_index, is_zero, mat, &shard_counts, &count, k, &dm_parent, keep_other_shard);
+		do_intersect(fmd, ob, t, inner_mat_index, is_zero, mat, &shard_counts, &count, k, &dm_parent, keep_other_shard, solver, 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list