2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r17853:HEAD
This commit is contained in:
@@ -139,71 +139,6 @@ void SCA_ISensor::DecLink() {
|
||||
}
|
||||
}
|
||||
|
||||
/* python integration */
|
||||
|
||||
PyTypeObject SCA_ISensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
"SCA_ISensor",
|
||||
sizeof(SCA_ISensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0, //&cvalue_as_number,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
PyParentObject SCA_ISensor::Parents[] = {
|
||||
&SCA_ISensor::Type,
|
||||
&SCA_ILogicBrick::Type,
|
||||
&CValue::Type,
|
||||
NULL
|
||||
};
|
||||
PyMethodDef SCA_ISensor::Methods[] = {
|
||||
{"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
|
||||
METH_NOARGS, (PY_METHODCHAR)IsPositive_doc},
|
||||
{"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered,
|
||||
METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc},
|
||||
{"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc},
|
||||
{"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc},
|
||||
{"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc},
|
||||
{"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc},
|
||||
{"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc},
|
||||
{"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc},
|
||||
{"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetInvert_doc},
|
||||
{"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetInvert_doc},
|
||||
{"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetLevel_doc},
|
||||
{"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetLevel_doc},
|
||||
{"reset", (PyCFunction) SCA_ISensor::sPyReset,
|
||||
METH_NOARGS, (PY_METHODCHAR)Reset_doc},
|
||||
{NULL,NULL} //Sentinel
|
||||
};
|
||||
|
||||
|
||||
PyObject*
|
||||
SCA_ISensor::_getattr(const STR_String& attr)
|
||||
{
|
||||
_getattr_up(SCA_ILogicBrick);
|
||||
}
|
||||
|
||||
|
||||
void SCA_ISensor::RegisterToManager()
|
||||
{
|
||||
// sensor is just activated, initialize it
|
||||
@@ -275,13 +210,17 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ----------------------------------------------- */
|
||||
/* Python Functions */
|
||||
/* ----------------------------------------------- */
|
||||
|
||||
/* Python functions: */
|
||||
//Deprecated Functions ------>
|
||||
const char SCA_ISensor::IsPositive_doc[] =
|
||||
"isPositive()\n"
|
||||
"\tReturns whether the sensor is in an active state.\n";
|
||||
PyObject* SCA_ISensor::PyIsPositive(PyObject* self)
|
||||
{
|
||||
ShowDeprecationWarning("isPositive()", "the read-only positive property");
|
||||
int retval = IsPositiveTrigger();
|
||||
return PyInt_FromLong(retval);
|
||||
}
|
||||
@@ -291,6 +230,7 @@ const char SCA_ISensor::IsTriggered_doc[] =
|
||||
"\tReturns whether the sensor has triggered the current controller.\n";
|
||||
PyObject* SCA_ISensor::PyIsTriggered(PyObject* self)
|
||||
{
|
||||
ShowDeprecationWarning("isTriggered()", "the read-only triggered property");
|
||||
// check with the current controller
|
||||
int retval = 0;
|
||||
if (SCA_PythonController::m_sCurrentController)
|
||||
@@ -306,6 +246,7 @@ const char SCA_ISensor::GetUsePosPulseMode_doc[] =
|
||||
"\tReturns whether positive pulse mode is active.\n";
|
||||
PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self)
|
||||
{
|
||||
ShowDeprecationWarning("getUsePosPulseMode()", "the usePosPulseMode property");
|
||||
return BoolToPyArg(m_pos_pulsemode);
|
||||
}
|
||||
|
||||
@@ -319,6 +260,7 @@ const char SCA_ISensor::SetUsePosPulseMode_doc[] =
|
||||
"\tSet whether to do pulsing when positive pulses occur.\n";
|
||||
PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
ShowDeprecationWarning("setUsePosPulseMode()", "the usePosPulseMode property");
|
||||
int pyarg = 0;
|
||||
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
|
||||
m_pos_pulsemode = PyArgToBool(pyarg);
|
||||
@@ -333,6 +275,7 @@ const char SCA_ISensor::GetFrequency_doc[] =
|
||||
"\tReturns the frequency of the updates in pulse mode.\n" ;
|
||||
PyObject* SCA_ISensor::PyGetFrequency(PyObject* self)
|
||||
{
|
||||
ShowDeprecationWarning("getFrequency()", "the frequency property");
|
||||
return PyInt_FromLong(m_pulse_frequency);
|
||||
}
|
||||
|
||||
@@ -346,6 +289,7 @@ const char SCA_ISensor::SetFrequency_doc[] =
|
||||
"\tIf the frequency is negative, it is set to 0.\n" ;
|
||||
PyObject* SCA_ISensor::PySetFrequency(PyObject* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
ShowDeprecationWarning("setFrequency()", "the frequency property");
|
||||
int pulse_frequencyArg = 0;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "i", &pulse_frequencyArg)) {
|
||||
@@ -368,6 +312,7 @@ const char SCA_ISensor::GetInvert_doc[] =
|
||||
"\tReturns whether or not pulses from this sensor are inverted.\n" ;
|
||||
PyObject* SCA_ISensor::PyGetInvert(PyObject* self)
|
||||
{
|
||||
ShowDeprecationWarning("getInvert()", "the invert property");
|
||||
return BoolToPyArg(m_invert);
|
||||
}
|
||||
|
||||
@@ -377,6 +322,7 @@ const char SCA_ISensor::SetInvert_doc[] =
|
||||
"\tSet whether to invert pulses.\n";
|
||||
PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
ShowDeprecationWarning("setInvert()", "the invert property");
|
||||
int pyarg = 0;
|
||||
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
|
||||
m_invert = PyArgToBool(pyarg);
|
||||
@@ -392,6 +338,7 @@ const char SCA_ISensor::GetLevel_doc[] =
|
||||
"\tA edge detector will wait for a state change before generating a pulse.\n";
|
||||
PyObject* SCA_ISensor::PyGetLevel(PyObject* self)
|
||||
{
|
||||
ShowDeprecationWarning("getLevel()", "the level property");
|
||||
return BoolToPyArg(m_level);
|
||||
}
|
||||
|
||||
@@ -401,6 +348,7 @@ const char SCA_ISensor::SetLevel_doc[] =
|
||||
"\tSet whether to detect level or edge transition when entering a state.\n";
|
||||
PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
ShowDeprecationWarning("setLevel()", "the level property");
|
||||
int pyarg = 0;
|
||||
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
|
||||
m_level = PyArgToBool(pyarg);
|
||||
@@ -412,6 +360,7 @@ const char SCA_ISensor::GetUseNegPulseMode_doc[] =
|
||||
"\tReturns whether negative pulse mode is active.\n";
|
||||
PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self)
|
||||
{
|
||||
ShowDeprecationWarning("getUseNegPulseMode()", "the useNegPulseMode property");
|
||||
return BoolToPyArg(m_neg_pulsemode);
|
||||
}
|
||||
|
||||
@@ -422,21 +371,121 @@ const char SCA_ISensor::SetUseNegPulseMode_doc[] =
|
||||
"\tSet whether to do pulsing when negative pulses occur.\n";
|
||||
PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
ShowDeprecationWarning("setUseNegPulseMode()", "the useNegPulseMode property");
|
||||
int pyarg = 0;
|
||||
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
|
||||
m_neg_pulsemode = PyArgToBool(pyarg);
|
||||
Py_Return;
|
||||
}
|
||||
//<------Deprecated
|
||||
|
||||
const char SCA_ISensor::Reset_doc[] =
|
||||
KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
|
||||
"reset()\n"
|
||||
"\tReset sensor internal state, effect depends on the type of sensor and settings.\n"
|
||||
"\tThe sensor is put in its initial state as if it was just activated.\n";
|
||||
PyObject* SCA_ISensor::PyReset(PyObject* self)
|
||||
"\tThe sensor is put in its initial state as if it was just activated.\n")
|
||||
{
|
||||
Init();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------- */
|
||||
/* Python Integration Hooks */
|
||||
/* ----------------------------------------------- */
|
||||
|
||||
PyTypeObject SCA_ISensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
"SCA_ISensor",
|
||||
sizeof(SCA_ISensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0, //&cvalue_as_number,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
PyParentObject SCA_ISensor::Parents[] = {
|
||||
&SCA_ISensor::Type,
|
||||
&SCA_ILogicBrick::Type,
|
||||
&CValue::Type,
|
||||
NULL
|
||||
};
|
||||
PyMethodDef SCA_ISensor::Methods[] = {
|
||||
//Deprecated functions ----->
|
||||
{"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
|
||||
METH_NOARGS, (PY_METHODCHAR)IsPositive_doc},
|
||||
{"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered,
|
||||
METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc},
|
||||
{"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc},
|
||||
{"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc},
|
||||
{"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc},
|
||||
{"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc},
|
||||
{"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc},
|
||||
{"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc},
|
||||
{"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetInvert_doc},
|
||||
{"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetInvert_doc},
|
||||
{"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel,
|
||||
METH_NOARGS, (PY_METHODCHAR)GetLevel_doc},
|
||||
{"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel,
|
||||
METH_VARARGS, (PY_METHODCHAR)SetLevel_doc},
|
||||
//<----- Deprecated
|
||||
KX_PYMETHODTABLE_NOARGS(SCA_ISensor, reset),
|
||||
{NULL,NULL} //Sentinel
|
||||
};
|
||||
|
||||
PyAttributeDef SCA_ISensor::Attributes[] = {
|
||||
KX_PYATTRIBUTE_BOOL_RW("usePosPulseMode",SCA_ISensor,m_pos_pulsemode),
|
||||
KX_PYATTRIBUTE_BOOL_RW("useNegPulseMode",SCA_ISensor,m_neg_pulsemode),
|
||||
KX_PYATTRIBUTE_INT_RW("frequency",0,100000,true,SCA_ISensor,m_pulse_frequency),
|
||||
KX_PYATTRIBUTE_BOOL_RW("invert",SCA_ISensor,m_invert),
|
||||
KX_PYATTRIBUTE_BOOL_RW("level",SCA_ISensor,m_level),
|
||||
// make these properties read-only in _setaddr, must still implement them in _getattr
|
||||
KX_PYATTRIBUTE_DUMMY("triggered"),
|
||||
KX_PYATTRIBUTE_DUMMY("positive"),
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject*
|
||||
SCA_ISensor::_getattr(const STR_String& attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
if (attr == "triggered")
|
||||
{
|
||||
int retval = 0;
|
||||
if (SCA_PythonController::m_sCurrentController)
|
||||
retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
|
||||
return PyInt_FromLong(retval);
|
||||
}
|
||||
if (attr == "positive")
|
||||
{
|
||||
int retval = IsPositiveTrigger();
|
||||
return PyInt_FromLong(retval);
|
||||
}
|
||||
_getattr_up(SCA_ILogicBrick);
|
||||
}
|
||||
|
||||
int SCA_ISensor::_setattr(const STR_String& attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ILogicBrick::_setattr(attr, value);
|
||||
}
|
||||
/* eof */
|
||||
|
||||
Reference in New Issue
Block a user