Commit: 6276e3d174afe08af171a78efee5f1d57c913217
Author: Martin Felke
Date:   Thu Oct 13 00:52:23 2016 +0200
Branches: fracture_modifier
https://developer.blender.org/rB6276e3d174afe08af171a78efee5f1d57c913217

dynamic fracture, added a third new constraint option "none"

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

M       release/scripts/startup/bl_ui/properties_physics_fracture.py
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_ui/properties_physics_fracture.py 
b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index dbe0f7b..2dba3b3 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -95,9 +95,9 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel):
             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")
+            col = layout.column()
+            col.prop(md, "dynamic_new_constraints")
+            col.prop(md, "limit_impact")
 
         layout.prop(md, "frac_algorithm")
         if md.frac_algorithm in {'BOOLEAN', 'BOOLEAN_FRACTAL'}:
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index c2d2f91..e86dea9 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5244,7 +5244,7 @@ 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_new_constraints = 
MOD_FRACTURE_ALL_DYNAMIC_CONSTRAINTS;
                fmd->dynamic_percentage = 0;
        }
 
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 19c26d8..22ef3b2 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1551,6 +1551,12 @@ enum {
        MOD_FRACTURE_KEEP_DIFFERENCE     = (1 << 2),
 };
 
+enum {
+       MOD_FRACTURE_NO_DYNAMIC_CONSTRAINTS     = (1 << 0),
+       MOD_FRACTURE_MIXED_DYNAMIC_CONSTRAINTS  = (1 << 1),
+       MOD_FRACTURE_ALL_DYNAMIC_CONSTRAINTS     = (1 << 2),
+};
+
 typedef struct ShardSequence {
        struct ShardSequence *next, *prev;
        struct FracMesh *frac_mesh;
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 41c51f3..fd22d36 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5877,6 +5877,13 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
                {0, NULL, 0, NULL, NULL}
        };
 
+       static EnumPropertyItem prop_dynamic_constraints[] = {
+               {MOD_FRACTURE_NO_DYNAMIC_CONSTRAINTS, "NO_CONSTRAINTS", 0, 
"None", "Build no new constraints"},
+               {MOD_FRACTURE_MIXED_DYNAMIC_CONSTRAINTS, "MIXED_CONSTRAINTS", 
0, "Mixed", "Build constraints between new and old shards"},
+               {MOD_FRACTURE_ALL_DYNAMIC_CONSTRAINTS, "ALL_CONSTRAINTS", 0, 
"All", "Build all new constraints"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        srna = RNA_def_struct(brna, "FractureModifier", "Modifier");
        RNA_def_struct_ui_text(srna, "Fracture Modifier", "Add a fracture 
container to this object");
        RNA_def_struct_sdna(srna, "FractureModifierData");
@@ -6400,9 +6407,10 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
        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");
+       prop = RNA_def_property(srna, "dynamic_new_constraints", PROP_ENUM, 
PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_dynamic_constraints);
+       RNA_def_property_enum_default(prop, 
MOD_FRACTURE_NO_DYNAMIC_CONSTRAINTS);
+       RNA_def_property_ui_text(prop, "New Constraints", "Which constraints 
are created while dynamically fracturing");
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
        RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
diff --git a/source/blender/modifiers/intern/MOD_fracture.c 
b/source/blender/modifiers/intern/MOD_fracture.c
index 1e754cf..7d47e1f 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -224,7 +224,7 @@ 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;
+       fmd->dynamic_new_constraints = MOD_FRACTURE_ALL_DYNAMIC_CONSTRAINTS;
 }
 
 //XXX TODO, freeing functionality should be in BKE too
@@ -2559,7 +2559,8 @@ 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)
+       if ((rmd->fracture_mode == MOD_FRACTURE_DYNAMIC) &&
+           (rmd->dynamic_new_constraints != 
MOD_FRACTURE_ALL_DYNAMIC_CONSTRAINTS))
        {
                Shard* s = find_shard(&rmd->frac_mesh->shard_map, mi->id);
                if (s->parent_id > -1) {
@@ -2605,6 +2606,25 @@ static void search_tree_based(FractureModifierData *rmd, 
MeshIsland *mi, MeshIsl
                                break;
                        }
 
+                       if ((rmd->fracture_mode == MOD_FRACTURE_DYNAMIC))
+                       {
+                               Shard* s1 = 
find_shard(&rmd->frac_mesh->shard_map, mi->id);
+                               Shard* s2 = 
find_shard(&rmd->frac_mesh->shard_map, mi2->id);
+
+                               if (rmd->dynamic_new_constraints == 
MOD_FRACTURE_MIXED_DYNAMIC_CONSTRAINTS) {
+                                       //only build between old and new
+                                       if (s1->parent_id > -1 && s2->parent_id 
> -1) {
+                                               continue;
+                                       }
+                               }
+                               else if (rmd->dynamic_new_constraints == 
MOD_FRACTURE_NO_DYNAMIC_CONSTRAINTS){
+                                       // dont build at all
+                                       if (s2->parent_id > -1) {
+                                               continue;
+                                       }
+                               }
+                       }
+
                        connect_meshislands(rmd, mi, mi2, con_type, thresh);
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to