remove python2.x support
[blender.git] / source / gameengine / GameLogic / SCA_IObject.cpp
index b3c4708978dc8bff612132bd9b9ef27ebc3828e4..2bffd029bd4d980606b4357d524c1579604b1a9b 100644 (file)
 #endif
 
 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)
+SCA_IObject::SCA_IObject():
+       CValue(),
+       m_initState(0),
+       m_state(0),
+       m_firstState(NULL)
 {
        m_suspended = false;
 }
-       
-
 
 SCA_IObject::~SCA_IObject()
 {
@@ -70,7 +73,7 @@ SCA_IObject::~SCA_IObject()
        }
        for (ita = m_actuators.begin(); !(ita==m_actuators.end()); ++ita)
        {
-               ((CValue*)(*ita))->Release();
+               (*ita)->Delete();
        }
 
        //T_InterpolatorList::iterator i;
@@ -79,29 +82,6 @@ SCA_IObject::~SCA_IObject()
        //}
 }
 
-
-
-SCA_ControllerList& SCA_IObject::GetControllers()
-{
-       return m_controllers;
-}
-
-
-
-SCA_SensorList& SCA_IObject::GetSensors()
-{
-       return m_sensors;
-}
-
-
-
-SCA_ActuatorList& SCA_IObject::GetActuators()
-{
-       return m_actuators;
-}
-
-
-
 void SCA_IObject::AddSensor(SCA_ISensor* act)
 {
        act->AddRef();
@@ -133,7 +113,7 @@ void SCA_IObject::RegisterActuator(SCA_IActuator* act)
 void SCA_IObject::UnregisterActuator(SCA_IActuator* act)
 {
        SCA_ActuatorList::iterator ita;
-       for (ita = m_registeredActuators.begin(); ita != m_registeredActuators.end(); ita++)
+       for (ita = m_registeredActuators.begin(); ita != m_registeredActuators.end(); ++ita)
        {
                if ((*ita) == act) {
                        (*ita) = m_registeredActuators.back();
@@ -143,20 +123,6 @@ void SCA_IObject::UnregisterActuator(SCA_IActuator* act)
        }
 }
 
-void SCA_IObject::SetIgnoreActivityCulling(bool b)
-{
-       m_ignore_activity_culling = b;
-}
-
-
-
-bool SCA_IObject::GetIgnoreActivityCulling()
-{
-       return m_ignore_activity_culling;
-}
-
-
-
 void SCA_IObject::ReParentLogic()
 {
        SCA_ActuatorList& oldactuators  = GetActuators();
@@ -208,7 +174,7 @@ SCA_ISensor* SCA_IObject::FindSensor(const STR_String& sensorname)
 {
        SCA_ISensor* foundsensor = NULL;
 
-       for (SCA_SensorList::iterator its = m_sensors.begin();!(its==m_sensors.end());its++)
+       for (SCA_SensorList::iterator its = m_sensors.begin();!(its==m_sensors.end());++its)
        {
                if ((*its)->GetName() == sensorname)
                {
@@ -225,7 +191,7 @@ SCA_IController* SCA_IObject::FindController(const STR_String& controllername)
 {
        SCA_IController* foundcontroller = NULL;
 
-       for (SCA_ControllerList::iterator itc = m_controllers.begin();!(itc==m_controllers.end());itc++)
+       for (SCA_ControllerList::iterator itc = m_controllers.begin();!(itc==m_controllers.end());++itc)
        {
                if ((*itc)->GetName() == controllername)
                {
@@ -242,7 +208,7 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname)
 {
        SCA_IActuator* foundactuator = NULL;
 
-       for (SCA_ActuatorList::iterator ita = m_actuators.begin();!(ita==m_actuators.end());ita++)
+       for (SCA_ActuatorList::iterator ita = m_actuators.begin();!(ita==m_actuators.end());++ita)
        {
                if ((*ita)->GetName() == actuatorname)
                {
@@ -255,59 +221,6 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname)
 }
 
 
-
-void SCA_IObject::SetCurrentTime(float currentTime) {
-       //T_InterpolatorList::iterator i;
-       //for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
-       //      (*i)->Execute(currentTime);
-       //}
-}
-       
-
-#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) 
@@ -317,7 +230,7 @@ void SCA_IObject::Suspend()
                SCA_SensorList::iterator i = m_sensors.begin();
                while (i != m_sensors.end()) {
                        (*i)->Suspend();
-                       i++;
+                       ++i;
                }
        }
 }
@@ -332,7 +245,7 @@ void SCA_IObject::Resume(void)
                SCA_SensorList::iterator i = m_sensors.begin();
                while (i != m_sensors.end()) {
                        (*i)->Resume();
-                       i++;
+                       ++i;
                }
        }
 }
@@ -352,7 +265,7 @@ void SCA_IObject::SetState(unsigned int state)
        if (tmpstate != m_state)
        {
                // update the status of the controllers
-               for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++)
+               for (contit = m_controllers.begin(); contit != m_controllers.end(); ++contit)
                {
                        (*contit)->ApplyState(tmpstate);
                }
@@ -360,7 +273,7 @@ void SCA_IObject::SetState(unsigned int state)
        m_state = state;
        if (m_state != tmpstate)
        {
-               for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++)
+               for (contit = m_controllers.begin(); contit != m_controllers.end(); ++contit)
                {
                        (*contit)->ApplyState(m_state);
                }
@@ -375,13 +288,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,
@@ -391,23 +298,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},
@@ -417,12 +318,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);
-}