Guarded assimp-related code

This commit is contained in:
Vladyslav Baranovskyi
2024-12-19 17:04:50 +02:00
parent b9f3e2545e
commit 308c361d89

View File

@@ -16,10 +16,13 @@
#include <fstream> #include <fstream>
#include <fmt/core.h> #include <fmt/core.h>
#if __has_include("assimp/Exporter.hpp")
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/Exporter.hpp> #include <assimp/Exporter.hpp>
#include <assimp/mesh.h> #include <assimp/mesh.h>
#include <assimp/material.h> #include <assimp/material.h>
#endif
namespace OpenVulkano::Scene namespace OpenVulkano::Scene
{ {
@@ -89,6 +92,7 @@ namespace OpenVulkano::Scene
void MeshWriter::WriteAsFBX(Geometry* geometry, const std::string& texturePath, const std::string& fbxPath) void MeshWriter::WriteAsFBX(Geometry* geometry, const std::string& texturePath, const std::string& fbxPath)
{ {
#if __has_include("assimp/Exporter.hpp")
aiNode rootNode; aiNode rootNode;
aiScene scene; aiScene scene;
@@ -177,5 +181,8 @@ namespace OpenVulkano::Scene
{ {
throw std::runtime_error("Unable to write a fbx file to " + fbxPath + ": " + exporter.GetErrorString()); throw std::runtime_error("Unable to write a fbx file to " + fbxPath + ": " + exporter.GetErrorString());
} }
#else
throw std::runtime_error("Unable to convert the scene to FBX: Assimp is not available!");
#endif
} }
} }