[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59894] branches/soc-2013-rigid_body_sim: rigidbody: Add ghost objects

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


Revision: 59894
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59894
Author:   sergof
Date:     2013-09-06 17:58:58 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
rigidbody: Add ghost objects

Ghost objects simply don't respond to collisions, mostly useful for
triggers for now.
The UI is getting messy now, will clean up later.

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:56 UTC (rev 59893)
+++ branches/soc-2013-rigid_body_sim/intern/rigidbody/RBI_api.h	2013-09-06 17:58:58 UTC (rev 59894)
@@ -185,6 +185,7 @@
 extern void RB_body_suspend(rbRigidBody *object);
 
 extern void RB_body_set_trigger(rbRigidBody *object, int trigger);
+extern void RB_body_set_ghost(rbRigidBody *object, int ghost);
 
 /* RigidBody Interface - Rigid Body Activation States */
 extern int RB_body_get_activation_state(rbRigidBody *body);

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:56 UTC (rev 59893)
+++ branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp	2013-09-06 17:58:58 UTC (rev 59894)
@@ -633,6 +633,15 @@
 	object->is_trigger = trigger;
 }
 
+void RB_body_set_ghost(rbRigidBody *object, int ghost)
+{
+	btRigidBody *body = object->body;
+	if (ghost)
+		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:56 UTC (rev 59893)
+++ branches/soc-2013-rigid_body_sim/release/scripts/startup/bl_ui/properties_physics_rigidbody.py	2013-09-06 17:58:58 UTC (rev 59894)
@@ -49,6 +49,7 @@
                 row.prop(rbo, "enabled", text="Dynamic")
             row.prop(rbo, "kinematic", text="Animated")
             row.prop(rbo, "trigger", text="Trigger")
+            row.prop(rbo, "ghost", text="Ghost")
 
             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:56 UTC (rev 59893)
+++ branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c	2013-09-06 17:58:58 UTC (rev 59894)
@@ -674,6 +674,7 @@
 			RB_body_suspend(rbo->physics_object);
 		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);
+		RB_body_set_ghost(rbo->physics_object, rbo->flag & RBO_FLAG_GHOST);
 	}
 
 	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:56 UTC (rev 59893)
+++ branches/soc-2013-rigid_body_sim/source/blender/makesdna/DNA_rigidbody_types.h	2013-09-06 17:58:58 UTC (rev 59894)
@@ -154,7 +154,9 @@
 	RBO_FLAG_COMPOUND_PARENT	= (1 << 7),
 	RBO_FLAG_COMPOUND_CHILD		= (1 << 8),
 	/* rigidbdody is used as a collision trigger */
-	RBO_FLAG_TRIGGER			= (1 << 9)
+	RBO_FLAG_TRIGGER			= (1 << 9),
+	/* rigidbdody has no collision response */
+	RBO_FLAG_GHOST				= (1 << 10)
 } 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:56 UTC (rev 59893)
+++ branches/soc-2013-rigid_body_sim/source/blender/makesrna/intern/rna_rigidbody.c	2013-09-06 17:58:58 UTC (rev 59894)
@@ -795,6 +795,12 @@
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 	RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
 
+	prop = RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_GHOST);
+	RNA_def_property_ui_text(prop, "Ghost", "Rigid body does not respond to collisions");
+	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