[Bf-blender-cvs] [64ada2985f5] fracture_modifier: added Dissolve plastic constraints option, only relevant for external mode
Martin Felke
noreply at git.blender.org
Fri Jun 16 12:21:20 CEST 2017
Commit: 64ada2985f56779bffd5ecca994a100b33a2d9c0
Author: Martin Felke
Date: Fri Jun 16 12:21:02 2017 +0200
Branches: fracture_modifier
https://developer.blender.org/rB64ada2985f56779bffd5ecca994a100b33a2d9c0
added Dissolve plastic constraints option, only relevant for external mode
===================================================================
M release/scripts/startup/bl_ui/properties_physics_rigidbody.py
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/makesdna/DNA_rigidbody_types.h
M source/blender/makesrna/intern/rna_rigidbody.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index 984b7800ddf..21e1ae37a04 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -79,6 +79,8 @@ class PHYSICS_PT_rigid_body_trigger_advanced(PHYSICS_PT_rigidbody_panel, Panel):
row = layout.row()
row.prop(rbo, "constraint_dissolve")
row.prop(rbo, "dynamic_trigger")
+ row = layout.row()
+ row.prop(rbo, "plastic_dissolve")
class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 2c708a9de49..c42ee663e98 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -111,12 +111,17 @@ static void activateRigidbody(RigidBodyOb* rbo, RigidBodyWorld *UNUSED(rbw), Mes
if (mi && ob->rigidbody_object->flag & RBO_FLAG_CONSTRAINT_DISSOLVE) {
for (i = 0; i < mi->participating_constraint_count; i++) {
bool different_cluster = false;
+ bool dissolve_plastic = (ob->rigidbody_object->flag & RBO_FLAG_PLASTIC_DISSOLVE);
con = mi->participating_constraints[i];
different_cluster = ((con->mi1->particle_index != con->mi2->particle_index) ||
((con->mi1->particle_index == -1) && (con->mi2->particle_index == -1)));
if (con->physics_constraint && different_cluster) {
+ if (dissolve_plastic) {
+ con->flag |= RBC_FLAG_PLASTIC_ACTIVE;
+ }
+
RB_constraint_set_enabled(con->physics_constraint, false);
}
}
@@ -4092,11 +4097,14 @@ static bool do_update_modifier(Scene* scene, Object* ob, RigidBodyWorld *rbw, bo
/*reset plastic constraints with immediate activation*/
if (rbsc->flag & RBC_FLAG_USE_PLASTIC)
{
- rbsc->flag |= RBC_FLAG_PLASTIC_ACTIVE;
- rigidbody_set_springs_active(rbsc, true);
- RB_constraint_set_enabled(rbsc->physics_constraint, true);
- if (rbsc->physics_constraint)
- RB_constraint_set_equilibrium_6dof_spring(rbsc->physics_constraint);
+ if (!(rbsc->flag & RBC_FLAG_PLASTIC_ACTIVE))
+ {
+ rbsc->flag |= RBC_FLAG_PLASTIC_ACTIVE;
+ rigidbody_set_springs_active(rbsc, true);
+ RB_constraint_set_enabled(rbsc->physics_constraint, true);
+ if (rbsc->physics_constraint)
+ RB_constraint_set_equilibrium_6dof_spring(rbsc->physics_constraint);
+ }
}
else
{
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index c9c57deab6e..f8b75344886 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -185,6 +185,9 @@ typedef enum eRigidBodyOb_Flag {
RBO_FLAG_CONSTRAINT_DISSOLVE = (1 << 13),
/* trigger a dynamic fracture with this type */
RBO_FLAG_DYNAMIC_TRIGGER = (1 << 14),
+ /* dissolve plastic constraints too (if any) */
+ RBO_FLAG_PLASTIC_DISSOLVE = (1 << 15),
+
} eRigidBodyOb_Flag;
/* RigidBody Collision Shape */
@@ -404,7 +407,7 @@ typedef enum eRigidBodyCon_Flag {
/* mark this constraint to be able to go into "plastic" mode */
RBC_FLAG_USE_PLASTIC = (1 << 17),
/* mark already active plastic constraints */
- RBC_FLAG_PLASTIC_ACTIVE = (1 << 18)
+ RBC_FLAG_PLASTIC_ACTIVE = (1 << 18),
} eRigidBodyCon_Flag;
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index b9c15a334be..0f51deb0947 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -1102,6 +1102,11 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_DYNAMIC_TRIGGER);
RNA_def_property_ui_text(prop, "Dynamic Trigger", "Triggers a dynamic fracture independently of force threshold");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+
+ prop = RNA_def_property(srna, "plastic_dissolve", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_PLASTIC_DISSOLVE);
+ RNA_def_property_ui_text(prop, "Dissolve Plastic Constraints", "Dissolves plastic constraints on shards of this trigger target, only relevant for external mode");
+ RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
/* Physics Parameters */
prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
More information about the Bf-blender-cvs
mailing list