Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / gameengine / Ketsji / KX_ConstraintActuator.cpp
index 7f1d2c7..5f6244c 100644 (file)
@@ -587,6 +587,30 @@ PyTypeObject KX_ConstraintActuator::Type = {
 };
 
 PyMethodDef KX_ConstraintActuator::Methods[] = {
+       // Deprecated -->
+       {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, (const char *)SetDamp_doc},
+       {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, (const char *)GetDamp_doc},
+       {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, (const char *)SetRotDamp_doc},
+       {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, (const char *)GetRotDamp_doc},
+       {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, (const char *)SetDirection_doc},
+       {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, (const char *)GetDirection_doc},
+       {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, (const char *)SetOption_doc},
+       {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, (const char *)GetOption_doc},
+       {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, (const char *)SetTime_doc},
+       {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc},
+       {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc},
+       {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc},
+       {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (const char *)SetMin_doc},
+       {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (const char *)GetMin_doc},
+       {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (const char *)SetDistance_doc},
+       {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (const char *)GetDistance_doc},
+       {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (const char *)SetMax_doc},
+       {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (const char *)GetMax_doc},
+       {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (const char *)SetRayLength_doc},
+       {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (const char *)GetRayLength_doc},
+       {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, (const char *)SetLimit_doc},
+       {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, (const char *)GetLimit_doc},
+       // <--
        {NULL,NULL} //Sentinel
 };
 
@@ -618,4 +642,318 @@ int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PY
        return 0;       
 }
 
