Commit: 57c9742438b5774ab392eb6a89b755e9cdec89ee
Author: Martin Felke
Date:   Fri Sep 9 14:12:09 2016 +0200
Branches: fracture_modifier
https://developer.blender.org/rB57c9742438b5774ab392eb6a89b755e9cdec89ee

added global keep shards mode for cutter groups

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

M       release/scripts/startup/bl_ui/properties_physics_fracture.py
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/release/scripts/startup/bl_ui/properties_physics_fracture.py 
b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index 7d4ea5a..e151343 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -137,6 +137,8 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel):
             col.prop(md, "dm_group")
             if md.frac_algorithm == 'BOOLEAN':
                 col.prop(md, "cutter_group")
+                if (md.cutter_group):
+                   col.prop(md, "keep_cutter_shards")
             col.prop(md, "use_particle_birth_coordinates")
 
             box.prop(md, "percentage")
diff --git a/source/blender/blenkernel/intern/fracture.c 
b/source/blender/blenkernel/intern/fracture.c
index b43e680..0cceed8 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -1275,16 +1275,20 @@ static void do_intersect(FractureModifierData *fmd, 
Object* ob, Shard *t, short
 
        //printf("Fractured: %d\n", k);
 
-       if (s != NULL) {
-               add_shard(fmd->frac_mesh, s, mat);
-               shards++;
-               s = NULL;
+       if (ELEM(fmd->keep_cutter_shards, MOD_FRACTURE_KEEP_BOTH, 
MOD_FRACTURE_KEEP_INTERSECT)) {
+               if (s != NULL) {
+                       add_shard(fmd->frac_mesh, s, mat);
+                       shards++;
+                       s = NULL;
+               }
        }
 
-       if (s2 != NULL) {
-               add_shard(fmd->frac_mesh, s2, mat);
-               shards++;
-               s2 = NULL;
+       if (ELEM(fmd->keep_cutter_shards, MOD_FRACTURE_KEEP_BOTH, 
MOD_FRACTURE_KEEP_DIFFERENCE)) {
+               if (s2 != NULL) {
+                       add_shard(fmd->frac_mesh, s2, mat);
+                       shards++;
+                       s2 = NULL;
+               }
        }
 
        if ((is_zero && ob->derivedFinal == NULL) || !is_zero) {
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index cd0991b..42d7528 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1537,6 +1537,12 @@ enum {
        MOD_FRACTURE_EXTERNAL          = (1 << 2),
 };
 
+enum {
+       MOD_FRACTURE_KEEP_BOTH          = (1 << 0),
+       MOD_FRACTURE_KEEP_INTERSECT      = (1 << 1),
+       MOD_FRACTURE_KEEP_DIFFERENCE     = (1 << 2),
+};
+
 typedef struct ShardSequence {
        struct ShardSequence *next, *prev;
        struct FracMesh *frac_mesh;
@@ -1755,7 +1761,9 @@ typedef struct FractureModifierData {
        int matstart;
        int defstart;
 
-       char pad[4];
+       int keep_cutter_shards;
+
+       //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 f6a50d4..0b1e933 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5820,6 +5820,13 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
                {0, NULL, 0, NULL, NULL}
        };
 
+       static EnumPropertyItem prop_keep_cutter_shards[] = {
+               {MOD_FRACTURE_KEEP_BOTH, "KEEP_BOTH", 0, "Both", "Keep both 
shards(intersect and difference)"},
+               {MOD_FRACTURE_KEEP_INTERSECT, "KEEP_INTERSECT", 0, "Intersect 
Only", "Keep intersected shards only"},
+               {MOD_FRACTURE_KEEP_DIFFERENCE, "KEEP_DIFFERENCE", 0, 
"Difference Only", "Keep difference shards only"},
+               {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");
@@ -6315,6 +6322,13 @@ 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, "keep_cutter_shards", PROP_ENUM, 
PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_keep_cutter_shards);
+       RNA_def_property_enum_default(prop, MOD_FRACTURE_KEEP_BOTH);
+       RNA_def_property_ui_text(prop, "Cutter mode", "Determines which shards 
to keep from cutting process");
+       //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 1d3987d..359bf88 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -3721,6 +3721,18 @@ static void updateDepgraph(ModifierData *md, DagForest 
*forest,
                        }
                }
        }
+
+       if (fmd->cutter_group) {
+               GroupObject *go;
+               for (go = fmd->cutter_group->gobject.first; go; go = go->next) {
+                       if (go->ob)
+                       {
+                               DagNode *curNode = dag_get_node(forest, go->ob);
+                               dag_add_relation(forest, curNode, obNode,
+                                                DAG_RL_DATA_DATA | 
DAG_RL_OB_DATA, "Fracture Modifier Cutter Group");
+                       }
+               }
+       }
 }
 
 static void foreachObjectLink(
@@ -3755,6 +3767,16 @@ static void foreachObjectLink(
                        }
                }
        }
+
+       if (fmd->cutter_group) {
+               GroupObject *go;
+               for (go = fmd->cutter_group->gobject.first; go; go = go->next) {
+                       if (go->ob)
+                       {
+                               walk(userData, ob, &go->ob, IDWALK_NOP);
+                       }
+               }
+       }
 }
 
 static ShardSequence* shard_sequence_add(FractureModifierData* fmd, float 
frame, DerivedMesh* dm)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to