Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2011-03-12 23:34:17 +0300
committerErwin Coumans <blender@erwincoumans.com>2011-03-12 23:34:17 +0300
commit5e374328a87c1b418f8454d5ef38470484804961 (patch)
tree1d6de85165175c5192f74dbd423e1d5cb48f8ff6 /source/gameengine
parent8c526e79e31d40d56a6fecce9343c74bd9fe62d8 (diff)
update Bullet physics sdk to latest trunk/version 2.78
add PhysicsConstraints.exportBulletFile(char* fileName) python command I'll be checking the bf-committers mailing list, in case this commit broke stuff scons needs to be updated, I'll do that in a second.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp17
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp16
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h1
4 files changed, 35 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index f08fc14c29c..8776bf6fe88 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -542,6 +542,18 @@ static PyObject* gPyRemoveConstraint(PyObject* self,
Py_RETURN_NONE;
}
+static PyObject* gPyExportBulletFile(PyObject*, PyObject* args)
+{
+ char* filename;
+ if (!PyArg_ParseTuple(args,"s:exportBulletFile",&filename))
+ return NULL;
+
+ if (PHY_GetActiveEnvironment())
+ {
+ PHY_GetActiveEnvironment()->exportFile(filename);
+ }
+ Py_RETURN_NONE;
+}
static struct PyMethodDef physicsconstraints_methods[] = {
{"setGravity",(PyCFunction) gPySetGravity,
@@ -594,6 +606,9 @@ static struct PyMethodDef physicsconstraints_methods[] = {
{"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse,
METH_VARARGS, (const char *)gPyGetAppliedImpulse__doc__},
+ {"exportBulletFile",(PyCFunction)gPyExportBulletFile,
+ METH_VARARGS, "export a .bullet file"},
+
//sentinel
{ NULL, (PyCFunction) NULL, 0, NULL }
@@ -664,5 +679,7 @@ PHY_IPhysicsEnvironment* PHY_GetActiveEnvironment()
return g_CurrentActivePhysicsEnvironment;
}
+
+
#endif // WITH_PYTHON
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 7dfdb67d2c6..171f13e9b9f 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -1457,7 +1457,7 @@ struct OcclusionBuffer
const float face,
const btScalar minarea)
{
- const btScalar a2=cross(b-a,c-a)[2];
+ const btScalar a2=btCross(b-a,c-a)[2];
if((face*a2)<0.f || btFabs(a2)<minarea)
return false;
// further down we are normally going to write to the Zbuffer, mark it so
@@ -2793,3 +2793,17 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid)
return 0.f;
}
+
+void CcdPhysicsEnvironment::exportFile(const char* filename)
+{
+ btDefaultSerializer* serializer = new btDefaultSerializer();
+ m_dynamicsWorld->serialize(serializer);
+
+ FILE* file = fopen(filename,"wb");
+ if (file)
+ {
+ fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
+ fclose(file);
+ }
+}
+
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 4b97dc95179..586e75d2d00 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -280,6 +280,8 @@ protected:
bool m_scalingPropagated;
+ virtual void exportFile(const char* filename);
+
#ifdef WITH_CXX_GUARDEDALLOC
public:
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index e2a9b5e99e4..60da4523dd5 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -180,6 +180,7 @@ class PHY_IPhysicsEnvironment
virtual void setConstraintParam(int constraintId,int param,float value,float value1) = 0;
virtual float getConstraintParam(int constraintId,int param) = 0;
+ virtual void exportFile(const char* filename) {};
#ifdef WITH_CXX_GUARDEDALLOC
public: