diff options
Diffstat (limited to 'source/gameengine/Ketsji')
39 files changed, 506 insertions, 423 deletions
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp index ad2f786a328..93c7ab37edb 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp @@ -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 diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h index 75715f5569c..9c0d14674c1 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h @@ -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; } diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index 23bc35fdeac..e142d2a1a1b 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -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(); diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h index cec3b27c4a6..c81437dbd91 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h @@ -57,7 +57,7 @@ public: PyTypeObject* T=&Type); virtual ~KX_NetworkMessageActuator(); - virtual bool Update(double curtime, double deltatime); + virtual bool Update(); virtual CValue* GetReplica(); /* ------------------------------------------------------------ */ diff --git a/source/gameengine/Ketsji/KX_CDActuator.cpp b/source/gameengine/Ketsji/KX_CDActuator.cpp index efa7fb73ba5..b4a7763763a 100644 --- a/source/gameengine/Ketsji/KX_CDActuator.cpp +++ b/source/gameengine/Ketsji/KX_CDActuator.cpp @@ -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(); diff --git a/source/gameengine/Ketsji/KX_CDActuator.h b/source/gameengine/Ketsji/KX_CDActuator.h index 3e76db56264..db6dc1e3475 100644 --- a/source/gameengine/Ketsji/KX_CDActuator.h +++ b/source/gameengine/Ketsji/KX_CDActuator.h @@ -76,7 +76,7 @@ public: ~KX_CDActuator(); - bool Update(double curtime,double deltatime); + virtual bool Update(); CValue* GetReplica(); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 478bf388fb1..f96276c37f1 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -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; diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index cb061206a21..68bc91694e7 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -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 ); diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index b60841e8634..c53749131c0 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -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, diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index c1c58b3b664..dfd39f1455c 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -87,7 +87,7 @@ protected: return replica; }; - virtual bool Update(double curtime,double deltatime); + virtual bool Update(double curtime, bool frame); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 2cd7e4db518..ada6e3eda0d 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -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(); diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 19908a37e54..5da10576dde 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -72,7 +72,7 @@ protected: virtual CValue* GetReplica(); - virtual bool Update(double curtime,double deltatime); + virtual bool Update(); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 7a894db6647..6234a5809f2 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -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: */ diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index e2f877c7f7c..cdc815dff7b 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -40,20 +40,30 @@ 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 ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index f257b8dfb73..fbe2fd9c6cd 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -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) { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 79baf09f597..9a6f18a5c5f 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -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. diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 04385859994..74f3dd1ef3b 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -68,7 +68,7 @@ KX_ObjectActuator( { } -bool KX_ObjectActuator::Update(double curtime,double deltatime) +bool KX_ObjectActuator::Update() { bool bNegativeEvent = IsNegativeEvent(); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index 92365eba3ca..1ef3e34625a 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -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(); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 3d6995ab4e0..ba466f20f64 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -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 } }; diff --git a/source/gameengine/Ketsji/KX_RayEventManager.cpp b/source/gameengine/Ketsji/KX_RayEventManager.cpp index ca16ceb015b..0fb1cee6446 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.cpp +++ b/source/gameengine/Ketsji/KX_RayEventManager.cpp @@ -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++) { diff --git a/source/gameengine/Ketsji/KX_RayEventManager.h b/source/gameengine/Ketsji/KX_RayEventManager.h index 7acc0b04ded..8aa1ed990cd 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.h +++ b/source/gameengine/Ketsji/KX_RayEventManager.h @@ -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); }; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index d972d880070..3df0092dfb5 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -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(); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index d9f82e7251e..2a7c27669fa 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -92,11 +92,8 @@ public: GetReplica( ) ; - bool - Update( - double curtime, - double deltatime - ); + virtual bool + Update(); virtual PyObject* _getattr( diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index e91f0b86b71..11d2a895ce9 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -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(); diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h index 3b6e340f872..ca77d80027d 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h @@ -60,11 +60,8 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator GetReplica( ); - bool - Update( - double curtime, - double deltatime - ); + virtual bool + Update(); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 84e12ac86af..742bcd43607 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -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(); diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index e38cf412539..c1b1fd6735d 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -69,11 +69,8 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator GetReplica( ); - bool - Update( - double curtime, - double deltatime - ); + virtual bool + Update(); virtual PyObject* _getattr( diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index c44c9413538..f10ea902c96 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 9e6909168cb..2f867c28c40 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -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; diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index ddd0672b2fe..60e5195534b 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -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(); diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 76039fcf436..6416e0f48d0 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -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 ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index e71902519f3..267bb414c13 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -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! diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index dcb46f1b5d0..796e202df70 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -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(); diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 2186c442f32..704d949b0e7 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -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) { diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h index 4439ba6f3bd..923ecd10884 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.h +++ b/source/gameengine/Ketsji/KX_TouchEventManager.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 6880ac5d683..2c4d02854ad 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -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; } diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index 817bb4a8cfa..6b0ddd7103e 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index dc0178976fa..8ec3e05e303 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -69,10 +69,7 @@ KX_VisibilityActuator::GetReplica( } bool -KX_VisibilityActuator::Update( - double curtime, - double deltatime - ) +KX_VisibilityActuator::Update() { bool bNegativeEvent = IsNegativeEvent(); diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h index 9d5d38666f1..9a78eb1cc07 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.h +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h @@ -62,10 +62,7 @@ class KX_VisibilityActuator : public SCA_IActuator ); virtual bool - Update( - double curtime, - double deltatime - ); + Update(); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ |