[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30074] branches/soc-2010-aligorith-2: Bullet SoC - Assorted work on constraints

Joshua Leung aligorith at gmail.com
Wed Jul 7 14:29:55 CEST 2010


Revision: 30074
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30074
Author:   aligorith
Date:     2010-07-07 14:29:53 +0200 (Wed, 07 Jul 2010)

Log Message:
-----------
Bullet SoC - Assorted work on constraints

* Silenced warning in console about Rigid Body Joint constraint
* Started implementing RigidBody constraints API (Bullet side). Still have to determine best way to setup most of the constraints...

Modified Paths:
--------------
    branches/soc-2010-aligorith-2/release/scripts/ui/properties_object_constraint.py
    branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_constraint.c
    branches/soc-2010-aligorith-2/source/blender/rigidbody/RBI_api.h
    branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp

Modified: branches/soc-2010-aligorith-2/release/scripts/ui/properties_object_constraint.py
===================================================================
--- branches/soc-2010-aligorith-2/release/scripts/ui/properties_object_constraint.py	2010-07-07 11:13:34 UTC (rev 30073)
+++ branches/soc-2010-aligorith-2/release/scripts/ui/properties_object_constraint.py	2010-07-07 12:29:53 UTC (rev 30074)
@@ -580,7 +580,7 @@
         self.space_template(layout, con, wide_ui)
 
     def RIGID_BODY_JOINT(self, context, layout, con, wide_ui):
-        self.target_template(layout, con, wide_ui)
+        self.target_template(layout, con, wide_ui, subtargets=False)
 
         if wide_ui:
             layout.prop(con, "pivot_type")

Modified: branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_constraint.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_constraint.c	2010-07-07 11:13:34 UTC (rev 30073)
+++ branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_constraint.c	2010-07-07 12:29:53 UTC (rev 30074)
@@ -1187,7 +1187,8 @@
 	srna= RNA_def_struct(brna, "RigidBodyJointConstraint", "Constraint");
 	RNA_def_struct_ui_text(srna, "Rigid Body Joint Constraint", "For use with the Game Engine");
 	RNA_def_struct_sdna_from(srna, "bRigidBodyJointConstraint", "data");
-
+	
+	// xxx: wtf is this used for?
 	prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "tar");
 	RNA_def_property_ui_text(prop, "Target", "Target Object");

Modified: branches/soc-2010-aligorith-2/source/blender/rigidbody/RBI_api.h
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/rigidbody/RBI_api.h	2010-07-07 11:13:34 UTC (rev 30073)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/RBI_api.h	2010-07-07 12:29:53 UTC (rev 30074)
@@ -59,8 +59,8 @@
 /* Collision Shape */
 typedef struct _rbCollisionShape rbCollisionShape;
 
-/* Motion States */
-// XXX: Bullet only?
+/* Constraint */
+typedef struct _rbConstraint rbConstraint;
 
 /* ********************************** */
 /* Dynamics World Methods */
@@ -194,6 +194,7 @@
 
 /* Setup (Special Shapes) ------------ */
 
+/* Convex Hull */
 extern rbCollisionShape *rbShapeNewConvexHull();
 extern void rbShapeAddVert(rbCollisionShape *cshape, const float co[3]);
 
@@ -203,11 +204,31 @@
 
 /* Settings --------------------------- */
 
+/* Collision Margin */
 extern float rbShapeGetMargin(rbCollisionShape *cshape);
 extern void rbShapeSetMargin(rbCollisionShape *cshape, float value);
 
 /* ********************************** */
+/* Constraints */
 
+/* Setup ----------------------------- */
+
+/* Add Rigid Body Constraint to simulation world */
+extern void rbDWorldAddConstraint(rbDynamicsWorld *world, rbConstraint *con);
+
+/* Remove Rigid Body Constraint from simulation world */
+extern void rbDWorldRemoveConstraint(rbDynamicsWorld *world, rbConstraint *con);
+
+/* ............ */
+
+/* Cleanup --------------------------- */
+
+extern void rbConstraintDelete(rbConstraint *con);
+
+/* Settings --------------------------- */
+
+/* ********************************** */
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp	2010-07-07 11:13:34 UTC (rev 30073)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp	2010-07-07 12:29:53 UTC (rev 30074)
@@ -243,6 +243,15 @@
 void rbBodyDelete(rbRigidBody *object)
 {
 	btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+	
+	/* motion state */
+	btMotionState *ms = body->getMotionState();
+	if (ms)
+		btAlignedFree(ms);
+	
+	/* collision shape is done elsewhere... */
+	
+	/* body itself */
 	btAlignedFree(body);
 }
 
@@ -537,3 +546,38 @@
 }
 
 /* ********************************** */
+/* Constraints */
+
+/* Setup ----------------------------- */
+
+void rbDWorldAddConstraint(rbDynamicsWorld *world, rbConstraint *con)
+{
+	btDynamicsWorld *dynamicsWorld = reinterpret_cast<btDynamicsWorld*>(world);
+	btTypedConstraint *constraint = reinterpret_cast<btTypedConstraint*>(con);
+	
+	dynamicsWorld->addConstraint(constraint);
+}
+
+void rbDWorldRemoveConstraint(rbDynamicsWorld *world, rbConstraint *con)
+{
+	btDynamicsWorld *dynamicsWorld = reinterpret_cast<btDynamicsWorld*>(world);
+	btTypedConstraint *constraint = reinterpret_cast<btTypedConstraint*>(con);
+	
+	dynamicsWorld->removeConstraint(constraint);
+}
+
+/* ............ */
+
+// TODO: inidividual constraint types
+
+/* Cleanup ----------------------------- */
+
+void rbConstraintDelete(rbConstraint *con)
+{
+	btTypedConstraint *constraint = reinterpret_cast<btTypedConstraint*>(con);
+	btAlignedFree(constraint);
+}
+
+/* Settings ------------------------- */
+
+/* ********************************** */





More information about the Bf-blender-cvs mailing list