Jump to content

Is there a synchronous version of the command world_load


photo

Recommended Posts

Command “world_load” seems an asynchronous call. And I want to do something right after this command call.

Is there a synchronous version of this command, so the calling thread would be blocked until the command is finished?

Link to comment

Or is there some kind of "stop- and-waiting" mechanism for asynchronous commands, by which I can wait for an event to make sure the asynchronous command is done.

Link to comment
  • 4 weeks later...
Hello Andrey,

 

I attempt to load a new world and then get the information of the world.

So I put the follow codes into CMySystemLogic::Update() mothed:



int CMySystemLogic::update()
{
......
if (bl)
{
Console::get()->run("world_load ../data/UnigineEng/UnigineEng");
int nNum = Editor::get()->getNumNodes();//nNum is always equal to zero
                bl = FALSE;
}
......
}



 

I do load the world successfully(I can see the objects),but I can't get the currect number of the nodes in the world.

Since the command “world_load” is an asynchronous call,It seems understandable.

 

But when I add the code: "pConsole->flush()" as follows:



Console::get()->run("world_load ../data/UnigineEng/UnigineEng");
Console::get()->flush();
int nNum = Editor::get()->getNumNodes();//nNum is always equal to zero



 

The result turns to the opposite side: I can see nothing from the output window, but I get the currect return of getNumNodes();

 

1>Is it a proper response? what dose "pConsole->flush()" exactly mean?

2>What is the proper way to reach my goal: load a new world and then get the information of the world immediately.

 

Thanks

Link to comment

I try the exact same codes in CMySystemLogic::init() mothed. 

The outcome of the first one without "flush()" is same: loading is successful,but the return number of nodes is NOT correct.

but outcome of the second one with "flush()" is perfect: Both succeeded.  

Link to comment

What I want to figure out is Not only the numble of the nodes but also the further details of the nodes(e.g mesh and verteics).

So I don't think .XML can give me all of them.

Link to comment

I don't think there are some major differences between WorldLogic and SystemLogic. They are at the same thread, aren't they?

 

/// Engine main loop. Replaces while (isDone() == 0) { update(): render(); swap(); } commands.
virtual void main(SystemLogic *system = NULL, WorldLogic *world = NULL, EditorLogic *editor = NULL) = 0;
 
Link to comment

Hi Lin,

 

As Andrey said, Console::flush() will execute internal command queue immediately, otherwise, the result of some commands may come to effect only the next frame.

 

The sequence:

Console::get()->run("world_load scene");
Console::get()->flush();

both in SystemLogic::init() and SystemLogic::update() should fully load the scene and prepare it for any interrogations you have in mind.

I've just tried both cases and they've worked fine for me.

If you still have issues with loading the scene in the update(), please provide us with a small test scene so that we can reproduce the problem.
 

You're right, the system script and the world script are executed in the main thread.

They differ mainly in a callback set and their semantics.

In Unigine Script they also differ in their lifetime: system script has a lifetime of the running engine instance and the world script has a lifetime of a world.

Link to comment
×
×
  • Create New...