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
diff options
context:
space:
mode:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-11-06 15:31:56 +0300
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-11-06 15:31:56 +0300
commitcf407da71903b513ba5a9ea85fdb2a6037dc2c3c (patch)
tree47ad500c3b10df4604c1f1fbf55b26d6bae80ea1 /source/gameengine/Ketsji/KX_KetsjiEngine.cpp
parent38b993f787b1694957f7c9876189f8ef9e346515 (diff)
Reorder update: do physics before logic, so logic doesn't get stale position data (eg for camera actuator)
Diffstat (limited to 'source/gameengine/Ketsji/KX_KetsjiEngine.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 04777bf4a36..6c347b88f7d 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -317,7 +317,7 @@ void KX_KetsjiEngine::NextFrame()
double curtime;
double localtime = m_previoustime;
if (m_bFixedTime)
- curtime = m_previoustime + m_deltatime;
+ curtime = m_previoustime + 0.1/m_ticrate;
else
curtime = m_kxsystem->GetTimeInSeconds();
m_deltatime += curtime - m_previoustime;
@@ -325,8 +325,6 @@ void KX_KetsjiEngine::NextFrame()
// 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;
@@ -344,14 +342,6 @@ void KX_KetsjiEngine::NextFrame()
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
PHY_SetActiveScene(scene);
- // 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);
@@ -360,6 +350,14 @@ void KX_KetsjiEngine::NextFrame()
// into node positions.
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
scene->UpdateParents(curtime);
+
+ // 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);
} // suspended
DoSound(scene);
@@ -396,6 +394,15 @@ void KX_KetsjiEngine::NextFrame()
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
PHY_SetActiveScene(scene);
+ // 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);
+
// Process sensors, and controllers
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
scene->LogicBeginFrame(curtime);
@@ -415,15 +422,6 @@ void KX_KetsjiEngine::NextFrame()
// 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);