diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-06-09 00:08:19 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-06-09 00:08:19 +0400 |
commit | c8b4cf92067ffeb625aa39003baf5d8f7c3f0025 (patch) | |
tree | c6c50dbc3d90a65fca6c1ca56a93e4a57cf7e154 /source/gameengine/Ketsji/KX_ObjectActuator.cpp | |
parent | e93db433a086a3e739c0f4026cd500f0b595b0f1 (diff) | |
parent | d76a6f5231c015c35123d22e1f5c3ffcdfbf9bbd (diff) |
2.50:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19820:HEAD
Notes:
* Game and sequencer RNA, and sequencer header are now out of date
a bit after changes in trunk.
* I didn't know how to port these bugfixes, most likely they are
not needed anymore.
* Fix "duplicate strip" always increase the user count for ipo.
* IPO pinning on sequencer strips was lost during Undo.
Diffstat (limited to 'source/gameengine/Ketsji/KX_ObjectActuator.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_ObjectActuator.cpp | 337 |
1 files changed, 292 insertions, 45 deletions
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 861c5757971..eaae04d406d 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -31,6 +31,7 @@ #include "KX_ObjectActuator.h" #include "KX_GameObject.h" +#include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus? #include "KX_IPhysicsController.h" #ifdef HAVE_CONFIG_H @@ -44,6 +45,7 @@ KX_ObjectActuator:: KX_ObjectActuator( SCA_IObject* gameobj, + KX_GameObject* refobj, const MT_Vector3& force, const MT_Vector3& torque, const MT_Vector3& dloc, @@ -68,6 +70,7 @@ KX_ObjectActuator( m_previous_error(0.0,0.0,0.0), m_error_accumulator(0.0,0.0,0.0), m_bitLocalFlag (flag), + m_reference(refobj), m_active_combined_velocity (false), m_linear_damping_active(false), m_angular_damping_active(false) @@ -76,10 +79,20 @@ KX_ObjectActuator( { // in servo motion, the force is local if the target velocity is local m_bitLocalFlag.Force = m_bitLocalFlag.LinearVelocity; + + m_pid = m_torque; } + if (m_reference) + m_reference->RegisterActuator(this); UpdateFuzzyFlags(); } +KX_ObjectActuator::~KX_ObjectActuator() +{ + if (m_reference) + m_reference->UnregisterActuator(this); +} + bool KX_ObjectActuator::Update() { @@ -128,11 +141,23 @@ bool KX_ObjectActuator::Update() if (mass < MT_EPSILON) return false; MT_Vector3 v = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity); + if (m_reference) + { + const MT_Point3& mypos = parent->NodeGetWorldPosition(); + const MT_Point3& refpos = m_reference->NodeGetWorldPosition(); + MT_Point3 relpos; + relpos = (mypos-refpos); + MT_Vector3 vel= m_reference->GetVelocity(relpos); + if (m_bitLocalFlag.LinearVelocity) + // must convert in local space + vel = parent->NodeGetWorldOrientation().transposed()*vel; + v -= vel; + } MT_Vector3 e = m_linear_velocity - v; MT_Vector3 dv = e - m_previous_error; MT_Vector3 I = m_error_accumulator + e; - m_force = m_torque.x()*e+m_torque.y()*I+m_torque.z()*dv; + m_force = m_pid.x()*e+m_pid.y()*I+m_pid.z()*dv; // to automatically adapt the PID coefficient to mass; m_force *= mass; if (m_bitLocalFlag.Torque) @@ -253,13 +278,37 @@ CValue* KX_ObjectActuator::GetReplica() KX_ObjectActuator* replica = new KX_ObjectActuator(*this);//m_float,GetName()); replica->ProcessReplica(); - // this will copy properties and so on... - CValue::AddDataToReplica(replica); - return replica; } +void KX_ObjectActuator::ProcessReplica() +{ + SCA_IActuator::ProcessReplica(); + if (m_reference) + m_reference->RegisterActuator(this); +} +bool KX_ObjectActuator::UnlinkObject(SCA_IObject* clientobj) +{ + if (clientobj == (SCA_IObject*)m_reference) + { + // this object is being deleted, we cannot continue to use it as reference. + m_reference = NULL; + return true; + } + return false; +} + +void KX_ObjectActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map) +{ + void **h_obj = (*obj_map)[m_reference]; + if (h_obj) { + if (m_reference) + m_reference->UnregisterActuator(this); + m_reference = (KX_GameObject*)(*h_obj); + m_reference->RegisterActuator(this); + } +} /* some 'standard' utilities... */ bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type) @@ -277,8 +326,13 @@ bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_ObjectActuator::Type = { - PyObject_HEAD_INIT(NULL) - 0, +#if (PY_VERSION_HEX >= 0x02060000) + PyVarObject_HEAD_INIT(NULL, 0) +#else + /* python 2.5 and below */ + PyObject_HEAD_INIT( NULL ) /* required py macro */ + 0, /* ob_size */ +#endif "KX_ObjectActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -304,6 +358,7 @@ PyParentObject KX_ObjectActuator::Parents[] = { }; PyMethodDef KX_ObjectActuator::Methods[] = { + // Deprecated -----> {"getForce", (PyCFunction) KX_ObjectActuator::sPyGetForce, METH_NOARGS}, {"setForce", (PyCFunction) KX_ObjectActuator::sPySetForce, METH_VARARGS}, {"getTorque", (PyCFunction) KX_ObjectActuator::sPyGetTorque, METH_NOARGS}, @@ -327,18 +382,188 @@ PyMethodDef KX_ObjectActuator::Methods[] = { {"setPID", (PyCFunction) KX_ObjectActuator::sPyGetPID, METH_NOARGS}, {"getPID", (PyCFunction) KX_ObjectActuator::sPySetPID, METH_VARARGS}, - + // <----- Deprecated {NULL,NULL} //Sentinel }; PyAttributeDef KX_ObjectActuator::Attributes[] = { + KX_PYATTRIBUTE_VECTOR_RW_CHECK("force", -1000, 1000, false, KX_ObjectActuator, m_force, PyUpdateFuzzyFlags), + KX_PYATTRIBUTE_BOOL_RW("useLocalForce", KX_ObjectActuator, m_bitLocalFlag.Force), + KX_PYATTRIBUTE_VECTOR_RW_CHECK("torque", -1000, 1000, false, KX_ObjectActuator, m_torque, PyUpdateFuzzyFlags), + KX_PYATTRIBUTE_BOOL_RW("useLocalTorque", KX_ObjectActuator, m_bitLocalFlag.Torque), + KX_PYATTRIBUTE_VECTOR_RW_CHECK("dLoc", -1000, 1000, false, KX_ObjectActuator, m_dloc, PyUpdateFuzzyFlags), + KX_PYATTRIBUTE_BOOL_RW("useLocalDLoc", KX_ObjectActuator, m_bitLocalFlag.DLoc), + KX_PYATTRIBUTE_VECTOR_RW_CHECK("dRot", -1000, 1000, false, KX_ObjectActuator, m_drot, PyUpdateFuzzyFlags), + KX_PYATTRIBUTE_BOOL_RW("useLocalDRot", KX_ObjectActuator, m_bitLocalFlag.DRot), + KX_PYATTRIBUTE_VECTOR_RW_CHECK("linV", -1000, 1000, false, KX_ObjectActuator, m_linear_velocity, PyUpdateFuzzyFlags), + KX_PYATTRIBUTE_BOOL_RW("useLocalLinV", KX_ObjectActuator, m_bitLocalFlag.LinearVelocity), + KX_PYATTRIBUTE_VECTOR_RW_CHECK("angV", -1000, 1000, false, KX_ObjectActuator, m_angular_velocity, PyUpdateFuzzyFlags), + KX_PYATTRIBUTE_BOOL_RW("useLocalAngV", KX_ObjectActuator, m_bitLocalFlag.AngularVelocity), + KX_PYATTRIBUTE_SHORT_RW("damping", 0, 1000, false, KX_ObjectActuator, m_damping), + KX_PYATTRIBUTE_RW_FUNCTION("forceLimitX", KX_ObjectActuator, pyattr_get_forceLimitX, pyattr_set_forceLimitX), + KX_PYATTRIBUTE_RW_FUNCTION("forceLimitY", KX_ObjectActuator, pyattr_get_forceLimitY, pyattr_set_forceLimitY), + KX_PYATTRIBUTE_RW_FUNCTION("forceLimitZ", KX_ObjectActuator, pyattr_get_forceLimitZ, pyattr_set_forceLimitZ), + KX_PYATTRIBUTE_VECTOR_RW_CHECK("pid", -100, 200, true, KX_ObjectActuator, m_pid, PyCheckPid), + KX_PYATTRIBUTE_RW_FUNCTION("reference", KX_ObjectActuator,pyattr_get_reference,pyattr_set_reference), { NULL } //Sentinel }; PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) { py_getattro_up(SCA_IActuator); -}; +} + + +PyObject* KX_ObjectActuator::py_getattro_dict() { + py_getattro_dict_up(SCA_IActuator); +} + +int KX_ObjectActuator::py_setattro(PyObject *attr, PyObject *value) +{ + py_setattro_up(SCA_IActuator); +} + +/* Attribute get/set functions */ + +PyObject* KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[0])); + PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.Torque)); + + return retVal; +} + +int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); + + PyObject* seq = PySequence_Fast(value, ""); + if (seq && PySequence_Fast_GET_SIZE(seq) == 3) + { + self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); + self->m_dloc[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); + self->m_bitLocalFlag.Torque = (PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); + + if (!PyErr_Occurred()) + { + Py_DECREF(seq); + return PY_SET_ATTR_SUCCESS; + } + } + + Py_XDECREF(seq); + + PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); + return PY_SET_ATTR_FAIL; +} + +PyObject* KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[1])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[1])); + PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DLoc)); + + return retVal; +} + +int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); + + PyObject* seq = PySequence_Fast(value, ""); + if (seq && PySequence_Fast_GET_SIZE(seq) == 3) + { + self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); + self->m_dloc[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); + self->m_bitLocalFlag.DLoc = (PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); + + if (!PyErr_Occurred()) + { + Py_DECREF(seq); + return PY_SET_ATTR_SUCCESS; + } + } + + Py_XDECREF(seq); + + PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); + return PY_SET_ATTR_FAIL; +} + +PyObject* KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[2])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[2])); + PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DRot)); + + return retVal; +} + +int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); + + PyObject* seq = PySequence_Fast(value, ""); + if (seq && PySequence_Fast_GET_SIZE(seq) == 3) + { + self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); + self->m_dloc[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); + self->m_bitLocalFlag.DRot = (PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); + + if (!PyErr_Occurred()) + { + Py_DECREF(seq); + return PY_SET_ATTR_SUCCESS; + } + } + + Py_XDECREF(seq); + + PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); + return PY_SET_ATTR_FAIL; +} + +PyObject* KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); + if (!actuator->m_reference) + Py_RETURN_NONE; + + return actuator->m_reference->GetProxy(); +} + +int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); + KX_GameObject *refOb; + + if (!ConvertPythonToGameObject(value, &refOb, true, "actu.reference = value: KX_ObjectActuator")) + return PY_SET_ATTR_FAIL; + + if (actuator->m_reference) + actuator->m_reference->UnregisterActuator(actuator); + + if(refOb==NULL) { + actuator->m_reference= NULL; + } + else { + actuator->m_reference = refOb; + actuator->m_reference->RegisterActuator(actuator); + } + + return PY_SET_ATTR_SUCCESS; +} + /* 1. set ------------------------------------------------------------------ */ /* Removed! */ @@ -346,18 +571,20 @@ PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) { /* 2. getForce */ PyObject* KX_ObjectActuator::PyGetForce() { + ShowDeprecationWarning("getForce()", "the force and the useLocalForce properties"); PyObject *retVal = PyList_New(4); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_force[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_force[1])); - PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_force[2])); - PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.Force)); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_force[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_force[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_force[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.Force)); return retVal; } /* 3. setForce */ PyObject* KX_ObjectActuator::PySetForce(PyObject* args) { + ShowDeprecationWarning("setForce()", "the force and the useLocalForce properties"); float vecArg[3]; int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi:setForce", &vecArg[0], &vecArg[1], @@ -373,18 +600,20 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* args) /* 4. getTorque */ PyObject* KX_ObjectActuator::PyGetTorque() { + ShowDeprecationWarning("getTorque()", "the torque and the useLocalTorque properties"); PyObject *retVal = PyList_New(4); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_torque[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_torque[1])); - PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_torque[2])); - PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.Torque)); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_torque[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_torque[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_torque[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.Torque)); return retVal; } /* 5. setTorque */ PyObject* KX_ObjectActuator::PySetTorque(PyObject* args) { + ShowDeprecationWarning("setTorque()", "the torque and the useLocalTorque properties"); float vecArg[3]; int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi:setTorque", &vecArg[0], &vecArg[1], @@ -400,18 +629,20 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* args) /* 6. getDLoc */ PyObject* KX_ObjectActuator::PyGetDLoc() { + ShowDeprecationWarning("getDLoc()", "the dLoc and the useLocalDLoc properties"); PyObject *retVal = PyList_New(4); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_dloc[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[1])); - PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_dloc[2])); - PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.DLoc)); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_dloc[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_dloc[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.DLoc)); return retVal; } /* 7. setDLoc */ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* args) { + ShowDeprecationWarning("setDLoc()", "the dLoc and the useLocalDLoc properties"); float vecArg[3]; int bToggle = 0; if(!PyArg_ParseTuple(args, "fffi:setDLoc", &vecArg[0], &vecArg[1], @@ -427,18 +658,20 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* args) /* 8. getDRot */ PyObject* KX_ObjectActuator::PyGetDRot() { + ShowDeprecationWarning("getDRot()", "the dRot and the useLocalDRot properties"); PyObject *retVal = PyList_New(4); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_drot[1])); - PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_drot[2])); - PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.DRot)); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_drot[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_drot[2])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.DRot)); return retVal; } /* 9. setDRot */ PyObject* KX_ObjectActuator::PySetDRot(PyObject* args) { + ShowDeprecationWarning("setDRot()", "the dRot and the useLocalDRot properties"); float vecArg[3]; int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi:setDRot", &vecArg[0], &vecArg[1], @@ -453,18 +686,20 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* args) /* 10. getLinearVelocity */ PyObject* KX_ObjectActuator::PyGetLinearVelocity() { + ShowDeprecationWarning("getLinearVelocity()", "the linV and the useLocalLinV properties"); PyObject *retVal = PyList_New(4); - 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])); - PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.LinearVelocity)); + 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_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.LinearVelocity)); return retVal; } /* 11. setLinearVelocity */ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* args) { + ShowDeprecationWarning("setLinearVelocity()", "the linV and the useLocalLinV properties"); float vecArg[3]; int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi:setLinearVelocity", &vecArg[0], &vecArg[1], @@ -480,17 +715,19 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* args) { /* 12. getAngularVelocity */ PyObject* KX_ObjectActuator::PyGetAngularVelocity() { + ShowDeprecationWarning("getAngularVelocity()", "the angV and the useLocalAngV properties"); PyObject *retVal = PyList_New(4); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1])); - PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2])); - PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.AngularVelocity)); + 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])); + PyList_SET_ITEM(retVal, 3, BoolToPyArg(m_bitLocalFlag.AngularVelocity)); return retVal; } /* 13. setAngularVelocity */ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* args) { + ShowDeprecationWarning("setAngularVelocity()", "the angV and the useLocalAngV properties"); float vecArg[3]; int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi:setAngularVelocity", &vecArg[0], &vecArg[1], @@ -505,6 +742,7 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* args) { /* 13. setDamping */ PyObject* KX_ObjectActuator::PySetDamping(PyObject* args) { + ShowDeprecationWarning("setDamping()", "the damping property"); int damping = 0; if (!PyArg_ParseTuple(args, "i:setDamping", &damping) || damping < 0 || damping > 1000) { return NULL; @@ -515,22 +753,25 @@ PyObject* KX_ObjectActuator::PySetDamping(PyObject* args) { /* 13. getVelocityDamping */ PyObject* KX_ObjectActuator::PyGetDamping() { + ShowDeprecationWarning("getDamping()", "the damping property"); return Py_BuildValue("i",m_damping); } /* 6. getForceLimitX */ PyObject* KX_ObjectActuator::PyGetForceLimitX() { + ShowDeprecationWarning("getForceLimitX()", "the forceLimitX property"); PyObject *retVal = PyList_New(3); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[0])); - PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.Torque)); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[0])); + PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.Torque)); return retVal; } /* 7. setForceLimitX */ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* args) { + ShowDeprecationWarning("setForceLimitX()", "the forceLimitX property"); float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi:setForceLimitX", &vecArg[0], &vecArg[1], &bToggle)) { @@ -545,17 +786,19 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* args) /* 6. getForceLimitY */ PyObject* KX_ObjectActuator::PyGetForceLimitY() { + ShowDeprecationWarning("getForceLimitY()", "the forceLimitY property"); PyObject *retVal = PyList_New(3); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[1])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[1])); - PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DLoc)); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[1])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[1])); + PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.DLoc)); return retVal; } /* 7. setForceLimitY */ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* args) { + ShowDeprecationWarning("setForceLimitY()", "the forceLimitY property"); float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi:setForceLimitY", &vecArg[0], &vecArg[1], &bToggle)) { @@ -570,17 +813,19 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* args) /* 6. getForceLimitZ */ PyObject* KX_ObjectActuator::PyGetForceLimitZ() { + ShowDeprecationWarning("getForceLimitZ()", "the forceLimitZ property"); PyObject *retVal = PyList_New(3); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[2])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[2])); - PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DRot)); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[2])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_dloc[2])); + PyList_SET_ITEM(retVal, 2, BoolToPyArg(m_bitLocalFlag.DRot)); return retVal; } /* 7. setForceLimitZ */ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* args) { + ShowDeprecationWarning("setForceLimitZ()", "the forceLimitZ property"); float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi:setForceLimitZ", &vecArg[0], &vecArg[1], &bToggle)) { @@ -595,22 +840,24 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* args) /* 4. getPID */ PyObject* KX_ObjectActuator::PyGetPID() { + ShowDeprecationWarning("getPID()", "the pid property"); PyObject *retVal = PyList_New(3); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_torque[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_torque[1])); - PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_torque[2])); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_pid[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_pid[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_pid[2])); return retVal; } /* 5. setPID */ PyObject* KX_ObjectActuator::PySetPID(PyObject* args) { + ShowDeprecationWarning("setPID()", "the pid property"); float vecArg[3]; if (!PyArg_ParseTuple(args, "fff:setPID", &vecArg[0], &vecArg[1], &vecArg[2])) { return NULL; } - m_torque.setValue(vecArg); + m_pid.setValue(vecArg); Py_RETURN_NONE; } |