diff options
Diffstat (limited to 'source/gameengine/GameLogic/SCA_IObject.cpp')
-rw-r--r-- | source/gameengine/GameLogic/SCA_IObject.cpp | 116 |
1 files changed, 40 insertions, 76 deletions
diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 9876f2512c0..fbf66b64d08 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -26,6 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ #include <iostream> +#include <algorithm> #include "SCA_IObject.h" #include "SCA_ISensor.h" @@ -41,8 +42,11 @@ MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0); SG_QList SCA_IObject::m_activeBookmarkedControllers; -SCA_IObject::SCA_IObject(PyTypeObject* T): CValue(T), m_initState(0), m_state(0), m_firstState(NULL) - +SCA_IObject::SCA_IObject(): + CValue(), + m_initState(0), + m_state(0), + m_firstState(NULL) { m_suspended = false; } @@ -73,6 +77,12 @@ SCA_IObject::~SCA_IObject() (*ita)->Delete(); } + SCA_ObjectList::iterator ito; + for (ito = m_registeredObjects.begin(); !(ito==m_registeredObjects.end()); ++ito) + { + (*ito)->UnlinkObject(this); + } + //T_InterpolatorList::iterator i; //for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { // delete *i; @@ -120,6 +130,26 @@ void SCA_IObject::UnregisterActuator(SCA_IActuator* act) } } +void SCA_IObject::RegisterObject(SCA_IObject* obj) +{ + // one object may be registered multiple times via constraint target + // store multiple reference, this will serve as registration counter + m_registeredObjects.push_back(obj); +} + +void SCA_IObject::UnregisterObject(SCA_IObject* obj) +{ + SCA_ObjectList::iterator ito; + for (ito = m_registeredObjects.begin(); ito != m_registeredObjects.end(); ++ito) + { + if ((*ito) == obj) { + (*ito) = m_registeredObjects.back(); + m_registeredObjects.pop_back(); + break; + } + } +} + void SCA_IObject::ReParentLogic() { SCA_ActuatorList& oldactuators = GetActuators(); @@ -162,7 +192,7 @@ void SCA_IObject::ReParentLogic() // a new object cannot be client of any actuator m_registeredActuators.clear(); - + m_registeredObjects.clear(); } @@ -218,51 +248,6 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname) } - -#if 0 -const MT_Point3& SCA_IObject::ConvertPythonPylist(PyObject* pylist) -{ - bool error = false; - m_sDummy = MT_Vector3(0,0,0); - if (pylist->ob_type == &CListValue::Type) - { - CListValue* listval = (CListValue*) pylist; - int numelem = listval->GetCount(); - if ( numelem <= 3) - { - int index; - for (index = 0;index<numelem;index++) - { - m_sDummy[index] = listval->GetValue(index)->GetNumber(); - } - } else - { - error = true; - } - - } else - { - - // assert the list is long enough... - int numitems = PyList_Size(pylist); - if (numitems <= 3) - { - int index; - for (index=0;index<numitems;index++) - { - m_sDummy[index] = PyFloat_AsDouble(PyList_GetItem(pylist,index)); - } - } - else - { - error = true; - } - - } - return m_sDummy; -} -#endif - void SCA_IObject::Suspend() { if ((!m_ignore_activity_culling) @@ -330,13 +315,7 @@ void SCA_IObject::SetState(unsigned int state) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_IObject::Type = { -#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 "SCA_IObject", sizeof(PyObjectPlus_Proxy), 0, @@ -346,23 +325,17 @@ PyTypeObject SCA_IObject::Type = { 0, 0, py_base_repr, - 0,0,0,0,0,0, - py_base_getattro, - py_base_setattro, 0,0,0,0,0,0,0,0,0, - Methods -}; - - - -PyParentObject SCA_IObject::Parents[] = { - &SCA_IObject::Type, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, &CValue::Type, - NULL + 0,0,0,0,0,0, + py_base_new }; - - PyMethodDef SCA_IObject::Methods[] = { //{"setOrientation", (PyCFunction) SCA_IObject::sPySetOrientation, METH_VARARGS}, //{"getOrientation", (PyCFunction) SCA_IObject::sPyGetOrientation, METH_VARARGS}, @@ -372,12 +345,3 @@ PyMethodDef SCA_IObject::Methods[] = { PyAttributeDef SCA_IObject::Attributes[] = { { NULL } //Sentinel }; - - -PyObject* SCA_IObject::py_getattro(PyObject *attr) { - py_getattro_up(CValue); -} - -PyObject* SCA_IObject::py_getattro_dict() { - py_getattro_dict_up(CValue); -} |