45 return _performLoad([&] {
return _loadData(std::move(blob), _params); });
50 const auto& path = _params.
getPath();
51 return _performLoad([&] {
return _loadData(path, _params); });
60 catch (
const std::exception& e)
69 return _engine.
getScene().
loadModel(std::move(blob), params, {_getProgressFunc()});
72 ModelDescriptorPtr LoadModelFunctor::_loadData(
const std::string& path,
const ModelParams& params)
77 void LoadModelFunctor::_updateProgress(
const std::string& message,
const size_t increment)
79 _currentProgress += increment;
83 std::function<void(std::string,
float)> LoadModelFunctor::_getProgressFunc()
85 return [
this](
const std::string& msg,
const float progress)
89 if (newProgress == 0 || newProgress %
size_t(
TOTAL_PROGRESS) > _nextTic)
91 _updateProgress(msg, newProgress - _nextTic);
92 _nextTic = newProgress;
Provides an abstract implementation of a ray-tracing engine.
PLATFORM_API Scene & getScene()
Returns the scene.
ModelDescriptorPtr operator()()
LoadModelFunctor(Engine &engine, const ModelParams ¶ms)
The ModelParams class represents the parameters needed for initializing a model instance.
PLATFORM_API const std::string & getPath() const
getPath gets the path of the model
PLATFORM_API ModelDescriptorPtr loadModel(Blob &&blob, const ModelParams ¶ms, LoaderProgress cb)
Load a model from the given blob.
void progress(const std::string &message, const float increment, const float amount)
std::shared_ptr< ModelDescriptor > ModelDescriptorPtr
const float TOTAL_PROGRESS
TaskRuntimeError LOADING_BINARY_FAILED(const std::string &error)