[Bf-blender-cvs] [3b0646b3ac] fracture_modifier: dissolve constraint now only dissolves constraints between different clusters if clusters are used
Martin Felke
noreply at git.blender.org
Tue Mar 7 16:42:18 CET 2017
Commit: 3b0646b3accbecb05f75568039c2b0462abc6848
Author: Martin Felke
Date: Tue Mar 7 16:41:09 2017 +0100
Branches: fracture_modifier
https://developer.blender.org/rB3b0646b3accbecb05f75568039c2b0462abc6848
dissolve constraint now only dissolves constraints between different clusters if clusters are used
additionally added a python-settable variable to indicate whether the dynamic fracture data has been loaded externally or not (just set it from the handler)
===================================================================
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_fracture.c
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 3a3eb6ab68..dbc0c13dc7 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -110,8 +110,13 @@ 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;
con = mi->participating_constraints[i];
- if (con->physics_constraint) {
+
+ 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) {
RB_constraint_set_enabled(con->physics_constraint, false);
}
}
@@ -1774,7 +1779,7 @@ static void rigidbody_create_shard_physics_constraint(FractureModifierData* fmd,
return;
}
- if (fmd->fracture_mode == MOD_FRACTURE_EXTERNAL || fmd->fracture_mode == MOD_FRACTURE_DYNAMIC)
+ if (fmd->fracture_mode == MOD_FRACTURE_EXTERNAL || (fmd->fracture_mode == MOD_FRACTURE_DYNAMIC && fmd->is_dynamic_external))
{
mul_v3_m4v3(loc, ob->obmat, rbc->pos);
mat4_to_quat(rot, ob->obmat);
@@ -1845,7 +1850,7 @@ static void rigidbody_create_shard_physics_constraint(FractureModifierData* fmd,
case RBC_TYPE_6DOF_SPRING:
rbc->physics_constraint = RB_constraint_new_6dof_spring(loc, rot, rb1, rb2);
- if (fmd->fracture_mode == MOD_FRACTURE_EXTERNAL || fmd->fracture_mode == MOD_FRACTURE_DYNAMIC)
+ if (fmd->fracture_mode == MOD_FRACTURE_EXTERNAL || (fmd->fracture_mode == MOD_FRACTURE_DYNAMIC && fmd->is_dynamic_external))
{
if ((rbc->plastic_angle < 0.0f) && (rbc->plastic_dist < 0.0f))
{
@@ -2039,12 +2044,16 @@ static void do_activate(Object* ob, Object *ob2, MeshIsland *mi_compare, RigidBo
{
for (mi = fmd->meshIslands.first; mi; mi = mi->next)
{
- bool same_cluster = (mi->particle_index != -1) &&
- (mi->particle_index == mi_compare->particle_index);
+ bool dissolve = ob->rigidbody_object->flag & RBO_FLAG_CONSTRAINT_DISSOLVE;
+
+ bool same_cluster = ((mi->particle_index != -1) &&
+ (mi->particle_index == mi_compare->particle_index));
+
+ bool different_cluster = !same_cluster && dissolve;
RigidBodyOb* rbo = mi->rigidbody;
- if (((rbo->flag & RBO_FLAG_KINEMATIC) || (ob->rigidbody_object->flag & RBO_FLAG_CONSTRAINT_DISSOLVE)) &&
- ((mi_compare == mi) || same_cluster))
+ if (((rbo->flag & RBO_FLAG_KINEMATIC) || different_cluster) &&
+ ((mi_compare == mi) || (same_cluster && !dissolve)))
{
if (rbo->physics_object) {
activateRigidbody(rbo, rbw, mi, ob);
@@ -4070,7 +4079,8 @@ static bool do_update_modifier(Scene* scene, Object* ob, RigidBodyWorld *rbw, bo
rbsc->mi2->rigidbody->flag & RBO_FLAG_KINEMATIC_REBUILD) {
/* World has been rebuilt so rebuild constraint */
BKE_rigidbody_validate_sim_shard_constraint(rbw, fmd, ob, rbsc, true);
- BKE_rigidbody_start_dist_angle(rbsc, fmd->fracture_mode == MOD_FRACTURE_EXTERNAL || fmd->fracture_mode == MOD_FRACTURE_DYNAMIC);
+ BKE_rigidbody_start_dist_angle(rbsc, fmd->fracture_mode == MOD_FRACTURE_EXTERNAL ||
+ (fmd->fracture_mode == MOD_FRACTURE_DYNAMIC && fmd->is_dynamic_external));
//TODO ensure evaluation on transform change too
}
@@ -4085,7 +4095,8 @@ static bool do_update_modifier(Scene* scene, Object* ob, RigidBodyWorld *rbw, bo
handle_regular_breaking(fmd, ob, rbw, rbsc, max_con_mass, rebuild);
}
- if ((fmd->fracture_mode == MOD_FRACTURE_EXTERNAL || fmd->fracture_mode == MOD_FRACTURE_DYNAMIC) && (rbsc->flag & RBC_FLAG_USE_BREAKING) && !rebuild)
+ if ((fmd->fracture_mode == MOD_FRACTURE_EXTERNAL || fmd->fracture_mode == MOD_FRACTURE_DYNAMIC && fmd->is_dynamic_external) &&
+ (rbsc->flag & RBC_FLAG_USE_BREAKING) && !rebuild)
{
handle_plastic_breaking(rbsc, rbw, laststeps, lastscale);
}
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index f8c40407d2..2a72649078 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1767,6 +1767,7 @@ typedef struct FractureModifierData {
int limit_impact;
int fracture_all;
int dynamic_new_constraints;
+ int is_dynamic_external;
/* internal flags */
int use_experimental;
@@ -1786,7 +1787,7 @@ typedef struct FractureModifierData {
int keep_cutter_shards;
- //char pad[4];
+ char pad[4];
} FractureModifierData;
typedef struct DataTransferModifierData {
diff --git a/source/blender/makesrna/intern/rna_fracture.c b/source/blender/makesrna/intern/rna_fracture.c
index 855c123bd1..b8bdfe3712 100644
--- a/source/blender/makesrna/intern/rna_fracture.c
+++ b/source/blender/makesrna/intern/rna_fracture.c
@@ -1222,5 +1222,11 @@ void RNA_def_fracture(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Inner Crease", "Crease at edges of inner faces");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "is_dynamic_external", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "is_dynamic_external", false);
+ RNA_def_property_ui_text(prop, "Dynamic External", "Indicator whether the data for dynamic fracture was loaded externally");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ //RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
RNA_api_fracture(brna, srna);
}
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index e2c412ae2b..8f525053d7 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -230,6 +230,7 @@ static void initData(ModifierData *md)
fmd->keep_cutter_shards = MOD_FRACTURE_KEEP_BOTH;
fmd->use_constraint_collision = false;
fmd->inner_crease = 0.0f;
+ fmd->is_dynamic_external = false;
}
//XXX TODO, freeing functionality should be in BKE too
@@ -1802,6 +1803,7 @@ static void copyData(ModifierData *md, ModifierData *target)
trmd->keep_cutter_shards = rmd->keep_cutter_shards;
trmd->use_constraint_collision = rmd->use_constraint_collision;
trmd->inner_crease = rmd->inner_crease;
+ trmd->is_dynamic_external = rmd->is_dynamic_external;
}
//XXXX TODO, is BB really useds still ? aint there exact volume calc now ?
More information about the Bf-blender-cvs
mailing list