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/doc
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-12-22 09:38:32 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-12-22 09:38:32 +0400
commit84966c3d0ae2d39fa4e691ed0131d8b94f8785e4 (patch)
tree96f1fbaac1e4b2f151c7726c90b8491a718666c1 /doc
parent8062bcd16f9e91d76dbd074f32b889ce2e0cba84 (diff)
BGE: Committing async LibLoad from Swiss. This does the lib loading in a separate thread to keep the BGE from freezing. Here is an example from the docs:
# Print a message when an async LibLoad is done import bge def finished_cb(status): print("Library (%s) loaded in %.2fms." % (status.libraryName, status.timeTaken)) bge.logic.LibLoad('myblend.blend', 'Scene', async=True).onFinish = finished_cb LibLoad() now returns a KX_LibLoadStatus object for information on the library loading. LibNew() and LibFree() are unaffected by this commit. In other words, the async option only works for LibLoad(). Furthermore it only works for Scenes, not Actions or Meshes.
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/rst/bge.logic.rst10
-rw-r--r--doc/python_api/rst/bge.types.rst38
2 files changed, 46 insertions, 2 deletions
diff --git a/doc/python_api/rst/bge.logic.rst b/doc/python_api/rst/bge.logic.rst
index ee39f7659ca..944b1ca06a0 100644
--- a/doc/python_api/rst/bge.logic.rst
+++ b/doc/python_api/rst/bge.logic.rst
@@ -176,7 +176,7 @@ General functions
Restarts the current game by reloading the .blend file (the last saved version, not what is currently running).
-.. function:: LibLoad(blend, type, data, load_actions=False, verbose=False, load_scripts=True)
+.. function:: LibLoad(blend, type, data, load_actions=False, verbose=False, load_scripts=True, async=False)
Converts the all of the datablocks of the given type from the given blend.
@@ -191,7 +191,13 @@ General functions
:arg verbose: Whether or not to print debugging information (e.g., "SceneName: Scene")
:type verbose: bool
:arg load_scripts: Whether or not to load text datablocks as well (can be disabled for some extra security)
- :type load_scripts: bool
+ :type load_scripts: bool
+ :arg async: Whether or not to do the loading asynchronously (in another thread). Only the "Scene" type is currently supported for this feature.
+ :type async: bool
+
+ :rtype: :class:`bge.types.KX_LibLoadStatus`
+
+ .. note:: Asynchronously loaded libraries will not be available immediately after LibLoad() returns. Use the returned KX_LibLoadStatus to figure out when the libraries are ready.
.. function:: LibNew(name, type, data)
diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst
index 85429a00791..470e1c56bac 100644
--- a/doc/python_api/rst/bge.types.rst
+++ b/doc/python_api/rst/bge.types.rst
@@ -1929,6 +1929,44 @@ Types
:type: boolean
+.. class:: KX_LibLoadStatus(PyObjectPlus)
+
+ An object providing information about a LibLoad() operation.
+
+ .. code-block:: python
+
+ # Print a message when an async LibLoad is done
+ import bge
+
+ def finished_cb(status):
+ print("Library (%s) loaded in %.2fms." % (status.libraryName, status.timeTaken))
+
+ bge.logic.LibLoad('myblend.blend', 'Scene', async=True).onFinish = finished_cb
+
+ .. attribute:: onFinish
+
+ A callback that gets called when the lib load is done.
+
+ :type: callable
+
+ .. attribute:: progress
+
+ The current progress of the lib load as a normalized value from 0.0 to 1.0.
+
+ :type: float
+
+ .. attribute:: libraryName
+
+ The name of the library being loaded (the first argument to LibLoad).
+
+ :type: string
+
+ .. attribute:: timeTaken
+
+ The amount of time, in seconds, the lib load took (0 until the operation is complete).
+
+ :type: float
+
.. class:: KX_LightObject(KX_GameObject)
A Light object.