diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-07-03 09:58:23 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-07-03 09:58:23 +0400 |
commit | 3b1a592fb7a4ce3fb0582bcdf0472eef43b9778c (patch) | |
tree | e750f88902b9cc23c461c8589dfe9bc5b9707d8b /source | |
parent | da83509dca485b893aa76511d03a7e3aa8ff8a1f (diff) |
debug lines / register the applied impulse for constraint (for breaking)
Diffstat (limited to 'source')
4 files changed, 48 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 28138195a5e..6fbf2888bd9 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -73,6 +73,8 @@ static char gPySetSolverType__doc__[] = "setSolverType(int solverType) Very expe static char gPyCreateConstraint__doc__[] = "createConstraint(ob1,ob2,float restLength,float restitution,float damping)"; static char gPyGetVehicleConstraint__doc__[] = "getVehicleConstraint(int constraintId)"; static char gPyRemoveConstraint__doc__[] = "removeConstraint(int constraintId)"; +static char gPyGetAppliedImpulse__doc__[] = "getAppliedImpulse(int constraintId)"; + @@ -401,6 +403,32 @@ static PyObject* gPyCreateConstraint(PyObject* self, } + + +static PyObject* gPyGetAppliedImpulse(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + float appliedImpulse = 0.f; + +#if defined(_WIN64) + __int64 constraintid; + if (PyArg_ParseTuple(args,"L",&constraintid)) +#else + long constraintid; + if (PyArg_ParseTuple(args,"l",&constraintid)) +#endif + { + if (PHY_GetActiveEnvironment()) + { + appliedImpulse = PHY_GetActiveEnvironment()->getAppliedImpulse(constraintid); + } + } + + return PyFloat_FromDouble(appliedImpulse); +} + + static PyObject* gPyRemoveConstraint(PyObject* self, PyObject* args, PyObject* kwds) @@ -470,6 +498,9 @@ static struct PyMethodDef physicsconstraints_methods[] = { {"removeConstraint",(PyCFunction) gPyRemoveConstraint, METH_VARARGS, gPyRemoveConstraint__doc__}, + {"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse, + METH_VARARGS, gPyGetAppliedImpulse__doc__}, + //sentinel { NULL, (PyCFunction) NULL, 0, NULL } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 6ff471c4bd5..2fee6d06963 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1271,6 +1271,21 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl } +float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid) +{ + std::vector<TypedConstraint*>::iterator i; + + for (i=m_constraints.begin(); + !(i==m_constraints.end()); i++) + { + TypedConstraint* constraint = (*i); + if (constraint->GetUserConstraintId() == constraintid) + { + return constraint->GetAppliedImpulse(); + } + } + return 0.f; +} void CcdPhysicsEnvironment::removeConstraint(int constraintId) { std::vector<TypedConstraint*>::iterator i; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 9de7053d271..73bd9f8c95e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -113,6 +113,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ); virtual void removeConstraint(int constraintid); + virtual float getAppliedImpulse(int constraintid); virtual void CallbackTriggers(); diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index cdd67257de2..fe4370fa725 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -88,6 +88,7 @@ class PHY_IPhysicsEnvironment float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ)=0; virtual void removeConstraint(int constraintid)=0; + virtual float getAppliedImpulse(int constraintid){ return 0.f;} //complex constraint for vehicles virtual PHY_IVehicle* getVehicleConstraint(int constraintId) =0; |