About Store Forum Documentation Contact
Donations:
178$/mo



Post Reply 
Load world progress issue
Author Message
Lancer Offline
Member

Post: #1
Load world progress issue
Hi, I have the following issue with loading world.

I start loading world like this:
Code:
Game::World.activeRange(D.viewRange())
            .New(pEvent->worldFile);

if (Game::World.settings().environment) // if the world has environment settings (like sun, ambient, sky, ..)
            Game::World.settings().environment->set(); // then set them

// start background loader thread
        m_loaderThread.create(BackgroundLoader);

Now BackgroundLoader function:

Code:
Bool CLoadingScene::BackgroundLoader(Thread& thread)
{
    ThreadMayUseGPUData();

    Game::World.update(Cam.at);
    
    Flt fProgress = Game::World.updateProgress();
    if (fProgress >= 1.0f)
        return false; // return false, because we no longer need the thread

    LogN(fProgress);

    return true;
}

Issue: it never returns false.
Log shows this:
1.000
0.000
0.000
0.000

But when I use Dbl instead of Flt, then it shows the following result:
0.999997556
0.000000000
0.000000000
0.000000000

What could cause this issue?
The world is empty. It is a new created one with imported heightmap.
(This post was last modified: 06-13-2020 01:36 PM by Lancer.)
06-13-2020 01:35 PM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Bronze Supporter

Post: #2
RE: Load world progress issue
it never returns false because this is the initiator of the bg function, you need an update to check for constant updateprogress.

take a look at the tuto again, it will make sense.

you need a check on the main update to do something like this

if(BL.update())return true;
06-13-2020 05:07 PM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #3
RE: Load world progress issue
Im not sure where I found it. But I remember reading that the function Game::World.updateProgress() should return 1 when Game::World.update is fully loaded.
But in this case, it never returns 1 but 0.999997556.
06-13-2020 06:02 PM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Bronze Supporter

Post: #4
RE: Load world progress issue
yes it does, where do you call this function shown up here ?

Bool CLoadingScene::BackgroundLoader(Thread& thread) ?

only once ? or in a update loop ?
(This post was last modified: 06-13-2020 06:19 PM by RedcrowProd.)
06-13-2020 06:16 PM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #5
RE: Load world progress issue
The function CLoadingScene::BackgroundLoader is run by the a thread until false is returned.

As you see I have the following code

Flt fProgress = Game::World.updateProgress();
if (fProgress >= 1.0f)
return false; // return false, because we no longer need the thread

but it never returns false because the fProgress value is something like 0.999
06-13-2020 07:15 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Load world progress issue
Please check this tutorial:
UID(843796821, 1301324948, 315606446, 4112474063) /* Apps\14 - Game Basics\19 - Loading Screen */
06-14-2020 06:05 AM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #7
RE: Load world progress issue
Yes, I did that.
But there seems to be an issue with Game::World.updateProgress() not returning 1.f but only 0.999f
06-14-2020 01:01 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Load world progress issue
It's meant to be used only for drawing progress bar, please check tutorial, it works differently than your code.
06-14-2020 02:52 PM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #9
RE: Load world progress issue
Oh, I see.
Thanks.
06-17-2020 02:31 PM
Find all posts by this user Quote this message in a reply
Post Reply