blender/source/gameengine/Ketsji
Arnaud Degroote aae93ae4c6 BGE: Improve clock management
This patch improves clock management in BGE, to be able to accelerate /
slow the time, and also to finely synchronize clock with external
engines. Several new python functions have been added and existence ones
have been improved for that purpose. Now we have:

- getClockTime(): Get the current BGE render time, in seconds. The BGE
render time is the simulation time corresponding to the next scene that
will be rendered.

- getFrameTime(): Get the current BGE frame time, in seconds. The BGE
frame time is the simulation time corresponding to the current call of
the logic system. Generally speaking, it is what the user is interested
in.

- getRealTime(): Get the number of real (system-clock) seconds elapsed
since the beginning of the simulation.

- getTimeScale(): Get the time multiplier between real-time and
simulation time. The default value is 1.0. A value greater than 1.0
means that the simulation is going faster than real-time, a value lower
than 1.0 means that the simulation is going slower than real-time.

- setTimeScale(time_scale): Set the time multiplier between real-time
and simulation time. A value greater than 1.0 means that the simulation
is going faster than real-time, a value lower than 1.0 means that the
simulation is going slower than real-time. Note that a too large value
may lead to some physics instabilities.

- getUseExternalClock(): Get if the BGE use the inner BGE clock, or rely
or on an external clock. The default is to use the inner BGE clock.

- setUseExternalClock(use_external_clock): Set if the BGE use the inner
BGE clock, or rely or on an external clock. If the user selects the use
of an external clock, he should call regularly the setClockTime method.

- setClockTime(new_time): Set the next value of the simulation clock. It
is preferable to use this method from a custom main function in python,
as calling it in the logic block can easily lead to a blocked system (if
the time does not advance enough to run at least the next logic step).

Rationale are described more precisely in the thread
http://lists.blender.org/pipermail/bf-gamedev/2013-November/000165.html.

See also T37640

Reviewers: sybren, panzergame, #game_engine, lordloki, moguri

Reviewed By: sybren, panzergame, #game_engine, lordloki, moguri

Subscribers: moguri, hg1, sybren, panzergame, dfelinto, lordloki

Projects: #game_engine

Maniphest Tasks: T37640

