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:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-05-13 20:48:33 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-13 20:48:33 +0400
commitf5bacc6c8a6bf06c20301fbfdc36d7b5b9de041d (patch)
tree71392312b1d3182c292a5c8f42a16cb021685511 /source/gameengine
parent77f321d15fbd39d42700b43909d6d7ec8bbc0262 (diff)
BGE API cleanup: motion actuator. Apply patch from Moguri.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp185
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.h79
-rw-r--r--source/gameengine/PyDoc/GameTypes.py90
3 files changed, 298 insertions, 56 deletions
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
index e3d7a0f4b71..0232e3407b0 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
@@ -76,7 +77,10 @@ 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;
}
+
UpdateFuzzyFlags();
}
@@ -132,7 +136,7 @@ bool KX_ObjectActuator::Update()
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)
@@ -306,6 +310,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},
@@ -329,40 +334,163 @@ 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_TODO("force"),
- //KX_PYATTRIBUTE_TODO("torque"),
- //KX_PYATTRIBUTE_TODO("dLoc"),
- //KX_PYATTRIBUTE_TODO("dRot"),
- //KX_PYATTRIBUTE_TODO("linV"),
- //KX_PYATTRIBUTE_TODO("angV"),
- //KX_PYATTRIBUTE_TODO("damping"),
- //KX_PYATTRIBUTE_TODO("forceLimitX"),
- //KX_PYATTRIBUTE_TODO("forceLimitY"),
- //KX_PYATTRIBUTE_TODO("forceLimitZ"),
- //KX_PYATTRIBUTE_TODO("pid"),
+ 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),
{ 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;
+}
+
/* 1. set ------------------------------------------------------------------ */
/* Removed! */
/* 2. getForce */
PyObject* KX_ObjectActuator::PyGetForce()
{
+ ShowDeprecationWarning("getForce()", "the force and the useLocalForce properties");
PyObject *retVal = PyList_New(4);
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_force[0]));
@@ -375,6 +503,7 @@ PyObject* KX_ObjectActuator::PyGetForce()
/* 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],
@@ -390,6 +519,7 @@ 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_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_torque[0]));
@@ -402,6 +532,7 @@ PyObject* KX_ObjectActuator::PyGetTorque()
/* 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],
@@ -417,6 +548,7 @@ 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_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_dloc[0]));
@@ -429,6 +561,7 @@ PyObject* KX_ObjectActuator::PyGetDLoc()
/* 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],
@@ -444,6 +577,7 @@ 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_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0]));
@@ -456,6 +590,7 @@ PyObject* KX_ObjectActuator::PyGetDRot()
/* 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],
@@ -470,6 +605,7 @@ 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_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
@@ -482,6 +618,7 @@ PyObject* KX_ObjectActuator::PyGetLinearVelocity() {
/* 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],
@@ -497,6 +634,7 @@ 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_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
@@ -508,6 +646,7 @@ PyObject* KX_ObjectActuator::PyGetAngularVelocity() {
}
/* 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],
@@ -522,6 +661,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;
@@ -532,11 +672,13 @@ 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_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[0]));
@@ -548,6 +690,7 @@ PyObject* KX_ObjectActuator::PyGetForceLimitX()
/* 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)) {
@@ -562,6 +705,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* args)
/* 6. getForceLimitY */
PyObject* KX_ObjectActuator::PyGetForceLimitY()
{
+ ShowDeprecationWarning("getForceLimitY()", "the forceLimitY property");
PyObject *retVal = PyList_New(3);
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[1]));
@@ -573,6 +717,7 @@ PyObject* KX_ObjectActuator::PyGetForceLimitY()
/* 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)) {
@@ -587,6 +732,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* args)
/* 6. getForceLimitZ */
PyObject* KX_ObjectActuator::PyGetForceLimitZ()
{
+ ShowDeprecationWarning("getForceLimitZ()", "the forceLimitZ property");
PyObject *retVal = PyList_New(3);
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_drot[2]));
@@ -598,6 +744,7 @@ PyObject* KX_ObjectActuator::PyGetForceLimitZ()
/* 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)) {
@@ -612,22 +759,24 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* args)
/* 4. getPID */
PyObject* KX_ObjectActuator::PyGetPID()
{
+ ShowDeprecationWarning("getPID()", "the pid property");
PyObject *retVal = PyList_New(3);
- 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, 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;
}
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h
index ab5fbe44409..b60f877074d 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.h
@@ -36,7 +36,7 @@
#include "MT_Vector3.h"
//
-// Bitfield that stores the flags for each CValue derived class
+// Stores the flags for each CValue derived class
//
struct KX_LocalFlags {
KX_LocalFlags() :
@@ -55,20 +55,20 @@ struct KX_LocalFlags {
{
}
- unsigned short Force : 1;
- unsigned short Torque : 1;
- unsigned short DRot : 1;
- unsigned short DLoc : 1;
- unsigned short LinearVelocity : 1;
- unsigned short AngularVelocity : 1;
- unsigned short AddOrSetLinV : 1;
- unsigned short ServoControl : 1;
- unsigned short ZeroForce : 1;
- unsigned short ZeroTorque : 1;
- unsigned short ZeroDRot : 1;
- unsigned short ZeroDLoc : 1;
- unsigned short ZeroLinearVelocity : 1;
- unsigned short ZeroAngularVelocity : 1;
+ bool Force;
+ bool Torque;
+ bool DRot;
+ bool DLoc;
+ bool LinearVelocity;
+ bool AngularVelocity;
+ bool AddOrSetLinV;
+ bool ServoControl;
+ bool ZeroForce;
+ bool ZeroTorque;
+ bool ZeroDRot;
+ bool ZeroDLoc;
+ bool ZeroLinearVelocity;
+ bool ZeroAngularVelocity;
};
class KX_ObjectActuator : public SCA_IActuator
@@ -80,7 +80,8 @@ class KX_ObjectActuator : public SCA_IActuator
MT_Vector3 m_dloc;
MT_Vector3 m_drot;
MT_Vector3 m_linear_velocity;
- MT_Vector3 m_angular_velocity;
+ MT_Vector3 m_angular_velocity;
+ MT_Vector3 m_pid;
MT_Scalar m_linear_length2;
MT_Scalar m_angular_length2;
// used in damping
@@ -155,6 +156,7 @@ public:
virtual PyObject* py_getattro(PyObject *attr);
virtual PyObject* py_getattro_dict();
+ virtual int py_setattro(PyObject *attr, PyObject *value);
KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce);
KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForce);
@@ -178,6 +180,51 @@ public:
KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForceLimitZ);
KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetPID);
KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetPID);
+
+ /* Attributes */
+ static PyObject* pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+
+ // This lets the attribute macros use UpdateFuzzyFlags()
+ static int PyUpdateFuzzyFlags(void *self, const PyAttributeDef *attrdef)
+ {
+ KX_ObjectActuator* act = reinterpret_cast<KX_ObjectActuator*>(self);
+ act->UpdateFuzzyFlags();
+ return 0;
+ }
+
+ // This is the keep the PID values in check after they are assigned with Python
+ static int PyCheckPid(void *self, const PyAttributeDef *attrdef)
+ {
+ KX_ObjectActuator* act = reinterpret_cast<KX_ObjectActuator*>(self);
+
+ //P 0 to 200
+ if (act->m_pid[0] < 0) {
+ act->m_pid[0] = 0;
+ } else if (act->m_pid[0] > 200) {
+ act->m_pid[0] = 200;
+ }
+
+ //I 0 to 3
+ if (act->m_pid[1] < 0) {
+ act->m_pid[1] = 0;
+ } else if (act->m_pid[1] > 3) {
+ act->m_pid[1] = 3;
+ }
+
+ //D -100 to 100
+ if (act->m_pid[2] < -100) {
+ act->m_pid[2] = -100;
+ } else if (act->m_pid[2] > 100) {
+ act->m_pid[2] = 100;
+ }
+
+ return 0;
+ }
};
#endif //__KX_OBJECTACTUATOR
diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py
index d1b92e37099..828435b813a 100644
--- a/source/gameengine/PyDoc/GameTypes.py
+++ b/source/gameengine/PyDoc/GameTypes.py
@@ -2574,17 +2574,63 @@ class KX_ObjectActuator(SCA_IActuator):
The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
velocity, or angular velocity to an object.
Servo control allows to regulate force to achieve a certain speed target.
+
+ @ivar force: The force applied by the actuator
+ @type force: list [x, y, z]
+ @ivar useLocalForce: A flag specifying if the force is local
+ @type force: bool
+ @ivar torque: The torque applied by the actuator
+ @type torque: list [x, y, z]
+ @ivar useLocalTorque: A flag specifying if the torque is local
+ @type useLocalTorque: bool
+ @ivar dLoc: The displacement vector applied by the actuator
+ @type dLoc: list [x, y, z]
+ @ivar useLocalDLoc: A flag specifying if the dLoc is local
+ @type useLocalDLoc: bool
+ @ivar dRot: The angular displacement vector applied by the actuator
+ - note: Since the displacement is applied every frame, you must adjust the displacement
+ based on the frame rate, or you game experience will depend on the player's computer
+ speed.
+ @type dRot: list [x, y, z]
+ @ivar useLocalDRot: A flag specifying if the dRot is local
+ @type useLocalDRot: bool
+ @ivar linV: The linear velocity applied by the actuator
+ @type linV: list [x, y, z]
+ @ivar useLocalLinV: A flag specifying if the linear velocity is local
+ - note: This is the target speed for servo controllers
+ @type useLocalLinV: bool
+ @ivar angV: The angular velocity applied by the actuator
+ @type angV: list [x, y, z]
+ @ivar useLocalAngV: A flag specifying if the angular velocity is local
+ @type useLocalAngV: bool
+
+ @ivar damping: The damping parameter of the servo controller
+ @type damping: short
+
+ @ivar forceLimitX: The min/max force limit along the X axis and activates or deactivates the limits in the servo controller
+ @type forceLimitX: list [min(float), max(float), bool]
+ @ivar forceLimitY: The min/max force limit along the Y axis and activates or deactivates the limits in the servo controller
+ @type forceLimitY: list [min(float), max(float), bool]
+ @ivar forceLimitZ: The min/max force limit along the Z axis and activates or deactivates the limits in the servo controller
+ @type forceLimitZ: list [min(float), max(float), bool]
+
+ @ivar pid: The PID coefficients of the servo controller
+ @type pid: list of floats [proportional, integral, derivate]
+
+ @group Deprecated: getForce, setForce, getTorque, setTorque, getDLoc, setDLoc, getDRot, setDRot, getLinearVelocity, setLinearVelocity, getAngularVelocity,
+ setAngularVelocity, getDamping, setDamping, getForceLimitX, setForceLimitX, getForceLimitY, setForceLimitY, getForceLimitZ, setForceLimitZ,
+ getPID, setPID
"""
def getForce():
"""
- Returns the force applied by the actuator.
+ Returns the force applied by the actuator. (B{deprecated})
@rtype: list [fx, fy, fz, local]
@return: A four item list, containing the vector force, and a flag specifying whether the force is local.
"""
def setForce(fx, fy, fz, local):
"""
- Sets the force applied by the actuator.
+ Sets the force applied by the actuator. (B{deprecated})
@type fx: float
@param fx: the x component of the force.
@@ -2598,7 +2644,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getTorque():
"""
- Returns the torque applied by the actuator.
+ Returns the torque applied by the actuator. (B{deprecated})
@rtype: list [S{Tau}x, S{Tau}y, S{Tau}z, local]
@return: A four item list, containing the vector torque, and a flag specifying whether
@@ -2606,7 +2652,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setTorque(tx, ty, tz, local):
"""
- Sets the torque applied by the actuator.
+ Sets the torque applied by the actuator. (B{deprecated})
@type tx: float
@param tx: the x component of the torque.
@@ -2620,7 +2666,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getDLoc():
"""
- Returns the displacement vector applied by the actuator.
+ Returns the displacement vector applied by the actuator. (B{deprecated})
@rtype: list [dx, dy, dz, local]
@return: A four item list, containing the vector displacement, and whether
@@ -2629,7 +2675,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setDLoc(dx, dy, dz, local):
"""
- Sets the displacement vector applied by the actuator.
+ Sets the displacement vector applied by the actuator. (B{deprecated})
Since the displacement is applied every frame, you must adjust the displacement
based on the frame rate, or you game experience will depend on the player's computer
@@ -2647,7 +2693,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getDRot():
"""
- Returns the angular displacement vector applied by the actuator.
+ Returns the angular displacement vector applied by the actuator. (B{deprecated})
@rtype: list [dx, dy, dz, local]
@return: A four item list, containing the angular displacement vector, and whether
@@ -2656,7 +2702,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setDRot(dx, dy, dz, local):
"""
- Sets the angular displacement vector applied by the actuator.
+ Sets the angular displacement vector applied by the actuator. (B{deprecated})
Since the displacement is applied every frame, you must adjust the displacement
based on the frame rate, or you game experience will depend on the player's computer
@@ -2675,7 +2721,7 @@ class KX_ObjectActuator(SCA_IActuator):
def getLinearVelocity():
"""
Returns the linear velocity applied by the actuator.
- For the servo control actuator, this is the target speed.
+ For the servo control actuator, this is the target speed. (B{deprecated})
@rtype: list [vx, vy, vz, local]
@return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world coordinates (False)
@@ -2683,7 +2729,7 @@ class KX_ObjectActuator(SCA_IActuator):
def setLinearVelocity(vx, vy, vz, local):
"""
Sets the linear velocity applied by the actuator.
- For the servo control actuator, sets the target speed.
+ For the servo control actuator, sets the target speed. (B{deprecated})
@type vx: float
@param vx: the x component of the velocity vector.
@@ -2697,7 +2743,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getAngularVelocity():
"""
- Returns the angular velocity applied by the actuator.
+ Returns the angular velocity applied by the actuator. (B{deprecated})
@rtype: list [S{omega}x, S{omega}y, S{omega}z, local]
@return: A four item list, containing the vector velocity, and whether
@@ -2706,7 +2752,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setAngularVelocity(wx, wy, wz, local):
"""
- Sets the angular velocity applied by the actuator.
+ Sets the angular velocity applied by the actuator. (B{deprecated})
@type wx: float
@param wx: the x component of the velocity vector.
@@ -2720,21 +2766,21 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getDamping():
"""
- Returns the damping parameter of the servo controller.
+ Returns the damping parameter of the servo controller. (B{deprecated})
@rtype: integer
@return: the time constant of the servo controller in frame unit.
"""
def setDamping(damp):
"""
- Sets the damping parameter of the servo controller.
+ Sets the damping parameter of the servo controller. (B{deprecated})
@type damp: integer
@param damp: the damping parameter in frame unit.
"""
def getForceLimitX():
"""
- Returns the min/max force limit along the X axis used by the servo controller.
+ Returns the min/max force limit along the X axis used by the servo controller. (B{deprecated})
@rtype: list [min, max, enabled]
@return: A three item list, containing the min and max limits of the force as float
@@ -2742,7 +2788,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setForceLimitX(min, max, enable):
"""
- Sets the min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
+ Sets the min/max force limit along the X axis and activates or deactivates the limits in the servo controller. (B{deprecated})
@type min: float
@param min: the minimum value of the force along the X axis.
@@ -2754,7 +2800,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getForceLimitY():
"""
- Returns the min/max force limit along the Y axis used by the servo controller.
+ Returns the min/max force limit along the Y axis used by the servo controller. (B{deprecated})
@rtype: list [min, max, enabled]
@return: A three item list, containing the min and max limits of the force as float
@@ -2762,7 +2808,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setForceLimitY(min, max, enable):
"""
- Sets the min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
+ Sets the min/max force limit along the Y axis and activates or deactivates the limits in the servo controller. (B{deprecated})
@type min: float
@param min: the minimum value of the force along the Y axis.
@@ -2774,7 +2820,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getForceLimitZ():
"""
- Returns the min/max force limit along the Z axis used by the servo controller.
+ Returns the min/max force limit along the Z axis used by the servo controller. (B{deprecated})
@rtype: list [min, max, enabled]
@return: A three item list, containing the min and max limits of the force as float
@@ -2782,7 +2828,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setForceLimitZ(min, max, enable):
"""
- Sets the min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
+ Sets the min/max force limit along the Z axis and activates or deactivates the limits in the servo controller. (B{deprecated})
@type min: float
@param min: the minimum value of the force along the Z axis.
@@ -2794,7 +2840,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def getPID():
"""
- Returns the PID coefficient of the servo controller.
+ Returns the PID coefficient of the servo controller. (B{deprecated})
@rtype: list [P, I, D]
@return: A three item list, containing the PID coefficient as floats:
@@ -2804,7 +2850,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
def setPID(P, I, D):
"""
- Sets the PID coefficients of the servo controller.
+ Sets the PID coefficients of the servo controller. (B{deprecated})
@type P: flat
@param P: proportional coefficient