[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29727] branches/soc-2010-aligorith-2/ source/blender: == Bullet SoC - (WIP Commit) Everything compiles again ==
Joshua Leung
aligorith at gmail.com
Sun Jun 27 07:16:40 CEST 2010
Revision: 29727
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29727
Author: aligorith
Date: 2010-06-27 07:16:39 +0200 (Sun, 27 Jun 2010)
Log Message:
-----------
== Bullet SoC - (WIP Commit) Everything compiles again ==
* Compiling fixes for Blender and also the RigidBody C-API. Overall, there weren't as many bugs as anticipated :)
* Scons files for RigidBody API are now set up ok...
* Added API calls for getting and setting collision shapes of Rigid Bodies.
Modified Paths:
--------------
branches/soc-2010-aligorith-2/source/blender/SConscript
branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_rigidbody.c
branches/soc-2010-aligorith-2/source/blender/rigidbody/SConscript
branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_api.h
branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp
Modified: branches/soc-2010-aligorith-2/source/blender/SConscript
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/SConscript 2010-06-27 00:33:12 UTC (rev 29726)
+++ branches/soc-2010-aligorith-2/source/blender/SConscript 2010-06-27 05:16:39 UTC (rev 29727)
@@ -38,5 +38,5 @@
if env['WITH_BF_COLLADA']:
SConscript (['collada/SConscript'])
-#if env['WITH_BF_BULLET']:
-# SConscript (['rigidbody/SConscript'])
+if env['WITH_BF_BULLET']:
+ SConscript (['rigidbody/SConscript'])
Modified: branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_rigidbody.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_rigidbody.c 2010-06-27 00:33:12 UTC (rev 29726)
+++ branches/soc-2010-aligorith-2/source/blender/makesrna/intern/rna_rigidbody.c 2010-06-27 05:16:39 UTC (rev 29727)
@@ -28,6 +28,7 @@
#include "rna_internal.h"
+#include "DNA_object_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
@@ -55,7 +56,7 @@
RigidBodyWorld *rbw= NULL; //ED_rigidbody_get_active_world(scene, 0);
Object *ob= (Object*)ptr->id.data;
- BKE_rigidbody_update_object(rbw, ob);
+ //BKE_rigidbody_update_object(rbw, ob);
}
#else
Modified: branches/soc-2010-aligorith-2/source/blender/rigidbody/SConscript
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/rigidbody/SConscript 2010-06-27 00:33:12 UTC (rev 29726)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/SConscript 2010-06-27 05:16:39 UTC (rev 29727)
@@ -29,7 +29,7 @@
sources = env.Glob('*.cpp')
-incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../makesrna ../editors/include ../../../intern/guardedalloc ../../../extern/bullet2/'
+incs = '../blenlib ../../../intern/guardedalloc ../../../extern/bullet2/src'
-env.BlenderLib ('bf_rigidbody', sources, Split(incs), [], libtype='core', priority=200 )
+env.BlenderLib ('bf_rigidbody', sources, Split(incs), [], libtype='core', priority=180 )
Modified: branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_api.h
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_api.h 2010-06-27 00:33:12 UTC (rev 29726)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_api.h 2010-06-27 05:16:39 UTC (rev 29727)
@@ -83,7 +83,7 @@
/* Simulation ----------------------- */
/* Step the simulation by the desired amount (in seconds) */
-extern void rbStepSimulation(rbDynamicsWorldHandle *world, float timeStep);
+extern void rbStepSimulation(rbDynamicsWorld *world, float timeStep);
/* ********************************** */
/* Rigid Body Methods */
@@ -107,6 +107,12 @@
/* Settings ------------------------- */
+/* Collision Shape */
+extern rbCollisionShape *rbBodyGetCollisionShape(rbRigidBody *body);
+extern void rbBodySetCollisionShape(rbRigidBody *body, rbCollisionShape *cshape);
+
+/* ............ */
+
/* Mass */
extern float rbBodyGetMass(rbRigidBody *body);
extern void rbBodySetMass(rbRigidBody *body, float value);
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-06-27 00:33:12 UTC (rev 29726)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp 2010-06-27 05:16:39 UTC (rev 29727)
@@ -73,7 +73,7 @@
btBroadphaseInterface *pairCache = new(mem) btAxisSweep3(physicsSdk->m_worldAabbMin,physicsSdk->m_worldAabbMax);
#else // Most demos use this one instead... so assume to be fine enough for most purposes...
mem = btAlignedAlloc(sizeof(btDbvtBroadphase),16);
- btBroadphaseInterface *overlappingPairCache = new(mem) btDbvtBroadphase();
+ btBroadphaseInterface *pairCache = new(mem) btDbvtBroadphase();
#endif
@@ -160,7 +160,7 @@
/* current transform */
btTransform trans;
- trans.setFromOpenGLMatrix(mat);
+ trans.setFromOpenGLMatrix((const btScalar*)mat);
/* calculate inertia if rigidbody is dynamic (mass != 0) */
// TODO: set include this in the set-mass code?
@@ -175,7 +175,7 @@
btDefaultMotionState *motionState = new(mem) btDefaultMotionState(trans);
/* make rigidbody */
- btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionShape, shape, localInertia);
+ btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState, shape, localInertia);
mem = btAlignedAlloc(sizeof(btRigidBody),16);
btRigidBody *body = new(mem) btRigidBody(rbInfo);
@@ -191,6 +191,28 @@
/* Settings ------------------------- */
+rbCollisionShape *rbBodyGetCollisionShape(rbRigidBody *object)
+{
+ btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+ btCollisionShape *shape = body->getCollisionShape();
+
+ return (rbCollisionShape*)shape;
+}
+
+void rbBodySetCollisionShape(rbRigidBody *object, rbCollisionShape *cshape)
+{
+ btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+ btCollisionShape *shape = reinterpret_cast<btCollisionShape*>(cshape);
+
+ /* set new collision shape */
+ body->setCollisionShape(shape);
+
+ /* recalculate inertia, since that depends on the collision shape... */
+ rbBodySetMass(object, rbBodyGetMass(object));
+}
+
+/* ............ */
+
float rbBodyGetMass(rbRigidBody *object)
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
@@ -255,8 +277,8 @@
void rbBodySetLinearDamping(rbRigidBody *object, float value)
{
- btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- body->setLinearDamping(value);
+ //btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+ //body->setLinearDamping(value);
}
@@ -268,34 +290,34 @@
void rbBodySetAngularDamping(rbRigidBody *object, float value)
{
- btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- body->setAngularDamping(value);
+ //btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+ //body->setAngularDamping(value);
}
float rbBodyGetLinearSleepThresh(rbRigidBody *object)
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- return body->getLinearSleepThresh();
+ return body->getLinearSleepingThreshold();
}
void rbBodySetLinearSleepThresh(rbRigidBody *object, float value)
{
- btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- body->setLinearSleepThresh(value);
+ //btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+ //body->setLinearSleepingThreshold(value);
}
float rbBodyGetAngularSleepThresh(rbRigidBody *object)
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- return body->getAngularSleepThresh();
+ return body->getAngularSleepingThreshold();
}
void rbBodySetAngularSleepThresh(rbRigidBody *object, float value)
{
- btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- body->setAngularSleepThresh(value);
+ //btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+ //body->setAngularSleepingThreshold(value);
}
/* ............ */
@@ -303,7 +325,7 @@
void rbBodyGetLinearVelocity(rbRigidBody *object, float v_out[3])
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- btVector3 &vec = body->getLinearVelocity();
+ btVector3 vec = body->getLinearVelocity();
v_out[0] = (float)vec[0];
v_out[1] = (float)vec[1];
@@ -322,7 +344,7 @@
void rbBodyGetAngularVelocity(rbRigidBody *object, float v_out[3])
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
- btVector3 &vec = body->getAngularVelocity();
+ btVector3 vec = body->getAngularVelocity();
v_out[0] = (float)vec[0];
v_out[1] = (float)vec[1];
@@ -342,6 +364,7 @@
int rbBodyGetActivationState(rbRigidBody *object)
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
+ return 0; // XXX...
}
void rbBodySetActivationState(rbRigidBody *object, int state)
@@ -355,7 +378,7 @@
* while Bullet uses the Right-Handed coordinate system style instead.
*/
-void rbGetTransformMatrix(rbRigidBody *body, float m_out[4][4])
+void rbGetTransformMatrix(rbRigidBody *object, float m_out[4][4])
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
btMotionState *ms = body->getMotionState();
@@ -363,17 +386,18 @@
btTransform trans;
ms->getWorldTransform(trans);
- trans.getOpenGLMatrix(m_out);
+ trans.getOpenGLMatrix((btScalar*)m_out);
}
-void rbSetTransformMatrix(rbRigidBody *body, const float m_in[4][4])
+void rbSetTransformMatrix(rbRigidBody *object, const float m_in[4][4])
{
btRigidBody *body = reinterpret_cast<btRigidBody*>(object);
btMotionState *ms = body->getMotionState();
- btTransform& worldTrans = ms->getWorldTransform();
+ btTransform worldTrans;
+ ms->getWorldTransform(worldTrans);
- worldTrans.setFromOpenGLMatrix(m_in);
+ worldTrans.setFromOpenGLMatrix((const btScalar*)m_in);
}
/* ********************************** */
More information about the Bf-blender-cvs
mailing list