[Bf-blender-cvs] [be30a2c] fracture_modifier: added a trigger flag, only rigidbody objects with this flag can trigger other objects (which themselves must be animated and have their "triggered" flag enabled

Martin Felke noreply at git.blender.org
Sat Dec 27 14:40:17 CET 2014


Commit: be30a2cd18797a9aa8a5b0db257ccd42bd4058c0
Author: Martin Felke
Date:   Sat Dec 27 13:27:10 2014 +0100
Branches: fracture_modifier
https://developer.blender.org/rBbe30a2cd18797a9aa8a5b0db257ccd42bd4058c0

added a trigger flag, only rigidbody objects with this flag can trigger other objects (which themselves must be animated and have their "triggered" flag enabled

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

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 449d905..b9cb0d5 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -51,6 +51,8 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
             if rbo.type == 'ACTIVE':
                 row = layout.row()
                 row.prop(rbo, "use_kinematic_deactivation", text="Triggered")
+                row.prop(rbo, "is_trigger")
+                row = layout.row()
                 row.prop(rbo, "is_ghost")
 
             if rbo.type == 'ACTIVE':
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index e3a9052..25ea922 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1709,12 +1709,12 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
 			fmd1 = (FractureModifierData*)modifiers_findByType(ob1, eModifierType_Fracture);
 			valid = valid && (fmd1 != NULL);
 			valid = valid && (ob1->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION);
-			//valid = valid && (ob2->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION);
+			valid = valid && (ob2->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER);
 
-			valid2 = valid2 && (fmd1 != NULL);
-			valid2 = valid2 && (fmd1->use_constraints == false);
+			//valid2 = valid2 && (fmd1 != NULL);
+			//valid2 = valid2 && (fmd1->use_constraints == false);
 
-			if (valid || valid2)
+			if (valid /*|| valid2*/)
 			{
 				for (mi = fmd1->meshIslands.first; mi; mi = mi->next)
 				{
@@ -1724,15 +1724,15 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
 						if (rbo->physics_object) {
 							activateRigidbody(rbo);
 						}
-
 					}
 				}
 			}
 			else if (!fmd1)
 			{
+				bool valid = ob2->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER;
 				RigidBodyOb* rbo = ob1->rigidbody_object;
 
-				if (rbo)
+				if (rbo && valid)
 				{
 					activateRigidbody(rbo);
 				}
@@ -1745,12 +1745,12 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
 			fmd2 = (FractureModifierData*)modifiers_findByType(ob2, eModifierType_Fracture);
 			valid = valid && (fmd2 != NULL);
 			valid = valid && (ob2->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION);
-			//valid = valid && (ob1->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION);
+			valid = valid && (ob1->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER);
 
-			valid2 = valid2 && (fmd2 != NULL);
-			valid2 = valid2 && (fmd2->use_constraints == false);
+			//valid2 = valid2 && (fmd2 != NULL);
+			//valid2 = valid2 && (fmd2->use_constraints == false);
 
-			if (valid || valid2)
+			if (valid /* || valid2*/)
 			{
 				for (mi = fmd2->meshIslands.first; mi; mi = mi->next)
 				{
@@ -1766,9 +1766,10 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
 			}
 			else if (!fmd2)
 			{
+				bool valid = ob1->rigidbody_object->flag & RBO_FLAG_IS_TRIGGER;
 				RigidBodyOb* rbo = ob2->rigidbody_object;
 
-				if (rbo)
+				if (rbo && valid)
 				{
 					activateRigidbody(rbo);
 				}
@@ -3240,6 +3241,11 @@ static void restoreKinematic(RigidBodyWorld *rbw)
 					}
 				}
 			}
+			else
+			{
+				go->ob->rigidbody_object->flag |= RBO_FLAG_KINEMATIC;
+				go->ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_VALIDATE;
+			}
 		}
 	}
 }
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index faba30b..c3a87c6 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -166,6 +166,8 @@ typedef enum eRigidBodyOb_Flag {
 	RBO_FLAG_USE_KINEMATIC_DEACTIVATION = (1 << 9),
 	/* ghost flag, do not collide with object (but can activate although) */
 	RBO_FLAG_IS_GHOST = (1 << 10),
+	/* trigger flag, trigger kinematic state change on other objects */
+	RBO_FLAG_IS_TRIGGER = (1 << 11),
 } eRigidBodyOb_Flag;
 
 /* RigidBody Collision Shape */
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 0f91dbc..1a27b0f 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -1010,6 +1010,11 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_IS_GHOST);
 	RNA_def_property_ui_text(prop, "Ghost", "Do not collide with object, but can activate other animated objects");
 	RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+
+	prop = RNA_def_property(srna, "is_trigger", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_IS_TRIGGER);
+	RNA_def_property_ui_text(prop, "Trigger", "Can trigger activation of other animated 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