I basicaly want to load my models asyncronously.
If I load the model the first time, I can get the loading working like a charm with the code below. But from the second time (when the model is already cached), it hangs the do_frame.
I want it to be cached AND async loaded.
I guess there’s some weird lock when using bamcache that there’s not when using the egg. Ok, the cache loads much faster, but it hangs the screen for the secs (it hangs the movie in my case).
It’s a bug? Am I doing something wrong?
NodePath box = window->load_model(render, "box");
PT(Loader) loader = new Loader("My Async Loader");
LoaderOptions options;
PT(ModelLoadRequest) request = new ModelLoadRequest("MyPandaModel", "ModelWithHeavyTexture.egg", options, loader);
loader->load_async(request);
/* Until here is all instantly */
bool loaded = false;
NodePath my_model;
while(!loaded){
nout << "Before do_frame" << endl;
/* Placeholder loader screen */
box.set_x(box, 2 * ClockObject::get_global_clock()->get_dt());
/* Here it hangs when reading from cache */
framework.do_frame(current_thread);
nout << "After do frame" << endl;
if(request->is_ready()){
my_model = NodePath(request->get_model());
my_model.reparent_to(render);
loaded = true;
}
}
framework.main_loop();