Page 1 of 1

Is it possible for the engine to load resources asynchronously

Posted: Thu Aug 27, 2020 8:07 pm
by Azureusbin
I created an object that I displayed to engine-world using IStatObj and IRenderNode.

But When I use ’gEnv->p3DEngine->LoadStatObj(mv_geometryFile);‘ to loading model, the whole engine will be stuck until the resource file was loaded.

This is very embarrassed because I would load hundreds or thousands of large models at the same time.

So, Is there a way to make CryEngine can load assets asynchronously?

Re: Is it possible for the engine to load resources asynchronously

Posted: Thu Sep 03, 2020 5:42 am
by Azureusbin
Ok, I found a solution to async Loading model files. :)

USE CObjManager::LoadStatObjAsync AND class IStatObjFoundCallback.

Code: Select all

class CObjManager { // ... void LoadStatObjAsync(const char* szFileName, const char* szGeomName, bool useStreaming, uint32 loadingFlags, IStatObjFoundCallback* pCallback = nullptr); }

Code: Select all

class IStatObjFoundCallback { public: virtual ~IStatObjFoundCallback() = default; //! Gets called once loading is finished. //! Will be called directly from the thread invoking LoadStatObjAsync or later from the main thread. //! \param pObject can be null in case of a loading error. //! \param pSubObject may point to a named sub-object, if a geometryName was requested and found virtual void OnFound(CStatObj* pObject, IStatObj::SSubObject* pSubObject) = 0; };