[Bf-blender-cvs] [0e7fb6d0bd6] fracture_modifier: support for "anti-triggers" which stop movement of active rigidbody shards
Martin Felke
noreply at git.blender.org
Wed Aug 9 15:30:22 CEST 2017
Commit: 0e7fb6d0bd613a0924bc027a5ac213d6351ae11e
Author: Martin Felke
Date: Wed Aug 9 15:30:00 2017 +0200
Branches: fracture_modifier
https://developer.blender.org/rB0e7fb6d0bd613a0924bc027a5ac213d6351ae11e
support for "anti-triggers" which stop movement of active rigidbody shards
===================================================================
M release/scripts/startup/bl_ui/properties_physics_rigidbody.py
M source/blender/blenkernel/BKE_rigidbody.h
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 21e1ae37a04..fd6fa2223df 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -81,7 +81,7 @@ class PHYSICS_PT_rigid_body_trigger_advanced(PHYSICS_PT_rigidbody_panel, Panel):
row.prop(rbo, "dynamic_trigger")
row = layout.row()
row.prop(rbo, "plastic_dissolve")
-
+ row.prop(rbo, "is_anti_trigger")
class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Rigid Body Collisions"
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 5e15c2a7241..73ce652b271 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -107,6 +107,7 @@ void BKE_rigidbody_start_dist_angle(struct RigidBodyShardCon* con, bool exact);
void BKE_rigidbody_remove_shard_con(struct Scene* scene, struct RigidBodyShardCon* con);
void BKE_rigidbody_remove_shard(struct Scene* scene, struct MeshIsland *mi);
void BKE_rigidbody_update_ob_array(struct RigidBodyWorld *rbw, bool do_bake_correction);
+void BKE_deactivateRigidbody(struct RigidBodyOb *rbo);
/* -------------- */
/* Utility Macros */
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 1913dee9b7a..34705ed569e 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -2064,15 +2064,18 @@ static void do_activate(Object* ob, Object *ob2, MeshIsland *mi_compare, RigidBo
{
FractureModifierData *fmd;
bool valid = true;
+ bool antiValid = ob2->rigidbody_object->flag & RBO_FLAG_ANTI_TRIGGER;
MeshIsland *mi;
fmd = (FractureModifierData*)modifiers_findByType(ob, eModifierType_Fracture);
valid = valid && (fmd != NULL);
+ antiValid = antiValid && (fmd != NULL);
+
valid = valid && (ob->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION);
valid = valid && ((ob2->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER) || ((ob2->rigidbody_object->flag & RBO_FLAG_PROPAGATE_TRIGGER) &&
((mi_trigger) && (mi_trigger->rigidbody->flag & RBO_FLAG_PROPAGATE_TRIGGER))));
- if (valid)
+ if (valid || antiValid)
{
for (mi = fmd->meshIslands.first; mi; mi = mi->next)
{
@@ -2084,24 +2087,37 @@ static void do_activate(Object* ob, Object *ob2, MeshIsland *mi_compare, RigidBo
bool different_cluster = !same_cluster && dissolve;
RigidBodyOb* rbo = mi->rigidbody;
- if (((rbo->flag & RBO_FLAG_KINEMATIC) || different_cluster) &&
- ((mi_compare == mi) || (same_cluster && !dissolve)))
+ if ((((rbo->flag & RBO_FLAG_KINEMATIC) || different_cluster) &&
+ ((mi_compare == mi) || (same_cluster && !dissolve))) && valid)
{
if (rbo->physics_object) {
activateRigidbody(rbo, rbw, mi, ob);
}
}
+
+ if ((mi_compare == mi) && antiValid)
+ {
+ if (rbo->physics_object) {
+ BKE_deactivateRigidbody(rbo);
+ }
+ }
}
}
else if (!fmd)
{
bool valid = ob2->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER;
+ bool antiValid = ob2->rigidbody_object->flag & RBO_FLAG_ANTI_TRIGGER;
RigidBodyOb* rbo = ob->rigidbody_object;
if (rbo && valid)
{
activateRigidbody(rbo, rbw, NULL, ob);
}
+
+ if (rbo && antiValid)
+ {
+ BKE_deactivateRigidbody(rbo);
+ }
}
}
@@ -2237,7 +2253,8 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
((ob1->rigidbody_object->type == RBO_TYPE_ACTIVE) && (ob2->rigidbody_object->type == RBO_TYPE_ACTIVE)));
}
- if (validOb || (ob1->rigidbody_object->flag & RBO_FLAG_CONSTRAINT_DISSOLVE) || (ob2->rigidbody_object->flag & RBO_FLAG_CONSTRAINT_DISSOLVE))
+ if (validOb || (ob1->rigidbody_object->flag & RBO_FLAG_CONSTRAINT_DISSOLVE) || (ob2->rigidbody_object->flag & RBO_FLAG_CONSTRAINT_DISSOLVE) ||
+ (ob1->rigidbody_object->flag & RBO_FLAG_ANTI_TRIGGER) || (ob2->rigidbody_object->flag & RBO_FLAG_ANTI_TRIGGER))
{
if (ob1->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION)
{
@@ -3738,14 +3755,17 @@ static void handle_breaking_percentage(FractureModifierData* fmd, Object *ob, Me
}
}
-static void deactivateRigidbody(RigidBodyOb *rbo)
+void BKE_deactivateRigidbody(RigidBodyOb *rbo)
{
//make kinematic again (un-trigger)
- //RB_body_set_kinematic_state(rbo->physics_object, true);
- //RB_body_set_mass(rbo->physics_object, 0.0f);
- //rbo->flag |= RBO_FLAG_IS_GHOST;
- //rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
- RB_body_deactivate(rbo->physics_object);
+ //printf("Untrigger\n");
+ if (rbo->physics_object)
+ {
+ RB_body_set_kinematic_state(rbo->physics_object, true);
+ RB_body_set_mass(rbo->physics_object, 0.0f);
+ //rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
+ RB_body_deactivate(rbo->physics_object);
+ }
}
static void deform_constraint(FractureModifierData *fmd, Object *ob, RigidBodyShardCon* rbsc, RigidBodyWorld *rbw)
@@ -3763,8 +3783,8 @@ static void deform_constraint(FractureModifierData *fmd, Object *ob, RigidBodySh
thresh = RB_constraint_get_breaking_threshold(rbsc->physics_constraint);
RB_constraint_set_breaking_threshold(rbsc->physics_constraint, thresh * weakening);
- deactivateRigidbody(rbsc->mi1->rigidbody);
- deactivateRigidbody(rbsc->mi2->rigidbody);
+ RB_body_deactivate(rbsc->mi1->rigidbody->physics_object);
+ RB_body_deactivate(rbsc->mi2->rigidbody->physics_object);
}
static void handle_deform_angle(FractureModifierData *fmd, Object *ob, RigidBodyShardCon *rbsc, RigidBodyWorld *rbw,
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index f8b75344886..bc3d06894c1 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -187,6 +187,8 @@ typedef enum eRigidBodyOb_Flag {
RBO_FLAG_DYNAMIC_TRIGGER = (1 << 14),
/* dissolve plastic constraints too (if any) */
RBO_FLAG_PLASTIC_DISSOLVE = (1 << 15),
+ /* anti trigger flag, make simulated objects kinematic again */
+ RBO_FLAG_ANTI_TRIGGER = (1 << 16),
} eRigidBodyOb_Flag;
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 0f51deb0947..7dae2028c49 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -1107,6 +1107,11 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
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");
+
+ prop = RNA_def_property(srna, "is_anti_trigger", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_ANTI_TRIGGER);
+ RNA_def_property_ui_text(prop, "Anti-Trigger", "Can trigger deactivation of other simulated objects, which are set up to be triggered");
+ 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