Differential Revision: https://developer.blender.org/D728
2015-12-12 02:46:53 +01:00
..
KXNetwork BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
BL_Action.cpp BGE: Fix T45945: Action bouncing. 2015-10-28 15:13:12 +01:00
BL_Action.h BGE: Fix T45945: Action bouncing. 2015-10-28 15:13:12 +01:00
BL_ActionManager.cpp BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
BL_ActionManager.h BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
BL_BlenderShader.cpp OpenGL: split off framebuffer, shader and texture code into separate files. 2015-12-08 19:00:56 +01:00
BL_BlenderShader.h Fix a few compiler warnings reported by clang. 2013-08-18 14:15:51 +00:00
BL_Material.cpp Move from MTFace to MTexPoly w/ texture checks 2015-07-14 22:36:00 +10:00
BL_Material.h Move from MTFace to MTexPoly w/ texture checks 2015-07-14 22:36:00 +10:00
BL_Shader.cpp BGE code cleanup: Removing RAS_GLExtensionManager. 2015-12-07 19:25:12 -08:00
BL_Shader.h BGE: Cleanup: Code style BL_Shader 2015-10-25 19:43:46 +01:00
BL_Texture.cpp OpenGL: remove non-power-of-two texture check, where even ES 2.0 does not need it. 2015-12-08 18:58:52 +01:00
BL_Texture.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
CMakeLists.txt BGE: Remove KX_IPOActuator. 2015-11-03 10:31:08 +01:00
KX_ArmatureSensor.cpp style cleanup 2013-03-18 11:44:56 +00:00
KX_ArmatureSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_BlenderMaterial.cpp BGE code cleanup: Removing RAS_GLExtensionManager. 2015-12-07 19:25:12 -08:00
KX_BlenderMaterial.h Move from MTFace to MTexPoly w/ texture checks 2015-07-14 22:36:00 +10:00
KX_Camera.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_Camera.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_CameraActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_CameraActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_CameraIpoSGController.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_CameraIpoSGController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_CharacterWrapper.cpp BGE: Adding a Max Jumps value to the character physic window 2015-10-11 18:28:43 +02:00
KX_CharacterWrapper.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ClientObjectInfo.h BGE: Fix T35288 Touch/Ray/Mouse sensor and Constraint actuator with material check doesn't work. 2015-07-25 09:43:06 +02:00
KX_ConstraintActuator.cpp BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_ConstraintActuator.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_ConstraintWrapper.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ConstraintWrapper.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_Dome.cpp BGE: Fix T45110, T44174, armature animations update and mirror render. 2015-06-22 18:16:31 +02:00
KX_Dome.h Ghost Context Refactor 2014-10-07 15:47:32 -05:00
KX_EmptyObject.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_EmptyObject.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_FontObject.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_FontObject.h fix D1130 renamed the enum OBJ_FONT to OBJ_TEXT to avoid naming conflicts in Windows 2015-03-16 18:46:40 +01:00
KX_GameActuator.cpp BGE: Adding a screenshot function to game actuator 2015-10-11 13:41:38 +02:00
KX_GameActuator.h BGE: Adding a screenshot function to game actuator 2015-10-11 13:41:38 +02:00
KX_GameObject.cpp BGE: Fix ray cast with unfound property. 2015-11-26 19:54:27 +01:00
KX_GameObject.h BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
KX_IInterpolator.h style cleanup 2012-09-16 04:58:18 +00:00
KX_IPO_SGController.cpp BGE: Fix T38986: Start object position not initialized in IPO. 2015-10-29 18:44:09 +01:00
KX_IPO_SGController.h BGE: Cleanup KX_IPO_SGCOntroller. 2015-10-29 17:24:35 +01:00
KX_IpoConvert.cpp BGE: Adding material IPO support to GLSL materials 2015-05-11 23:05:04 -07:00
KX_IpoConvert.h BGE: Fix T27322: World F-Curve 2015-03-23 21:43:42 +01:00
KX_IPOTransform.h style cleanup 2012-10-29 02:11:40 +00:00
KX_IScalarInterpolator.h style cleanup 2012-09-16 04:58:18 +00:00
KX_ISceneConverter.h BGE: Fix issues with async libload. 2015-10-25 19:22:29 +01:00
KX_ISystem.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_KetsjiEngine.cpp BGE: Improve clock management 2015-12-12 02:46:53 +01:00
KX_KetsjiEngine.h BGE: Improve clock management 2015-12-12 02:46:53 +01:00
KX_Light.cpp BGE : addObject in python without reference object. 2015-04-26 16:29:58 +02:00
KX_Light.h BGE : addObject in python without reference object. 2015-04-26 16:29:58 +02:00
KX_LightIpoSGController.cpp BGE code cleanup: Removing OpenGL and bf_gpu code from KX_LightObject 2014-03-27 22:32:06 -07:00
KX_LightIpoSGController.h Code cleanup: RAS_ILightObject is class, not a struct. 2014-04-12 20:12:07 +02:00
KX_MaterialIpoController.cpp BGE: Adding material IPO support to GLSL materials 2015-05-11 23:05:04 -07:00
KX_MaterialIpoController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_MeshProxy.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_MeshProxy.h style cleanup 2013-03-29 06:21:28 +00:00
KX_MotionState.cpp BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_MotionState.h BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_MouseActuator.cpp Fix for building without Python 2015-06-14 04:53:10 +10:00
KX_MouseActuator.h Fix for building without Python 2015-06-14 04:53:10 +10:00
KX_MouseFocusSensor.cpp BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_MouseFocusSensor.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_NavMeshObject.cpp BGE: Navmesh fixes and improvements 2015-07-28 13:54:41 +02:00
KX_NavMeshObject.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_NearSensor.cpp Fix T38539: Can't set near sensor distance above 100 via python 2014-02-22 13:57:12 +11:00
KX_NearSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_ObColorIpoSGController.cpp BGE: Object color channels can now be animated separately without zeroing out the other channels. Problem reported by Dalai via IRC. 2013-02-23 01:17:01 +00:00
KX_ObColorIpoSGController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_ObjectActuator.cpp BGE: allow setting velocity to zero in a motion actuator. 2015-11-10 13:39:20 +01:00
KX_ObjectActuator.h BGE: Fix: Double jumps are not working with character motion actuator 2015-05-14 09:45:51 +02:00
KX_ObstacleSimulation.cpp fix memory leak in KX_ObstacleSimulation 2013-08-04 17:20:03 +00:00
KX_ObstacleSimulation.h style cleanup 2012-09-16 04:58:18 +00:00
KX_OrientationInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_OrientationInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_ParentActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ParentActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_PhysicsEngineEnums.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_PolyProxy.cpp BGE: Fix T38030: wrong vertex index returned by KX_PolyProxy 2015-06-20 14:21:31 +02:00
KX_PolyProxy.h code cleanup: remove unused define, correct header guard mismatch, add NULL check so DM_to_mesh() can have a NULL object passed (currently not used) and remove redundant NULL check. 2013-08-03 23:58:17 +00:00
KX_PositionInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_PositionInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_PyConstraintBinding.cpp BGE: Fix memory leak and crash with certain physic types 2015-08-16 11:38:25 +02:00
KX_PyConstraintBinding.h BGE: python API cleanup - bge submodules definitions 2015-02-03 15:32:54 +00:00
KX_PyMath.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_PyMath.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_PythonInit.cpp BGE: Improve clock management 2015-12-12 02:46:53 +01:00
KX_PythonInit.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_PythonInitTypes.cpp BGE: Remove KX_IPOActuator. 2015-11-03 10:31:08 +01:00
KX_PythonInitTypes.h Recreating bge python modules instead of using existing 2015-02-09 20:56:38 +00:00
KX_PythonMain.cpp code cleanup: remove $Id's that crept back in, also osl style edits 2012-10-23 11:47:23 +00:00
KX_PythonMain.h Fix T37488: Crash with --debug reading userpref.blend 2013-11-18 18:13:23 +06:00
KX_RadarSensor.cpp BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_RadarSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_RayCast.cpp BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_RayCast.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_RayEventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_RayEventManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_RaySensor.cpp BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_RaySensor.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_SCA_AddObjectActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_SCA_AddObjectActuator.h style cleanup: trailing tabs & expand some non prefix tabs into spaces. 2012-10-21 05:46:41 +00:00
KX_SCA_DynamicActuator.cpp BGE: Fix T19377 restore dynamics after unparenting object. 2015-08-10 17:08:11 +02:00
KX_SCA_DynamicActuator.h BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_SCA_EndObjectActuator.cpp code cleanup: some warnings and formatting for PyMethodDef's in the BGE. 2012-11-10 05:42:50 +00:00
KX_SCA_EndObjectActuator.h style cleanup: also correct some doxy comments 2012-08-18 13:07:48 +00:00
KX_SCA_ReplaceMeshActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_SCA_ReplaceMeshActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_ScalarInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_ScalarInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_ScalingInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_ScalingInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_Scene.cpp BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
KX_Scene.h BGE: Add recursive dupli group deletion 2015-10-11 14:08:38 +02:00
KX_SceneActuator.cpp style cleanup: 2013-03-26 07:29:01 +00:00
KX_SceneActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_SG_BoneParentNodeRelationship.cpp style cleanup 2012-09-16 04:58:18 +00:00
KX_SG_BoneParentNodeRelationship.h style cleanup 2012-09-16 04:58:18 +00:00
KX_SG_NodeRelationships.cpp style cleanup 2012-09-16 04:58:18 +00:00
KX_SG_NodeRelationships.h style cleanup 2012-09-16 04:58:18 +00:00
KX_SoundActuator.cpp Fix T46458: BGE Crash on load 2015-10-13 08:43:41 +11:00
KX_SoundActuator.h Audaspace: fixing problems for the merge to master suggested by Campbell and Sergey. 2015-07-28 14:01:53 +02:00
KX_StateActuator.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_StateActuator.h use __ prefix on header guards to avoid mixing up defines with api functions / classes. 2012-02-23 10:41:31 +00:00
KX_SteeringActuator.cpp Cleanup: style 2015-09-02 18:39:19 +10:00
KX_SteeringActuator.h BGE: Fix T41502 Path following jumping 2015-02-18 23:24:02 +01:00
KX_TimeCategoryLogger.cpp code cleanup: float formatting was confusing in some cases - eg: (0.,0.,0.) 2012-04-11 08:15:13 +00:00
KX_TimeCategoryLogger.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
KX_TimeLogger.cpp code cleanup: float formatting was confusing in some cases - eg: (0.,0.,0.) 2012-04-11 08:15:13 +00:00
KX_TimeLogger.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
KX_TouchEventManager.cpp BGE physics: When colliding, report first contact point to Python 2015-02-08 15:52:13 +01:00
KX_TouchEventManager.h BGE physics: When colliding, report first contact point to Python 2015-02-08 15:52:13 +01:00
KX_TouchSensor.cpp BGE: Fix T35288 Touch/Ray/Mouse sensor and Constraint actuator with material check doesn't work. 2015-07-25 09:43:06 +02:00
KX_TouchSensor.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_TrackToActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_TrackToActuator.h BGE: TrackTo actuator: increasing up & track axis options 2014-07-14 18:30:27 -07:00
KX_VehicleWrapper.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_VehicleWrapper.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_VertexProxy.cpp Revert "BGE : KX_VertexProxy support for more than 2 UV channel." 2015-06-06 13:12:27 -07:00
KX_VertexProxy.h Revert "BGE : KX_VertexProxy support for more than 2 UV channel." 2015-06-06 13:12:27 -07:00
KX_VisibilityActuator.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_VisibilityActuator.h use __ prefix on header guards to avoid mixing up defines with api functions / classes. 2012-02-23 10:41:31 +00:00
KX_WorldInfo.cpp BGE: Change KX_WolrdInfo mathutils vector to color 2015-10-11 18:43:05 +02:00
KX_WorldInfo.h Fix for building with C++ guarded alloc 2015-09-08 19:42:58 +10:00
KX_WorldIpoController.cpp BGE: Fix T27322: World F-Curve 2015-03-23 21:43:42 +01:00
KX_WorldIpoController.h BGE: Fix T27322: World F-Curve 2015-03-23 21:43:42 +01:00
SConscript SCons: Fix for really nasty bug with polluting configuration environment 2015-08-04 18:06:28 +02:00