Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp24
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp10
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h2
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp41
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h4
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp12
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.cpp10
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.h3
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h4
-rw-r--r--source/gameengine/GameLogic/SCA_IInputDevice.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_IInputDevice.h2
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.h3
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.cpp20
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.h4
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h22
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.cpp2
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.h2
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp7
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h4
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp2
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h2
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_CDActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_CDActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.h11
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp7
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.cpp385
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.h16
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp342
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h18
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp44
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.h2
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h8
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.h2
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.h5
-rw-r--r--source/gameengine/Network/NG_NetworkScene.cpp2
-rw-r--r--source/gameengine/Network/NG_NetworkScene.h2
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.cpp4
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h1
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h4
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp17
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp48
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.cpp6
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp16
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h9
-rw-r--r--source/gameengine/PyDoc/GameLogic.py34
-rw-r--r--source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py4
-rw-r--r--source/gameengine/PyDoc/SCA_ILogicBrick.py3
-rw-r--r--source/gameengine/PyDoc/WhatsNew.py4
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp2
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.cpp17
88 files changed, 770 insertions, 561 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 6f609b01d2f..f0eb36107e8 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -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)
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
index b128d616209..c6ae91ae282 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
@@ -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;
+}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
index 33809f039fa..932751c37eb 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
@@ -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
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 52b948b18f1..5206f33ccd7 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -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;
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index ca1f937cbd4..bf030b5861f 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -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;
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index ec9a70fccb1..aa57e883f71 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -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,
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
index 18423c4171f..c4b5b8197a7 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
@@ -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++)
{
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
index 6ac00515a0e..bffd21da74c 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
+++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
@@ -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);
diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp
index 468d9a8c381..cf4af636290 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_EventManager.cpp
@@ -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()
{
diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h
index 67908b9d5c7..92bda9df170 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.h
+++ b/source/gameengine/GameLogic/SCA_EventManager.h
@@ -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();
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
index 31e6d3fdb10..322936c7819 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_IActuator.cpp
@@ -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()
{
diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h
index 6b3d1007079..e58ac74dacf 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.h
+++ b/source/gameengine/GameLogic/SCA_IActuator.h
@@ -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.
diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.cpp b/source/gameengine/GameLogic/SCA_IInputDevice.cpp
index d73549b8818..87d161ecabc 100644
--- a/source/gameengine/GameLogic/SCA_IInputDevice.cpp
+++ b/source/gameengine/GameLogic/SCA_IInputDevice.cpp
@@ -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)
{
diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h
index b2ed8686b43..6dee608a568 100644
--- a/source/gameengine/GameLogic/SCA_IInputDevice.h
+++ b/source/gameengine/GameLogic/SCA_IInputDevice.h
@@ -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
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
index 039f0c14801..cd7e07a7e81 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
@@ -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;
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h
index fcdb8ed5c4e..562f28417ad 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h
@@ -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();
};
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index 1eee83ad3d6..fb8c340b09e 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -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;
}
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp
index 62b532ee5a0..0829fb0657b 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.cpp
+++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp
@@ -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);
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h
index 4447104a0a2..7af1190f03b 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.h
+++ b/source/gameengine/GameLogic/SCA_LogicManager.h
@@ -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);
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp
index 96abe2c9135..e4d54c94395 100644
--- a/source/gameengine/GameLogic/SCA_MouseManager.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp
@@ -74,7 +74,7 @@ SCA_IInputDevice* SCA_MouseManager::GetInputDevice()
-void SCA_MouseManager::NextFrame(double curtime,double deltatime)
+void SCA_MouseManager::NextFrame()
{
if (m_mousedevice)
{
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h
index 4c8fe102bfe..e98405b1b7d 100644
--- a/source/gameengine/GameLogic/SCA_MouseManager.h
+++ b/source/gameengine/GameLogic/SCA_MouseManager.h
@@ -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();
};
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index c416d8e1dd5..a39e59fe451 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -58,7 +58,7 @@ SCA_PropertyActuator::~SCA_PropertyActuator()
{
}
-bool SCA_PropertyActuator::Update(double curtime,double deltatime)
+bool SCA_PropertyActuator::Update()
{
bool result = false;
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index 2fdf1a62559..cdcda7a84e0 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -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 ---------------------------------------------------- */
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
index 4b81b0e4124..4ac3d162229 100644
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
@@ -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++)
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h
index dccaa6b52fe..664beb68695 100644
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h
+++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h
@@ -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;}
};
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index b4a28291e66..da6fe06a708 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -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();
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
index 1048790c9b6..4be7f2dbe9e 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.h
@@ -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();
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
index 17cfa351994..6bf10a83f55 100644
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
@@ -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++)
{
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h
index f0832044042..17b2894434d 100644
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.h
+++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h
@@ -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);
};
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
index 05d1bebf18a..d97727d2a33 100644
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
@@ -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);
}
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h
index fb2f1cee970..388d9ce53bd 100644
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.h
+++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h
@@ -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);
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
index 71e20bfe35d..6b6f619f820 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
@@ -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;
+}
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
index 678200b62d9..da3dc2398dd 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
@@ -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
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 ---------------------------------------------------- */
diff --git a/source/gameengine/Network/NG_NetworkScene.cpp b/source/gameengine/Network/NG_NetworkScene.cpp
index e24fade91f8..b867791e12d 100644
--- a/source/gameengine/Network/NG_NetworkScene.cpp
+++ b/source/gameengine/Network/NG_NetworkScene.cpp
@@ -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;
diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h
index 4cbdcf7d39a..da3855d08bb 100644
--- a/source/gameengine/Network/NG_NetworkScene.h
+++ b/source/gameengine/Network/NG_NetworkScene.h
@@ -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
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
index 4dee694bcd7..6d4adc961c8 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
+++ b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
@@ -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
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
index db7f5f07603..54574f9fc55 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
@@ -227,6 +227,7 @@ public:
SM_Object *getDynamicParent() ;
+ void beginFrame();
void integrateForces(MT_Scalar timeStep);
void integrateMomentum(MT_Scalar timeSteo);
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
index 7afa2a59084..1c11df66c38 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
@@ -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
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
index 613212b642a..940f0d221a0 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
+++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
@@ -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
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
index 8034cfdc86d..aee0f1470fe 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
+++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
@@ -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);
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
index 87513f1a18c..5301e125ce1 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
@@ -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)
{
}
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
index 0eb50b8134b..151c55d75de 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
@@ -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)
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
index 991d18cd8b3..09ffe6ce112 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
@@ -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;
};
diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py
index 6ccbce004f5..09780c94e83 100644
--- a/source/gameengine/PyDoc/GameLogic.py
+++ b/source/gameengine/PyDoc/GameLogic.py
@@ -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
+ """
diff --git a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
index 7d6d1ee60df..44f9e051c8c 100644
--- a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
+++ b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
@@ -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.
"""
diff --git a/source/gameengine/PyDoc/SCA_ILogicBrick.py b/source/gameengine/PyDoc/SCA_ILogicBrick.py
index 6defe6a28a3..ea09fcaea37 100644
--- a/source/gameengine/PyDoc/SCA_ILogicBrick.py
+++ b/source/gameengine/PyDoc/SCA_ILogicBrick.py
@@ -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.
"""
diff --git a/source/gameengine/PyDoc/WhatsNew.py b/source/gameengine/PyDoc/WhatsNew.py
index 5e16f08375f..777c87a2f48 100644
--- a/source/gameengine/PyDoc/WhatsNew.py
+++ b/source/gameengine/PyDoc/WhatsNew.py
@@ -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
------------
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 1a3f40491f7..8b949ac57b6 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -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();
}
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp
index a91b462b3ae..6ad5cf9912a 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.cpp
+++ b/source/gameengine/SceneGraph/SG_Spatial.cpp
@@ -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