[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59890] branches/soc-2013-rigid_body_sim: rigidbody: Add option to mark rigid bodies as collision triggers

Sergej Reich sergej.reich at googlemail.com
Fri Sep 6 19:58:52 CEST 2013


Revision: 59890
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59890
Author:   sergof
Date:     2013-09-06 17:58:52 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
rigidbody: Add option to mark rigid bodies as collision triggers

Trigger object behave like normal rigid bodies but don't respond to
collisions.

Modified Paths:
--------------
    branches/soc-2013-rigid_body_sim/intern/rigidbody/RBI_api.h
    branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp
    branches/soc-2013-rigid_body_sim/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
    branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c
    branches/soc-2013-rigid_body_sim/source/blender/makesdna/DNA_rigidbody_types.h
    branches/soc-2013-rigid_body_sim/source/blender/makesrna/intern/rna_rigidbody.c

Modified: branches/soc-2013-rigid_body_sim/intern/rigidbody/RBI_api.h
===================================================================
--- branches/soc-2013-rigid_body_sim/intern/rigidbody/RBI_api.h	2013-09-06 17:58:50 UTC (rev 59889)
+++ branches/soc-2013-rigid_body_sim/intern/rigidbody/RBI_api.h	2013-09-06 17:58:52 UTC (rev 59890)
@@ -182,6 +182,8 @@
 /* Kinematic State */
 extern void RB_body_set_kinematic_state(rbRigidBody *body, int kinematic);
 
+extern void RB_body_set_trigger(rbRigidBody *object, int trigger);
+
 /* RigidBody Interface - Rigid Body Activation States */
 extern int RB_body_get_activation_state(rbRigidBody *body);
 extern void RB_body_set_activation_state(rbRigidBody *body, int use_deactivation);

Modified: branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp
===================================================================
--- branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp	2013-09-06 17:58:50 UTC (rev 59889)
+++ branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp	2013-09-06 17:58:52 UTC (rev 59890)
@@ -88,6 +88,7 @@
 struct rbRigidBody {
 	btRigidBody *body;
 	int col_groups;
+	bool is_trigger;
 };
 
 struct rbCollisionShape {
@@ -592,6 +593,16 @@
 		body->setCollisionFlags(body->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
 }
 
+void RB_body_set_trigger(rbRigidBody *object, int trigger)
+{
+	btRigidBody *body = object->body;
+	object->is_trigger = trigger;
+	if (trigger)
+		body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
+	else
+		body->setCollisionFlags(body->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE);
+}
+
 /* ............ */
 
 void RB_body_set_activation_state(rbRigidBody *object, int use_deactivation)

Modified: branches/soc-2013-rigid_body_sim/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
===================================================================
--- branches/soc-2013-rigid_body_sim/release/scripts/startup/bl_ui/properties_physics_rigidbody.py	2013-09-06 17:58:50 UTC (rev 59889)
+++ branches/soc-2013-rigid_body_sim/release/scripts/startup/bl_ui/properties_physics_rigidbody.py	2013-09-06 17:58:52 UTC (rev 59890)
@@ -48,6 +48,7 @@
             if rbo.type == 'ACTIVE':
                 row.prop(rbo, "enabled", text="Dynamic")
             row.prop(rbo, "kinematic", text="Animated")
+            row.prop(rbo, "trigger", text="Trigger")
 
             if rbo.type == 'ACTIVE':
                 layout.prop(rbo, "mass")

Modified: branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c	2013-09-06 17:58:50 UTC (rev 59889)
+++ branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c	2013-09-06 17:58:52 UTC (rev 59890)
@@ -671,6 +671,7 @@
 
 		RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
 		RB_body_set_kinematic_state(rbo->physics_object, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
+		RB_body_set_trigger(rbo->physics_object, rbo->flag & RBO_FLAG_TRIGGER);
 	}
 
 	if (rbw && rbw->physics_world && (rbo->flag & RBO_FLAG_COMPOUND_CHILD) == 0) // RB_TODO find better solution for compound shapes

Modified: branches/soc-2013-rigid_body_sim/source/blender/makesdna/DNA_rigidbody_types.h
===================================================================
--- branches/soc-2013-rigid_body_sim/source/blender/makesdna/DNA_rigidbody_types.h	2013-09-06 17:58:50 UTC (rev 59889)
+++ branches/soc-2013-rigid_body_sim/source/blender/makesdna/DNA_rigidbody_types.h	2013-09-06 17:58:52 UTC (rev 59890)
@@ -152,7 +152,9 @@
 	RBO_FLAG_USE_MARGIN			= (1 << 6),
 	/* compound shape flags, should not be set manually */
 	RBO_FLAG_COMPOUND_PARENT	= (1 << 7),
-	RBO_FLAG_COMPOUND_CHILD		= (1 << 8)
+	RBO_FLAG_COMPOUND_CHILD		= (1 << 8),
+	/* rigidbdody is used as a collision trigger */
+	RBO_FLAG_TRIGGER			= (1 << 9)
 } eRigidBodyOb_Flag;
 
 /* RigidBody Collision Shape */

Modified: branches/soc-2013-rigid_body_sim/source/blender/makesrna/intern/rna_rigidbody.c
===================================================================
--- branches/soc-2013-rigid_body_sim/source/blender/makesrna/intern/rna_rigidbody.c	2013-09-06 17:58:50 UTC (rev 59889)
+++ branches/soc-2013-rigid_body_sim/source/blender/makesrna/intern/rna_rigidbody.c	2013-09-06 17:58:52 UTC (rev 59890)
@@ -789,6 +789,12 @@
 	RNA_def_property_ui_text(prop, "Kinematic", "Allow rigid body to be controlled by the animation system");
 	RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
 	
+	prop = RNA_def_property(srna, "trigger", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_TRIGGER);
+	RNA_def_property_ui_text(prop, "Trigger", "Rigid body acts as collision trigger");
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	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);
 	RNA_def_property_float_sdna(prop, NULL, "mass");




More information about the Bf-blender-cvs mailing list