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:
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 /source/gameengine/Converter/KX_BlenderSceneConverter.h
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 'source/gameengine/Converter/KX_BlenderSceneConverter.h')
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
index eddb377dbc7..f7723350eee 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -52,6 +52,7 @@ class BL_InterpolatorList;
class BL_Material;
struct Main;
struct Scene;
+struct ThreadInfo;
class KX_BlenderSceneConverter : public KX_ISceneConverter
{
@@ -61,10 +62,16 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter
vector<pair<KX_Scene*,RAS_MeshObject*> > m_meshobjects;
vector<pair<KX_Scene*,BL_Material *> > m_materials;
+ vector<class KX_LibLoadStatus*> m_mergequeue;
+ ThreadInfo *m_threadinfo;
+
// Cached material conversions
map<struct Material*, BL_Material*> m_mat_cache;
map<struct Material*, RAS_IPolyMaterial*> m_polymat_cache;
+ // Saved KX_LibLoadStatus objects
+ map<char *, class KX_LibLoadStatus*> m_status_map;
+
// Should also have a list of collision shapes.
// For the time being this is held in KX_Scene::m_shapes
@@ -159,13 +166,16 @@ public:
struct Main* GetMainDynamicPath(const char *path);
vector<struct Main*> &GetMainDynamic();
- bool LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
- bool LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
- bool LinkBlendFile(struct BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
+ class KX_LibLoadStatus *LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
+ class KX_LibLoadStatus *LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
+ class KX_LibLoadStatus *LinkBlendFile(struct BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
bool MergeScene(KX_Scene *to, KX_Scene *from);
RAS_MeshObject *ConvertMeshSpecial(KX_Scene* kx_scene, Main *maggie, const char *name);
bool FreeBlendFile(struct Main *maggie);
bool FreeBlendFile(const char *path);
+
+ virtual void MergeAsyncLoads();
+ void AddScenesToMergeQueue(class KX_LibLoadStatus *status);
void PrintStats() {
printf("BGE STATS!\n");
@@ -195,6 +205,7 @@ public:
LIB_LOAD_LOAD_ACTIONS = 1,
LIB_LOAD_VERBOSE = 2,
LIB_LOAD_LOAD_SCRIPTS = 4,
+ LIB_LOAD_ASYNC = 8,
};