[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59896] branches/soc-2013-rigid_body_sim: rigidbody: Add activation types
Sergej Reich
sergej.reich at googlemail.com
Fri Sep 6 19:59:02 CEST 2013
Revision: 59896
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59896
Author: sergof
Date: 2013-09-06 17:59:02 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
rigidbody: Add activation types
Now users can specify how object can be activated.
Right now only two options work:
Collision: bodies are activated on collision with other bodies
Trigger: bodies are activated on collision with trigger objects
TODO: implement activation based on time.
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:59:00 UTC (rev 59895)
+++ branches/soc-2013-rigid_body_sim/intern/rigidbody/RBI_api.h 2013-09-06 17:59:02 UTC (rev 59896)
@@ -186,6 +186,7 @@
extern void RB_body_set_trigger(rbRigidBody *object, int trigger);
extern void RB_body_set_ghost(rbRigidBody *object, int ghost);
+extern void RB_body_set_activation_type(rbRigidBody *object, int type);
/* 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:59:00 UTC (rev 59895)
+++ branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp 2013-09-06 17:59:02 UTC (rev 59896)
@@ -85,6 +85,13 @@
btConstraintSolver *constraintSolver;
btOverlapFilterCallback *filterCallback;
};
+
+enum ActivationType {
+ ACTIVATION_COLLISION = 0,
+ ACTIVATION_TRIGGER,
+ ACTIVATION_TIME
+};
+
struct rbRigidBody {
btRigidBody *body;
btDiscreteDynamicsWorld *world;
@@ -92,6 +99,7 @@
bool is_trigger;
bool suspended;
float saved_mass;
+ int activation_type;
};
struct rbCollisionShape {
@@ -121,7 +129,7 @@
rbRigidBody *rb0 = (rbRigidBody *)((btRigidBody *)collisionPair.m_pProxy0->m_clientObject)->getUserPointer();
rbRigidBody *rb1 = (rbRigidBody *)((btRigidBody *)collisionPair.m_pProxy1->m_clientObject)->getUserPointer();
- if (rb1->suspended) {
+ if (rb1->suspended && !(rb1->activation_type == ACTIVATION_TRIGGER && !rb0->is_trigger)) {
btRigidBody *body = rb1->body;
rb1->suspended = false;
rb1->world->removeRigidBody(body);
@@ -642,6 +650,11 @@
body->setCollisionFlags(body->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE);
}
+void RB_body_set_activation_type(rbRigidBody *object, int type)
+{
+ object->activation_type = type;
+}
+
/* ............ */
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:59:00 UTC (rev 59895)
+++ branches/soc-2013-rigid_body_sim/release/scripts/startup/bl_ui/properties_physics_rigidbody.py 2013-09-06 17:59:02 UTC (rev 59896)
@@ -117,6 +117,9 @@
col = split.column()
col.label(text="Activation:")
col.prop(rbo, "use_start_deactivated")
+ sub = col.column()
+ sub.active = rbo.use_start_deactivated
+ sub.prop(rbo, "activation_type")
col = split.column()
col.label(text="Deactivation:")
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:59:00 UTC (rev 59895)
+++ branches/soc-2013-rigid_body_sim/source/blender/blenkernel/intern/rigidbody.c 2013-09-06 17:59:02 UTC (rev 59896)
@@ -675,6 +675,7 @@
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);
+ RB_body_set_activation_type(rbo->physics_object, rbo->activation_type);
}
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:59:00 UTC (rev 59895)
+++ branches/soc-2013-rigid_body_sim/source/blender/makesdna/DNA_rigidbody_types.h 2013-09-06 17:59:02 UTC (rev 59896)
@@ -103,8 +103,8 @@
int flag; /* (eRigidBodyOb_Flag) */
int col_groups; /* Collision groups that determines wich rigid bodies can collide with each other */
- short mesh_source; /* mesh source for mesh based collision shapes */
- short pad;
+ short mesh_source; /* (eRigidBody_MeshSource) mesh source for mesh based collision shapes */
+ short activation_type; /* (eRigidBody_ActivationType) specifies how the RigidBody can be activaged */
/* Physics Parameters */
float mass; /* how much object 'weighs' (i.e. absolute 'amount of stuff' it holds) */
@@ -180,7 +180,6 @@
RB_SHAPE_APPROX
} eRigidBody_Shape;
-/* RigidBody Collision Shape */
typedef enum eRigidBody_MeshSource {
/* base mesh */
RBO_MESH_BASE = 0,
@@ -190,6 +189,15 @@
RBO_MESH_FINAL
} eRigidBody_MeshSource;
+typedef enum eRigidBody_ActivationType {
+ /* body gets activated on collision with other bodies */
+ RBO_ACTIVATION_COLLISION = 0,
+ /* body gets activated on collision with a trigger body */
+ RBO_ACTIVATION_TRIGGER,
+ /* body gets activated after a certain ammount of time */
+ RBO_ACTIVATION_TIME
+} eRigidBody_ActivationType;
+
/* ******************************** */
/* RigidBody Constraint */
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:59:00 UTC (rev 59895)
+++ branches/soc-2013-rigid_body_sim/source/blender/makesrna/intern/rna_rigidbody.c 2013-09-06 17:59:02 UTC (rev 59896)
@@ -77,14 +77,20 @@
{RBC_TYPE_MOTOR, "MOTOR", ICON_NONE, "Motor", "Drive rigid body around or along an axis"},
{0, NULL, 0, NULL, NULL}};
-/* roles of objects in RigidBody Sims */
+/* mesh source for collision shape creation */
EnumPropertyItem rigidbody_mesh_source_items[] = {
{RBO_MESH_BASE, "BASE", 0, "Base", "Base mesh"},
{RBO_MESH_DEFORM, "DEFORM", 0, "Deform", "Deformations (shaps keys, deform modifiers"},
{RBO_MESH_FINAL, "FINAL", 0, "Final", "All modifiers"},
{0, NULL, 0, NULL, NULL}};
+EnumPropertyItem rigidbody_activation_type_items[] = {
+ {RBO_ACTIVATION_COLLISION, "COLLISION", 0, "Collision", "Activation on collision with other rigid bodies"},
+ {RBO_ACTIVATION_TRIGGER, "TRIGGER", 0, "Trigger", "Activation on collision with trigger object"},
+ {RBO_ACTIVATION_TIME, "TIME", 0, "Time", "Activation after a specified ammount of time"},
+ {0, NULL, 0, NULL, NULL}};
+
#ifdef RNA_RUNTIME
#ifdef WITH_BULLET
@@ -761,7 +767,7 @@
RNA_def_property_ui_text(prop, "Type", "Role of object in Rigid Body Simulations");
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, "mesh_source", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mesh_source");
RNA_def_property_enum_items(prop, rigidbody_mesh_source_items);
@@ -769,6 +775,13 @@
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, "activation_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "activation_type");
+ RNA_def_property_enum_items(prop, rigidbody_activation_type_items);
+ RNA_def_property_ui_text(prop, "Activation Type", "Type of activation used");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+
/* booleans */
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBO_FLAG_DISABLED);
More information about the Bf-blender-cvs
mailing list