3
3
// For conditions of distribution and use, see copyright notice in nabla.h
4
4
5
5
#include " nbl/asset/asset.h"
6
+ #include " nbl/asset/interchange/CGraphicsPipelineLoaderMTL.h"
7
+ #include " nbl/asset/utils/IGLSLEmbeddedIncludeLoader.h"
8
+ #include " nbl/asset/utils/CDerivativeMapCreator.h"
6
9
7
10
#include < utility>
8
11
#include < regex>
9
12
#include < filesystem>
10
13
11
- #include " nbl/asset/asset.h"
12
- #include " nbl/asset/interchange/CGraphicsPipelineLoaderMTL.h"
13
- #include " nbl/asset/utils/IGLSLEmbeddedIncludeLoader.h"
14
- #include " nbl/asset/utils/CDerivativeMapCreator.h"
15
- #include " nbl/system/IFileViewAllocator.h"
14
+ #include " nbl/system/CFileView.h"
16
15
17
16
#include " nbl/builtin/MTLdefaults.h"
18
17
@@ -84,13 +83,12 @@ void CGraphicsPipelineLoaderMTL::initialize()
84
83
}
85
84
86
85
// default pipelines
87
- constexpr std::string_view filename = " Nabla default MTL material" ;
88
-
89
- auto default_mtl_file = core::make_smart_refctd_ptr<system::CFileView<system::CPlainHeapAllocator>>(core::smart_refctd_ptr (m_system), filename, system::IFile::ECF_READ_WRITE, strlen (DUMMY_MTL_CONTENT));
90
-
91
- system::future<size_t > future;
92
- default_mtl_file->write (future, DUMMY_MTL_CONTENT, 0 , strlen (DUMMY_MTL_CONTENT));
93
- future.get ();
86
+ auto default_mtl_file = core::make_smart_refctd_ptr<system::CFileView<system::CNullAllocator>>(
87
+ system::path (" Nabla default MTL material" ),
88
+ system::IFile::ECF_READ,
89
+ const_cast <char *>(DUMMY_MTL_CONTENT),
90
+ strlen (DUMMY_MTL_CONTENT)
91
+ );
94
92
95
93
SAssetLoadParams assetLoadParams;
96
94
auto bundle = loadAsset (default_mtl_file.get (), assetLoadParams, &dfltOver);
@@ -105,11 +103,9 @@ bool CGraphicsPipelineLoaderMTL::isALoadableFileFormat(system::IFile* _file, con
105
103
106
104
std::string mtl;
107
105
mtl.resize (_file->getSize ());
108
- system::future<size_t > future;
109
- _file->read (future, mtl.data (), 0 , _file->getSize ());
110
- future.get ();
111
-
112
- return mtl.find (" newmtl" ) != std::string::npos;
106
+ system::IFile::success_t success;
107
+ _file->read (success, mtl.data (), 0 , _file->getSize ());
108
+ return success && mtl.find (" newmtl" )!=std::string::npos;
113
109
}
114
110
115
111
SAssetBundle CGraphicsPipelineLoaderMTL::loadAsset (system::IFile* _file, const IAssetLoader::SAssetLoadParams& _params, IAssetLoader::IAssetLoaderOverride* _override, uint32_t _hierarchyLevel)
@@ -726,10 +722,11 @@ auto CGraphicsPipelineLoaderMTL::readMaterials(system::IFile* _file, const syste
726
722
std::string mtl;
727
723
size_t fileSize = _file->getSize ();
728
724
mtl.resize (fileSize);
729
- system::future<size_t > fut;
730
-
731
- _file->read (fut, mtl.data (), 0 , fileSize);
732
- fut.get ();
725
+
726
+ system::IFile::success_t success;
727
+ _file->read (success, mtl.data (), 0 , fileSize);
728
+ if (!success)
729
+ return {};
733
730
734
731
const char * bufPtr = mtl.c_str ();
735
732
const char * const bufEnd = mtl.c_str ()+mtl.size ();
@@ -868,7 +865,7 @@ auto CGraphicsPipelineLoaderMTL::readMaterials(system::IFile* _file, const syste
868
865
{
869
866
case ' f' : // Tf - Transmitivity
870
867
currMaterial->params .transmissionFilter = readRGB ();
871
- sprintf (tmpbuf, " %s, %s: Detected Tf parameter, it won't be used in generated shader - fallback to alpha=0.5 instead" , _file->getFileName ().c_str (), currMaterial->name .c_str ());
868
+ sprintf (tmpbuf, " %s, %s: Detected Tf parameter, it won't be used in generated shader - fallback to alpha=0.5 instead" , _file->getFileName ().string (). c_str (), currMaterial->name .c_str ());
872
869
logger.log (tmpbuf, system::ILogger::ELL_WARNING);
873
870
break ;
874
871
case ' r' : // Tr, transparency = 1.0-d
0 commit comments