Commit: d22d1bae7ccd2aae2baa9641d2cf6cf14731f1a2 Author: Martin Felke Date: Wed Oct 12 12:06:21 2016 +0200 Branches: fracture_modifier https://developer.blender.org/rBd22d1bae7ccd2aae2baa9641d2cf6cf14731f1a2
added constraint dynamic percentage and dynamic constraint building option =================================================================== M release/scripts/startup/bl_operators/presets.py M release/scripts/startup/bl_ui/properties_physics_fracture.py M source/blender/blenkernel/intern/rigidbody.c 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/intern/MOD_fracture.c =================================================================== diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 1bf6329..b0cb74f 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -677,7 +677,11 @@ class AddPresetFracture(AddPresetBase, Operator): "fracture.minimum_impulse", "fracture.mass_threshold_factor", "fracture.autohide_filter_group", - "fracture.uv_layer" + "fracture.uv_layer", + "fracture.boolean_solver", + "fracture.boolean_double_threshold", + "fracture.dynamic_percentage", + "fracture.dynamic_new_constraints" ] preset_subdir = "fracture" diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py index 297529a..dbe0f7b 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fracture.py +++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py @@ -92,8 +92,12 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel): return if md.fracture_mode == 'DYNAMIC': - layout.prop(md, "dynamic_force") - layout.prop(md, "limit_impact") + row = layout.row(align=True) + row.prop(md, "dynamic_force") + row.prop(md, "dynamic_percentage") + row = layout.row() + row.prop(md, "limit_impact") + row.prop(md, "dynamic_new_constraints") layout.prop(md, "frac_algorithm") if md.frac_algorithm in {'BOOLEAN', 'BOOLEAN_FRACTAL'}: diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 1b438ef..7fcefe0 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -2066,6 +2066,22 @@ static Shard* findShard(FractureModifierData *fmd, int id) return s; } +static MeshIsland* findMeshIsland(FractureModifierData *fmd, int id) +{ + MeshIsland *mi = fmd->meshIslands.first; + + while (mi) + { + if (mi->id == id) + { + return mi; + } + mi = mi->next; + } + + return NULL; +} + static bool check_shard_size(FractureModifierData *fmd, int id) { FractureID *fid; @@ -2100,6 +2116,27 @@ static bool check_shard_size(FractureModifierData *fmd, int id) return true; } +static bool check_constraints(FractureModifierData *fmd, MeshIsland *mi) { + //count broken constraints + RigidBodyShardCon *con; + int i = 0, broken = 0; + float percentage; + for (i = 0; i < mi->participating_constraint_count; i++) { + con = mi->participating_constraints[i]; + if (con->physics_constraint && !RB_constraint_is_enabled(con->physics_constraint)) { + broken++; + } + } + + percentage = (float)broken / (float)mi->participating_constraint_count; + + if ((percentage * 100) >= fmd->dynamic_percentage) { + return true; + } + + return false; +} + static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw) { int linear_index1, linear_index2; @@ -2140,11 +2177,12 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw) RigidBodyOb *rbo = rbw->cache_index_map[linear_index1]; int id = rbo->meshisland_index; Shard *s = findShard(fmd1, id); + MeshIsland* mi = findMeshIsland(fmd1, id); //printf("FORCE1:%f\n",force); bool canbreak = (force > fmd1->dynamic_force) || (fmd1->limit_impact && can_break(ob2, ob1, fmd1->limit_impact)); - if (canbreak) + if (canbreak && check_constraints(fmd1, mi)) { if (s) { float size[3]; @@ -2187,11 +2225,12 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw) RigidBodyOb *rbo = rbw->cache_index_map[linear_index2]; int id = rbo->meshisland_index; Shard *s = findShard(fmd2, id); + MeshIsland* mi = findMeshIsland(fmd2, id); //printf("FORCE2:%f\n",force); bool canbreak = (force > fmd2->dynamic_force) || (fmd2->limit_impact && can_break(ob1, ob2, fmd2->limit_impact)); - if (canbreak) + if (canbreak && check_constraints(fmd2, mi)) { if (s) { float size[3]; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 067fdef..c2d2f91 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5244,6 +5244,8 @@ static void load_fracture_modifier(FileData* fd, FractureModifierData *fmd) fmd->boolean_solver = eBooleanModifierSolver_Carve; fmd->boolean_double_threshold = 1e-6f; fmd->keep_cutter_shards = MOD_FRACTURE_KEEP_BOTH; + fmd->dynamic_new_constraints = true; + fmd->dynamic_percentage = 0; } if (fm == NULL || fmd->dm_group) { diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index f7e35fc..19c26d8 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1705,6 +1705,7 @@ typedef struct FractureModifierData { int cluster_constraint_type; int fracture_mode; int boolean_solver; + int dynamic_percentage; float breaking_angle; float breaking_distance; @@ -1755,6 +1756,7 @@ typedef struct FractureModifierData { int constraint_target; int limit_impact; int fracture_all; + int dynamic_new_constraints; /* internal flags */ int use_experimental; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 15896ba..41c51f3 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -6392,6 +6392,22 @@ static void rna_def_modifier_fracture(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Overlap Threshold", "Threshold for checking overlapping geometry"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "dynamic_percentage", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "dynamic_percentage"); + RNA_def_property_range(prop, 0, 100); + //RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyModifier_breaking_percentage_set", NULL); + RNA_def_property_ui_text(prop, "Constraint Percentage", "Percentage of broken constraints per island which leads to dynamic fracturing of this island"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "dynamic_new_constraints", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dynamic_new_constraints", false); + RNA_def_property_ui_text(prop, "New Constraints", "Create new constraints while dynamically fracturing"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + + /*Fracture Modifiers own python / RNA API */ rna_def_mesh_island(brna); prop = RNA_def_property(srna, "mesh_islands", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c index ebf8270..dbab9b6 100644 --- a/source/blender/modifiers/intern/MOD_fracture.c +++ b/source/blender/modifiers/intern/MOD_fracture.c @@ -223,6 +223,8 @@ static void initData(ModifierData *md) fmd->boolean_solver = eBooleanModifierSolver_Carve; fmd->boolean_double_threshold = 1e-6f; + fmd->dynamic_percentage = 0.0f; + fmd->dynamic_new_constraints = true; } //XXX TODO, freeing functionality should be in BKE too @@ -1767,6 +1769,12 @@ static void copyData(ModifierData *md, ModifierData *target) trmd->use_compounds = rmd->use_compounds; trmd->autohide_filter_group = rmd->autohide_filter_group; + + trmd->boolean_solver = rmd->boolean_solver; + trmd->boolean_double_threshold = rmd->boolean_double_threshold; + + trmd->dynamic_percentage = rmd->dynamic_percentage; + trmd->dynamic_new_constraints = rmd->dynamic_new_constraints; } //XXXX TODO, is BB really useds still ? aint there exact volume calc now ? @@ -2531,6 +2539,14 @@ static void search_tree_based(FractureModifierData *rmd, MeshIsland *mi, MeshIsl dist = rmd->contact_dist; factor = rmd->mass_threshold_factor; + if ((rmd->fracture_mode == MOD_FRACTURE_DYNAMIC) && !rmd->dynamic_new_constraints) + { + Shard* s = find_shard(&rmd->frac_mesh->shard_map, mi->id); + if (s->parent_id > -1) { + return; + } + } + #if 0 if (factor > 0.0f && rmd->use_compounds) { if (mi->rigidbody->mass > 0.0f && max_mass > 0.0f) { _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs