[Bf-blender-cvs] [0b0fe66] fracture_modifier: vary the seed when using presplit in dynafrac and fix for error when applying split to a single island
Martin Felke
noreply at git.blender.org
Mon Oct 10 23:24:25 CEST 2016
Commit: 0b0fe66838bb6e716913f3e8c4df35fc787996ac
Author: Martin Felke
Date: Mon Oct 10 23:24:16 2016 +0200
Branches: fracture_modifier
https://developer.blender.org/rB0b0fe66838bb6e716913f3e8c4df35fc787996ac
vary the seed when using presplit in dynafrac and fix for error when applying split to a single island
===================================================================
M source/blender/blenkernel/BKE_fracture.h
M source/blender/blenkernel/intern/fracture.c
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_fracture.h b/source/blender/blenkernel/BKE_fracture.h
index 77c005e..264dc43 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 solver, float thresh);
+ int num_settings, char uv_layer[], bool threaded, int solver, float thresh, bool shards_to_islands);
/* 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/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 6f92463..516d62e 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -1599,7 +1599,8 @@ static FractureData segment_cells(cell *voro_cells, int startcell, int totcells,
void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *pointcloud, 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, int solver, float thresh)
+ bool reset, int active_setting, int num_settings, char uv_layer[64], bool threaded, int solver, float thresh,
+ bool shards_to_islands)
{
int n_size = 8;
@@ -1623,7 +1624,8 @@ void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *p
shard = BKE_shard_by_id(fmesh, id, dm);
if (!shard || (shard->flag & SHARD_FRACTURED && (mode == MOD_FRACTURE_DYNAMIC))) {
- if (id == 0)
+ int val = shards_to_islands ? -1 : 0;
+ if (id == val)
{
//fallback to entire mesh
shard = BKE_shard_by_id(fmesh, -1 , dm);
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 1ca44da..76e458d 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -1264,7 +1264,14 @@ static FracPointCloud get_points_global(FractureModifierData *emd, Object *ob, D
}
}
- BLI_srandom(emd->point_seed);
+ //omg, vary the seed here
+ if (emd->shards_to_islands && emd->fracture_mode == MOD_FRACTURE_DYNAMIC) {
+ BLI_srandom(id);
+ }
+ else
+ {
+ BLI_srandom(emd->point_seed);
+ }
for (i = 0; i < count; ++i) {
if (BLI_frand() < thresh) {
float co[3];
@@ -1584,7 +1591,7 @@ static void do_fracture(FractureModifierData *fmd, ShardID id, Object *obj, Deri
BKE_fracture_shard_by_points(fmd->frac_mesh, id, &points, fmd->frac_algorithm, obj, dm, mat_index, mat,
fmd->fractal_cuts, fmd->fractal_amount, fmd->use_smooth, fmd->fractal_iterations,
fmd->fracture_mode, fmd->reset_shards, fmd->active_setting, num_settings, fmd->uvlayer_name,
- fmd->execute_threaded, fmd->boolean_solver, fmd->boolean_double_threshold);
+ fmd->execute_threaded, fmd->boolean_solver, fmd->boolean_double_threshold, fmd->shards_to_islands);
}
/*TODO, limit this to settings shards !*/
@@ -1874,7 +1881,7 @@ static int do_shard_to_island(FractureModifierData *fmd, BMesh* bm_new, ShardID
}
#endif
id = BLI_listbase_count(&fmd->frac_mesh->shard_map);
- s->shard_id = id+1;
+ s->shard_id = id;
s->parent_id = par_id;
s->flag = SHARD_INTACT;
BLI_addtail(&fmd->frac_mesh->shard_map, s);
More information about the Bf-blender-cvs
mailing list