+/* 2. setDamp                                                                */
+const char KX_ConstraintActuator::SetDamp_doc[] = 
+"setDamp(duration)\n"
+"\t- duration: integer\n"
+"\tSets the time constant of the orientation and distance constraint.\n"
+"\tIf the duration is negative, it is set to 0.\n";
+PyObject* KX_ConstraintActuator::PySetDamp(PyObject* args) {
+       ShowDeprecationWarning("setDamp()", "the damp property");
+       int dampArg;
+       if(!PyArg_ParseTuple(args, "i:setDamp", &dampArg)) {
+               return NULL;            
+       }
+       
+       m_posDampTime = dampArg;
+       if (m_posDampTime < 0) m_posDampTime = 0;
+
+       Py_RETURN_NONE;
+}
+/* 3. getDamp                                                                */
+const char KX_ConstraintActuator::GetDamp_doc[] = 
+"getDamp()\n"
+"\tReturns the damping parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetDamp(){
+       ShowDeprecationWarning("getDamp()", "the damp property");
+       return PyLong_FromSsize_t(m_posDampTime);
+}
+
+/* 2. setRotDamp                                                                */
+const char KX_ConstraintActuator::SetRotDamp_doc[] = 
+"setRotDamp(duration)\n"
+"\t- duration: integer\n"
+"\tSets the time constant of the orientation constraint.\n"
+"\tIf the duration is negative, it is set to 0.\n";
+PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* args) {
+       ShowDeprecationWarning("setRotDamp()", "the rotDamp property");
+       int dampArg;
+       if(!PyArg_ParseTuple(args, "i:setRotDamp", &dampArg)) {
+               return NULL;            
+       }
+       
+       m_rotDampTime = dampArg;
+       if (m_rotDampTime < 0) m_rotDampTime = 0;
+
+       Py_RETURN_NONE;
+}
+/* 3. getRotDamp                                                                */
+const char KX_ConstraintActuator::GetRotDamp_doc[] = 
+"getRotDamp()\n"
+"\tReturns the damping time for application of the constraint.\n";
+PyObject* KX_ConstraintActuator::PyGetRotDamp(){
+       ShowDeprecationWarning("getRotDamp()", "the rotDamp property");
+       return PyLong_FromSsize_t(m_rotDampTime);
+}
+
+/* 2. setDirection                                                                */
+const char KX_ConstraintActuator::SetDirection_doc[] = 
+"setDirection(vector)\n"
+"\t- vector: 3-tuple\n"
+"\tSets the reference direction in world coordinate for the orientation constraint.\n";
+PyObject* KX_ConstraintActuator::PySetDirection(PyObject* args) {
+       ShowDeprecationWarning("setDirection()", "the direction property");
+       float x, y, z;
+       MT_Scalar len;
+       MT_Vector3 dir;
+
+       if(!PyArg_ParseTuple(args, "(fff):setDirection", &x, &y, &z)) {
+               return NULL;            
+       }
+       dir[0] = x;
+       dir[1] = y;
+       dir[2] = z;
+       len = dir.length();
+       if (MT_fuzzyZero(len)) {
+               std::cout << "Invalid direction" << std::endl;
+               return NULL;
+       }
+       m_refDirVector = dir/len;
+       m_refDirection[0] = x/len;
+       m_refDirection[1] = y/len;
+       m_refDirection[2] = z/len;
+
+       Py_RETURN_NONE;
+}
+/* 3. getDirection                                                                */
+const char KX_ConstraintActuator::GetDirection_doc[] = 
+"getDirection()\n"
+"\tReturns the reference direction of the orientation constraint as a 3-tuple.\n";
+PyObject* KX_ConstraintActuator::PyGetDirection(){
+       ShowDeprecationWarning("getDirection()", "the direction property");
+       PyObject *retVal = PyList_New(3);
+
+       PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_refDirection[0]));
+       PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_refDirection[1]));
+       PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_refDirection[2]));
+       return retVal;
+}
+
+/* 2. setOption                                                                */
+const char KX_ConstraintActuator::SetOption_doc[] = 
+"setOption(option)\n"
+"\t- option: integer\n"
+"\tSets several options of the distance  constraint.\n"
+"\tBinary combination of the following values:\n"
+"\t\t 64 : Activate alignment to surface\n"
+"\t\t128 : Detect material rather than property\n"
+"\t\t256 : No deactivation if ray does not hit target\n"
+"\t\t512 : Activate distance control\n";
+PyObject* KX_ConstraintActuator::PySetOption(PyObject* args) {
+       ShowDeprecationWarning("setOption()", "the option property");
+       int option;
+       if(!PyArg_ParseTuple(args, "i:setOption", &option)) {
+               return NULL;            
+       }
+       
+       m_option = option;
+
+       Py_RETURN_NONE;
+}
+/* 3. getOption                                                              */
+const char KX_ConstraintActuator::GetOption_doc[] = 
+"getOption()\n"
+"\tReturns the option parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetOption(){
+       ShowDeprecationWarning("getOption()", "the option property");
+       return PyLong_FromSsize_t(m_option);
+}
+
+/* 2. setTime                                                                */
+const char KX_ConstraintActuator::SetTime_doc[] = 
+"setTime(duration)\n"
+"\t- duration: integer\n"
+"\tSets the activation time of the actuator.\n"
+"\tThe actuator disables itself after this many frame.\n"
+"\tIf set to 0 or negative, the actuator is not limited in time.\n";
+PyObject* KX_ConstraintActuator::PySetTime(PyObject* args) {
+       ShowDeprecationWarning("setTime()", "the time property");
+       int t;
+       if(!PyArg_ParseTuple(args, "i:setTime", &t)) {
+               return NULL;            
+       }
+       
+       if (t < 0)
+               t = 0;
+       m_activeTime = t;
+
+       Py_RETURN_NONE;
+}
+/* 3. getTime                                                                */
+const char KX_ConstraintActuator::GetTime_doc[] = 
+"getTime()\n"
+"\tReturns the time parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetTime(){
+       ShowDeprecationWarning("getTime()", "the time property");
+       return PyLong_FromSsize_t(m_activeTime);
+}
+
+/* 2. setProperty                                                                */
+const char KX_ConstraintActuator::SetProperty_doc[] = 
+"setProperty(property)\n"
+"\t- property: string\n"
+"\tSets the name of the property or material for the ray detection of the distance constraint.\n"
+"\tIf empty, the ray will detect any collisioning object.\n";
+PyObject* KX_ConstraintActuator::PySetProperty(PyObject* args) {
+       ShowDeprecationWarning("setProperty()", "the 'property' property");
+       char *property;
+       if (!PyArg_ParseTuple(args, "s:setProperty", &property)) {
+               return NULL;
+       }
+       if (property == NULL) {
+               m_property = "";
+       } else {
+               m_property = property;
+       }
+
+       Py_RETURN_NONE;
+}
+/* 3. getProperty                                                                */
+const char KX_ConstraintActuator::GetProperty_doc[] = 
+"getProperty()\n"
+"\tReturns the property parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetProperty(){
+       ShowDeprecationWarning("getProperty()", "the 'property' property");
+       return PyUnicode_FromString(m_property.Ptr());
+}
+
+/* 4. setDistance                                                                 */
+const char KX_ConstraintActuator::SetDistance_doc[] = 
+"setDistance(distance)\n"
+"\t- distance: float\n"
+"\tSets the target distance in distance constraint\n";
+/* 4. setMin                                                                 */
+const char KX_ConstraintActuator::SetMin_doc[] = 
+"setMin(lower_bound)\n"
+"\t- lower_bound: float\n"
+"\tSets the lower value of the interval to which the value\n"
+"\tis clipped.\n";
+PyObject* KX_ConstraintActuator::PySetMin(PyObject* args) {
+       ShowDeprecationWarning("setMin() or setDistance()", "the min or distance property");
+       float minArg;
+       if(!PyArg_ParseTuple(args, "f:setMin", &minArg)) {
+               return NULL;            
+       }
+
+       switch (m_locrot) {
+       default:
+               m_minimumBound = minArg;
+               break;
+       case KX_ACT_CONSTRAINT_ROTX:
+       case KX_ACT_CONSTRAINT_ROTY:
+       case KX_ACT_CONSTRAINT_ROTZ:
+               m_minimumBound = MT_radians(minArg);
+               break;
+       }
+
+       Py_RETURN_NONE;
+}
+/* 5. getDistance                                                                 */
+const char KX_ConstraintActuator::GetDistance_doc[] = 
+"getDistance()\n"
+"\tReturns the distance parameter \n";
+/* 5. getMin                                                                 */
+const char KX_ConstraintActuator::GetMin_doc[] = 
+"getMin()\n"
+"\tReturns the lower value of the interval to which the value\n"
+"\tis clipped.\n";
+PyObject* KX_ConstraintActuator::PyGetMin() {
+       ShowDeprecationWarning("getMin() or getDistance()", "the min or distance property");
+       return PyFloat_FromDouble(m_minimumBound);
+}
+
+/* 6. setRayLength                                                                 */
+const char KX_ConstraintActuator::SetRayLength_doc[] = 
+"setRayLength(length)\n"
+"\t- length: float\n"
+"\tSets the maximum ray length of the distance constraint\n";
+/* 6. setMax                                                                 */
+const char KX_ConstraintActuator::SetMax_doc[] = 
+"setMax(upper_bound)\n"
+"\t- upper_bound: float\n"
+"\tSets the upper value of the interval to which the value\n"
+"\tis clipped.\n";
+PyObject* KX_ConstraintActuator::PySetMax(PyObject* args){
+       ShowDeprecationWarning("setMax() or setRayLength()", "the max or rayLength property");
+       float maxArg;
+       if(!PyArg_ParseTuple(args, "f:setMax", &maxArg)) {
+               return NULL;            
+       }
+
+       switch (m_locrot) {
+       default:
+               m_maximumBound = maxArg;
+               break;
+       case KX_ACT_CONSTRAINT_ROTX:
+       case KX_ACT_CONSTRAINT_ROTY:
+       case KX_ACT_CONSTRAINT_ROTZ:
+               m_maximumBound = MT_radians(maxArg);
+               break;
+       }
+
+       Py_RETURN_NONE;
+}
+/* 7. getRayLength                                                                 */
+const char KX_ConstraintActuator::GetRayLength_doc[] = 
+"getRayLength()\n"
+"\tReturns the length of the ray\n";
+/* 7. getMax                                                                 */
+const char KX_ConstraintActuator::GetMax_doc[] = 
+"getMax()\n"
+"\tReturns the upper value of the interval to which the value\n"
+"\tis clipped.\n";
+PyObject* KX_ConstraintActuator::PyGetMax() {
+       ShowDeprecationWarning("getMax() or getRayLength()", "the max or rayLength property");
+       return PyFloat_FromDouble(m_maximumBound);
+}
+
+
+/* This setter/getter probably for the constraint type                       */
+/* 8. setLimit                                                               */
+const char KX_ConstraintActuator::SetLimit_doc[] = 
+"setLimit(type)\n"
+"\t- type: integer\n"
+"\t  1  : LocX\n"
+"\t  2  : LocY\n"
+"\t  3  : LocZ\n"
+"\t  7  : Distance along +X axis\n"
+"\t  8  : Distance along +Y axis\n"
+"\t  9  : Distance along +Z axis\n"
+"\t  10 : Distance along -X axis\n"
+"\t  11 : Distance along -Y axis\n"
+"\t  12 : Distance along -Z axis\n"
+"\t  13 : Align X axis\n"
+"\t  14 : Align Y axis\n"
+"\t  15 : Align Z axis\n"
+"\tSets the type of constraint.\n";
+PyObject* KX_ConstraintActuator::PySetLimit(PyObject* args) {
+       ShowDeprecationWarning("setLimit()", "the limit property");
+       int locrotArg;
+       if(!PyArg_ParseTuple(args, "i:setLimit", &locrotArg)) {
+               return NULL;            
+       }
+       
+       if (IsValidMode((KX_CONSTRAINTTYPE)locrotArg)) m_locrot = locrotArg;
+
+       Py_RETURN_NONE;
+}
+/* 9. getLimit                                                               */
+const char KX_ConstraintActuator::GetLimit_doc[] = 
+"getLimit()\n"
+"\tReturns the type of constraint.\n";
+PyObject* KX_ConstraintActuator::PyGetLimit() {
+       ShowDeprecationWarning("setLimit()", "the limit property");
+       return PyLong_FromSsize_t(m_locrot);
+}
+
 /* eof */