Commit: c890d60651a8d42b97a41b3019aae3eb1869e2e7
Author: Martin Felke
Date:   Mon Nov 24 16:36:27 2014 +0100
Branches: fracture_modifier
https://developer.blender.org/rBc890d60651a8d42b97a41b3019aae3eb1869e2e7

cluster breaking angle, distance, percentage added, rename contact distance to 
search radius, jump back to start frame of rigidbody cache now automatically at 
fracture time (or frame 1)

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

M       release/scripts/startup/bl_ui/properties_physics_fracture.py
M       source/blender/blenkernel/intern/rigidbody.c
M       source/blender/editors/object/object_modifier.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 919ee6e..5a32eaa 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -129,16 +129,21 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, 
Panel):
             box.prop(md, "percentage")
             box.label("Constraint Breaking Settings")
             col = box.column(align=True)
-            row = col.row()
+            row = col.row(align=True)
             row.prop(md, "breaking_percentage", text="Percentage")
-            row.prop(md, "breaking_percentage_weighted")
+            row.prop(md, "cluster_breaking_percentage", text="Cluster 
Percentage")
 
-            row = col.row()
+            row = col.row(align=True)
             row.prop(md, "breaking_angle", text="Angle")
-            row.prop(md, "breaking_angle_weighted")
+            row.prop(md, "cluster_breaking_angle", text="Cluster Angle")
 
-            row = col.row()
+            row = col.row(align=True)
             row.prop(md, "breaking_distance", text="Distance")
+            row.prop(md, "cluster_breaking_distance", text="Cluster Distance")
+
+            row = col.row(align=True)
+            row.prop(md, "breaking_percentage_weighted")
+            row.prop(md, "breaking_angle_weighted")
             row.prop(md, "breaking_distance_weighted")
 
             col = box.column(align=True)
diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index b87d2d2..bb401dc 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -2670,7 +2670,7 @@ static void rigidbody_update_simulation(Scene *scene, 
RigidBodyWorld *rbw, bool
                                                int breaking_percentage = 
rmd->breaking_percentage_weighted ? (rmd->breaking_percentage * weight) : 
rmd->breaking_percentage;
                                                
                                                if (rmd->breaking_percentage > 
0 || (rmd->breaking_percentage_weighted && weight > 0)) {
-                                                       int broken_cons = 0, 
cons = 0, i = 0;
+                                                       int broken_cons = 0, 
cons = 0, i = 0, cluster_cons = 0, broken_cluster_cons = 0;
                                                        RigidBodyShardCon *con;
                                                        
                                                        cons = 
mi->participating_constraint_count;
@@ -2678,11 +2678,41 @@ static void rigidbody_update_simulation(Scene *scene, 
RigidBodyWorld *rbw, bool
                                                        for (i = 0; i < cons; 
i++) {
                                                                con = 
mi->participating_constraints[i];
                                                                if (con && 
con->physics_constraint) {
+                                                                       if 
(rmd->cluster_breaking_percentage > 0)
+                                                                       {
+                                                                               
/*only count as broken if between clusters!*/
+                                                                               
if (con->mi1->particle_index != con->mi2->particle_index)
+                                                                               
{
+                                                                               
        cluster_cons++;
+
+                                                                               
        if (!RB_constraint_is_enabled(con->physics_constraint)) {
+                                                                               
                broken_cluster_cons++;
+                                                                               
        }
+                                                                               
}
+                                                                       }
+
                                                                        if 
(!RB_constraint_is_enabled(con->physics_constraint)) {
                                                                                
broken_cons++;
                                                                        }
                                                                }
                                                        }
+
+                                                       if (cluster_cons > 0) {
+                                                               if 
((float)broken_cluster_cons / (float)cluster_cons * 100 >= 
rmd->cluster_breaking_percentage) {
+                                                                       for (i 
= 0; i < cons; i++) {
+                                                                               
con = mi->participating_constraints[i];
+                                                                               
if (con && con->mi1->particle_index != con->mi2->particle_index) {
+                                                                               
        con->flag &= ~RBC_FLAG_ENABLED;
+                                                                               
        con->flag |= RBC_FLAG_NEEDS_VALIDATE;
+
+                                                                               
        if (con->physics_constraint) {
+                                                                               
                RB_constraint_set_enabled(con->physics_constraint, false);
+                                                                               
        }
+                                                                               
}
+                                                                       }
+                                                               }
+                                                       }
+
                                                        
                                                        if (cons > 0) {
                                                                if 
((float)broken_cons / (float)cons * 100 >= breaking_percentage) {
@@ -2741,31 +2771,66 @@ static void rigidbody_update_simulation(Scene *scene, 
RigidBodyWorld *rbw, bool
                                        }
                                        
                                        if (((rmd->breaking_angle) > 0) || 
(rmd->breaking_angle_weighted && weight > 0) ||
-                                           (((rmd->breaking_distance > 0) || 
(rmd->breaking_distance_weighted && weight > 0)) && !rebuild))
+                                           (((rmd->breaking_distance > 0) || 
(rmd->breaking_distance_weighted && weight > 0)) ||
+                                            (rmd->cluster_breaking_angle > 0 
|| rmd->cluster_breaking_distance > 0)) && !rebuild )
                                        {
                                                float dist, angle, distdiff, 
anglediff;
                                                calc_dist_angle(rbsc, &dist, 
&angle);
                                                
                                                anglediff = fabs(angle - 
rbsc->start_angle);
                                                distdiff = fabs(dist - 
rbsc->start_dist);
-                                               
+
+                                               /* Treat angles here */
                                                if ((rmd->breaking_angle > 0 || 
(rmd->breaking_angle_weighted && weight > 0)) &&
                                                    (anglediff > 
breaking_angle))
                                                {
+                                                       /* if we have cluster 
breaking angle, then only treat equal cluster indexes like the default, else 
all */
+                                                       if 
((rmd->cluster_breaking_angle > 0 && rbsc->mi1->particle_index == 
rbsc->mi2->particle_index) ||
+                                                            
rmd->cluster_breaking_angle == 0)
+                                                       {
+                                                               rbsc->flag &= 
~RBC_FLAG_ENABLED;
+                                                               rbsc->flag |= 
RBC_FLAG_NEEDS_VALIDATE;
+                                                       
+                                                               if 
(rbsc->physics_constraint) {
+                                                                       
RB_constraint_set_enabled(rbsc->physics_constraint, false);
+                                                               }
+                                                       }
+                                               }
+
+                                               if 
((rmd->cluster_breaking_angle > 0) && (rbsc->mi1->particle_index != 
rbsc->mi2->particle_index)
+                                                   && anglediff > 
rmd->cluster_breaking_angle)
+                                               {
                                                        rbsc->flag &= 
~RBC_FLAG_ENABLED;
                                                        rbsc->flag |= 
RBC_FLAG_NEEDS_VALIDATE;
-                                                       
+
                                                        if 
(rbsc->physics_constraint) {
                                                                
RB_constraint_set_enabled(rbsc->physics_constraint, false);
                                                        }
                                                }
                                                
+                                               /* Treat distances here */
                                                if ((rmd->breaking_distance > 0 
|| (rmd->breaking_distance_weighted && weight > 0)) &&
                                                    (distdiff > 
breaking_distance))
                                                {
+                                                       /* if we have cluster 
breaking distance, then only treat equal cluster indexes like the default, else 
all */
+                                                       if 
((rmd->cluster_breaking_distance > 0 && rbsc->mi1->particle_index == 
rbsc->mi2->particle_index) ||
+                                                            
rmd->cluster_breaking_distance == 0)
+                                                       {
+                                                               rbsc->flag &= 
~RBC_FLAG_ENABLED;
+                                                               rbsc->flag |= 
RBC_FLAG_NEEDS_VALIDATE;
+
+                                                               if 
(rbsc->physics_constraint) {
+                                                                       
RB_constraint_set_enabled(rbsc->physics_constraint, false);
+                                                               }
+                                                       }
+                                               }
+
+                                               if 
((rmd->cluster_breaking_distance > 0) && (rbsc->mi1->particle_index != 
rbsc->mi2->particle_index)
+                                                   && distdiff > 
rmd->cluster_breaking_distance)
+                                               {
                                                        rbsc->flag &= 
~RBC_FLAG_ENABLED;
                                                        rbsc->flag |= 
RBC_FLAG_NEEDS_VALIDATE;
-                                                       
+
                                                        if 
(rbsc->physics_constraint) {
                                                                
RB_constraint_set_enabled(rbsc->physics_constraint, false);
                                                        }
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index ff3c9d3..2a0c9dd 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2339,12 +2339,25 @@ static int fracture_refresh_exec(bContext *C, 
wmOperator *UNUSED(op))
        Object *obact = ED_object_active_context(C);
        Scene *scene = CTX_data_scene(C);
        float cfra = BKE_scene_frame_get(scene);
+       double start = 1.0;
        FractureModifierData *rmd;
        FractureJob *fj;
        wmJob* wm_job;
 
        rmd = (FractureModifierData *)modifiers_findByType(obact, 
eModifierType_Fracture);
-       if (!rmd || (rmd && rmd->refresh) || (scene->rigidbody_world && cfra != 
scene->rigidbody_world->pointcache->startframe)) {
+
+       if (scene->rigidbody_world != NULL)
+       {
+               start = (double)scene->rigidbody_world->pointcache->startframe;
+       }
+
+       BKE_scene_frame_set(scene, start);
+       DAG_relations_tag_update(G.main);
+       WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+       WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
+       WM_event_add_notifier(C, NC_SCENE | ND_FRAME, NULL);
+
+       if (!rmd || (rmd && rmd->refresh) /*|| (scene->rigidbody_world && cfra 
!= scene->rigidbody_world->pointcache->startframe)*/) {
                rmd->refresh = false;
                return OPERATOR_CANCELLED;
        }
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index fca26a4..6f28b9a 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1453,10 +1453,13 @@ typedef struct FractureModifierData {
        int solver_iterations_override;
        int cluster_solver_iterations_override;
        int breaking_percentage;
+       int cluster_breaking_percentage;
        int splinter_axis;
 
        float breaking_angle;
        float breaking_distance;
+       float cluster_breaking_angle;
+       float cluster_breaking_distance;
        float origmat[4][4];
        float breaking_threshold;
        float cluster_breaking_threshold;
@@ -1490,7 +1493,7 @@ typedef struct FractureModifierData {
        /* internal values */
        float max_vol;
 
-       char pad[4];
+       //char pad[4];
 } FractureModifierData;
 
 #endif  /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index f3cae89..de2eec2 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -727,6 +727,28 @@ static void 
rna_RigidBodyModifier_autohide_dist_set(PointerRNA *ptr, float value
        rmd->refresh_autohide = true;
 }
 
+static void rna_RigidBodyModifier_cluster_breaking_angle_set(PointerRNA *ptr, 
float value)
+{
+       FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+       rmd->cluster_breaking_angle = value;
+       rmd->refresh_constraints = true;
+}
+
+static void rna_RigidBodyModifier_cluster_breaking_distance_set(PointerRNA 
*ptr, float value)
+{
+       FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+       rmd->cluster_breaking_distance = value;
+       rmd->refresh_constraints = true;
+}
+
+static void rna_RigidBodyModifier_cluster_breaking_percentage_set(PointerRNA 
*ptr, int value)
+{
+       FractureModifierData *rmd = (FractureModifierData*)ptr->data;
+       rmd->cluster_breaking_percentage = value;
+       rmd->refresh_constraints = true;
+}
+
+
 #else
 
 static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const 
char type[])
@@ -3846,7 +3868,7 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
        RNA_def_property_range(prop, 0.0f, FLT_MAX);
        RNA_def_property_float_default(prop

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to