Switch fixed time system. Logic updates should now happen at 30Hz, physics at 60Hz...
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sat, 16 Oct 2004 11:41:50 +0000 (11:41 +0000)
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sat, 16 Oct 2004 11:41:50 +0000 (11:41 +0000)
Keyboard sensors can now hook escape key.  Ctrl-Break can be used from within blender if you've forgotten an end game actuator.

Fixed a stupid bug preventing some actuators working (like TrackTo).

88 files changed:
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ActionActuator.h
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
source/gameengine/GameLogic/SCA_AlwaysEventManager.h
source/gameengine/GameLogic/SCA_EventManager.cpp
source/gameengine/GameLogic/SCA_EventManager.h
source/gameengine/GameLogic/SCA_IActuator.cpp
source/gameengine/GameLogic/SCA_IActuator.h
source/gameengine/GameLogic/SCA_IInputDevice.cpp
source/gameengine/GameLogic/SCA_IInputDevice.h
source/gameengine/GameLogic/SCA_KeyboardManager.cpp
source/gameengine/GameLogic/SCA_KeyboardManager.h
source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
source/gameengine/GameLogic/SCA_LogicManager.cpp
source/gameengine/GameLogic/SCA_LogicManager.h
source/gameengine/GameLogic/SCA_MouseManager.cpp
source/gameengine/GameLogic/SCA_MouseManager.h
source/gameengine/GameLogic/SCA_PropertyActuator.cpp
source/gameengine/GameLogic/SCA_PropertyActuator.h
source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
source/gameengine/GameLogic/SCA_PropertyEventManager.h
source/gameengine/GameLogic/SCA_RandomActuator.cpp
source/gameengine/GameLogic/SCA_RandomActuator.h
source/gameengine/GameLogic/SCA_RandomEventManager.cpp
source/gameengine/GameLogic/SCA_RandomEventManager.h
source/gameengine/GameLogic/SCA_TimeEventManager.cpp
source/gameengine/GameLogic/SCA_TimeEventManager.h
source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
source/gameengine/Ketsji/KX_CDActuator.cpp
source/gameengine/Ketsji/KX_CDActuator.h
source/gameengine/Ketsji/KX_CameraActuator.cpp
source/gameengine/Ketsji/KX_CameraActuator.h
source/gameengine/Ketsji/KX_ConstraintActuator.cpp
source/gameengine/Ketsji/KX_ConstraintActuator.h
source/gameengine/Ketsji/KX_GameActuator.cpp
source/gameengine/Ketsji/KX_GameActuator.h
source/gameengine/Ketsji/KX_IpoActuator.cpp
source/gameengine/Ketsji/KX_IpoActuator.h
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.h
source/gameengine/Ketsji/KX_ObjectActuator.cpp
source/gameengine/Ketsji/KX_ObjectActuator.h
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_RayEventManager.cpp
source/gameengine/Ketsji/KX_RayEventManager.h
source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_Scene.h
source/gameengine/Ketsji/KX_SceneActuator.cpp
source/gameengine/Ketsji/KX_SceneActuator.h
source/gameengine/Ketsji/KX_SoundActuator.cpp
source/gameengine/Ketsji/KX_SoundActuator.h
source/gameengine/Ketsji/KX_TouchEventManager.cpp
source/gameengine/Ketsji/KX_TouchEventManager.h
source/gameengine/Ketsji/KX_TrackToActuator.cpp
source/gameengine/Ketsji/KX_TrackToActuator.h
source/gameengine/Ketsji/KX_VisibilityActuator.cpp
source/gameengine/Ketsji/KX_VisibilityActuator.h
source/gameengine/Network/NG_NetworkScene.cpp
source/gameengine/Network/NG_NetworkScene.h
source/gameengine/Physics/BlOde/OdePhysicsController.cpp
source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
source/gameengine/PyDoc/GameLogic.py
source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
source/gameengine/PyDoc/SCA_ILogicBrick.py
source/gameengine/PyDoc/WhatsNew.py
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
source/gameengine/SceneGraph/SG_Spatial.cpp

index 6f609b01d2f6b851c98800eb1521c0ca67657655..f0eb36107e8159e0e5b072f831534c540639a38f 100644 (file)
@@ -35,6 +35,8 @@
 #include <config.h>
 #endif
 
+#include <signal.h>
+
 #ifdef WIN32
 // don't show stl-warnings
 #pragma warning (disable:4786)
@@ -100,7 +102,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
        BlendFileData *bfd= NULL;
        
        bgl::InitExtensions(1);
-
+       
        do
        {
                View3D *v3d= (View3D*) area->spacedata.first;
@@ -221,6 +223,26 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
                        }
                }
                
+               Scene *blscene = NULL;
+               if (!bfd)
+               {
+                       blscene = (Scene*) maggie->scene.first;
+                       for (Scene *sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
+                       {
+                               if (startscenename == (sce->id.name+2))
+                               {
+                                       blscene = sce;
+                                       break;
+                               }
+                       }
+               } else {
+                       blscene = bfd->curscene;
+               }
+
+               // Quad buffered needs a special window.
+               if (blscene->r.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
+                       rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->r.stereomode);
+               
                if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
                {
                        if (v3d->persp != 2)
index b128d616209fad54f6b2753cb0972a14a9065cb9..c6ae91ae282145a7df9236059610029d85ac0116 100644 (file)
@@ -41,6 +41,7 @@
 #include "KX_BlenderKeyboardDevice.h"
 
 KX_BlenderKeyboardDevice::KX_BlenderKeyboardDevice()
+       : m_hookesc(false)
 {
 
 }
@@ -108,7 +109,9 @@ bool        KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode,short v
 
                if (val > 0)
                {
-                       if (kxevent == SCA_IInputDevice::KX_ESCKEY && val != 0)
+                       if (kxevent == KX_ESCKEY && val != 0 && !m_hookesc)
+                               result = true;
+                       if (kxevent == KX_PAUSEKEY && val && (IsPressed(KX_LEFTCTRLKEY) || IsPressed(KX_RIGHTCTRLKEY)))
                                result = true;
 
                        // todo: convert val ??
@@ -162,3 +165,8 @@ bool        KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode,short v
        }
        return result;
 }
+
+void KX_BlenderKeyboardDevice::HookEscape()
+{
+       m_hookesc = true;
+}
index 33809f039faab92840d6fd75e59920bd763a3702..932751c37eb39edadd279575f760758573a059ff 100644 (file)
@@ -36,6 +36,7 @@
 
 class KX_BlenderKeyboardDevice : public BL_BlenderInputDevice
 {
+       bool    m_hookesc;
 public:
        KX_BlenderKeyboardDevice();
        virtual ~KX_BlenderKeyboardDevice();
@@ -44,6 +45,7 @@ public:
 //     virtual const SCA_InputEvent&   GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode);
        virtual bool    ConvertBlenderEvent(unsigned short incode,short val);
        virtual void    NextFrame();
+       virtual void    HookEscape();
 };
 
 #endif //__KX_BLENDERKEYBOARDDEVICE
index 52b948b18f1ecba8e2f09ee9665a8111adc77fb3..5206f33ccd7ba97e1e9b87546655a2e9cbbe9de0 100644 (file)
@@ -30,6 +30,8 @@
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
 */
 
+#include <cmath>
+
 #include "SCA_LogicManager.h"
 #include "BL_ActionActuator.h"
 #include "BL_ArmatureObject.h"
@@ -95,7 +97,7 @@ CValue* BL_ActionActuator::GetReplica() {
        return replica;
 };
 
-bool BL_ActionActuator::Update(double curtime,double deltatime)
+bool BL_ActionActuator::Update(double curtime, bool frame)
 {
        bool bNegativeEvent = false;
        bool bPositiveEvent = false;
@@ -149,6 +151,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
                                m_flag &= ~ACT_FLAG_REVERSE;
                                m_flag |= ACT_FLAG_LOCKINPUT;
                                m_localtime = m_starttime;
+                               m_startWallTime = curtime;
                        }
                }
                if (bNegativeEvent){
@@ -181,6 +184,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
                        if (!(m_flag & ACT_FLAG_LOCKINPUT)){
                                m_flag &= ~ACT_FLAG_REVERSE;
                                m_localtime = m_starttime;
+                               m_startWallTime = curtime;
                                m_flag |= ACT_FLAG_LOCKINPUT;
                        }
                }
