[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31134] branches/soc-2010-aligorith-2/ source/blender: Bullet SoC - Tweaks to force calculations

Joshua Leung aligorith at gmail.com
Sat Aug 7 06:48:11 CEST 2010


Revision: 31134
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31134
Author:   aligorith
Date:     2010-08-07 06:48:09 +0200 (Sat, 07 Aug 2010)

Log Message:
-----------
Bullet SoC - Tweaks to force calculations

Added back some RigidBody API calls to get data from the simulation. This is now used to give more accurate data for the force calculations, allowing forces to take more influence than they could before. However, something still seems to be missing here for some reason or other...

Modified Paths:
--------------
    branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.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/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c	2010-08-07 04:18:16 UTC (rev 31133)
+++ branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c	2010-08-07 04:48:09 UTC (rev 31134)
@@ -567,10 +567,12 @@
 		float force[3];
 		
 		/* create dummy 'point' which represents last known position of object as result of sim */
-		// WARN: this can create some inaccuracies with sim position, but is probably better than using unsimulated vals?
-#if 1 // XXX: this is the 'safe' version for now (using object info), but really should try grabbing from sim... need api calls
+#if 0 // XXX: this is the 'safe' version (using object info), but really should try grabbing from sim for better responses?
 		VECCOPY(loc, ob->obmat[3]);
 		vel[0]=vel[1]=vel[2]= 1.0f;
+#else // XXX: this can create some inaccuracies with sim position, but is probably better than using unsimulated vals?
+		rbBodyGetPosition(rbo->physics_object, loc);
+		rbBodyGetLinearVelocity(rbo->physics_object, vel);
 #endif
 		pd_point_from_loc(scene, loc, vel, 0, &epoint);
 		

Modified: branches/soc-2010-aligorith-2/source/blender/rigidbody/RBI_api.h
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/rigidbody/RBI_api.h	2010-08-07 04:18:16 UTC (rev 31133)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/RBI_api.h	2010-08-07 04:48:09 UTC (rev 31134)
@@ -187,8 +187,10 @@
 
 /* ............ */
 
+// XXX: are these in the correct spaces?
+void rbBodyGetPosition(rbRigidBody *body, float v_out[3]);
+void rbBodyGetOrientation(rbRigidBody *body, float v_out[4]);
 
-
 /* ............ */
 
 extern void rbBodyApplyCentralForce(rbRigidBody *body, const float v_in[3]);

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-08-07 04:18:16 UTC (rev 31133)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp	2010-08-07 04:48:09 UTC (rev 31134)
@@ -483,7 +483,27 @@
 /* ............ */
 /* Read-only state info about status of simulation */
 
+void rbBodyGetPosition(rbRigidBody *object, float v_out[3])
+{
+	btRigidBody *body = reinterpret_cast<btRigidBody *>(object);
+	const btVector3 &pos = body->getWorldTransform().getOrigin();
+	
+	v_out[0] = pos.getX();
+	v_out[1] = pos.getY();
+	v_out[2] = pos.getZ();
+}
 
+void rbBodyGetOrientation(rbRigidBody *object, float v_out[4])
+{
+	btRigidBody *body = reinterpret_cast<btRigidBody *>(object);
+	const btQuaternion &orn = body->getWorldTransform().getRotation();
+	
+	v_out[0] = orn.getX();
+	v_out[1] = orn.getY();
+	v_out[2] = orn.getZ();
+	v_out[3] = orn.getW();
+}
+
 /* ............ */
 /* Overrides for simulation */
 





More information about the Bf-blender-cvs mailing list