Merge of itasc branch. Project files, scons and cmake should be working. Makefile...
[blender.git] / source / gameengine / GameLogic / SCA_IObject.h
index d47353b..64ea0a7 100644 (file)
@@ -36,6 +36,7 @@
 #include "Value.h"
 #include <vector>
 
+class SCA_IObject;
 class SCA_ISensor;
 class SCA_IController;
 class SCA_IActuator;
@@ -45,6 +46,7 @@ template<class T> T PyVecTo(PyObject*);
 typedef std::vector<SCA_ISensor *>       SCA_SensorList;
 typedef std::vector<SCA_IController *>   SCA_ControllerList;
 typedef std::vector<SCA_IActuator *>     SCA_ActuatorList;
+typedef std::vector<SCA_IObject *>              SCA_ObjectList;
 
 class SCA_IObject :    public CValue
 {
@@ -52,10 +54,31 @@ class SCA_IObject : public CValue
        Py_Header;
        
 protected:
+       friend class KX_StateActuator;
+       friend class SCA_IActuator;
+       friend class SCA_IController;
        SCA_SensorList         m_sensors;
        SCA_ControllerList     m_controllers;
        SCA_ActuatorList       m_actuators;
        SCA_ActuatorList       m_registeredActuators;   // actuators that use a pointer to this object
+       SCA_ObjectList             m_registeredObjects;         // objects that hold reference to this object
+
+       // SG_Dlist: element of objects with active actuators
+       //           Head: SCA_LogicManager::m_activeActuators
+       // SG_QList: Head of active actuators list on this object
+       //           Elements: SCA_IActuator
+       SG_QList                           m_activeActuators;
+       // SG_Dlist: element of list os lists with active controllers
+       //           Head: SCA_LogicManager::m_activeControllers
+       // SG_QList: Head of active controller list on this object
+       //           Elements: SCA_IController
+       SG_QList                           m_activeControllers;
+       // SG_Dlist: element of list of lists of active controllers
+       //           Head: SCA_LogicManager::m_activeControllers
+       // SG_QList: Head of active bookmarked controller list globally
+       //           Elements: SCA_IController with bookmark option
+       static SG_QList            m_activeBookmarkedControllers;
+
        static class MT_Point3 m_sDummy;
 
        /**
@@ -78,39 +101,84 @@ protected:
         */
        unsigned int                    m_state;
 
+       /**
+        * pointer inside state actuator list for sorting
+        */
+       SG_QList*                               m_firstState;
+
 public:
        
-       SCA_IObject(PyTypeObject* T=&Type);
+       SCA_IObject();
        virtual ~SCA_IObject();
 
-       SCA_ControllerList& GetControllers();
-       SCA_SensorList& GetSensors();
-       SCA_ActuatorList& GetActuators();
+       SCA_ControllerList& GetControllers()
+       {
+               return m_controllers;
+       }
+       SCA_SensorList& GetSensors()
+       {
+               return m_sensors;
+       }
+       SCA_ActuatorList& GetActuators()
+       {
+               return m_actuators;
+       }
+       SG_QList& GetActiveActuators()
+       {
+               return m_activeActuators;
+       }
 
        void AddSensor(SCA_ISensor* act);
+       void ReserveSensor(int num)
+       {
+               m_sensors.reserve(num);
+       }
        void AddController(SCA_IController* act);
+       void ReserveController(int num)
+       {
+               m_controllers.reserve(num);
+       }
        void AddActuator(SCA_IActuator* act);
+       void ReserveActuator(int num)
+       {
+               m_actuators.reserve(num);
+       }
        void RegisterActuator(SCA_IActuator* act);
        void UnregisterActuator(SCA_IActuator* act);
        
+       void RegisterObject(SCA_IObject* objs);
+       void UnregisterObject(SCA_IObject* objs);
+       /**
+        * UnlinkObject(...)
+        * this object is informed that one of the object to which it holds a reference is deleted
+        * returns true if there was indeed a reference.
+        */
+       virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; }
+
        SCA_ISensor* FindSensor(const STR_String& sensorname);
        SCA_IActuator* FindActuator(const STR_String& actuatorname);
        SCA_IController* FindController(const STR_String& controllername);
 
-       void SetCurrentTime(float currentTime);
+       void SetCurrentTime(float currentTime) {}
 
-       void ReParentLogic();
+       virtual void ReParentLogic();
        
        /**
         * Set whether or not to ignore activity culling requests
         */
-       void SetIgnoreActivityCulling(bool b);
+       void SetIgnoreActivityCulling(bool b)
+       {
+               m_ignore_activity_culling = b;
+       }
 
        /**
         * Set whether or not this object wants to ignore activity culling
         * requests
         */
-       bool GetIgnoreActivityCulling();
+       bool GetIgnoreActivityCulling()
+       {
+               return m_ignore_activity_culling;
+       }
 
        /**
         * Suspend all progress.
@@ -143,14 +211,12 @@ public:
        unsigned int GetState(void)     { return m_state; }
 
 //     const class MT_Point3&  ConvertPythonPylist(PyObject* pylist);
-       
-       // here come the python forwarded methods
-       virtual PyObject* _getattr(const char *attr);
 
        virtual int GetGameObjectType() {return -1;}
        
        typedef enum ObjectTypes {
                OBJ_ARMATURE=0,
+               OBJ_CAMERA=1,
        }ObjectTypes;
 
 };