@@ -204,31 +208,19 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
                }
                else{
                        if (m_flag & ACT_FLAG_REVERSE)
-                               m_localtime -= deltatime* KX_FIXED_FRAME_PER_SEC;
+                               m_localtime = m_endtime - (curtime - m_startWallTime) * KX_FIXED_FRAME_PER_SEC;
                        else
-                               m_localtime += deltatime* KX_FIXED_FRAME_PER_SEC;
+                               m_localtime = m_starttime + (curtime - m_startWallTime) * KX_FIXED_FRAME_PER_SEC;
                }
        }
        
        /* Check if a wrapping response is needed */
        if (length){
-               if (m_flag & ACT_FLAG_REVERSE){
-                       if (m_localtime < m_starttime){
-                               m_localtime = m_endtime+(
-                                       (int)((m_localtime - m_starttime)/length)
-                                       *(int)length);
-                               wrap = true;
-                       }                       
-               }
-               else{
-                       if (m_localtime > m_endtime){
-                               m_localtime = m_starttime+(
-                                       (int)((m_localtime - m_endtime)/length)
-                                       *(int)length);
-                               wrap = true;
-                       }
+               if (m_localtime < m_starttime || m_localtime > m_endtime)
+               {
+                       m_localtime = m_starttime + std::fmod(m_localtime, length);
+                       wrap = true;
                }
-               
        }
        else
                m_localtime = m_starttime;
@@ -238,9 +230,8 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
        case ACT_ACTION_FROM_PROP:
                {
                        CValue* propval = GetParent()->GetProperty(m_propname);
-                       if (propval)             {
+                       if (propval)
                                m_localtime = propval->GetNumber();
-                       };
                        
                        if (bNegativeEvent){
                                keepgoing=false;
@@ -285,11 +276,8 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
        }
        
        
-       if (bNegativeEvent){
+       if (bNegativeEvent)
                m_blendframe=0.0;
-               
-       }
-       
        
        /* Apply the pose if necessary*/
        if (apply){
@@ -316,6 +304,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
                                /* If this is the start of a blending sequence... */
                                if ((m_blendframe==0.0) || (!m_blendpose)){
                                        obj->GetMRDPose(&m_blendpose);
+                                       m_blendstart = curtime;
                                }
                                
                                /* Find percentages */
@@ -323,7 +312,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
                                blend_poses(m_pose, m_blendpose, 1.0 - newweight, POSE_BLEND);
 
                                /* Increment current blending percentage */
-                               m_blendframe+=(deltatime*KX_FIXED_FRAME_PER_SEC);
+                               m_blendframe = (curtime - m_blendstart)*KX_FIXED_FRAME_PER_SEC;
                                if (m_blendframe>m_blendin)
                                        m_blendframe = m_blendin;
                                
index ca1f937cbd42c0989d35e4fc23cd486597825cef..bf030b5861fe30d2e7f4ddd9096b484455ebc452 100644 (file)
@@ -71,7 +71,7 @@ public:
        {
        };
        virtual ~BL_ActionActuator();
-       virtual bool Update(double curtime,double deltatime);
+       virtual bool Update(double curtime, bool frame);
        CValue* GetReplica();
        void ProcessReplica();
 
@@ -113,11 +113,13 @@ protected:
        MT_Point3       m_lastpos;
        int             m_flag;
        float   m_starttime;
+       float   m_startWallTime;
        float   m_endtime;
        float   m_localtime;
        float   m_lastUpdate;
        short   m_playtype;
        float   m_blendin;
+       float   m_blendstart;
        short   m_priority;
        float   m_stridelength;
        struct bPose* m_pose;
index ec9a70fccb1c8557a3c90d5c001c8f4a6fb5514f..aa57e883f71c283bee5ecbe24e6776e937888cd1 100644 (file)
@@ -486,13 +486,7 @@ void BL_ConvertActuators(char* maggiename,
                                - let the object-with-property report itself to the act when converted
                                */
                                if (propact->ob)
-                               {
-                                       KX_GameObject* tempObj = converter->FindGameObject(propact->ob);
-                                       if (tempObj)
-                                       {
-                                               destinationObj = tempObj;
-                                       }
-                               } 
+                                       destinationObj = converter->FindGameObject(propact->ob);
                                
                                SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
                                        gameobj,
@@ -550,7 +544,7 @@ void BL_ConvertActuators(char* maggiename,
                                        {
                                                RAS_MeshObject *tmpmesh = NULL;
                                                if (editobact->me)
-                                                       RAS_MeshObject *tmpmesh = BL_ConvertMesh(
+                                                       tmpmesh = BL_ConvertMesh(
                                                                editobact->me,
                                                                blenderobject,
                                                                rendertools,
@@ -572,7 +566,7 @@ void BL_ConvertActuators(char* maggiename,
                                        {
                                                SCA_IObject* originalval = NULL;
                                                if (editobact->ob)
-                                                       SCA_IObject* originalval = converter->FindGameObject(editobact->ob);
+                                                       originalval = converter->FindGameObject(editobact->ob);
                                                        
                                                KX_TrackToActuator* tmptrackact 
                                                        = new KX_TrackToActuator(gameobj, 
index 18423c4171ff4c8eecef12eef885771e15bfb432..c4b5b8197a7492dd8923d9b5b37430aad6093bdb 100644 (file)
@@ -52,7 +52,7 @@ SCA_AlwaysEventManager::SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr)
 
 
 
-void SCA_AlwaysEventManager::NextFrame(double curtime,double deltatime)
+void SCA_AlwaysEventManager::NextFrame()
 {
        for (vector<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
        {
index 6ac00515a0ec018f1714812883f148e3c5382a06..bffd21da74c60f5b8e6bf4e54760a92b11fc1059 100644 (file)
@@ -41,7 +41,7 @@ class SCA_AlwaysEventManager : public SCA_EventManager
        class SCA_LogicManager* m_logicmgr;
 public:
        SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr);
-       virtual void NextFrame(double curtime,double deltatime);
+       virtual void NextFrame();
        virtual void    RegisterSensor(SCA_ISensor* sensor);
 
 
index 468d9a8c3815426df56c56062bd73b1792ba0b34..cf4af636290d0823169a4d2e9653bd93515fe545 100644 (file)
@@ -35,6 +35,7 @@
 #include <config.h>
 #endif
 
+
 SCA_EventManager::SCA_EventManager(EVENT_MANAGER_TYPE mgrtype)
        :m_mgrtype(mgrtype)
 {
@@ -59,6 +60,15 @@ void SCA_EventManager::RemoveSensor(class SCA_ISensor* sensor)
        }
 }
 
+void SCA_EventManager::NextFrame(double curtime, double fixedtime)
+{
+       NextFrame();
+}
+
+void SCA_EventManager::NextFrame()
+{
+       assert(false && "Event managers should override a NextFrame method");
+}
 
 void SCA_EventManager::EndFrame()
 {
index 67908b9d5c7bd18e6c179ae39b1c58da23d495d0..92bda9df17092970542c4f3c36666c47f5d82863 100644 (file)
@@ -58,7 +58,8 @@ public:
        virtual ~SCA_EventManager();
        
        virtual void    RemoveSensor(class SCA_ISensor* sensor);
-       virtual void    NextFrame(double curtime,double deltatime)=0;
+       virtual void    NextFrame(double curtime, double fixedtime);
+       virtual void    NextFrame();
        virtual void    EndFrame();
        virtual void    RegisterSensor(class SCA_ISensor* sensor)=0;
        int             GetType();
index 31e6d3fdb10be43dfc9b919fb1221e7a0bf3d73c..322936c781981e9effc3eed740c14a7dfa7dd69e 100644 (file)
@@ -64,11 +64,6 @@ void SCA_IActuator::RemoveAllEvents()
 
 
 
-bool SCA_IActuator::Update(double curtime,double deltatime)
-{
-       return true;
-}
-
 
 
 bool SCA_IActuator::IsNegativeEvent() const
@@ -91,7 +86,19 @@ bool SCA_IActuator::IsNegativeEvent() const
        return !bPositiveEvent && bNegativeEvent;
 }
 
+bool SCA_IActuator::Update(double curtime, bool frame)
+{
+       if (frame)
+               return Update();
+       
+       return true;
+}
 
+bool SCA_IActuator::Update()
+{
+       assert(false && "Actuators should override an Update method.");
+       return false;
+}
 
 void SCA_IActuator::ProcessReplica()
 {
index 6b3d10070795d4066afb731e9eb648960c6592c7..e58ac74dacfd5cdc9ac1606992159c5e486f080c 100644 (file)
@@ -60,8 +60,8 @@ public:
         */
 
 
-       virtual bool Update(double curtime,
-                                               double deltatime);
+       virtual bool Update(double curtime, bool frame);
+       virtual bool Update();
 
        /** 
         * Add an event to an actuator.
index d73549b8818c152881b1602cfdcfd2b2fedb84c3..87d161ecabc196503302e039f0b0ccc83c39e7d4 100644 (file)
@@ -50,7 +50,10 @@ SCA_IInputDevice::~SCA_IInputDevice()
 {
 }      
 
-
+void SCA_IInputDevice::HookEscape()
+{
+       assert(false && "This device does not support hooking escape.");
+}
 
 void SCA_IInputDevice::ClearStatusTable(int tableid)
 {
index b2ed8686b43b0743ac0297ad2f00095a1899a88b..6dee608a56869c4d044108c41761a11846d924af 100644 (file)
@@ -291,6 +291,8 @@ public:
         */
        virtual int             GetNumJustEvents();
        
+       virtual void            HookEscape();
+       
        /* Next frame: we calculate the new key states. This goes as follows:
        *
        * KX_NO_INPUTSTATUS -> KX_NO_INPUTSTATUS
index 039f0c148010a9f88b6683422265260d228594a1..cd7e07a7e8182ca82c7199695289a9de561f413a 100644 (file)
@@ -66,7 +66,7 @@ SCA_IInputDevice* SCA_KeyboardManager::GetInputDevice()
 
 
 
-void SCA_KeyboardManager::NextFrame(double curtime,double deltatime)
+void SCA_KeyboardManager::NextFrame()
 {
        //const SCA_InputEvent& event = GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
   //   cerr << "SCA_KeyboardManager::NextFrame"<< endl;
index fcdb8ed5c4ef8cb9b8dadc887568f8998a834241..562f28417ad62c1e784746ff879d9315e1cb1efa 100644 (file)
@@ -56,9 +56,8 @@ public:
        virtual ~SCA_KeyboardManager();
 
        bool                    IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
-
        
-       virtual void    NextFrame(double curtime,double deltatime);     
+       virtual void    NextFrame();    
        virtual void    RegisterSensor(class SCA_ISensor* sensor);
        SCA_IInputDevice* GetInputDevice();
 };
index 1eee83ad3d61e180b385d5a56cbac833260d9aad..fb8c340b09e813904972184afbd6a63bd4fa964d 100644 (file)
@@ -62,7 +62,8 @@ SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr,
         m_targetprop(targetProp),
         m_toggleprop(toggleProp)
 {
-       
+       if (hotkey == SCA_IInputDevice::KX_ESCKEY)
+               keybdmgr->GetInputDevice()->HookEscape();
 //     SetDrawColor(0xff0000ff);
        m_val=0;
 }
index 62b532ee5a0dc62b0adf5149a81207052abce8ac..0829fb0657b907c7d3f5c16e4eb24483481fe3cf 100644 (file)
@@ -42,6 +42,7 @@
 #include <config.h>
 #endif
 
+
 SCA_LogicManager::SCA_LogicManager()
 {
 }
@@ -175,13 +176,10 @@ void SCA_LogicManager::RegisterToActuator(SCA_IController* controller,SCA_IActua
 
 
 
-void SCA_LogicManager::BeginFrame(double curtime,double deltatime)
+void SCA_LogicManager::BeginFrame(double curtime, double fixedtime)
 {
-       for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin();
-       !(ie==m_eventmanagers.end());ie++)
-       {
-               (*ie)->NextFrame(curtime,deltatime);
-       }
+       for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++)
+               (*ie)->NextFrame(curtime, fixedtime);
 
        // for this frame, look up for activated sensors, and build the collection of triggered controllers
        int numsensors = this->m_activatedsensors.size();
@@ -214,11 +212,10 @@ void SCA_LogicManager::BeginFrame(double curtime,double deltatime)
 
 
 
-void SCA_LogicManager::UpdateFrame(double curtime,double deltatime)
+void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
 {
        vector<SmartActuatorPtr>::iterator ra;
-       for (ra = m_removedActuators.begin();
-       !(ra == m_removedActuators.end());ra++)
+       for (ra = m_removedActuators.begin(); !(ra == m_removedActuators.end()); ra++)
        {
                m_activeActuators.erase(*ra);
                (*ra)->SetActive(false);
@@ -228,7 +225,7 @@ void SCA_LogicManager::UpdateFrame(double curtime,double deltatime)
        for (set<SmartActuatorPtr>::iterator ia = m_activeActuators.begin();!(ia==m_activeActuators.end());ia++)
        {
                //SCA_IActuator* actua = *ia;
-               if (!(*ia)->Update(curtime,deltatime))
+               if (!(*ia)->Update(curtime, frame))
                {
                        //*ia = m_activeactuators.back();
                        m_removedActuators.push_back(*ia);
@@ -238,8 +235,7 @@ void SCA_LogicManager::UpdateFrame(double curtime,double deltatime)
                }
        }
        
-       for ( ra = m_removedActuators.begin();
-       !(ra == m_removedActuators.end());ra++)
+       for ( ra = m_removedActuators.begin(); !(ra == m_removedActuators.end()); ra++)
        {
                m_activeActuators.erase(*ra);
                (*ra)->SetActive(false);
index 4447104a0a26d3f5f97ecb167c0d65a1f5f4f92c..7af1190f03b4f924bad4ae4305e782326d4e574a 100644 (file)
@@ -123,8 +123,8 @@ public:
        void    RegisterToActuator(SCA_IController* controller,
                                                           class SCA_IActuator* actuator);
        
-       void    BeginFrame(double curtime,double deltatime);
-       void    UpdateFrame(double curtime,double deltatime);
+       void    BeginFrame(double curtime, double fixedtime);
+       void    UpdateFrame(double curtime, bool frame);
        void    EndFrame();
        void    AddActivatedSensor(SCA_ISensor* sensor);
        void    AddActiveActuator(SCA_IActuator* sensor,class CValue* event);
index 96abe2c9135db4bde568d1d744c3c927a8128655..e4d54c943951b928def85eca6cedecebbccd32aa 100644 (file)
@@ -74,7 +74,7 @@ SCA_IInputDevice* SCA_MouseManager::GetInputDevice()
 
 
 
-void SCA_MouseManager::NextFrame(double curtime,double deltatime)
+void SCA_MouseManager::NextFrame()
 {
        if (m_mousedevice)
        {
index 4c8fe102bfe62aaad1240c5405eeb98b7403d401..e98405b1b7da5a8279f1f29a753f4f4db09ed4d1 100644 (file)
@@ -64,7 +64,7 @@ public:
         * mouse related evenst. Can also flag mouse movement.
         */
        bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
-       virtual void    NextFrame(double curtime,double deltatime);     
+       virtual void    NextFrame();    
        virtual void    RegisterSensor(class SCA_ISensor* sensor);
        SCA_IInputDevice* GetInputDevice();
 };
index c416d8e1dd5560d0a02dc7a205d6286980ed63fa..a39e59fe451481207c810a1fb8e360c6a2fec60b 100644 (file)
@@ -58,7 +58,7 @@ SCA_PropertyActuator::~SCA_PropertyActuator()
 {
 }
 
-bool SCA_PropertyActuator::Update(double curtime,double deltatime)
+bool SCA_PropertyActuator::Update()
 {
        bool result = false;
 
index 2fdf1a62559680885b0afd6cf2d5e3faaa38653f..cdcda7a84e0644b2885308753de129f0b8841808 100644 (file)
@@ -62,41 +62,23 @@ public:
 
 
        SCA_PropertyActuator(
-
                SCA_IObject* gameobj,
-
                CValue* sourceObj,
-
                const STR_String& propname,
-
                const STR_String& expr,
-
                int acttype,
-
                PyTypeObject* T=&Type
-
        );
 
 
        ~SCA_PropertyActuator();
 
-
                CValue* 
-
        GetReplica(
-
        );
 
-
-               bool 
-
-       Update(
-
-               double curtime,
-
-               double deltatime
-
-       );
+       virtual bool 
+       Update();
 
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
index 4b81b0e41242142dc1faec0e2a05c5ac442a182e..4ac3d16222929ab183f556b63218f47a82fae734 100644 (file)
@@ -59,7 +59,7 @@ void SCA_PropertyEventManager::RegisterSensor(SCA_ISensor* sensor)
 
 
 
-void SCA_PropertyEventManager::NextFrame(double curtime,double deltatime)
+void SCA_PropertyEventManager::NextFrame()
 {
        // check for changed properties
        for (vector<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
index dccaa6b52fed1de6acfa09eaa9aa832b3476da4a..664beb68695d8dc506a13bfe26c784f32292926c 100644 (file)
@@ -45,7 +45,7 @@ class SCA_PropertyEventManager : public SCA_EventManager
 public:
        SCA_PropertyEventManager(class SCA_LogicManager* logicmgr);
        virtual ~SCA_PropertyEventManager();
-       virtual void NextFrame(double curtime,double deltatime);
+       virtual void NextFrame();
        virtual void    RegisterSensor(SCA_ISensor* sensor);
        //SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
 };
index b4a28291e669a9f802998f87631c9f199ea04f3e..da6fe06a70855b461e9386fe5f7cd5a7fd2d2a12 100644 (file)
@@ -86,7 +86,7 @@ CValue* SCA_RandomActuator::GetReplica()
 
 
 
-bool SCA_RandomActuator::Update(double curtime,double deltatime)
+bool SCA_RandomActuator::Update()
 {
        bool result = false;    
        bool bNegativeEvent = IsNegativeEvent();
index 1048790c9b6e11f0d21ca81416d1f01b0f0d847b..4be7f2dbe9ead36a204b03c8fa933a687bbf0454 100644 (file)
@@ -91,7 +91,7 @@ class SCA_RandomActuator : public SCA_IActuator
                                          const STR_String &propName,
                                          PyTypeObject* T=&Type);
        virtual ~SCA_RandomActuator();
-       virtual bool Update(double curtime,double deltatime);
+       virtual bool Update();
        
        virtual CValue* GetReplica();
        
index 17cfa351994f64fc3506ef2c0397fb2be12aace8..6bf10a83f550cac96237d938d5e6986339143a7f 100644 (file)
@@ -51,7 +51,7 @@ SCA_RandomEventManager::SCA_RandomEventManager(class SCA_LogicManager* logicmgr)
 }
 
 
-void SCA_RandomEventManager::NextFrame(double curtime,double deltatime)
+void SCA_RandomEventManager::NextFrame()
 {
        for (vector<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
        {
index f0832044042339766da0250c34b69a5ed6120655..17b2894434dfb9796ad25f77ceaee5a3941df672 100644 (file)
@@ -47,7 +47,7 @@ class SCA_RandomEventManager : public SCA_EventManager
 public:
        SCA_RandomEventManager(class SCA_LogicManager* logicmgr);
 
-       virtual void NextFrame(double curtime,double deltatime);
+       virtual void NextFrame();
        virtual void    RegisterSensor(SCA_ISensor* sensor);
 };
 
index 05d1bebf18ae4a5ed6c7942b0dba41ef54a68f8a..d97727d2a3314d7131e48296df2a0714799f5fba 100644 (file)
@@ -70,9 +70,9 @@ void SCA_TimeEventManager::RegisterSensor(SCA_ISensor* sensor)
 
 
 
-void SCA_TimeEventManager::NextFrame(double curtime,double deltatime)
+void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime)
 {
-       if (m_timevalues.size() > 0)
+       if (m_timevalues.size() > 0 && fixedtime > 0.0)
        {
                CFloatValue* floatval = new CFloatValue(curtime);
                
@@ -80,7 +80,7 @@ void SCA_TimeEventManager::NextFrame(double curtime,double deltatime)
                for (vector<CValue*>::iterator it = m_timevalues.begin();
                !(it == m_timevalues.end()); it++)
                {
-                       float newtime = (*it)->GetNumber() + deltatime;
+                       float newtime = (*it)->GetNumber() + fixedtime;
                        floatval->SetFloat(newtime);
                        (*it)->SetValue(floatval);
                }
index fb2f1cee97033ff0888af74a63384a25f1b5a264..388d9ce53bdbf6ee6817bdbe7131683530441c63 100644 (file)
@@ -46,7 +46,7 @@ public:
        SCA_TimeEventManager(class SCA_LogicManager* logicmgr);
        virtual ~SCA_TimeEventManager();
 
-       virtual void    NextFrame(double curtime,double deltatime);
+       virtual void    NextFrame(double curtime, double fixedtime);
        virtual void    RegisterSensor(class SCA_ISensor* sensor);
        void                    AddTimeProperty(CValue* timeval);
        void                    RemoveTimeProperty(CValue* timeval);
index 71e20bfe35d20aa1298103e63a946cc365901847..6b6f619f820a5be47853c06441a241fd081db713 100644 (file)
@@ -81,7 +81,7 @@ bool GPC_KeyboardDevice::ConvertEvent(int incode, int val)
 
                if (val > 0)
                {
-                       if (kxevent == SCA_IInputDevice::KX_ESCKEY && val != 0)
+                       if (kxevent == SCA_IInputDevice::KX_ESCKEY && val != 0 && !m_hookesc)
                                result = true;
 
                        // todo: convert val ??
@@ -125,3 +125,8 @@ bool GPC_KeyboardDevice::ConvertEvent(int incode, int val)
        }       
        return result;
 }
+
+void GPC_KeyboardDevice::HookEscape()
+{
+       m_hookesc = true;
+}
index 678200b62d9065b924f0dfaf790a6a5a58f02bbc..da3dc2398dd1c406cb67a1a3e4518ce66e51632d 100644 (file)
@@ -58,9 +58,11 @@ protected:
         * System dependent keyboard codes are stored as ints.
         */
        std::map<int, KX_EnumInputs> m_reverseKeyTranslateTable;
+       bool m_hookesc;
 
 public:
        GPC_KeyboardDevice()
+               : m_hookesc(false)
        {
        }
 
@@ -81,6 +83,8 @@ public:
        }
 
        virtual bool ConvertEvent(int incode, int val);
+       
+       virtual void HookEscape();
 };
 
 #endif  // _GPC_KEYBOARDDEVICE_H
index ad2f786a3281625ae5e0e43cfc1a61874b5f0a60..93c7ab37edbe1d1ba2d00c33553e6ab6b926689d 100644 (file)
@@ -73,7 +73,7 @@ void KX_NetworkEventManager::RemoveSensor(class SCA_ISensor* sensor)
        SCA_EventManager::RemoveSensor(sensor);
 }
 
-void KX_NetworkEventManager::NextFrame(double curtime, double deltatime)
+void KX_NetworkEventManager::NextFrame()
 {
 // printf("KX_NetworkEventManager::proceed %.2f - %.2f\n", curtime, deltatime);
        // each frame, the logicmanager will call the network
index 75715f5569cae013ef2ad10c2ed0bc2478fe4e19..9c0d14674c145e93cde8e5637e0a529b7203fd9d 100644 (file)
@@ -48,7 +48,7 @@ public:
        virtual void RegisterSensor(class SCA_ISensor* sensor);
        virtual void RemoveSensor(class SCA_ISensor* sensor);
 
-       virtual void NextFrame(double curtime, double deltatime);
+       virtual void NextFrame();
        virtual void EndFrame();
 
        SCA_LogicManager* GetLogicManager() { return m_logicmgr; }
index 23bc35fdeacb5a68a7989fe5973729f505032e82..e142d2a1a1bdbb4b52f606cf61d2b154ffef6bcc 100644 (file)
@@ -60,7 +60,7 @@ KX_NetworkMessageActuator::~KX_NetworkMessageActuator()
 }
 
 // returns true if the actuators needs to be running over several frames
-bool KX_NetworkMessageActuator::Update(double curtime, double deltatime)
+bool KX_NetworkMessageActuator::Update()
 {
        //printf("update messageactuator\n");
        bool bNegativeEvent = IsNegativeEvent();
index cec3b27c4a6b6a195de2f948af93d1ddbc62e2d2..c81437dbd915bf8f80e77961e61db7523eb26cff 100644 (file)
@@ -57,7 +57,7 @@ public:
                PyTypeObject* T=&Type);
        virtual ~KX_NetworkMessageActuator();
 
-       virtual bool Update(double curtime, double deltatime);
+       virtual bool Update();
        virtual CValue* GetReplica();
 
        /* ------------------------------------------------------------ */
index efa7fb73ba54f5c772c382ca819f8424066653b3..b4a7763763ac4c199760316c338419f0f3910a0d 100644 (file)
@@ -85,7 +85,7 @@ CValue* KX_CDActuator::GetReplica()
 
 
 
-bool KX_CDActuator::Update(double curtime,double deltatime)
+bool KX_CDActuator::Update()
 {
        bool result = false;
        bool bNegativeEvent = IsNegativeEvent();
index 3e76db56264534454e29be8dd25c15e9389963c5..db6dc1e34758ee9167f599ff9f836641699ee426 100644 (file)
@@ -76,7 +76,7 @@ public:
 
        ~KX_CDActuator();
 
-       bool Update(double curtime,double deltatime);
+       virtual bool Update();
 
        CValue* GetReplica();
 
index 478bf388fb123ed945fb6032957f9aabe854f182..f96276c37f145d14454e6e901f4f270ceaf66179 100644 (file)
@@ -172,7 +172,7 @@ void VecUpMat3(float *vec, float mat[][3], short axis)
        
 }
 
-bool KX_CameraActuator::Update(double curtime,double deltatime)
+bool KX_CameraActuator::Update(double curtime, bool frame)
 {
        bool result = true;
 
index cb061206a215f00dd8dbe62aa5886196c9b67ee5..68bc91694e7dc4fb6d51dded68dd3ad942d2282f 100644 (file)
@@ -96,20 +96,13 @@ private :
 
 
        /** Methods Inherited from  CValue */
-
-
        CValue* GetReplica();
        
 
        /** Methods inherited from SCA_IActuator */
-
-
-       bool Update(
-
+       virtual bool Update(
                double curtime,
-
-               double deltatime
-
+               bool frame
        );
 
 
index b60841e86340696a047cfad0b3d7f6853eeb074b..c53749131c08de1400967241fe6b5e413c367f86 100644 (file)
@@ -86,7 +86,7 @@ KX_ConstraintActuator::~KX_ConstraintActuator()
        // there's nothing to be done here, really....
 } /* end of destructor */
 
-bool KX_ConstraintActuator::Update(double curtime,double deltatime)
+bool KX_ConstraintActuator::Update(double curtime, bool frame)
 {
 
        bool result = false;    
@@ -109,12 +109,15 @@ bool KX_ConstraintActuator::Update(double curtime,double deltatime)
        switch (m_locrot) {
        case KX_ACT_CONSTRAINT_LOCX:
                Clamp(position[0], m_minimumBound, m_maximumBound);
+               result = true;
                break;
        case KX_ACT_CONSTRAINT_LOCY:
                Clamp(position[1], m_minimumBound, m_maximumBound);
+               result = true;
                break;
        case KX_ACT_CONSTRAINT_LOCZ:
                Clamp(position[2], m_minimumBound, m_maximumBound);
+               result = true;
                break;
        
 //     case KX_ACT_CONSTRAINT_ROTX:
@@ -154,7 +157,7 @@ bool KX_ConstraintActuator::Update(double curtime,double deltatime)
                ; /* error */
        }
 
-       return false;
+       return result;
 } /* end of KX_ConstraintActuator::Update(double curtime,double deltatime)   */
 
 void KX_ConstraintActuator::Clamp(MT_Scalar &var, 
index c1c58b3b664befef17daa31078d25d906b03c8d2..dfd39f1455c7aa934e19f7e52f62441bc3493c68 100644 (file)
@@ -87,7 +87,7 @@ protected:
                return replica;
        };
 
-       virtual bool Update(double curtime,double deltatime);
+       virtual bool Update(double curtime, bool frame);
 
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
index 2cd7e4db51832a3ec7f072deb4fd4f72e9770698..ada6e3eda0d39a9f0426660dd07c6584046be341 100644 (file)
@@ -83,7 +83,7 @@ CValue* KX_GameActuator::GetReplica()
 
 
 
-bool KX_GameActuator::Update(double curtime, double deltatime)
+bool KX_GameActuator::Update()
 {
        bool result = false;    
        bool bNegativeEvent = IsNegativeEvent();
index 19908a37e543c86e9096db7f2827178956941814..5da10576dde927f64f3e823c2d9109724fe2e7a1 100644 (file)
@@ -72,7 +72,7 @@ protected:
 
        virtual CValue* GetReplica();
 
-       virtual bool Update(double curtime,double deltatime);
+       virtual bool Update();
        
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
index 7a894db66473c19494710088ae4577837b39a1da..6234a5809f2b514df665bb14e06a35fd8501b154 100644 (file)
@@ -32,6 +32,8 @@
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
+#include <cmath>
 #include "KX_IpoActuator.h"
 #include "KX_GameObject.h"
 
@@ -39,6 +41,8 @@
 #include <config.h>
 #endif
 
+#include "KX_KetsjiEngine.h"
+
 /* ------------------------------------------------------------------------- */
 /* Type strings                                                              */
 /* ------------------------------------------------------------------------- */
@@ -100,10 +104,11 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
                                                           PyTypeObject* T) 
        : SCA_IActuator(gameobj,T),
        m_bNegativeEvent(false),
-       m_starttime (starttime),
-       m_endtime(endtime),
+       m_startframe (starttime),
+       m_endframe(endtime),
        m_recurse(recurse),
        m_localtime(starttime),
+       m_starttime(-1.0),
        m_direction(1),
        m_propname(propname),
        m_ipo_as_force(ipo_as_force),
@@ -115,22 +120,35 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
 
 void KX_IpoActuator::SetStart(float starttime) 
 { 
-       m_starttime=starttime;
+       m_startframe=starttime;
 }
 
 void KX_IpoActuator::SetEnd(float endtime) 
 { 
-       m_endtime=endtime;
+       m_endframe=endtime;
 }
 
+void KX_IpoActuator::SetStartTime(float curtime)
+{
+       if (m_direction > 0)
+               m_starttime = curtime - (m_localtime - m_startframe)/KX_FIXED_FRAME_PER_SEC;
+       else
+               m_starttime = curtime - (m_endframe - m_localtime)/KX_FIXED_FRAME_PER_SEC;
+}
 
-bool KX_IpoActuator::Update(double curtime,double delta_time)
+void KX_IpoActuator::SetLocalTime(float curtime)
+{
+       float delta_time = (curtime - m_starttime)*KX_FIXED_FRAME_PER_SEC;
+       if (m_direction > 0)
+               m_localtime = m_startframe + delta_time;
+       else
+               m_localtime = m_endframe - delta_time;
+}
+
+bool KX_IpoActuator::Update(double curtime, bool frame)
 {
-       SCA_IActuator::Update(curtime,delta_time);
        // result = true if animation has to be continued, false if animation stops
        // maybe there are events for us in the queue !
-       
-
        bool bNegativeEvent = false;
        int numevents = m_events.size();
 
@@ -138,10 +156,8 @@ bool KX_IpoActuator::Update(double curtime,double delta_time)
        {
                i--;
                if ((*i)->GetNumber() == 0.0f)
-               {
-                       int ka=0;
                        bNegativeEvent = true;
-               }
+               
                (*i)->Release();
                m_events.pop_back();
        }
@@ -152,101 +168,195 @@ bool KX_IpoActuator::Update(double curtime,double delta_time)
        }
        
 
-       double  start_smaller_then_end = ( m_starttime < m_endtime ? 1.0 : -1.0);
-
-       double deltaframetime = start_smaller_then_end  * delta_time * KX_FIXED_FRAME_PER_SEC;
+       double  start_smaller_then_end = ( m_startframe < m_endframe ? 1.0 : -1.0);
 
        bool result=true;
+       if (m_starttime < 0.0)
+               m_starttime = curtime;
        
        switch (m_type)
        {
                
        case KX_ACT_IPO_PLAY:
+       {
+               // Check if playing forwards.  result = ! finished
+               if (start_smaller_then_end > 0.0)
+                       result = (m_localtime < m_endframe && !(m_localtime == m_startframe && bNegativeEvent));
+               else
+                       result = (m_localtime > m_endframe && !(m_localtime == m_startframe && bNegativeEvent));
+               
+               if (result)
                {
-                       
-                       if (start_smaller_then_end > 0.0)
-                               result = (m_localtime < m_endtime && !(m_localtime == m_starttime && bNegativeEvent));
-                       else
-                               result = (m_localtime > m_endtime && !(m_localtime == m_starttime && bNegativeEvent));
-                       if (result)
-                       {
-                               m_localtime += m_direction * deltaframetime;
-                               
-                               /* Perform clamping */
-                               if ((m_localtime*start_smaller_then_end)>(m_endtime*start_smaller_then_end))
-                                       m_localtime=m_endtime;
-
-                               CIpoAction ipoaction(
-                                       (KX_GameObject*)GetParent(), 
-                                       m_localtime, 
-                                       m_recurse, 
-                                       m_ipo_as_force,
-                                       m_force_ipo_local);
-                               GetParent()->Execute(ipoaction);
-                       } else
-                       {
-                               m_localtime=m_starttime;
-                               m_direction=1;
-                       }
-                       break;
-               }
-       case KX_ACT_IPO_PINGPONG:
-               {
-                       result = true;
-                       if (bNegativeEvent && ((m_localtime == m_starttime )|| (m_localtime == m_endtime)))
-                       {
-                               result = false;
-                       } else
-                       {
-                               m_localtime += m_direction * deltaframetime;
-                       }
-                       
-                       if (m_localtime*start_smaller_then_end < m_starttime*start_smaller_then_end)
-                       {
-                               m_localtime = m_starttime;
-                               result = false;
-                               m_direction = 1;
-                       }else
-                       if (m_localtime*start_smaller_then_end > m_endtime*start_smaller_then_end)
-                       {
-                               m_localtime = m_endtime;
-                               result = false;
-                               m_direction = -1;
-                       } 
-                       
+                       SetLocalTime(curtime);
+               
+                       /* Perform clamping */
+                       if ((m_localtime*start_smaller_then_end)>(m_endframe*start_smaller_then_end))
+                               m_localtime=m_endframe;
+
                        CIpoAction ipoaction(
-                               (KX_GameObject*) GetParent(),
-                               m_localtime,
+                               (KX_GameObject*)GetParent(), 
+                               m_localtime, 
                                m_recurse, 
                                m_ipo_as_force,
                                m_force_ipo_local);
                        GetParent()->Execute(ipoaction);
-                       break;
+               } else
+               {
+                       m_localtime=m_startframe;
+                       m_starttime=curtime;
+                       m_direction=1;
                }
-
+               break;
+       }
+       case KX_ACT_IPO_PINGPONG:
+       {
+               result = true;
+               if (bNegativeEvent && ((m_localtime == m_startframe )|| (m_localtime == m_endframe)))
+                       result = false;
+               else
+                       SetLocalTime(curtime);
+               
+               if (m_localtime*start_smaller_then_end < m_startframe*start_smaller_then_end)
+               {
+                       m_localtime = m_startframe;
+                       result = false;
+                       m_direction = 1;
+               }
+               else if (m_localtime*start_smaller_then_end > m_endframe*start_smaller_then_end)
+               {
+                       m_localtime = m_endframe;
+                       result = false;
+                       m_direction = -1;
+               } 
+               
+               CIpoAction ipoaction(
+                       (KX_GameObject*) GetParent(),
+                       m_localtime,
+                       m_recurse, 
+                       m_ipo_as_force,
+                       m_force_ipo_local);
+               GetParent()->Execute(ipoaction);
+               break;
+       }
        case KX_ACT_IPO_FLIPPER:
+       {
+               result = true;
+               if (numevents)
+               {
+                       if (bNegativeEvent)
+                               m_direction = -1;
+                       else
+                               m_direction = 1;
+                       SetStartTime(curtime);
+               }
+
+               SetLocalTime(curtime);
+
+               if (m_localtime*start_smaller_then_end > m_endframe*start_smaller_then_end)
+               {
+                       m_localtime = m_endframe;
+               } 
+               else if (m_localtime*start_smaller_then_end < m_startframe*start_smaller_then_end)
                {
-                       result = true;
-                       if (numevents)
+                       m_localtime = m_startframe;
+                       result = false;
+               }
+               
+               CIpoAction ipoaction(
+                       (KX_GameObject*) GetParent(),
+                       m_localtime,
+                       m_recurse,
+                       m_ipo_as_force,
+                       m_force_ipo_local);
+               GetParent()->Execute(ipoaction);
+               break;
+       }
+
+       case KX_ACT_IPO_LOOPSTOP:
+       {
+               if (numevents)
+               {
+                       if (bNegativeEvent)
+                       {
+                               result = false;
+                               m_bNegativeEvent = false;
+                               numevents = 0;
+                       }
+                       SetStartTime(curtime);
+               } // fall through to loopend, and quit the ipo animation immediatly 
+       }
+       case KX_ACT_IPO_LOOPEND:
+       {
+               if (numevents){
+                       if (bNegativeEvent){
+                               m_bNegativeEvent = true;
+                       }
+               }
+               
+               if (bNegativeEvent && m_localtime == m_startframe){
+                       result = false;
+               } 
+               else{
+                       if (m_localtime*start_smaller_then_end < m_endframe*start_smaller_then_end)
                        {
-                               if (bNegativeEvent)
-                                       m_direction = -1;
+                               SetLocalTime(curtime);
+                       }
+                       else{
+                               if (!m_bNegativeEvent){
+                                       /* Perform wraparound */
+                                       SetLocalTime(curtime);
+                                       m_localtime = m_startframe + std::fmod(m_localtime, m_startframe - m_endframe);
+                                       SetStartTime(curtime);
+                               }
                                else
-                                       m_direction = 1;
+                               {       
+                                       /* Perform clamping */
+                                       m_localtime=m_endframe;
+                                       result = false;
+                                       m_bNegativeEvent = false;
+                               }
                        }
+               }
+               
+               CIpoAction ipoaction(
+                       (KX_GameObject*) GetParent(),
+                       m_localtime,
+                       m_recurse,
+                       m_ipo_as_force,
+                       m_force_ipo_local);
+               GetParent()->Execute(ipoaction);
+               break;
+       }
+       
+       case KX_ACT_IPO_KEY2KEY:
+       {
+               // not implemented yet
+               result = false;
+               break;
+       }
+       
+       case KX_ACT_IPO_FROM_PROP:
+       {
+               result = !bNegativeEvent;
 
-                       m_localtime += m_direction * deltaframetime;
-
-                       if (m_localtime*start_smaller_then_end > m_endtime*start_smaller_then_end)
+               CValue* propval = GetParent()->GetProperty(m_propname);
+               if (propval)
+               {
+                       float target = propval->GetNumber(); 
+                       float delta_time = (curtime - m_starttime)*KX_FIXED_FRAME_PER_SEC;
+                       if (target > m_localtime)
                        {
-                               m_localtime = m_endtime;
-                       } else
-                        if (m_localtime*start_smaller_then_end < m_starttime*start_smaller_then_end)
-                        {
-                               m_localtime = m_starttime;
-                               result = false;
-                        }
-                       
+                               m_localtime += delta_time;
+                               if (m_localtime > target)
+                                       m_localtime = target;
+                       }
+                       else
+                       {
+                               m_localtime -= delta_time;
+                               if (m_localtime < target)
+                                       m_localtime = target;
+                       }
+       
                        CIpoAction ipoaction(
                                (KX_GameObject*) GetParent(),
                                m_localtime,
@@ -254,99 +364,20 @@ bool KX_IpoActuator::Update(double curtime,double delta_time)
                                m_ipo_as_force,
                                m_force_ipo_local);
                        GetParent()->Execute(ipoaction);
-                       break;
-               }
 
-               case KX_ACT_IPO_LOOPSTOP:
-               {
-                       if (numevents)
-                       {
-                               if (bNegativeEvent)
-                               {
-                                       result = false;
-                                       m_bNegativeEvent = false;
-                                       numevents = 0;
-                               }
-                       } // fall through to loopend, and quit the ipo animation immediatly 
-               }
-       
-               case KX_ACT_IPO_LOOPEND:
-                       {
-                               if (numevents){
-                                       if (bNegativeEvent){
-                                               m_bNegativeEvent = true;
-                                       }
-                               }
-                               
-                               if (bNegativeEvent && m_localtime == m_starttime){
-                                       result = false;
-                               } 
-                               else{
-                                       if (m_localtime*start_smaller_then_end < m_endtime*start_smaller_then_end){
-                                               m_localtime += m_direction * deltaframetime;
-                                       }
-                                       else{
-                                               if (!m_bNegativeEvent){
-                                                       /* Perform wraparound */
-                                                       float slop = m_localtime-m_endtime;
-                                                       float length = fabs(m_starttime-m_endtime);
-                                                       m_localtime = m_starttime + (slop - (int(slop/length)*(int(length))));
-                                                       
-                                               }
-                                               else
-                                               {       
-                                                       /* Perform clamping */
-                                                       if ((m_localtime*start_smaller_then_end)>(m_endtime*start_smaller_then_end))
-                                                               m_localtime=m_endtime;
-                                                       
-                                                       result = false;
-                                                       m_bNegativeEvent = false;
-                                               }
-                                       }
-                               }       
-                               CIpoAction ipoaction(
-                                       (KX_GameObject*) GetParent(),
-                                       m_localtime,
-                                       m_recurse,
-                                       m_ipo_as_force,
-                                       m_force_ipo_local);
-                               GetParent()->Execute(ipoaction);
-                               break;
-               }
-       case KX_ACT_IPO_KEY2KEY:
+               } else
                {
-                       // not implemented yet
                        result = false;
-                       break;
-               }
-       case KX_ACT_IPO_FROM_PROP:
-               {
-                       result = !bNegativeEvent;
-
-                        CValue* propval = GetParent()->GetProperty(m_propname);
-                        if (propval)
-                        {
-                               m_localtime = propval->GetNumber();
-                               CIpoAction ipoaction(
-                                       (KX_GameObject*) GetParent(),
-                                       m_localtime,
-                                       m_recurse,
-                                       m_ipo_as_force,
-                                       m_force_ipo_local);
-                               GetParent()->Execute(ipoaction);
-
-                        } else
-                        {
-                                result = false;
-                        }
-                       break;
                }
+               break;
+       }
                
        default:
-               {
-                       result = false;
-               }
+               result = false;
        }
+       
+       if (!result && m_type != KX_ACT_IPO_LOOPSTOP)
+               m_starttime = -1.0;
 
        return result;
 }
@@ -472,8 +503,8 @@ PyObject* KX_IpoActuator::PySet(PyObject* self,
        case KX_ACT_IPO_LOOPSTOP:
        case KX_ACT_IPO_LOOPEND:
                m_type         = modenum;
-               m_starttime    = startFrame;
-               m_endtime      = stopFrame;
+               m_startframe    = startFrame;
+               m_endframe      = stopFrame;
                m_ipo_as_force = PyArgToBool(forceToggle);
                break;
        default:
@@ -516,7 +547,7 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self,
                return NULL;            
        }
        
-       m_starttime = startArg;
+       m_startframe = startArg;
 
        Py_Return;
 }
@@ -527,7 +558,7 @@ char KX_IpoActuator::GetStart_doc[] =
 PyObject* KX_IpoActuator::PyGetStart(PyObject* self, 
                                                                         PyObject* args, 
                                                                         PyObject* kwds) {
-       return PyFloat_FromDouble(m_starttime);
+       return PyFloat_FromDouble(m_startframe);
 }
 
 /* 6. setEnd:                                                                */
@@ -543,7 +574,7 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self,
                return NULL;            
        }
        
-       m_endtime = endArg;
+       m_endframe = endArg;
 
        Py_Return;
 }
@@ -554,7 +585,7 @@ char KX_IpoActuator::GetEnd_doc[] =
 PyObject* KX_IpoActuator::PyGetEnd(PyObject* self, 
                                                                   PyObject* args, 
                                                                   PyObject* kwds) {
-       return PyFloat_FromDouble(m_endtime);
+       return PyFloat_FromDouble(m_endframe);
 }
 
 /* 6. setIpoAsForce:                                                           */
index e2f877c7f7ceb99b774ef92d80efadb0480f8486..cdc815dff7bea4f3896533daac06c3e2c3381e1a 100644 (file)
 class KX_IpoActuator : public SCA_IActuator
 {
        Py_Header;
+private:
+       /** Computes the IPO start time from the current time
+           and the current frame. */
+       void SetStartTime(float curtime);
+       /** Computes the current frame from the current time
+           and the IPO start time. */
+       void SetLocalTime(float curtime);
+
 protected:
        bool    m_bNegativeEvent;
 
        /** Begin frame of the ipo. */
-       float   m_starttime;
+       float   m_startframe;
        
        /** End frame of the ipo. */
-       float   m_endtime;
+       float   m_endframe;
 
        /** Include children in the transforms? */
        bool    m_recurse;
 
        /** Current active frame of the ipo. */
        float   m_localtime;
+       
+       float   m_starttime;
 
        /** play backwards or forwards? (positive means forward). */
        float   m_direction;
@@ -114,7 +124,7 @@ public:
 
        void            SetStart(float starttime);
        void            SetEnd(float endtime);
-       virtual         bool Update(double curtime,double deltatime);
+       virtual         bool Update(double curtime, bool frame);
 
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
index f257b8dfb739c134d3cd3d6ece536944b3a2386c..fbe2fd9c6cd0087b14f2dc2d0c6bdd095ed01af9 100644 (file)
@@ -65,6 +65,7 @@
 #include "KX_PythonInit.h"
 #include "KX_PyConstraintBinding.h"
 #include "PHY_IPhysicsEnvironment.h"
+#include "SumoPhysicsEnvironment.h"
 
 #include "SND_Scene.h"
 #include "SND_IAudioDevice.h"
@@ -81,7 +82,8 @@
 // If define: little test for Nzc: guarded drawing. If the canvas is
 // not valid, skip rendering this frame.
 //#define NZC_GUARDED_OUTPUT
-
+#define DEFAULT_LOGIC_TIC_RATE 30.0
+#define DEFAULT_PHYSICS_TIC_RATE 60.0
 
 const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
        "Physics:",             // tc_physics
@@ -95,47 +97,70 @@ const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
        "Outside:"              // tc_outside
 };
 
-
+double KX_KetsjiEngine::m_ticrate = DEFAULT_LOGIC_TIC_RATE;
 
 
 /**
  *     Constructor of the Ketsji Engine
  */
 KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
-:
+     : m_canvas(NULL),
        m_rasterizer(NULL),
+       m_kxsystem(system),
+       m_rendertools(NULL),
+       m_sceneconverter(NULL),
+       m_networkdevice(NULL),
+       m_audiodevice(NULL),
+       m_pythondictionary(NULL),
+       m_keyboarddevice(NULL),
+       m_mousedevice(NULL),
+
+       m_propertiesPresent(false),
+
        m_bInitialized(false),
-       m_activecam(0)
-{
-       m_kxsystem = system;
-       m_bFixedTime = false;
+       m_activecam(0),
+       m_bFixedTime(false),
+       
+       m_firstframe(true),
+       
+       m_previoustime(0.0),
+       m_deltatime(0.0),
 
-       // Initialize the time logger
-       m_logger = new KX_TimeCategoryLogger (25);
+       m_exitcode(KX_EXIT_REQUEST_NO_REQUEST),
+       m_exitstring(""),
+       
+       m_drawingmode(5),
+       m_cameraZoom(1.0),
+       
+       m_overrideCam(false),
+       m_overrideCamUseOrtho(false),
 
-       for (int i = tc_first; i < tc_numCategories; i++)
-               m_logger->AddCategory((KX_TimeCategory)i);
+       m_stereo(false),
+       m_curreye(0),
 
+       m_logger(NULL),
+       
        // Set up timing info display variables
-       m_show_framerate = false;
-       m_show_profile   = false;
-       m_show_debug_properties = false;
-       m_propertiesPresent = false;
+       m_show_framerate(false),
+       m_show_profile(false),
+       m_showProperties(false),
+       m_showBackground(false),
+       m_show_debug_properties(false),
 
        // Default behavior is to hide the cursor every frame.
-       m_hideCursor = false;
+       m_hideCursor(false),
 
-       m_overrideFrameColor = false;
-       m_overrideFrameColorR = (float)0;
-       m_overrideFrameColorG = (float)0;
-       m_overrideFrameColorB = (float)0;
-       
-       m_cameraZoom = 1.0;
-       m_drawingmode = 5; /* textured drawing mode */
-       m_overrideCam = false;
+       m_overrideFrameColor(false),
+       m_overrideFrameColorR(0.0),
+       m_overrideFrameColorG(0.0),
+       m_overrideFrameColorB(0.0)
+{
+       // Initialize the time logger
+       m_logger = new KX_TimeCategoryLogger (25);
 
-       m_exitcode = KX_EXIT_REQUEST_NO_REQUEST;
-       m_exitstring = "";
+       for (int i = tc_first; i < tc_numCategories; i++)
+               m_logger->AddCategory((KX_TimeCategory)i);
+               
 }
 
 
@@ -145,8 +170,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
  */
 KX_KetsjiEngine::~KX_KetsjiEngine()
 {
-       if (m_logger)
-               delete m_logger;
+       delete m_logger;
 }
 
 
@@ -230,61 +254,13 @@ void KX_KetsjiEngine::SetSceneConverter(KX_ISceneConverter* sceneconverter)
  */
 void KX_KetsjiEngine::StartEngine()
 {
-       m_previoustime = 0.0;
-       m_missedtime = 0.0;
+       m_previoustime = m_kxsystem->GetTimeInSeconds();
        m_firstframe = true;
-       
-       // for all scenes, initialize the scenegraph for the first time
-       m_lasttime = m_kxsystem->GetTimeInSeconds()*100.0;
-
        m_bInitialized = true;
+       m_ticrate = DEFAULT_LOGIC_TIC_RATE;
+       SumoPhysicsEnvironment::setTicRate(DEFAULT_PHYSICS_TIC_RATE);
 }
 
-
-
-#define DELTALENGTH 25 
-
-double KX_KetsjiEngine::CalculateAverage(double newdelta)
-{
-       if (m_deltatimes.size() < DELTALENGTH)
-       {
-               m_deltatimes.push_back(newdelta);
-       } else
-       {
-               //
-               double totaltime = 0.0;
-               double newlasttime,lasttime = newdelta;
-               double peakmin = 10000;
-               double peakmax = -10000;
-
-               for (int i=m_deltatimes.size()-1;i>=0;i--)
-               {       newlasttime = m_deltatimes[i];
-                       totaltime += newlasttime;
-                       if (peakmin > newlasttime)
-                               peakmin = newlasttime;
-                       if (peakmax < newlasttime)
-                               peakmax = newlasttime;
-
-                       m_deltatimes[i] = lasttime;
-                       lasttime = newlasttime;
-               };
-               double averagetime;
-               
-               if (peakmin < peakmax)
-               {
-                       averagetime = ((totaltime - peakmin) - peakmax) / (double) (m_deltatimes.size()-2); 
-               } else
-               {       
-                       averagetime = totaltime / (double) m_deltatimes.size();
-               }
-               return averagetime;
-       }       
-
-       return newdelta;
-}
-
-
-
 bool KX_KetsjiEngine::BeginFrame()
 {
        bool result = false;
@@ -338,106 +314,138 @@ void KX_KetsjiEngine::NextFrame()
 {
        m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
 
-       double deltatime = 0.02; 
        double curtime;
-
        if (m_bFixedTime)
        {
-               curtime = m_previoustime + deltatime;
+               m_deltatime = 1.0/m_ticrate;
+               curtime = m_previoustime + m_deltatime;
        }
        else
        {
                curtime = m_kxsystem->GetTimeInSeconds();
-               if (m_previoustime)
-                       deltatime = curtime - m_previoustime;
-
-               if (deltatime > 0.1)
-                       deltatime = 0.1;
-
-               deltatime = CalculateAverage(deltatime);
+               m_deltatime += curtime - m_previoustime;
+               m_previoustime = curtime;
        }
 
-       m_previoustime = curtime;
-
+       // Compute the number of logic frames to do each update (fixed tic bricks)
+       int frames = (int) (m_deltatime*m_ticrate);
+       //printf("LogicUpdate: %0.1f %0.3f %d\n", curtime, m_deltatime, frames);
+       
+       m_deltatime -= double(frames)/m_ticrate;
+       
        KX_SceneList::iterator sceneit;
-       for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
-       // for each scene, call the proceed functions
+       
+       if (!frames)
        {
-               KX_Scene* scene = *sceneit;
-
-
-
-               /* Suspension holds the physics and logic processing for an
-                * entire scene. Objects can be suspended individually, and
-                * the settings for that preceed the logic and physics
-                * update. */
-               m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
-               scene->UpdateObjectActivity();
-
-               if (!scene->IsSuspended())
+               for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
+               // for each scene, call the proceed functions
                {
-                       m_logger->StartLog(tc_network, m_kxsystem->GetTimeInSeconds(), true);
-                       scene->GetNetworkScene()->proceed(curtime, deltatime);
-
-                       // set Python hooks for each scene
-                       PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
-                       PHY_SetActiveScene(scene);
-
-                       // Process sensors, and controllers
-                       m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
-                       scene->LogicBeginFrame(curtime,deltatime);
-
-                       // Scenegraph needs to be updated again, because Logic Controllers 
-                       // can affect the local matrices.
-                       m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
-                       scene->UpdateParents(curtime);
-
-                       // Process actuators
-
-                       // Do some cleanup work for this logic frame
+                       KX_Scene* scene = *sceneit;
+       
+                       if (!scene->IsSuspended())
+                       {
+                               // Do some cleanup work for this logic frame
+                               m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->LogicUpdateFrame(curtime, false);
+       
+                               // Actuators can affect the scenegraph
+                               m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->UpdateParents(curtime);
+       
+                               // Perform physics calculations on the scene. This can involve 
+                               // many iterations of the physics solver.
+                               m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->GetPhysicsEnvironment()->proceed(curtime);
+               
+                               // Update scenegraph after physics step. This maps physics calculations
+                               // into node positions.         
+                               m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->UpdateParents(curtime);
+                       } // suspended
+       
+                       DoSound(scene);
+       
+                       m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
+               }
+       }
+       
+       while (frames--)
+       {
+               for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
+               // for each scene, call the proceed functions
+               {
+                       KX_Scene* scene = *sceneit;
+       
+                       /* Suspension holds the physics and logic processing for an
+                       * entire scene. Objects can be suspended individually, and
+                       * the settings for that preceed the logic and physics
+                       * update. */
                        m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
-                       scene->LogicUpdateFrame(curtime,deltatime);             
-                       scene->LogicEndFrame();
-
-                       // Actuators can affect the scenegraph
-                       m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
-                       scene->UpdateParents(curtime);
-
-                       // Perform physics calculations on the scene. This can involve 
-                       // many iterations of the physics solver.
-                       m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
-                       scene->GetPhysicsEnvironment()->proceed(deltatime);
-
-                       // Update scenegraph after physics step. This maps physics calculations
-                       // into node positions.         
-                       m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
-                       scene->UpdateParents(curtime);
-
-               } // suspended
-
-               DoSound(scene);
+                       scene->UpdateObjectActivity();
+       
+                       if (!scene->IsSuspended())
+                       {
+                               m_logger->StartLog(tc_network, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->GetNetworkScene()->proceed(curtime);
+       
+                               // set Python hooks for each scene
+                               PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
+                               PHY_SetActiveScene(scene);
+       
+                               // Process sensors, and controllers
+                               m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->LogicBeginFrame(curtime);
+       
+                               // Scenegraph needs to be updated again, because Logic Controllers 
+                               // can affect the local matrices.
+                               m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->UpdateParents(curtime);
+       
+                               // Process actuators
+       
+                               // Do some cleanup work for this logic frame
+                               m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->LogicUpdateFrame(curtime, true);
+                               scene->LogicEndFrame();
+       
+                               // Actuators can affect the scenegraph
+                               m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->UpdateParents(curtime);
+       
+                               // Perform physics calculations on the scene. This can involve 
+                               // many iterations of the physics solver.
+                               m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->GetPhysicsEnvironment()->proceed(curtime);
+               
+                               // Update scenegraph after physics step. This maps physics calculations
+                               // into node positions.         
+                               m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
+                               scene->UpdateParents(curtime);
+                       } // suspended
+       
+                       DoSound(scene);
+       
+                       m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
+               }
 
-               m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
+               // update system devices
+               m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
+               if (m_keyboarddevice)
+                       m_keyboarddevice->NextFrame();
+       
+               if (m_mousedevice)
+                       m_mousedevice->NextFrame();
+               
+               if (m_networkdevice)
+                       m_networkdevice->NextFrame();
+       
+               if (m_audiodevice)
+                       m_audiodevice->NextFrame();
+       
+               // scene management
+               ProcessScheduledScenes();
        }
 
-       // update system devices
-       m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
-
-       if (m_keyboarddevice)
-               m_keyboarddevice->NextFrame();
-
-       if (m_mousedevice)
-               m_mousedevice->NextFrame();
-
-       if (m_networkdevice)
-               m_networkdevice->NextFrame();
-
-       if (m_audiodevice)
-               m_audiodevice->NextFrame();
-
-       // scene management
-       ProcessScheduledScenes();
-
        // Start logging time spend outside main loop
        m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true);
 }
@@ -1177,7 +1185,15 @@ bool KX_KetsjiEngine::GetUseFixedTime(void) const
        return m_bFixedTime;
 }
 
+double KX_KetsjiEngine::GetTicRate()
+{
+       return m_ticrate;
+}
 
+void KX_KetsjiEngine::SetTicRate(double ticrate)
+{
+       m_ticrate = ticrate;
+}
 
 void KX_KetsjiEngine::SetTimingDisplay(bool frameRate, bool profile, bool properties)
 {
index 79baf09f597690e9f1c9f1c27adbadf6b3790d29..9a6f18a5c5f5142fd8d15bd23ea622d275f15b6f 100644 (file)
@@ -97,11 +97,10 @@ private:
        bool                            m_bFixedTime;
        
        bool                            m_firstframe;
+       
        double                          m_previoustime;
-       double                          m_missedtime;
-       double                          m_lasttime; // old style time
-       double                          m_dtime;
-       std::vector<double>     m_deltatimes;
+       double                          m_deltatime;
+       static double                   m_ticrate;
 
        int                                     m_exitcode;
        STR_String                      m_exitstring;
@@ -167,8 +166,6 @@ private:
        /** Blue component of framing bar color. */
        float                                   m_overrideFrameColorB;
 
-       double                                  CalculateAverage(double newdeltatime);
-       
        void                                    SetupRenderFrame(KX_Scene *scene);
        void                                    RenderFrame(KX_Scene* scene);
        void                                    RenderDebugProperties();
@@ -234,6 +231,15 @@ public:
         * @return Current setting for display all frames.
         */ 
        bool GetUseFixedTime(void) const;
+       
+       /**
+        * Gets the number of logic updates per second.
+        */
+       static double GetTicRate();
+       /**
+        * Sets the number of logic updates per second.
+        */
+       static void SetTicRate(double ticrate);
 
        /**
         * Activates or deactivates timing information display.
index 04385859994b269c2ab1671556412f806f20b61a..74f3dd1ef3be3c37bf7203cdc603cbc13455c148 100644 (file)
@@ -68,7 +68,7 @@ KX_ObjectActuator(
 {
 }
 
-bool KX_ObjectActuator::Update(double curtime,double deltatime)
+bool KX_ObjectActuator::Update()
 {
        
        bool bNegativeEvent = IsNegativeEvent();
index 92365eba3cab600ad34a85f01908c79db85907ed..1ef3e34625abd2891955e1d39b8a0d4fc513296c 100644 (file)
@@ -113,7 +113,7 @@ public:
        CValue* GetReplica();
 
        void SetForceLoc(const double force[3]) { /*m_force=force;*/ }
-       bool Update(double curtime,double deltatime);
+       virtual bool Update();
 
 
 
index 3d6995ab4e01a1045458f6541cebdcdcf0460243..ba466f20f641d56301e8e105c67d0e520a57c3da 100644 (file)
@@ -41,6 +41,8 @@
 
 #include "KX_PythonInit.h"
 
+#include "KX_KetsjiEngine.h"
+
 #include "SCA_IInputDevice.h"
 #include "SCA_PropertySensor.h"
 #include "SCA_RandomActuator.h"
@@ -58,6 +60,7 @@
 
 #include "KX_PyMath.h"
 
+#include "SumoPhysicsEnvironment.h"
 // FIXME: Enable for access to blender python modules.  This is disabled because
 // python has dependencies on a lot of other modules and is a pain to link.
 //#define USE_BLENDER_PYTHON
@@ -182,6 +185,43 @@ static PyObject* gPyStopDSP(PyObject*,
        return NULL;
 }
 
+static PyObject* gPySetLogicTicRate(PyObject*,
+                                       PyObject* args,
+                                       PyObject*)
+{
+       float ticrate;
+       if (PyArg_ParseTuple(args, "f", &ticrate))
+       {
+               KX_KetsjiEngine::SetTicRate(ticrate);
+               Py_Return;
+       }
+       
+       return NULL;
+}
+
+static PyObject* gPyGetLogicTicRate(PyObject*, PyObject*, PyObject*)
+{
+       return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
+}
+
+static PyObject* gPySetPhysicsTicRate(PyObject*,
+                                       PyObject* args,
+                                       PyObject*)
+{
+       float ticrate;
+       if (PyArg_ParseTuple(args, "f", &ticrate))
+       {
+               SumoPhysicsEnvironment::setTicRate(ticrate);
+               Py_Return;
+       }
+       
+       return NULL;
+}
+
+static PyObject* gPyGetPhysicsTicRate(PyObject*, PyObject*, PyObject*)
+{
+       return PyFloat_FromDouble(SumoPhysicsEnvironment::getTicRate());
+}
 
 static STR_String gPyGetCurrentScene_doc =  
 "getCurrentScene()\n"
@@ -209,6 +249,10 @@ static struct PyMethodDef game_methods[] = {
        {"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS,"set Gravitation"},
        {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_VARARGS,"get audio spectrum"},
        {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS,"stop using the audio dsp (for performance reasons)"},
+       {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_VARARGS, "Gets the logic tic rate"},
+       {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"},
+       {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_VARARGS, "Gets the physics tic rate"},
+       {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"},
        {NULL, (PyCFunction) NULL, 0, NULL }
 };
 
index ca16ceb015b3ab4b0d8351d2fd3e0a919a904ef8..0fb1cee644663a37f3d4324acf32fc1a6c7c5d8e 100644 (file)
@@ -45,7 +45,7 @@ using namespace std;
 #include <config.h>
 #endif
 
-void KX_RayEventManager::NextFrame(double curtime,double deltatime)
+void KX_RayEventManager::NextFrame()
 {
        for (vector<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
        {
index 7acc0b04dedb8aeef035097d91eb290807ae8902..8aa1ed990cd213161e61bccc379608a1dd4460c1 100644 (file)
@@ -47,7 +47,7 @@ public:
                : SCA_EventManager(RAY_EVENTMGR),
                  m_logicmgr(logicmgr)
        {}
-       virtual void NextFrame(double curtime,double deltatime);
+       virtual void NextFrame();
        virtual void    RegisterSensor(SCA_ISensor* sensor);
 };
 
index d972d880070eb33070655180906ae45e4e7868a8..3df0092dfb549ddc9701b474b3310fe853e4d02d 100644 (file)
@@ -78,8 +78,7 @@ KX_SCA_AddObjectActuator::~KX_SCA_AddObjectActuator()
 
 
 
-bool KX_SCA_AddObjectActuator::Update(double curtime,
-                                                                         double deltatime)
+bool KX_SCA_AddObjectActuator::Update()
 {
        bool result = false;    
        bool bNegativeEvent = IsNegativeEvent();
index d9f82e7251e40e065270d2e75b6a0a88ac65aca6..2a7c27669fae7a124aec1f50a7d78b3252e45d35 100644 (file)
@@ -92,11 +92,8 @@ public:
        GetReplica(
        ) ;
 
-               bool 
-       Update(
-               double curtime,
-               double deltatime
-       );
+       virtual bool 
+       Update();
 
        virtual PyObject*  
        _getattr(
index e91f0b86b712b276bc12d21c46b3168555469b33..11d2a895ce9109e513f71d620ab72be9f53e31d7 100644 (file)
@@ -63,9 +63,7 @@ KX_SCA_EndObjectActuator::~KX_SCA_EndObjectActuator()
 
 
 
-bool KX_SCA_EndObjectActuator::Update(double curtime,
-                                                                         double deltatime
-                                                                         )
+bool KX_SCA_EndObjectActuator::Update()
 {
        bool result = false;    
        bool bNegativeEvent = IsNegativeEvent();
index 3b6e340f8724eb8c96644a335025cfea1cc365db..ca77d80027d1477b323482c762f978c9e6414076 100644 (file)
@@ -60,11 +60,8 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator
        GetReplica(
        );
 
-               bool 
-       Update(
-               double curtime,
-               double deltatime
-       );
+       virtual bool 
+       Update();
 
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
index 84e12ac86af304fbc0e25fccf0577bab4e7abf62..742bcd43607298072e7cba37858014ba16b738d7 100644 (file)
@@ -159,8 +159,7 @@ KX_SCA_ReplaceMeshActuator::~KX_SCA_ReplaceMeshActuator()
 
 
 
-bool KX_SCA_ReplaceMeshActuator::Update(double curtime,
-                                                                               double deltatime)
+bool KX_SCA_ReplaceMeshActuator::Update()
 {
        bool result = false;    
        bool bNegativeEvent = IsNegativeEvent();
index e38cf412539c4852c4199f4c0844163993c31928..c1b1fd6735db928eab5b5b686379a1296a5aa3bc 100644 (file)
@@ -69,11 +69,8 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
        GetReplica(
        );
 
-               bool 
-       Update(
-               double curtime,
-               double deltatime
-       );
+       virtual bool 
+       Update();
 
        virtual PyObject*  
        _getattr(
index c44c941353862d741b21b70aa4fe6f7f7081ed7e..f10ea902c96b4bd9b6de5d08237e807cec35e0c5 100644 (file)
@@ -944,7 +944,7 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty)
 }
 
 // logic stuff
-void KX_Scene::LogicBeginFrame(double curtime,double deltatime)
+void KX_Scene::LogicBeginFrame(double curtime)
 {
        // have a look at temp objects ...
        int lastobj = m_tempObjectList->GetCount() - 1;
@@ -956,7 +956,7 @@ void KX_Scene::LogicBeginFrame(double curtime,double deltatime)
                
                if (propval)
                {
-                       float timeleft = propval->GetNumber() - deltatime;
+                       float timeleft = propval->GetNumber() - 1.0/KX_KetsjiEngine::GetTicRate();
                        
                        if (timeleft > 0)
                        {
@@ -973,14 +973,14 @@ void KX_Scene::LogicBeginFrame(double curtime,double deltatime)
                        // all object is the tempObjectList should have a clock
                }
        }
-       m_logicmgr->BeginFrame(curtime,deltatime);
+       m_logicmgr->BeginFrame(curtime, 1.0/KX_KetsjiEngine::GetTicRate());
 }
 
 
 
-void KX_Scene::LogicUpdateFrame(double curtime,double deltatime)
+void KX_Scene::LogicUpdateFrame(double curtime, bool frame)
 {
-       m_logicmgr->UpdateFrame(curtime,deltatime);
+       m_logicmgr->UpdateFrame(curtime, frame);
 }
 
 
index 9e6909168cbbe0d65ccf1941b1c5a351567e52f0..2f867c28c40f1b3eaf5162050aced80e39618da6 100644 (file)
@@ -292,10 +292,8 @@ public:
         * @section Logic stuff
         * Initiate an update of the logic system.
         */
-       void LogicBeginFrame(double curtime,
-                                                double deltatime);
-       void LogicUpdateFrame(double curtime,
-                                                 double deltatime);
+       void LogicBeginFrame(double curtime);
+       void LogicUpdateFrame(double curtime, bool frame);
 
                void                                            
        LogicEndFrame(
@@ -515,7 +513,7 @@ public:
        */
 
        virtual PyObject* _getattr(const STR_String& attr); /* name, active_camera, gravity, suspended, viewport, framing, activity_culling, activity_culling_radius */
-       virtual int KX_Scene::_setattr(const STR_String &attr, PyObject *pyvalue);
+       virtual int _setattr(const STR_String &attr, PyObject *pyvalue);
 };
 
 typedef std::vector<KX_Scene*> KX_SceneList;
index ddd0672b2fe8b63f7611cc051a3caed2bda1a9d8..60e5195534b062eec4f757810421603ac4482a2e 100644 (file)
@@ -84,7 +84,7 @@ CValue* KX_SceneActuator::GetReplica()
 
 
 
-bool KX_SceneActuator::Update(double curtime,double deltatime)
+bool KX_SceneActuator::Update()
 {
        bool result = false;    
        bool bNegativeEvent = IsNegativeEvent();
index 76039fcf4364badba7b4abc4bd54f5efae29cb3c..6416e0f48d0c36beac58f181d5bb5c61066245cb 100644 (file)
@@ -86,7 +86,7 @@ class KX_SceneActuator : public SCA_IActuator
 
        virtual CValue* GetReplica();
 
-       virtual bool Update(double curtime,double deltatime);
+       virtual bool Update();
        
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
index e71902519f3af23a87a226d59f61c2f5360520fb..267bb414c138829bfe2835f82fb5bdf9385d109d 100644 (file)
@@ -94,8 +94,10 @@ CValue* KX_SoundActuator::GetReplica()
 
 
 
-bool KX_SoundActuator::Update(double curtime,double deltatime)
+bool KX_SoundActuator::Update(double curtime, bool frame)
 {
+       if (!frame)
+               return true;
        bool result = false;
 
        // do nothing on negative events, otherwise sounds are played twice!
index dcb46f1b5d0f187b30918d663bfe26f3bcee0c32..796e202df706f8652618a8625e686d86edc3b658 100644 (file)
@@ -75,7 +75,7 @@ public:
        ~KX_SoundActuator();
 
        void setSoundObject(class SND_SoundObject* soundobject);
-       bool Update(double curtime,double deltatime);
+       virtual bool Update(double curtime, bool frame);
 
        CValue* GetReplica();
 
index 2186c442f3284ffb38af9d141ab3c97075af0eb6..704d949b0e7232a2a65754258c8a676cee2116dc 100644 (file)
@@ -109,7 +109,7 @@ void KX_TouchEventManager::EndFrame()
 
 
 
-void KX_TouchEventManager::NextFrame(double curtime,double deltatime)
+void KX_TouchEventManager::NextFrame()
 {
        if (m_sensors.size() > 0)
        {
index 4439ba6f3bdee81ffd84b01a205621867e4bf2ff..923ecd108848f7bbf2a820520f92bc14e84746ae 100644 (file)
@@ -55,7 +55,7 @@ class KX_TouchEventManager : public SCA_EventManager
 public:
        KX_TouchEventManager(class SCA_LogicManager* logicmgr,  
                SM_Scene *scene);
-       virtual void NextFrame(double curtime,double deltatime);
+       virtual void NextFrame();
        virtual void    EndFrame();
        virtual void    RemoveSensor(class SCA_ISensor* sensor);
        virtual void RegisterSensor(SCA_ISensor* sensor);
index 6880ac5d683f1392060666cfd9a9cdefc5cc0968..2c4d02854ade14d98d67beb5bfce16dd54eba090 100644 (file)
@@ -174,7 +174,7 @@ KX_TrackToActuator::~KX_TrackToActuator()
 
 
 
-bool KX_TrackToActuator::Update(double curtime,double deltatime)
+bool KX_TrackToActuator::Update(double curtime, bool frame)
 {
        bool result = false;    
        bool bNegativeEvent = IsNegativeEvent();
@@ -327,7 +327,6 @@ bool KX_TrackToActuator::Update(double curtime,double deltatime)
                
                curobj->NodeSetLocalOrientation(mat);
                
-               //cout << "\n TrackTo!";
                result = true;
        }
 
index 817bb4a8cface9d730b3ed2b9f03f7f70ebe6c41..6b0ddd7103e6730f5d043f580396aa2e37ee7789 100644 (file)
@@ -62,7 +62,7 @@ class KX_TrackToActuator : public SCA_IActuator
                return replica;
        };
 
-       virtual bool Update(double curtime,double deltatime);
+       virtual bool Update(double curtime, bool frame);
 
        /* Python part */
        virtual PyObject* _getattr(const STR_String& attr);
index dc0178976faba02a3a1bca1341b12817aee8b951..8ec3e05e30395c26ffb440b06a52fdf6c7b17711 100644 (file)
@@ -69,10 +69,7 @@ KX_VisibilityActuator::GetReplica(
 }
 
 bool
-KX_VisibilityActuator::Update(
-       double curtime,
-       double deltatime
-       )
+KX_VisibilityActuator::Update()
 {
        bool bNegativeEvent = IsNegativeEvent();
        
index 9d5d38666f1945abb7b3253068f61f087b24e0ad..9a78eb1cc07857eeb462797e4b71dd933551fd6f 100644 (file)
@@ -62,10 +62,7 @@ class KX_VisibilityActuator : public SCA_IActuator
                        );
 
        virtual bool
-               Update(
-                       double curtime,
-                       double deltatime
-                       );
+               Update();
 
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
index e24fade91f8e403139d05bbb3fcc404b899150ac..b867791e12d1e47b224c7e74bfd453312bc90695 100644 (file)
@@ -56,7 +56,7 @@ NG_NetworkScene::~NG_NetworkScene()
 /**
  * progress one frame, handle all network traffic
  */
-void NG_NetworkScene::proceed(double curtime, double deltatime)
+void NG_NetworkScene::proceed(double curtime)
 {
        if (!m_networkdevice) return;
        if (!m_networkdevice->IsOnline()) return;
index 4cbdcf7d39a2e6a544e0c8f16bafced6b3da41db..da3855d08bb3a8cda0ee5f146f5881d5b698c00e 100644 (file)
@@ -57,7 +57,7 @@ public:
        /**
         * progress one frame, handle all network traffic
         */
-       void proceed(double curtime, double deltatime);
+       void proceed(double curtime);
 
        /**
         * add a networkobject to the scene
index 4dee694bcd7ffd3a59d646060c808b91203a81ce..6d4adc961c8f69096e10c0b5ac8a5a359708f3c1 100644 (file)
@@ -19,6 +19,9 @@
  *
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
+#ifdef USE_ODE
+
 #include "OdePhysicsController.h"
 #include "PHY_IMotionState.h"
 
@@ -609,3 +612,4 @@ void ODEPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
 {
 
 }
+#endif
index db7f5f07603fcd01f4b7e18ae8934f14d0621c09..54574f9fc55622e817e2d52d2bc7bbe6841eb349 100644 (file)
@@ -227,6 +227,7 @@ public:
 
        SM_Object *getDynamicParent() ;
 
+       void beginFrame();
        void integrateForces(MT_Scalar timeStep);
        void integrateMomentum(MT_Scalar timeSteo);
 
index 7afa2a590843e64b78dc4813a11b650a9213eb4e..1c11df66c3866b8c0ee2dfe10b6ebad027bf9fbb 100644 (file)
@@ -107,7 +107,7 @@ public:
        // The maximum time interval between two collision checks.
        // 'subSampling' can be used to control aliasing effects
        // (fast moving objects traversing through walls and such). 
-       void proceed(MT_Scalar timeStep, MT_Scalar subSampling);
+       void proceed(MT_Scalar curtime, MT_Scalar ticrate);
 
        /**
         * Test whether any objects lie on the line defined by from and
@@ -178,6 +178,8 @@ private:
         * timestep. The list is built during the proceed(). During that
         * time, it is not valid. */
        T_PairList          m_pairList;
+       
+       MT_Scalar           m_lastTime;
 };
 
 #endif
index 613212b642a1e01473f366741d846645f38eab0f..940f0d221a0d5e14477312114172db59eefe6b5c 100644 (file)
@@ -101,15 +101,23 @@ SM_Object::SM_Object(
        m_suspended = false;
 }
 
-       void 
+       void
 SM_Object::
-integrateForces(
-       MT_Scalar timeStep
+beginFrame(
 ){
        if (!m_suspended) {
                m_prev_state = *this;
                m_prev_state.setLinearVelocity(actualLinVelocity());
                m_prev_state.setAngularVelocity(actualAngVelocity());
+       }
+}
+
+       void 
+SM_Object::
+integrateForces(
+       MT_Scalar timeStep
+){
+       if (!m_suspended) {
                if (isDynamic()) {
                        // Integrate momentum (forward Euler)
                        m_lin_mom += m_force * timeStep;
@@ -447,7 +455,8 @@ DT_Bool SM_Object::fix(
        // Get collision data from SOLID
        MT_Vector3 normal(local2 - local1);
        
-       if (normal.dot(normal) < MT_EPSILON)
+       MT_Scalar dist = normal.dot(normal);
+       if (dist < MT_EPSILON || dist > obj2->m_shapeProps->m_radius*obj2->m_shapeProps->m_radius)
                return DT_CONTINUE;
                
        // This distinction between dynamic and non-dynamic objects should not be 
index 8034cfdc86dcf179a02858f5413332068e681a1e..aee0f1470fe300792f6522c09d027410241ba891 100644 (file)
@@ -53,7 +53,8 @@ SM_Scene::SM_Scene() :
        m_respTable(DT_CreateRespTable()),
        m_secondaryRespTable(DT_CreateRespTable()),
        m_fixRespTable(DT_CreateRespTable()),
-       m_forceField(0.0, 0.0, 0.0)
+       m_forceField(0.0, 0.0, 0.0),
+       m_lastTime(-1.0)
 {
        for (int i = 0 ; i < NUM_RESPONSE; i++)
        {
@@ -158,20 +159,43 @@ void SM_Scene::remove(SM_Object& object) {
                // tried to remove an object that is not in the scene
                //assert(false);
        }
-}      
-
-void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
-       // Don't waste time...but it's OK to spill a little.
-       //if (timeStep < 0.001)
-       //      return;
+}
 
+void SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate) {
+       if (m_lastTime < 0.0)
+       {
+               m_lastTime = curtime;
+               return;
+       }
+               
        // Divide the timeStep into a number of subsamples of size roughly 
-       // equal to subSampling (might be a little smaller).
-       int num_samples = (int)ceil(timeStep / subSampling);
-
-       MT_Scalar subStep = timeStep / num_samples;
+       // equal to subS (might be a little smaller).
+       MT_Scalar timeStep = curtime - m_lastTime;
+       MT_Scalar subStep = 1.0/ticrate;
+       int num_samples = int(timeStep * ticrate);
+       
        T_ObjectList::iterator i;
+       
+       // No timestep! (should do a mini update)
+       if (!num_samples)
+       {
+               // Apply a forcefield (such as gravity)
+#if 0
+               for (i = m_objectList.begin(); i != m_objectList.end(); ++i) 
+               {
+                       //(*i)->applyForceField(m_forceField);
+                       //(*i)->integrateForces(timeStep);
+                       // And second we update the object positions by performing
+                       // an integration step for each object
+                       (*i)->integrateMomentum(timeStep);
+                       //(*i)->clearForce();
+               }
+#endif
+               return; 
+       }
 
+       m_lastTime += MT_Scalar(num_samples)*subStep;
+       
        // Apply a forcefield (such as gravity)
        for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
                (*i)->applyForceField(m_forceField);
@@ -183,6 +207,7 @@ void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
        for (step = 0; step != num_samples; ++step) {
 
                for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
+                       (*i)->beginFrame();
                        (*i)->integrateForces(subStep);
                        // And second we update the object positions by performing
                        // an integration step for each object
@@ -210,7 +235,6 @@ void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
        
        // Finish this timestep by saving al state information for the next
        // timestep and clearing the accumulated forces. 
-
        for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
                (*i)->relax();
                (*i)->proceedKinematic(timeStep);
index 87513f1a18cf524bbef058ba409c03a98acdff8a..5301e125ce10c43957c70d6e01191c522f9285dc 100644 (file)
@@ -83,7 +83,7 @@ float SumoPhysicsController::getMass()
        return 0.f;
 }
 
-bool SumoPhysicsController::SynchronizeMotionStates(float time)
+bool SumoPhysicsController::SynchronizeMotionStates(float)
 {
        if (m_bFirstTime)
        {
@@ -370,12 +370,12 @@ void              SumoPhysicsController::PostProcessReplica(class PHY_IMotionState* motionst
        m_sumoScene->add(* (m_sumoObj));
 }
 
-void                   SumoPhysicsController::SetSimulatedTime(float time)
+void                   SumoPhysicsController::SetSimulatedTime(float)
 {
 }
        
        
-void   SumoPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
+void   SumoPhysicsController::WriteMotionStateToDynamics(bool)
 {
 
 }
index 0eb50b8134bbee8fe3b44999e96b90913d176a8a..151c55d75de8fd74c1347d581c1e41bd4262ddea 100644 (file)
@@ -38,7 +38,7 @@
 #include <config.h>
 #endif
 
-MT_Scalar SumoPhysicsEnvironment::UpperBoundForFuzzicsIntegrator = 0.01;
+MT_Scalar SumoPhysicsEnvironment::PhysicsTicRate = 60.0;
 
 SumoPhysicsEnvironment::SumoPhysicsEnvironment()
 {
@@ -52,9 +52,19 @@ SumoPhysicsEnvironment::~SumoPhysicsEnvironment()
        delete m_sumoScene;
 }
 
-void SumoPhysicsEnvironment::proceed(double timeStep)
+void SumoPhysicsEnvironment::setTicRate(MT_Scalar ticrate)
 {
-       m_sumoScene->proceed(timeStep,UpperBoundForFuzzicsIntegrator);
+       PhysicsTicRate = ticrate;
+}
+
+MT_Scalar SumoPhysicsEnvironment::getTicRate()
+{
+       return PhysicsTicRate;
+}
+
+void SumoPhysicsEnvironment::proceed(double curtime)
+{
+       m_sumoScene->proceed(curtime, PhysicsTicRate);
 }
 
 void SumoPhysicsEnvironment::setGravity(float x,float y,float z)
index 991d18cd8b3c5f9bbdf16af7259deb7f35b87cd5..09ffe6ce112b7004b349cd183ea8dfd6be8067eb 100644 (file)
@@ -49,7 +49,7 @@ public:
        SumoPhysicsEnvironment();
        virtual         ~SumoPhysicsEnvironment();
 // Perform an integration step of duration 'timeStep'.
-       virtual void            proceed(double  timeStep);
+       virtual void            proceed(double curtime);
        virtual void            setGravity(float x,float y,float z);
        virtual int             createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                        float pivotX,float pivotY,float pivotZ,
@@ -59,7 +59,8 @@ public:
        virtual PHY_IPhysicsController* rayTest(void* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ, 
                                                                        float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
 
-
+       static void setTicRate(MT_Scalar ticrate);
+       static MT_Scalar getTicRate();
        // sumo specific
        SM_Scene* GetSumoScene()
        {
@@ -67,8 +68,8 @@ public:
        }
 
 protected:
-       // At least 100Hz (isn't this CPU hungry ?)
-       static MT_Scalar UpperBoundForFuzzicsIntegrator;
+       // 60Hz (Default)
+       static MT_Scalar PhysicsTicRate;
 
 };
 
index 6ccbce004f53a27cc1c29c9ba1ff5d8e15022a75..09780c94e83053e4d460ae1dbeca3c9bad954a26 100644 (file)
@@ -183,4 +183,38 @@ def stopDSP():
        Only the fmod sound driver supports this.
        DSP can be computationally expensive.
        """
+def getLogicTicRate():
+       """
+       Gets the logic update frequency.
+       
+       @return: The logic frequency in Hz
+       @rtype: float
+       """
+def setLogicTicRate(ticrate):
+       """
+       Sets the logic update frequency.
+       
+       The logic update frequency is the number of times logic bricks are executed every second.
+       The default is 30 Hz.
+       
+       @param ticrate: The new logic update frequency (in Hz).
+       @type ticrate: float
+       """
+def getPhysicsTicRate():
+       """
+       Gets the physics update frequency
+       
+       @return: The physics update frequency in Hz
+       @rtype: float
+       """
+def setPhysicsTicRate(ticrate):
+       """
+       Sets the physics update frequency
+       
+       The physics update frequency is the number of times the physics system is executed every second.
+       The default is 60 Hz.
+       
+       @param ticrate: The new update frequency (in Hz).
+       @type ticrate: float
+       """
 
index 7d6d1ee60df27ae7d65c63fc637ec1f8ac31410b..44f9e051c8cfda9e815416c57b16ba43d612e87f 100644 (file)
@@ -17,7 +17,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
                """
                Sets the game object to add.
                
-               A copy of the object will be added to the scene.
+               A copy of the object will be added to the scene when the actuator is activated.
                
                If the object does not exist, this function is ignored.
                
@@ -37,6 +37,8 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
                """
                Sets the lifetime of added objects, in frames.
                
+               If time == 0, the object will last forever.
+               
                @type time: integer
                @param time: The minimum value for time is 0.
                """
index 6defe6a28a3c09f5d485c7175a15464b743159cb..ea09fcaea376975ee490abb028bf9c7c86f9a7be 100644 (file)
@@ -17,6 +17,9 @@ class SCA_ILogicBrick:
                """
                Sets the priority of this logic brick.
                
+               This determines the order controllers are evaluated, and actuators are activated.
+               Bricks with lower priority will be executed first.
+               
                @type priority: integer
                @param priority: the priority of this logic brick.
                """
index 5e16f08375fa07bf42d9e53d8342d8a7e150ec3d..777c87a2f48dfe3dda4ae424111dede8c708792d 100644 (file)
@@ -5,6 +5,10 @@ New Python Functionality in this Version of Blender
 
 This document lists what has been changed in the Game Engine Python API.
 
+Blender CVS
+------------
+       - Added tic rate methods to L{GameLogic}
+
 Blender 2.34
 ------------
 
index 1a3f40491f7af1ab8930f6b2bd1f72171a229db4..8b949ac57b68bf8684f534a5ee5c5800c870efac 100644 (file)
@@ -454,7 +454,7 @@ void RAS_OpenGLRasterizer::SetEye(StereoEye eye)
                                m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER);
                                glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_FALSE);
                        } else {
-                               glAccum(GL_LOAD, 1.0);
+                               //glAccum(GL_LOAD, 1.0);
                                glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
                                ClearDepthBuffer();
                        }
index a91b462b3ae9b9d386b85d233029197944db5354..6ad5cf9912a8ca9728034b6a98598d82cafcf3d5 100644 (file)
@@ -47,15 +47,18 @@ SG_Spatial(
 ): 
 
        SG_IObject(clientobj,clientinfo,callbacks),
-       m_localPosition(MT_Point3(0,0,0)),
-       m_localRotation(1,0,0,0,1,0,0,0,1),
+       m_localPosition(MT_Point3(0.0,0.0,0.0)),
+       m_localRotation(MT_Matrix3x3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)),
        m_localScaling(MT_Vector3(1.f,1.f,1.f)),
        
-       m_worldPosition(MT_Point3(0,0,0)),
-       m_worldRotation(0,0,0,0,0,0,0,0,0),
+       m_worldPosition(MT_Point3(0.0,0.0,0.0)),
+       m_worldRotation(MT_Matrix3x3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)),
        m_worldScaling(MT_Vector3(1.f,1.f,1.f)),
 
-       m_parent_relation (NULL)
+       m_parent_relation (NULL),
+       
+       m_bbox(MT_Point3(-1.0, -1.0, -1.0), MT_Point3(1.0, 1.0, 1.0)),
+       m_radius(1.0)
 {
 }
 
@@ -302,7 +305,9 @@ void SG_Spatial::SetBBox(SG_BBox& bbox)
 
 MT_Transform SG_Spatial::GetWorldTransform() const
 {
-       return MT_Transform(m_worldPosition, m_worldRotation.scaled(m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]));
+       return MT_Transform(m_worldPosition, 
+               m_worldRotation.scaled(
+               m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]));
 }
 
 bool SG_Spatial::inside(const MT_Point3 &point) const