diff options
author | Jorge Bernal <jbernalmartinez@gmail.com> | 2014-07-07 19:01:49 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2014-07-07 19:06:39 +0400 |
commit | 1f43b083a97ee56b8b15692ef19d0e973b6d31ac (patch) | |
tree | 358346e602ab4be4ca8b1f650955d23b60c9e742 /source/gameengine/Ketsji/KX_GameObject.cpp | |
parent | ef22e972b1ad0bed1a79587b72d50c7da4c6b4e8 (diff) |
BGE: Fix for applyImpulse function
This is related to task T29419. Credit also goes to Goran Milovanovic
(goran) for proposing an initial fix for this issue.
The issue is the current behavior of applyImpulse doesn't match the behavior
described in the documentation as instead of a impulse point in world coordinates,
it seems to require a coordinate in a local space.
Additionally, applyImpulse function isn't consistent with similar functions (applyForce, applyTorque, etc)
as it doesn't allow to choose in which space (local or global) the impulse is applied.
Now, we have the following function:
applyImpulse(point, impulse, local=False)
being "point" the point to apply the impulse to (in world or local coordinates). When local is False will
have both point and impulse in World space and when local is True will have point and impulse in local space.
Reviewers: moguri, dfelinto, brita_
Reviewed By: moguri
Differential Revision: https://developer.blender.org/D567
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 44646f17a6e..f61d08e7f71 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -3034,19 +3034,20 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args) { PyObject *pyattach; PyObject *pyimpulse; + int local = 0; if (!m_pPhysicsController) { PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller"); return NULL; } - if (PyArg_ParseTuple(args, "OO:applyImpulse", &pyattach, &pyimpulse)) + if (PyArg_ParseTuple(args, "OO|i:applyImpulse", &pyattach, &pyimpulse, &local)) { MT_Point3 attach; MT_Vector3 impulse; if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse)) { - m_pPhysicsController->ApplyImpulse(attach, impulse); + m_pPhysicsController->ApplyImpulse(attach, impulse, (local!=0)); Py_RETURN_NONE; } |