Open a file for reading.
248{
250
252
253 if (!std::filesystem::exists(resolved)) {
254 set_error(
"File not found: " + filepath);
257 return false;
258 }
259
260 constexpr unsigned int flags = aiProcess_Triangulate
261 | aiProcess_GenSmoothNormals
262 | aiProcess_CalcTangentSpace
263 | aiProcess_FlipUVs
264 | aiProcess_JoinIdenticalVertices
265 | aiProcess_SortByPType;
266
267 m_impl->scene =
m_impl->importer.ReadFile(resolved, flags);
268
270 || (
m_impl->scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE)
271 || !
m_impl->scene->mRootNode) {
274 "ModelReader: Assimp import failed — {}",
m_last_error);
276 return false;
277 }
278
281 "ModelReader: opened '{}' — {} meshes, {} materials",
282 std::filesystem::path(resolved).filename().string(),
283 m_impl->scene->mNumMeshes,
284 m_impl->scene->mNumMaterials);
285
286 return true;
287}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
static std::string resolve_path(const std::string &filepath)
Resolve a filepath against the project source root if not found as-is.
std::unique_ptr< Impl > m_impl
void set_error(std::string msg) const
void close() override
Close the currently open file.
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.