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>2005-08-02 18:59:49 +0400
committerErwin Coumans <blender@erwincoumans.com>2005-08-02 18:59:49 +0400
commit558b8daf67bc986210d2ca9f778872ec6a4fab3b (patch)
treeda8cd2b52806c83deb0cb6acb7c54a3938e5f965
parent292c03ab8e9979a3792f8f96e4bad1a9d5b82275 (diff)
added python binding for debugdraw,
tweaked friction, some more preparations but no real functionality added yet
-rw-r--r--extern/bullet/Bullet/Bullet3_vc7.vcproj3
-rw-r--r--extern/bullet/Bullet/Bullet3_vc8.vcproj4
-rw-r--r--extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp9
-rw-r--r--extern/bullet/LinearMath/SimdQuadWord.h6
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp19
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp28
7 files changed, 52 insertions, 26 deletions
diff --git a/extern/bullet/Bullet/Bullet3_vc7.vcproj b/extern/bullet/Bullet/Bullet3_vc7.vcproj
index fcfc0ffb2ff..dab745810a0 100644
--- a/extern/bullet/Bullet/Bullet3_vc7.vcproj
+++ b/extern/bullet/Bullet/Bullet3_vc7.vcproj
@@ -391,9 +391,6 @@ ECHO Done
RelativePath="..\LinearMath\GEN_random.h">
</File>
<File
- RelativePath="..\LinearMath\IDebugDraw.h">
- </File>
- <File
RelativePath="..\LinearMath\SimdMatrix3x3.h">
</File>
<File
diff --git a/extern/bullet/Bullet/Bullet3_vc8.vcproj b/extern/bullet/Bullet/Bullet3_vc8.vcproj
index 125b4b6e0b1..b9046f451e5 100644
--- a/extern/bullet/Bullet/Bullet3_vc8.vcproj
+++ b/extern/bullet/Bullet/Bullet3_vc8.vcproj
@@ -509,6 +509,10 @@
>
</File>
<File
+ RelativePath="..\LinearMath\IDebugDraw.h"
+ >
+ </File>
+ <File
RelativePath="..\LinearMath\SimdMatrix3x3.h"
>
</File>
diff --git a/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp b/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp
index b0f26a343d5..bc89bd34c38 100644
--- a/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp
+++ b/extern/bullet/BulletDynamics/Dynamics/ContactJoint.cpp
@@ -3,6 +3,9 @@
#include "NarrowPhaseCollision/PersistentManifold.h"
+//this constant needs to be set up so different solvers give 'similar' results
+#define FRICTION_CONSTANT 120.f
+
ContactJoint::ContactJoint(PersistentManifold* manifold,int index,bool swap,RigidBody* body0,RigidBody* body1)
:m_manifold(manifold),
@@ -15,9 +18,6 @@ m_body1(body1)
int m_numRows = 3;
-//float gContactFrictionFactor = 0.f;//12.f;//30.5f;//100.f;//1e30f;//2.9f;
-
-
void ContactJoint::GetInfo1(Info1 *info)
{
@@ -150,7 +150,8 @@ void ContactJoint::GetInfo2(Info2 *info)
c2[1] = ccc2[1];
c2[2] = ccc2[2];
- float friction = 20.f*m_body0->getFriction() * m_body1->getFriction();
+
+ float friction = FRICTION_CONSTANT*m_body0->getFriction() * m_body1->getFriction();
// first friction direction
if (m_numRows >= 2)
diff --git a/extern/bullet/LinearMath/SimdQuadWord.h b/extern/bullet/LinearMath/SimdQuadWord.h
index f256a215559..818b2e6007d 100644
--- a/extern/bullet/LinearMath/SimdQuadWord.h
+++ b/extern/bullet/LinearMath/SimdQuadWord.h
@@ -91,15 +91,15 @@ class SimdQuadWord
m_unusedW=w;
}
- SIMD_FORCE_INLINE SimdQuadWord()
- :m_x(0.f),m_y(0.f),m_z(0.f),m_unusedW(0.f)
+ SIMD_FORCE_INLINE SimdQuadWord() :
+ m_x(0.f),m_y(0.f),m_z(0.f),m_unusedW(0.f)
{
}
SIMD_FORCE_INLINE SimdQuadWord(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z)
:m_x(x),m_y(y),m_z(z)
//todo, remove this in release/simd ?
- ,m_unusedW(0.f)
+ ,m_unusedW(1e30f)
{
}
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 8171baf689d..2b70f25eaf9 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -173,6 +173,7 @@ static struct Scene *GetSceneForName2(struct Main *maggie, const STR_String& sce
#include "KX_PythonInit.h"
#ifdef USE_BULLET
+
#include "IDebugDraw.h"
@@ -187,7 +188,7 @@ struct BlenderDebugDraw : public IDebugDraw
virtual void DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color)
{
- if (m_debugMode == 1)
+ if (m_debugMode >0)
{
MT_Vector3 kxfrom(from[0],from[1],from[2]);
MT_Vector3 kxto(to[0],to[1],to[2]);
@@ -260,9 +261,9 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
{
CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment();
ccdPhysEnv->setDebugDrawer(new BlenderDebugDraw());
-
- //disable / enable debug drawing (contact points, aabb's etc)
- // ccdPhysEnv->setDebugMode(1);
+ //todo: get a button in blender ?
+ //disable / enable debug drawing (contact points, aabb's etc)
+ //ccdPhysEnv->setDebugMode(1);
destinationscene->SetPhysicsEnvironment(ccdPhysEnv);
break;
}
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 338e9448e94..d767b480756 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -133,7 +133,7 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj,
smmaterial->m_fh_normal = kxmaterial->m_fh_normal;
smmaterial->m_fh_spring = kxmaterial->m_fh_spring;
smmaterial->m_friction = kxmaterial->m_friction;
- smmaterial->m_restitution = 0.f;//kxmaterial->m_restitution;
+ smmaterial->m_restitution = kxmaterial->m_restitution;
SumoPhysicsEnvironment* sumoEnv =
(SumoPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
@@ -854,7 +854,6 @@ static CollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool p
-
void KX_ConvertBulletObject( class KX_GameObject* gameobj,
class RAS_MeshObject* meshobj,
class KX_Scene* kxscene,
@@ -864,10 +863,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
{
CcdPhysicsEnvironment* env = (CcdPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
-
assert(env);
-
-
bool dyna = false;
@@ -912,8 +908,12 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
halfExtents /= 2.f;
- //todo: do this conversion internally !
+ //SimdVector3 he (halfExtents[0]-CONVEX_DISTANCE_MARGIN ,halfExtents[1]-CONVEX_DISTANCE_MARGIN ,halfExtents[2]-CONVEX_DISTANCE_MARGIN );
+ //he = he.absolute();
+
SimdVector3 he (halfExtents[0],halfExtents[1],halfExtents[2]);
+ he = he.absolute();
+
bm = new BoxShape(he);
bm->CalculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
@@ -929,7 +929,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
);
bm = new CylinderShapeZ(halfExtents);
bm->CalculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
- bm->SetMargin(0.05f);
break;
}
@@ -948,7 +947,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
bm = new ConeShape(objprop->m_boundobject.c.m_radius,objprop->m_boundobject.c.m_height);
bm->CalculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
- bm->SetMargin(0.05f);
break;
@@ -959,7 +957,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
if (bm)
{
bm->CalculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
- bm->SetMargin(0.05f);
}
break;
}
@@ -1007,8 +1004,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_restitution = smmaterial->m_restitution;
- ci.m_linearDamping = 0.5;//shapeprops->m_lin_drag;
- ci.m_angularDamping = 0.5f;//shapeprops->m_ang_drag;
+ ci.m_linearDamping = shapeprops->m_lin_drag;
+ ci.m_angularDamping = shapeprops->m_ang_drag;
KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,dyna);
env->addCcdPhysicsController( physicscontroller);
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index 0111fd36cb2..1f732098718 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -48,9 +48,11 @@ static char PhysicsConstraints_module_documentation[] =
static char gPySetGravity__doc__[] = "setGravity(float x,float y,float z)";
+static char gPySetDebugMode__doc__[] = "setDebugMode(int mode)";
static char gPyCreateConstraint__doc__[] = "createConstraint(ob1,ob2,float restLength,float restitution,float damping)";
static char gPyRemoveConstraint__doc__[] = "removeConstraint(constraint id)";
+
static PyObject* gPySetGravity(PyObject* self,
PyObject* args,
PyObject* kwds)
@@ -65,6 +67,26 @@ static PyObject* gPySetGravity(PyObject* self,
Py_INCREF(Py_None); return Py_None;
}
+static PyObject* gPySetDebugMode(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ int mode;
+ if (PyArg_ParseTuple(args,"i",&mode))
+ {
+ if (PHY_GetActiveEnvironment())
+ {
+ PHY_GetActiveEnvironment()->setDebugMode(mode);
+
+ }
+
+ }
+ printf("hi\n");
+
+ Py_INCREF(Py_None); return Py_None;
+}
+
+
@@ -142,7 +164,10 @@ static PyObject* gPyRemoveConstraint(PyObject* self,
static struct PyMethodDef physicsconstraints_methods[] = {
{"setGravity",(PyCFunction) gPySetGravity,
METH_VARARGS, gPySetGravity__doc__},
-
+ {"setDebugMode",(PyCFunction) gPySetDebugMode,
+ METH_VARARGS, gPySetDebugMode__doc__},
+
+
{"createConstraint",(PyCFunction) gPyCreateConstraint,
METH_VARARGS, gPyCreateConstraint__doc__},
{"removeConstraint",(PyCFunction) gPyRemoveConstraint,
@@ -161,6 +186,7 @@ PyObject* initPythonConstraintBinding()
PyObject* m;
PyObject* d;
+
m = Py_InitModule4("PhysicsConstraints", physicsconstraints_methods,
PhysicsConstraints_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);