[Bf-blender-cvs] [a051a76] fracture_modifier: attempt to add a cut by objects / geometry (other FM) option as well as properly resetting shards after fracture parameter change (the latter didnt work properly)
Martin Felke
noreply at git.blender.org
Sun Jun 7 22:22:15 CEST 2015
Commit: a051a76c8a025b5096efb7ce200506df63cef0e9
Author: Martin Felke
Date: Sun Jun 7 21:21:06 2015 +0200
Branches: fracture_modifier
https://developer.blender.org/rBa051a76c8a025b5096efb7ce200506df63cef0e9
attempt to add a cut by objects / geometry (other FM) option as well as properly resetting shards after fracture parameter change (the latter didnt work properly)
===================================================================
M source/blender/blenkernel/BKE_fracture.h
M source/blender/blenkernel/intern/fracture.c
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/source/blender/blenkernel/BKE_fracture.h b/source/blender/blenkernel/BKE_fracture.h
index 4b4ae6a..3f19d29 100644
--- a/source/blender/blenkernel/BKE_fracture.h
+++ b/source/blender/blenkernel/BKE_fracture.h
@@ -85,7 +85,8 @@ struct DerivedMesh *BKE_shard_create_dm(struct Shard *s, bool doCustomData);
/* create shards from base mesh and a list of points */
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);
+ 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);
/* 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 f1fd9c7..80188a6 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -742,7 +742,7 @@ static void do_prepare_cells(FracMesh *fm, cell *cells, int expected_shards, int
/* parse the voro++ cell data */
-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)
+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)
{
/*Parse voronoi raw data*/
int i = 0, j = 0, count = 0;
@@ -775,7 +775,18 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
return;
}
- if (mode == MOD_FRACTURE_PREFRACTURED)
+ if (reset)
+ {
+ while (fm->shard_map.first)
+ {
+ Shard *t = fm->shard_map.first;
+ BLI_remlink_safe(&fm->shard_map, t);
+ printf("Resetting shard: %d\n", t->shard_id);
+ BKE_shard_free(t, true);
+ }
+ }
+
+ if (mode == MOD_FRACTURE_PREFRACTURED && !reset)
{
//rebuild tree
if (!fm->last_shard_tree && (fm->shard_count > 0) && mode == MOD_FRACTURE_PREFRACTURED)
@@ -1173,7 +1184,7 @@ static void do_intersect(FractureModifierData *fmd, Object* ob, Shard *t, short
s = BKE_fracture_shard_boolean(ob, *dm_parent, t, inner_mat_index, 0, 0.0f, NULL, NULL, 0.0f, false, 0);
}
- printf("Fractured: %d\n", k);
+ //printf("Fractured: %d\n", k);
if (s != NULL) {
add_shard(fmd->frac_mesh, s, mat);
@@ -1234,7 +1245,8 @@ static void intersect_shards_by_dm(FractureModifierData *fmd, DerivedMesh *d, Ob
count = fmd->frac_mesh->shard_count;
/*TODO, pass modifier mesh here !!! */
- if (count == 0 || !keep_other_shard) {
+ if (count == 0 && keep_other_shard) {
+
if (ob->derivedFinal != NULL) {
dm_parent = CDDM_copy(ob->derivedFinal);
}
@@ -1259,11 +1271,16 @@ static void intersect_shards_by_dm(FractureModifierData *fmd, DerivedMesh *d, Ob
if (cnt > 0)
{
- /*clean up old entries here to avoid unnecessary shards*/
- Shard *first = fmd->frac_mesh->shard_map.first;
- BLI_remlink_safe(&fmd->frac_mesh->shard_map,first);
- BKE_shard_free(first, true);
- first = NULL;
+ if (keep_other_shard)
+ {
+ /*clean up old entries here to avoid unnecessary shards*/
+ Shard *first = fmd->frac_mesh->shard_map.first;
+ BLI_remlink_safe(&fmd->frac_mesh->shard_map,first);
+ BKE_shard_free(first, true);
+ first = NULL;
+ }
+
+ /* keep asynchronous by intent, to keep track of original shard count */
fmd->frac_mesh->shard_count--;
}
}
@@ -1346,7 +1363,7 @@ void BKE_fracture_shard_by_planes(FractureModifierData *fmd, Object *obj, short
int totvert = dm->getNumVerts(dm);
int i = 0;
- printf("Cutting with %s, island %d...\n", ob->id.name, j);
+ //printf("Cutting with %s, island %d...\n", ob->id.name, j);
for (i = 0, v = mv; i < totvert; i++, v++)
{
add_v3_v3(v->co, mi->centroid);
@@ -1359,6 +1376,20 @@ void BKE_fracture_shard_by_planes(FractureModifierData *fmd, Object *obj, short
dm = NULL;
j++;
}
+
+ /*now delete first shards, those are the old ones */
+ while (fmd->frac_mesh->shard_count > 0)
+ {
+ /*clean up old entries here to avoid unnecessary shards*/
+ Shard *first = fmd->frac_mesh->shard_map.first;
+ BLI_remlink_safe(&fmd->frac_mesh->shard_map,first);
+ BKE_shard_free(first, true);
+ first = NULL;
+ fmd->frac_mesh->shard_count--;
+ }
+
+ /* re-synchronize counts, was possibly different before */
+ fmd->frac_mesh->shard_count = BLI_listbase_count(&fmd->frac_mesh->shard_map);
}
else
{
@@ -1384,7 +1415,7 @@ void BKE_fracture_shard_by_planes(FractureModifierData *fmd, Object *obj, short
}
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) {
+ inner_material_index, float mat[4][4], int num_cuts, float fractal, bool smooth, int num_levels, int mode, bool reset) {
int n_size = 8;
Shard *shard;
@@ -1445,7 +1476,7 @@ void BKE_fracture_shard_by_points(FracMesh *fmesh, ShardID id, FracPointCloud *p
/*Evaluate result*/
parse_cells(voro_cells, pointcloud->totpoints, id, fmesh, algorithm, obj, dm, inner_material_index, mat,
- num_cuts, fractal, smooth, num_levels, mode);
+ num_cuts, fractal, smooth, num_levels, mode, reset);
/*Free structs in C++ area of memory */
cells_free(voro_cells, pointcloud->totpoints);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 7bf21c8..55299f5 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1564,6 +1564,7 @@ typedef struct FractureModifierData {
int refresh;
int refresh_constraints;
int refresh_autohide;
+ int reset_shards;
int use_constraints;
int use_mass_dependent_thresholds;
@@ -1593,7 +1594,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 b404902..3e0a52c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -787,6 +787,7 @@ static void rna_FractureModifier_thresh_defgrp_name_set(PointerRNA *ptr, const c
FractureModifierData *tmd = (FractureModifierData *)ptr->data;
rna_object_vgroup_name_set(ptr, value, tmd->thresh_defgrp_name, sizeof(tmd->thresh_defgrp_name));
tmd->refresh_constraints = true;
+ tmd->reset_shards = true;
}
static void rna_FractureModifier_ground_defgrp_name_set(PointerRNA *ptr, const char *value)
@@ -794,6 +795,7 @@ static void rna_FractureModifier_ground_defgrp_name_set(PointerRNA *ptr, const c
FractureModifierData *tmd = (FractureModifierData *)ptr->data;
rna_object_vgroup_name_set(ptr, value, tmd->ground_defgrp_name, sizeof(tmd->ground_defgrp_name));
tmd->refresh_constraints = true;
+ tmd->reset_shards = true;
}
static void rna_FractureModifier_inner_defgrp_name_set(PointerRNA *ptr, const char *value)
@@ -801,6 +803,7 @@ static void rna_FractureModifier_inner_defgrp_name_set(PointerRNA *ptr, const ch
FractureModifierData *tmd = (FractureModifierData *)ptr->data;
rna_object_vgroup_name_set(ptr, value, tmd->inner_defgrp_name, sizeof(tmd->inner_defgrp_name));
tmd->refresh_constraints = true;
+ tmd->reset_shards = true;
}
static void rna_RigidBodyModifier_threshold_set(PointerRNA *ptr, float value)
@@ -942,6 +945,157 @@ static void rna_FractureModifier_constraint_target_set(PointerRNA* ptr, int valu
rmd->refresh_constraints = true;
}
+static void rna_FractureModifier_frac_algorithm_set(PointerRNA* ptr, int value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->frac_algorithm = value;
+ rmd->reset_shards = true;
+}
+
+static void rna_FractureModifier_point_source_set(PointerRNA* ptr, int value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->point_source = value;
+ printf("PointSource\n");
+ rmd->reset_shards = true;
+}
+
+static void rna_FractureModifier_point_seed_set(PointerRNA* ptr, int value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->point_seed = value;
+ rmd->reset_shards = true;
+}
+
+static void rna_FractureModifier_percentage_set(PointerRNA* ptr, int value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->percentage = value;
+ rmd->reset_shards = true;
+}
+
+
+static void rna_FractureModifier_extra_group_set(PointerRNA* ptr, PointerRNA value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->extra_group = value.data;
+ rmd->reset_shards = true;
+}
+
+static void rna_FractureModifier_shards_to_islands_set(PointerRNA* ptr, int value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->shards_to_islands = value;
+ rmd->reset_shards = true;
+}
+
+static void rna_FractureModifier_fix_normals_set(PointerRNA* ptr, int value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->fix_normals = value;
+ rmd->reset_shards = true;
+}
+
+static void rna_FractureModifier_inner_material_set(PointerRNA* ptr, PointerRNA value)
+{
+ FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+ rmd->inner_material = value.data;
+ rmd->reset_shards = true;
+}
+
+static vo
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list