[Bf-blender-cvs] [41ae74d] fracture_modifier: added some random rotation for fast bisect, to reduce parallel cuts
Martin Felke
noreply at git.blender.org
Fri Dec 16 00:48:38 CET 2016
Commit: 41ae74df1232dc3e90cf241b38975e84149ca05b
Author: Martin Felke
Date: Fri Dec 16 00:48:30 2016 +0100
Branches: fracture_modifier
https://developer.blender.org/rB41ae74df1232dc3e90cf241b38975e84149ca05b
added some random rotation for fast bisect, to reduce parallel cuts
===================================================================
M source/blender/blenkernel/BKE_fracture_util.h
M source/blender/blenkernel/intern/fracture.c
M source/blender/blenkernel/intern/fracture_util.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_fracture_util.h b/source/blender/blenkernel/BKE_fracture_util.h
index 4736e4b..413e146 100644
--- a/source/blender/blenkernel/BKE_fracture_util.h
+++ b/source/blender/blenkernel/BKE_fracture_util.h
@@ -39,6 +39,6 @@ Shard *BKE_fracture_shard_boolean(Object *obj, DerivedMesh *dm_parent, Shard* ch
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);
+ short inner_mat_index, char uv_layer[], struct KDTree *preselect_tree, float quat[]);
#endif /* BKE_FRACTURE_UTIL_H*/
diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index db928d8..c8d21d8 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -477,6 +477,7 @@ static void handle_fast_bisect(FracMesh *fm, int expected_shards, int algorithm,
Shard *s = NULL;
Shard *s2 = NULL;
Shard *t;
+ float quat[4];
if (fm->cancel == 1) {
break;
@@ -501,13 +502,20 @@ static void handle_fast_bisect(FracMesh *fm, int expected_shards, int algorithm,
index = 0;
}
+ //add some random rotation
+ quat[0] = BLI_frand() * 2 - 1;
+ quat[1] = BLI_frand() * 2 - 1;
+ quat[2] = BLI_frand() * 2 - 1;
+ quat[3] = BLI_frand() * 2 - 1;
+ normalize_qt(quat);
+
printf("Bisecting cell %d...\n", i);
printf("Bisecting cell %d...\n", i + 1);
s = BKE_fracture_shard_bisect(*bm_parent, t, obmat, algorithm == MOD_FRACTURE_BISECT_FAST_FILL,
- false, true, index, centroid, inner_material_index, uv_layer, NULL);
+ false, true, index, centroid, inner_material_index, uv_layer, NULL, quat);
s2 = BKE_fracture_shard_bisect(*bm_parent, t, obmat, algorithm == MOD_FRACTURE_BISECT_FAST_FILL,
- true, false, index, centroid, inner_material_index, uv_layer, NULL);
+ true, false, index, centroid, inner_material_index, uv_layer, NULL, quat);
index++;
@@ -681,10 +689,10 @@ static bool handle_boolean_bisect(FracMesh *fm, Object *obj, int expected_shards
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};
+ float co[3] = {0, 0, 0}, quat[4] = {1, 0, 0, 0};
printf("Bisecting cell %d...\n", *i);
s = BKE_fracture_shard_bisect(bm_parent, t, obmat, algorithm == MOD_FRACTURE_BISECT_FILL, false, true, -1, co, inner_material_index, uv_layer,
- preselect_tree);
+ preselect_tree, quat);
}
else {
/* do not fracture case */
diff --git a/source/blender/blenkernel/intern/fracture_util.c b/source/blender/blenkernel/intern/fracture_util.c
index c3b4cec..043803e 100644
--- a/source/blender/blenkernel/intern/fracture_util.c
+++ b/source/blender/blenkernel/intern/fracture_util.c
@@ -737,7 +737,7 @@ static void do_fill(float plane_no[3], bool clear_outer, bool clear_inner, BMOpe
}
static void do_bisect(BMesh* bm_parent, BMesh* bm_child, float obmat[4][4], bool use_fill, bool clear_inner,
- bool clear_outer, int cutlimit, float centroid[3], short inner_mat_index)
+ bool clear_outer, int cutlimit, float centroid[3], short inner_mat_index, float quat[4])
{
BMIter iter;
BMFace *f;
@@ -764,6 +764,8 @@ static void do_bisect(BMesh* bm_parent, BMesh* bm_child, float obmat[4][4], bool
copy_v3_v3(plane_co, centroid);
copy_v3_v3(plane_no, f->no /*normal*/);
do_break = true;
+
+ mul_qt_v3(quat, plane_no);
}
else {
copy_v3_v3(plane_co, f->l_first->v->co);
@@ -892,7 +894,7 @@ static BMesh *do_preselection(BMesh* bm_orig, Shard *child, KDTree *preselect_tr
Shard *BKE_fracture_shard_bisect(BMesh *bm_orig, Shard *child, float obmat[4][4], bool use_fill, bool clear_inner,
bool clear_outer, int cutlimit, float centroid[3], short inner_mat_index, char uv_layer[64],
- KDTree *preselect_tree)
+ KDTree *preselect_tree, float quat[4])
{
Shard *output_s;
@@ -916,7 +918,7 @@ Shard *BKE_fracture_shard_bisect(BMesh *bm_orig, Shard *child, float obmat[4][4]
if (bm_parent != NULL) {
BM_mesh_elem_hflag_enable_all(bm_parent, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
- do_bisect(bm_parent, bm_child, obmat, use_fill, clear_inner, clear_outer, cutlimit, centroid, inner_mat_index);
+ do_bisect(bm_parent, bm_child, obmat, use_fill, clear_inner, clear_outer, cutlimit, centroid, inner_mat_index, quat);
output_s = do_output_shard(bm_parent, child, uv_layer);
BM_mesh_free(bm_parent);
}
More information about the Bf-blender-cvs
mailing list