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:
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp64
1 files changed, 27 insertions, 37 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 7d785f07ed2..82b5fff534c 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1030,8 +1030,8 @@ PyMethodDef KX_GameObject::Methods[] = {
{"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS},
KX_PYMETHODTABLE(KX_GameObject, rayCastTo),
KX_PYMETHODTABLE(KX_GameObject, rayCast),
- KX_PYMETHODTABLE(KX_GameObject, getDistanceTo),
- KX_PYMETHODTABLE(KX_GameObject, getVectTo),
+ KX_PYMETHODTABLE_O(KX_GameObject, getDistanceTo),
+ KX_PYMETHODTABLE_O(KX_GameObject, getVectTo),
{NULL,NULL} //Sentinel
};
@@ -1136,10 +1136,7 @@ PyObject* KX_GameObject::_getattr(const char *attr)
{
KX_GameObject* parent = GetParent();
if (parent)
- {
- parent->AddRef();
- return parent;
- }
+ return parent->AddRef();
Py_RETURN_NONE;
}
@@ -1297,7 +1294,7 @@ PyObject* KX_GameObject::PyApplyForce(PyObject* self, PyObject* args)
int local = 0;
PyObject* pyvect;
- if (PyArg_ParseTuple(args, "O|i", &pyvect, &local)) {
+ if (PyArg_ParseTuple(args, "O|i:applyForce", &pyvect, &local)) {
MT_Vector3 force;
if (PyVecTo(pyvect, force)) {
ApplyForce(force, (local!=0));
@@ -1312,7 +1309,7 @@ PyObject* KX_GameObject::PyApplyTorque(PyObject* self, PyObject* args)
int local = 0;
PyObject* pyvect;
- if (PyArg_ParseTuple(args, "O|i", &pyvect, &local)) {
+ if (PyArg_ParseTuple(args, "O|i:applyTorque", &pyvect, &local)) {
MT_Vector3 torque;
if (PyVecTo(pyvect, torque)) {
ApplyTorque(torque, (local!=0));
@@ -1327,7 +1324,7 @@ PyObject* KX_GameObject::PyApplyRotation(PyObject* self, PyObject* args)
int local = 0;
PyObject* pyvect;
- if (PyArg_ParseTuple(args, "O|i", &pyvect, &local)) {
+ if (PyArg_ParseTuple(args, "O|i:applyRotation", &pyvect, &local)) {
MT_Vector3 rotation;
if (PyVecTo(pyvect, rotation)) {
ApplyRotation(rotation, (local!=0));
@@ -1342,7 +1339,7 @@ PyObject* KX_GameObject::PyApplyMovement(PyObject* self, PyObject* args)
int local = 0;
PyObject* pyvect;
- if (PyArg_ParseTuple(args, "O|i", &pyvect, &local)) {
+ if (PyArg_ParseTuple(args, "O|i:applyMovement", &pyvect, &local)) {
MT_Vector3 movement;
if (PyVecTo(pyvect, movement)) {
ApplyMovement(movement, (local!=0));
@@ -1356,7 +1353,7 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, PyObject* args)
{
// only can get the velocity if we have a physics object connected to us...
int local = 0;
- if (PyArg_ParseTuple(args,"|i",&local))
+ if (PyArg_ParseTuple(args,"|i:getLinearVelocity",&local))
{
return PyObjectFrom(GetLinearVelocity((local!=0)));
}
@@ -1371,7 +1368,7 @@ PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self, PyObject* args)
int local = 0;
PyObject* pyvect;
- if (PyArg_ParseTuple(args,"O|i",&pyvect,&local)) {
+ if (PyArg_ParseTuple(args,"O|i:setLinearVelocity",&pyvect,&local)) {
MT_Vector3 velocity;
if (PyVecTo(pyvect, velocity)) {
setLinearVelocity(velocity, (local!=0));
@@ -1385,7 +1382,7 @@ PyObject* KX_GameObject::PyGetAngularVelocity(PyObject* self, PyObject* args)
{
// only can get the velocity if we have a physics object connected to us...
int local = 0;
- if (PyArg_ParseTuple(args,"|i",&local))
+ if (PyArg_ParseTuple(args,"|i:getAngularVelocity",&local))
{
return PyObjectFrom(GetAngularVelocity((local!=0)));
}
@@ -1400,7 +1397,7 @@ PyObject* KX_GameObject::PySetAngularVelocity(PyObject* self, PyObject* args)
int local = 0;
PyObject* pyvect;
- if (PyArg_ParseTuple(args,"O|i",&pyvect,&local)) {
+ if (PyArg_ParseTuple(args,"O|i:setAngularVelocity",&pyvect,&local)) {
MT_Vector3 velocity;
if (PyVecTo(pyvect, velocity)) {
setAngularVelocity(velocity, (local!=0));
@@ -1413,7 +1410,7 @@ PyObject* KX_GameObject::PySetAngularVelocity(PyObject* self, PyObject* args)
PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* args)
{
int visible, recursive = 0;
- if (!PyArg_ParseTuple(args,"i|i",&visible, &recursive))
+ if (!PyArg_ParseTuple(args,"i|i:setVisible",&visible, &recursive))
return NULL;
SetVisible(visible ? true:false, recursive ? true:false);
@@ -1464,7 +1461,7 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self, PyObject* args)
PyObject* pypos = NULL;
- if (PyArg_ParseTuple(args, "|O", &pypos))
+ if (PyArg_ParseTuple(args, "|O:getVelocity", &pypos))
{
if (pypos)
PyVecTo(pypos, point);
@@ -1520,10 +1517,7 @@ PyObject* KX_GameObject::PyGetParent(PyObject* self)
{
KX_GameObject* parent = this->GetParent();
if (parent)
- {
- parent->AddRef();
- return parent;
- }
+ return parent->AddRef();
Py_RETURN_NONE;
}
@@ -1592,7 +1586,7 @@ PyObject* KX_GameObject::PyGetMesh(PyObject* self, PyObject* args)
{
int mesh = 0;
- if (!PyArg_ParseTuple(args, "|i", &mesh))
+ if (!PyArg_ParseTuple(args, "|i:getMesh", &mesh))
return NULL; // python sets a simple error
if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0)
@@ -1638,7 +1632,7 @@ PyObject* KX_GameObject::PyApplyImpulse(PyObject* self, PyObject* args)
return NULL;
}
- if (PyArg_ParseTuple(args, "OO", &pyattach, &pyimpulse))
+ if (PyArg_ParseTuple(args, "OO:applyImpulse", &pyattach, &pyimpulse))
{
MT_Point3 attach;
MT_Vector3 impulse;
@@ -1705,7 +1699,7 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, PyObject* args)
int axis = 2; //z axis is the default
float fac = 1.0;
- if (PyArg_ParseTuple(args,"O|if",&pyvect,&axis, &fac))
+ if (PyArg_ParseTuple(args,"O|if:alignAxisToVect",&pyvect,&axis, &fac))
{
MT_Vector3 vect;
if (PyVecTo(pyvect, vect))
@@ -1773,19 +1767,18 @@ PyObject* KX_GameObject::PyGetPropertyNames(PyObject* self)
return ConvertKeysToPython();
}
-KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo,
+KX_PYMETHODDEF_DOC_O(KX_GameObject, getDistanceTo,
"getDistanceTo(other): get distance to another point/KX_GameObject")
{
MT_Point3 b;
- if (PyVecArgTo(args, b))
+ if (PyVecTo(value, b))
{
return PyFloat_FromDouble(NodeGetWorldPosition().distance(b));
}
PyErr_Clear();
- PyObject *pyother;
KX_GameObject *other;
- if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false))
+ if (ConvertPythonToGameObject(value, &other, false))
{
return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition()));
}
@@ -1793,7 +1786,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo,
return NULL;
}
-KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo,
+KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo,
"getVectTo(other): get vector and the distance to another point/KX_GameObject\n"
"Returns a 3-tuple with (distance,worldVector,localVector)\n")
{
@@ -1802,14 +1795,13 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo,
MT_Scalar distance;
PyObject *returnValue;
- PyObject *pyother;
- if (!PyVecArgTo(args, toPoint))
+ if (!PyVecTo(value, toPoint))
{
PyErr_Clear();
KX_GameObject *other;
- if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false))
+ if (ConvertPythonToGameObject(value, &other, false))
{
toPoint = other->NodeGetWorldPosition();
} else
@@ -1894,7 +1886,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
float dist = 0.0f;
char *propName = NULL;
- if (!PyArg_ParseTuple(args,"O|fs", &pyarg, &dist, &propName)) {
+ if (!PyArg_ParseTuple(args,"O|fs:rayCastTo", &pyarg, &dist, &propName)) {
return NULL; // python sets simple error
}
@@ -1937,10 +1929,8 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
KX_RayCast::RayTest(pe, fromPoint, toPoint, callback);
if (m_pHitObject)
- {
- m_pHitObject->AddRef();
- return m_pHitObject;
- }
+ return m_pHitObject->AddRef();
+
Py_RETURN_NONE;
}
@@ -1973,7 +1963,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
KX_GameObject *other;
int face=0, xray=0, poly=0;
- if (!PyArg_ParseTuple(args,"O|Ofsiii", &pyto, &pyfrom, &dist, &propName, &face, &xray, &poly)) {
+ if (!PyArg_ParseTuple(args,"O|Ofsiii:rayCast", &pyto, &pyfrom, &dist, &propName, &face, &xray, &poly)) {
return NULL; // Python sets a simple error
}