Merging with trunk up to r38631.
[blender.git] / source / gameengine / Ketsji / KX_Scene.cpp
index 1db174d72be7cb32eeef36d717b96d2aa8b2e3a8..a49c1bf4b4cbd48f918ae500277b73d55d786cff 100644 (file)
  * Ketsji scene. Holds references to all scene data.
  */
 
+/** \file gameengine/Ketsji/KX_Scene.cpp
+ *  \ingroup ketsji
+ */
+
+
 #if defined(WIN32) && !defined(FREE_WINDOWS)
 #pragma warning (disable : 4786)
 #endif //WIN32
@@ -62,7 +67,7 @@
 #include "SCA_IController.h"
 #include "SCA_IActuator.h"
 #include "SG_Node.h"
-#include "SYS_System.h"
+#include "BL_System.h"
 #include "SG_Controller.h"
 #include "SG_IObject.h"
 #include "SG_Tree.h"
@@ -264,10 +269,12 @@ KX_Scene::~KX_Scene()
 
 #ifdef WITH_PYTHON
        PyDict_Clear(m_attr_dict);
-       Py_DECREF(m_attr_dict);
+       /* Py_CLEAR: Py_DECREF's and NULL's */
+       Py_CLEAR(m_attr_dict);
 
-       Py_XDECREF(m_draw_call_pre);
-       Py_XDECREF(m_draw_call_post);
+       /* these may be NULL but the macro checks */
+       Py_CLEAR(m_draw_call_pre);
+       Py_CLEAR(m_draw_call_post);
 #endif
 }
 
@@ -1495,7 +1502,12 @@ void KX_Scene::LogicBeginFrame(double curtime)
        m_logicmgr->BeginFrame(curtime, 1.0/KX_KetsjiEngine::GetTicRate());
 }
 
-
+void KX_Scene::UpdateAnimations(double curtime)
+{
+       // Update any animations
+       for (int i=0; i<GetObjectList()->GetCount(); ++i)
+               ((KX_GameObject*)GetObjectList()->GetValue(i))->UpdateActionManager(curtime);
+}
 
 void KX_Scene::LogicUpdateFrame(double curtime, bool frame)
 {
@@ -1507,7 +1519,7 @@ void KX_Scene::LogicUpdateFrame(double curtime, bool frame)
 void KX_Scene::LogicEndFrame()
 {
        m_logicmgr->EndFrame();
-       int numobj = m_euthanasyobjects->GetCount();
+       int numobj;
 
        KX_GameObject* obj;
 
@@ -1661,6 +1673,11 @@ double KX_Scene::getSuspendedDelta()
        return m_suspendeddelta;
 }
 
+short KX_Scene::GetAnimationFPS()
+{
+       return m_blenderScene->r.frs_sec;
+}
+
 #ifdef USE_BULLET
 #include "KX_BulletPhysicsController.h"
 #endif
@@ -1857,6 +1874,16 @@ bool KX_Scene::MergeScene(KX_Scene *other)
 
                        /* when merging objects sensors are moved across into the new manager, dont need to do this here */
                }
+
+               /* grab any timer properties from the other scene */
+               SCA_TimeEventManager *timemgr=          GetTimeEventManager();
+               SCA_TimeEventManager *timemgr_other=    other->GetTimeEventManager();
+               vector<CValue*> times = timemgr_other->GetTimeValues();
+
+               for(unsigned int i= 0; i < times.size(); i++) {
+                       timemgr->AddTimeProperty(times[i]);
+               }
+               
        }
        return true;
 }
@@ -2119,8 +2146,7 @@ PyObject* KX_Scene::pyattr_get_drawing_callback_pre(void *self_v, const KX_PYATT
 
        if(self->m_draw_call_pre==NULL)
                self->m_draw_call_pre= PyList_New(0);
-       else
-               Py_INCREF(self->m_draw_call_pre);
+       Py_INCREF(self->m_draw_call_pre);
        return self->m_draw_call_pre;
 }
 
@@ -2130,8 +2156,7 @@ PyObject* KX_Scene::pyattr_get_drawing_callback_post(void *self_v, const KX_PYAT
 
        if(self->m_draw_call_post==NULL)
                self->m_draw_call_post= PyList_New(0);
-       else
-               Py_INCREF(self->m_draw_call_post);
+       Py_INCREF(self->m_draw_call_post);
        return self->m_draw_call_post;
 }