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_SCA_AddObjectActuator.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp122
1 files changed, 41 insertions, 81 deletions
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index c4c190e9fa1..ca0106d64d9 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -39,8 +39,6 @@
#include "KX_GameObject.h"
#include "KX_IPhysicsController.h"
-#include "PyObjectPlus.h"
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -54,20 +52,14 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj,
int time,
SCA_IScene* scene,
const MT_Vector3& linvel,
- bool linv_local,
- const MT_Vector3& angvel,
- bool angv_local,
+ bool local,
PyTypeObject* T)
:
SCA_IActuator(gameobj, T),
m_OriginalObject(original),
m_scene(scene),
-
m_linear_velocity(linvel),
- m_localLinvFlag(linv_local),
-
- m_angular_velocity(angvel),
- m_localAngvFlag(angv_local)
+ m_localFlag(local)
{
if (m_OriginalObject)
m_OriginalObject->RegisterActuator(this);
@@ -189,15 +181,13 @@ PyParentObject KX_SCA_AddObjectActuator::Parents[] = {
};
PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
{"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, SetObject_doc},
- {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, SetTime_doc},
+ {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_VARARGS, SetTime_doc},
{"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
- {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, GetTime_doc},
- {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, GetLinearVelocity_doc},
+ {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_VARARGS, GetTime_doc},
+ {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_VARARGS, GetLinearVelocity_doc},
{"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, SetLinearVelocity_doc},
- {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, GetAngularVelocity_doc},
- {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, SetAngularVelocity_doc},
- {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"},
- {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"},
+ {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_VARARGS,"getLastCreatedObject() : get the object handle to the last created object\n"},
+ {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_VARARGS,"instantAddObject() : immediately add object without delay\n"},
{NULL,NULL} //Sentinel
};
@@ -241,18 +231,19 @@ char KX_SCA_AddObjectActuator::SetTime_doc[] =
"\tIf the duration is negative, it is set to 0.\n";
-PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, PyObject* value)
+PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
{
- int deltatime = PyInt_AsLong(value);
- if (deltatime==-1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "expected an int");
+ int deltatime;
+
+ if (!PyArg_ParseTuple(args, "i", &deltatime))
return NULL;
- }
m_timeProp = deltatime;
if (m_timeProp < 0) m_timeProp = 0;
- Py_RETURN_NONE;
+ Py_Return;
}
@@ -263,7 +254,9 @@ char KX_SCA_AddObjectActuator::GetTime_doc[] =
"\tReturns the lifetime of the object that will be added.\n";
-PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self)
+PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
{
return PyInt_FromLong(m_timeProp);
}
@@ -297,13 +290,17 @@ char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] =
"\tReturns the linear velocity that will be assigned to \n"
"\tthe created object.\n";
-PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self)
+
+
+PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
{
PyObject *retVal = PyList_New(3);
- PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
- PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1]));
- PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2]));
+ PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
+ PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1]));
+ PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2]));
return retVal;
}
@@ -316,57 +313,20 @@ char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] =
"\t- vx: float\n"
"\t- vy: float\n"
"\t- vz: float\n"
-"\t- local: bool\n"
"\tAssign this velocity to the created object. \n";
-PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, PyObject* args)
-{
-
- float vecArg[3];
- if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2]))
- return NULL;
-
- m_linear_velocity.setValue(vecArg);
- Py_RETURN_NONE;
-}
-
-/* 7. getAngularVelocity */
-char KX_SCA_AddObjectActuator::GetAngularVelocity_doc[] =
-"GetAngularVelocity()\n"
-"\tReturns the angular velocity that will be assigned to \n"
-"\tthe created object.\n";
-PyObject* KX_SCA_AddObjectActuator::PyGetAngularVelocity(PyObject* self)
-{
- PyObject *retVal = PyList_New(3);
-
- PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
- PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1]));
- PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2]));
-
- return retVal;
-}
-
-
-
-/* 8. setAngularVelocity */
-char KX_SCA_AddObjectActuator::SetAngularVelocity_doc[] =
-"setAngularVelocity(vx, vy, vz)\n"
-"\t- vx: float\n"
-"\t- vy: float\n"
-"\t- vz: float\n"
-"\t- local: bool\n"
-"\tAssign this angular velocity to the created object. \n";
-
-PyObject* KX_SCA_AddObjectActuator::PySetAngularVelocity(PyObject* self, PyObject* args)
+PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
{
float vecArg[3];
if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2]))
return NULL;
- m_angular_velocity.setValue(vecArg);
- Py_RETURN_NONE;
+ m_linear_velocity.setValue(vecArg);
+ Py_Return;
}
void KX_SCA_AddObjectActuator::InstantAddObject()
@@ -377,9 +337,8 @@ void KX_SCA_AddObjectActuator::InstantAddObject()
// Now it needs to be added to the current scene.
SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp );
KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica);
- game_obj->setLinearVelocity(m_linear_velocity,m_localLinvFlag);
- game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag);
- game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag);
+ game_obj->setLinearVelocity(m_linear_velocity,m_localFlag);
+ game_obj->ResolveCombinedVelocities(m_linear_velocity, MT_Vector3(0., 0., 0.), m_localFlag, false);
// keep a copy of the last object, to allow python scripters to change it
if (m_lastCreatedObject)
@@ -396,11 +355,13 @@ void KX_SCA_AddObjectActuator::InstantAddObject()
}
}
-PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self)
+PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
{
InstantAddObject();
- Py_RETURN_NONE;
+ Py_Return;
}
@@ -411,17 +372,16 @@ char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] =
"\tReturn the last created object. \n";
-PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self)
+PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
{
SCA_IObject* result = this->GetLastCreatedObject();
-
- // if result->GetSGNode() is NULL
- // it means the object has ended, The BGE python api crashes in many places if the object is returned.
- if (result && (static_cast<KX_GameObject *>(result))->GetSGNode())
+ if (result)
{
result->AddRef();
return result;
}
// don't return NULL to python anymore, it gives trouble in the scripts
- Py_RETURN_NONE;
+ Py_Return;
}