Merge pull request 'Marked all (probably) functions that take regular string instead of std::fs::path as deprecated' (#198) from using_std_fs_path into master

Reviewed-on: https://git.madvoxel.net/OpenVulkano/OpenVulkano/pulls/198
Reviewed-by: Georg Hagen <georg.hagen@madvoxel.com>
This commit is contained in:
Vladyslav_Baranovskyi_EXT
2025-02-12 18:30:39 +01:00
27 changed files with 79 additions and 81 deletions

View File

@@ -121,7 +121,7 @@ namespace OpenVulkano::AR
* If path is changed after starting the recording, the already running recording will be moved to the new path. * If path is changed after starting the recording, the already running recording will be moved to the new path.
* @param path The path to be used to store the recording * @param path The path to be used to store the recording
*/ */
void SetRecordingPath(const std::string& path) [[deprecated]] void SetRecordingPath(const std::string& path)
{ {
std::filesystem::path p(path); std::filesystem::path p(path);
SetRecordingPath(p); SetRecordingPath(p);

View File

@@ -114,7 +114,7 @@ namespace OpenVulkano::AR
* @param autoAdvance If set to true the playback will advance based on the stored timestamps. If set to false it will only advance if a new frame is requested. * @param autoAdvance If set to true the playback will advance based on the stored timestamps. If set to false it will only advance if a new frame is requested.
* @return ArCreateResult about the status of the AR session creation. The session pointer will always be nullptr unless the status is SUCCESS. * @return ArCreateResult about the status of the AR session creation. The session pointer will always be nullptr unless the status is SUCCESS.
*/ */
[[nodiscard]] static ArCreateResult CreatePlayback(const std::string& recordingPath, bool autoAdvance = true, bool loadImages = true, bool loadDepth = true); [[nodiscard]] [[deprecated]] static ArCreateResult CreatePlayback(const std::string& recordingPath, bool autoAdvance = true, bool loadImages = true, bool loadDepth = true);
/** /**
* Creates a network streamed AR session. nullptr if failed to create session for given address. This will block till the connection with the remote host has been established. * Creates a network streamed AR session. nullptr if failed to create session for given address. This will block till the connection with the remote host has been established.

View File

@@ -60,8 +60,8 @@ namespace OpenVulkano::AR
static bool DirHasMetadata(const std::filesystem::path& dirPath); static bool DirHasMetadata(const std::filesystem::path& dirPath);
static ArSessionMetadata FromXML(const std::string& filePath); [[deprecated]] static ArSessionMetadata FromXML(const std::string& filePath);
static ArSessionMetadata FromYaml(const std::string& filePath); [[deprecated]] static ArSessionMetadata FromYaml(const std::string& filePath);
}; };
} }

View File

@@ -47,7 +47,7 @@ namespace OpenVulkano::AR::Playback
size_t m_imgTotalSize = 0, m_imgReadSize = 0; size_t m_imgTotalSize = 0, m_imgReadSize = 0;
public: public:
ArPlaybackReader(const std::string& recDir) [[deprecated]] ArPlaybackReader(const std::string& recDir)
{ {
std::string extensions = R"((_\d+|\.part\d+)?)" + std::string(TAR_EXTENSIONS_REGEX); std::string extensions = R"((_\d+|\.part\d+)?)" + std::string(TAR_EXTENSIONS_REGEX);
m_archiveMetadata.Open(recDir, ".*meta(data)?" + extensions); m_archiveMetadata.Open(recDir, ".*meta(data)?" + extensions);

View File

@@ -15,7 +15,7 @@ namespace OpenVulkano::AR::Playback
class ArSessionPlayback final : public ArSession, public std::enable_shared_from_this<ArSessionPlayback> class ArSessionPlayback final : public ArSession, public std::enable_shared_from_this<ArSessionPlayback>
{ {
public: public:
ArSessionPlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth); [[deprecated]] ArSessionPlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth);
~ArSessionPlayback() override; ~ArSessionPlayback() override;
@@ -31,7 +31,7 @@ class ArSessionPlayback final : public ArSession, public std::enable_shared_from
[[nodiscard]] ArType GetArType() override; [[nodiscard]] ArType GetArType() override;
[[nodiscard]] const std::string& GetPlaybackPath() const { return recordingPath; } [[nodiscard]] [[deprecated]] const std::string& GetPlaybackPath() const { return recordingPath; }
[[nodiscard]] bool IsLoadColorEnabled() const { return loadImages; } [[nodiscard]] bool IsLoadColorEnabled() const { return loadImages; }
[[nodiscard]] bool IsLoadDepthEnabled() const { return loadDepth; } [[nodiscard]] bool IsLoadDepthEnabled() const { return loadDepth; }

View File

@@ -35,7 +35,7 @@ namespace OpenVulkano
static Ptr PERF; static Ptr PERF;
static Ptr APP; static Ptr APP;
static void SetupLogger(std::string logFolder = "", const std::string& logFile = "openVulkano.log", bool handleSignals = false); [[deprecated]] static void SetupLogger(std::string logFolder = "", const std::string& logFile = "openVulkano.log", bool handleSignals = false);
/** /**
* \brief Creates a new custom logger that writes to the main log file. * \brief Creates a new custom logger that writes to the main log file.

View File

@@ -16,7 +16,7 @@ namespace OpenVulkano
class ExeAppendedZipResourceLoader : public ResourceLoader class ExeAppendedZipResourceLoader : public ResourceLoader
{ {
public: public:
std::string GetResourcePath(const std::string& resourceName) final { return ""; } [[deprecated]] std::string GetResourcePath(const std::string& resourceName) final { return ""; }
Array<char> GetResource(const std::string& resourceName) override; Array<char> GetResource(const std::string& resourceName) override;
protected: protected:
virtual std::string GetCurrentExecutablePath() const = 0; virtual std::string GetCurrentExecutablePath() const = 0;

View File

@@ -19,7 +19,7 @@ namespace OpenVulkano
[[nodiscard]] virtual Array<char> GetResource(const std::string& resourceName) = 0; [[nodiscard]] virtual Array<char> GetResource(const std::string& resourceName) = 0;
[[nodiscard]] virtual std::string GetResourcePath(const std::string& resourceName) { return ""; } [[nodiscard]] [[deprecated]] virtual std::string GetResourcePath(const std::string& resourceName) { return ""; }
static ResourceLoader& GetInstance(); static ResourceLoader& GetInstance();

View File

@@ -14,7 +14,7 @@ namespace OpenVulkano
class SystemFontResolver class SystemFontResolver
{ {
public: public:
static const std::string& GetSystemFontPath(const std::string& fontName); [[deprecated]] static const std::string& GetSystemFontPath(const std::string& fontName);
private: private:
static std::map<std::string, std::string> ReadSystemFonts(); static std::map<std::string, std::string> ReadSystemFonts();

View File

@@ -13,7 +13,7 @@ namespace OpenVulkano
class ResourceLoaderAppDirWindows final : public ResourceLoader class ResourceLoaderAppDirWindows final : public ResourceLoader
{ {
public: public:
std::string GetResourcePath(const std::string& resourceName) override; [[deprecated]] std::string GetResourcePath(const std::string& resourceName) override;
Array<char> GetResource(const std::string& resourceName) override; Array<char> GetResource(const std::string& resourceName) override;
}; };
} }

View File

@@ -30,13 +30,13 @@ namespace OpenVulkano
void CheckSize(size_t size); void CheckSize(size_t size);
public: public:
MultiPartArchiveWriter(const std::string& dir, const std::string& fileNamePattern, const ArchiveConfiguration& archiveConfiguration, size_t sizeLimit = 2_GiB, bool lazyCreation = false, const std::shared_ptr<spdlog::logger>& logger = nullptr); [[deprecated]] MultiPartArchiveWriter(const std::string& dir, const std::string& fileNamePattern, const ArchiveConfiguration& archiveConfiguration, size_t sizeLimit = 2_GiB, bool lazyCreation = false, const std::shared_ptr<spdlog::logger>& logger = nullptr);
~MultiPartArchiveWriter() override; ~MultiPartArchiveWriter() override;
bool AddFile(const FileDescription& description, const void* buffer) override; bool AddFile(const FileDescription& description, const void* buffer) override;
bool AddFile(const FileDescription& description, const std::vector<std::pair<const void*, size_t>>& buffers) override; bool AddFile(const FileDescription& description, const std::vector<std::pair<const void*, size_t>>& buffers) override;
bool AddFile(const char* fileName, const char* inArchiveName) override; [[deprecated]] bool AddFile(const char* fileName, const char* inArchiveName) override;
using IArchiveWriter::AddFile; using IArchiveWriter::AddFile;
[[nodiscard]] virtual ArchiveOStream AddFileStream(const FileDescription& description) override; [[nodiscard]] virtual ArchiveOStream AddFileStream(const FileDescription& description) override;

View File

@@ -19,10 +19,10 @@ namespace OpenVulkano::Image
virtual ~IImageLoader() = default; virtual ~IImageLoader() = default;
static std::unique_ptr<Image> loadData(const uint8_t* data, int size, int desiredChannels = 0); static std::unique_ptr<Image> loadData(const uint8_t* data, int size, int desiredChannels = 0);
virtual std::unique_ptr<Image> loadFromFile(const std::string& filePath) = 0; [[deprecated]] virtual std::unique_ptr<Image> loadFromFile(const std::string& filePath) = 0;
virtual std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) = 0; virtual std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) = 0;
virtual Math::Vector2i GetImageDimensions(const std::string& filename) = 0; [[deprecated]] virtual Math::Vector2i GetImageDimensions(const std::string& filename) = 0;
protected: protected:
static Math::Vector2i GetDimensionsInternal(const std::string& filename); [[deprecated]] static Math::Vector2i GetDimensionsInternal(const std::string& filename);
}; };
} }

View File

@@ -18,9 +18,9 @@ namespace OpenVulkano::Image
class ImageLoaderDds : public IImageLoader class ImageLoaderDds : public IImageLoader
{ {
public: public:
std::unique_ptr<Image> loadFromFile(const std::string& filePath) override; [[deprecated]] std::unique_ptr<Image> loadFromFile(const std::string& filePath) override;
std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override; std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override;
Math::Vector2i GetImageDimensions(const std::string& filename) override; [[deprecated]] Math::Vector2i GetImageDimensions(const std::string& filename) override;
protected: protected:
std::unique_ptr<Image> ExtractImage(dds::Image* ddsImage); std::unique_ptr<Image> ExtractImage(dds::Image* ddsImage);

View File

@@ -13,9 +13,9 @@ namespace OpenVulkano::Image
class ImageLoaderJpeg : public IImageLoader class ImageLoaderJpeg : public IImageLoader
{ {
public: public:
std::unique_ptr<Image> loadFromFile(const std::string& filePath) override; [[deprecated]] std::unique_ptr<Image> loadFromFile(const std::string& filePath) override;
std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override; std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override;
Math::Vector2i GetImageDimensions(const std::string& filename) override; [[deprecated]] Math::Vector2i GetImageDimensions(const std::string& filename) override;
private: private:
std::unique_ptr<Image> loadJpeg(const uint8_t* data, size_t size); std::unique_ptr<Image> loadJpeg(const uint8_t* data, size_t size);
}; };

View File

@@ -13,8 +13,8 @@ namespace OpenVulkano::Image
class ImageLoaderKtx : public IImageLoader class ImageLoaderKtx : public IImageLoader
{ {
public: public:
std::unique_ptr<Image> loadFromFile(const std::string& filePath) override; [[deprecated]] std::unique_ptr<Image> loadFromFile(const std::string& filePath) override;
std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override; std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override;
Math::Vector2i GetImageDimensions(const std::string& filename) override; [[deprecated]] Math::Vector2i GetImageDimensions(const std::string& filename) override;
}; };
} }

View File

@@ -13,8 +13,8 @@ namespace OpenVulkano::Image
class ImageLoaderPfm : public IImageLoader class ImageLoaderPfm : public IImageLoader
{ {
public: public:
std::unique_ptr<Image> loadFromFile(const std::string& filePath) override; [[deprecated]] std::unique_ptr<Image> loadFromFile(const std::string& filePath) override;
std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override; std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override;
Math::Vector2i GetImageDimensions(const std::string& filename) override; [[deprecated]] Math::Vector2i GetImageDimensions(const std::string& filename) override;
}; };
} }

View File

@@ -13,8 +13,8 @@ namespace OpenVulkano::Image
class ImageLoaderPng : public IImageLoader class ImageLoaderPng : public IImageLoader
{ {
public: public:
std::unique_ptr<Image> loadFromFile(const std::string& filePath) override; [[deprecated]] std::unique_ptr<Image> loadFromFile(const std::string& filePath) override;
std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override; std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override;
Math::Vector2i GetImageDimensions(const std::string& filename) override; [[deprecated]] Math::Vector2i GetImageDimensions(const std::string& filename) override;
}; };
} }

View File

@@ -12,8 +12,8 @@ namespace OpenVulkano::Image
class ImageLoaderPnm : public IImageLoader class ImageLoaderPnm : public IImageLoader
{ {
public: public:
std::unique_ptr<Image> loadFromFile(const std::string& filePath) override; [[deprecated]] std::unique_ptr<Image> loadFromFile(const std::string& filePath) override;
std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override; std::unique_ptr<Image> loadFromMemory(const std::vector<uint8_t>& buffer) override;
Math::Vector2i GetImageDimensions(const std::string& filename) override; [[deprecated]] Math::Vector2i GetImageDimensions(const std::string& filename) override;
}; };
} }

View File

@@ -6,6 +6,7 @@
#include "MeshWriter.hpp" #include "MeshWriter.hpp"
#include "Base/Utils.hpp" #include "Base/Utils.hpp"
#include "Extensions/FmtFormatter.hpp"
#include "IO/MemMappedFile.hpp" #include "IO/MemMappedFile.hpp"
#include "Scene/Geometry.hpp" #include "Scene/Geometry.hpp"
#include "Scene/Vertex.hpp" #include "Scene/Vertex.hpp"
@@ -102,27 +103,27 @@ namespace
namespace OpenVulkano::Scene namespace OpenVulkano::Scene
{ {
void MeshWriter::WriteAsOBJ(Geometry* geometry, const std::string& filePath) void MeshWriter::WriteAsOBJ(Geometry* geometry, const std::filesystem::path& filePath)
{ {
std::ofstream file(filePath); std::ofstream file(filePath);
if (!file.is_open()) [[unlikely]] if (!file.is_open()) [[unlikely]]
throw std::runtime_error("Failed to open file '" + filePath + "' for writing!"); throw std::runtime_error(fmt::format("Failed to open file '{}' for writing!", filePath));
WriteObjContents(geometry, "", file); WriteObjContents(geometry, "", file);
file.close(); file.close();
} }
void MeshWriter::WriteAsUSD(Geometry* geometry, const std::string& filePath) void MeshWriter::WriteAsUSD(Geometry* geometry, const std::filesystem::path& filePath)
{ {
std::ofstream file(filePath); std::ofstream file(filePath);
if (!file.is_open()) [[unlikely]] if (!file.is_open()) [[unlikely]]
throw std::runtime_error("Failed to open file '" + filePath + "' for writing!"); throw std::runtime_error(fmt::format("Failed to open file '{}' for writing!", filePath));
WriteUsdContents(file, geometry); WriteUsdContents(file, geometry);
file.close(); file.close();
} }
void MeshWriter::WriteObjAsZip(Geometry* geometry, const std::string& texturePath, const std::string& zipPath) void MeshWriter::WriteObjAsZip(Geometry* geometry, const std::filesystem::path& texturePath, const std::filesystem::path& zipPath)
{ {
OpenVulkano::ArchiveWriter zipWriter(zipPath.c_str()); OpenVulkano::ArchiveWriter zipWriter(zipPath.c_str());
@@ -146,7 +147,7 @@ namespace OpenVulkano::Scene
} }
} }
void MeshWriter::WriteAsUSDZ(Geometry* geometry, const std::string& texturePath, const std::string& usdzPath) void MeshWriter::WriteAsUSDZ(Geometry* geometry, const std::filesystem::path& texturePath, const std::filesystem::path& usdzPath)
{ {
OpenVulkano::ZipWriter zipWriter(usdzPath, true); OpenVulkano::ZipWriter zipWriter(usdzPath, true);
@@ -166,7 +167,7 @@ namespace OpenVulkano::Scene
} }
} }
void MeshWriter::WriteAsSTL(Geometry* geometry, const std::string& filePath, bool binary) void MeshWriter::WriteAsSTL(Geometry* geometry, const std::filesystem::path& filePath, bool binary)
{ {
#if __has_include("assimp/Exporter.hpp") #if __has_include("assimp/Exporter.hpp")
std::unique_ptr<aiScene> scene(new aiScene()); std::unique_ptr<aiScene> scene(new aiScene());
@@ -178,7 +179,7 @@ namespace OpenVulkano::Scene
Assimp::Exporter exporter; Assimp::Exporter exporter;
const char* formatId = binary ? "stlb" : "stl"; const char* formatId = binary ? "stlb" : "stl";
aiReturn result = exporter.Export(scene.get(), formatId, filePath); aiReturn result = exporter.Export(scene.get(), formatId, filePath.string().c_str());
scene->mRootNode = nullptr; scene->mRootNode = nullptr;
scene->mMeshes = nullptr; scene->mMeshes = nullptr;
@@ -190,14 +191,14 @@ namespace OpenVulkano::Scene
if (result != aiReturn_SUCCESS) if (result != aiReturn_SUCCESS)
{ {
throw std::runtime_error("Unable to write STL file to " + filePath + ": " + exporter.GetErrorString()); throw std::runtime_error(fmt::format("Unable to write STL file to {}: {}", filePath, exporter.GetErrorString()));
} }
#else #else
throw std::runtime_error("Unable to export to STL: Assimp is not available!"); throw std::runtime_error("Unable to export to STL: Assimp is not available!");
#endif #endif
} }
void MeshWriter::WriteAsFBX(Geometry* geometry, const std::string& texturePath, const std::string& fbxPath) void MeshWriter::WriteAsFBX(Geometry* geometry, const std::filesystem::path& texturePath, const std::filesystem::path& fbxPath)
{ {
#if __has_include("assimp/Exporter.hpp") #if __has_include("assimp/Exporter.hpp")
std::unique_ptr<aiScene> scene(new aiScene()); std::unique_ptr<aiScene> scene(new aiScene());
@@ -209,12 +210,12 @@ namespace OpenVulkano::Scene
if (!texturePath.empty()) if (!texturePath.empty())
{ {
aiString externalPath(texturePath); aiString externalPath(texturePath.string().c_str());
scene->mMaterials[0]->AddProperty(&externalPath, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0)); scene->mMaterials[0]->AddProperty(&externalPath, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));
} }
Assimp::Exporter exporter; Assimp::Exporter exporter;
aiReturn result = exporter.Export(scene.get(), "fbx", fbxPath); aiReturn result = exporter.Export(scene.get(), "fbx", fbxPath.string().c_str());
scene->mRootNode = nullptr; scene->mRootNode = nullptr;
scene->mMeshes = nullptr; scene->mMeshes = nullptr;
@@ -226,7 +227,7 @@ namespace OpenVulkano::Scene
if (result != aiReturn_SUCCESS) if (result != aiReturn_SUCCESS)
{ {
throw std::runtime_error("Unable to write a fbx file to " + fbxPath + ": " + exporter.GetErrorString()); throw std::runtime_error(fmt::format("Unable to write a fbx file to {}: {}", fbxPath, exporter.GetErrorString()));
} }
#else #else
throw std::runtime_error("Unable to convert the scene to FBX: Assimp is not available!"); throw std::runtime_error("Unable to convert the scene to FBX: Assimp is not available!");

View File

@@ -6,7 +6,7 @@
#pragma once #pragma once
#include <string> #include <filesystem>
namespace OpenVulkano::Scene namespace OpenVulkano::Scene
{ {
@@ -14,11 +14,11 @@ namespace OpenVulkano::Scene
class MeshWriter class MeshWriter
{ {
public: public:
static void WriteAsOBJ(Geometry* geometry, const std::string& filePath); static void WriteAsOBJ(Geometry* geometry, const std::filesystem::path& filePath);
static void WriteAsUSD(Geometry* geometry, const std::string& filePath); static void WriteAsUSD(Geometry* geometry, const std::filesystem::path& filePath);
static void WriteObjAsZip(Geometry* geometry, const std::string& texturePath, const std::string& zipPath); static void WriteObjAsZip(Geometry* geometry, const std::filesystem::path& texturePath, const std::filesystem::path& zipPath);
static void WriteAsUSDZ(Geometry* geometry, const std::string& texturePath, const std::string& usdzPath); static void WriteAsUSDZ(Geometry* geometry, const std::filesystem::path& texturePath, const std::filesystem::path& usdzPath);
static void WriteAsFBX(Geometry* geometry, const std::string& texturePath, const std::string& fbxPath); static void WriteAsFBX(Geometry* geometry, const std::filesystem::path& texturePath, const std::filesystem::path& fbxPath);
static void WriteAsSTL(Geometry* geometry, const std::string& filePath, bool binary); static void WriteAsSTL(Geometry* geometry, const std::filesystem::path& filePath, bool binary);
}; };
} }

View File

@@ -7,6 +7,7 @@
#include "MeshLoader.hpp" #include "MeshLoader.hpp"
#include "Scene/Geometry.hpp" #include "Scene/Geometry.hpp"
#include "Base/Logger.hpp" #include "Base/Logger.hpp"
#include "Extensions/FmtFormatter.hpp"
#if __has_include("assimp/Importer.hpp") #if __has_include("assimp/Importer.hpp")
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/scene.h> #include <assimp/scene.h>
@@ -26,17 +27,9 @@
#include "value-pprint.hh" #include "value-pprint.hh"
#include "value-types.hh" #include "value-types.hh"
namespace
{
static bool ends_with(std::string_view str, std::string_view suffix)
{
return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
}
}
namespace OpenVulkano::Scene namespace OpenVulkano::Scene
{ {
void MeshLoader::ParseAssimpFile(Geometry *geometry, const std::string& file) void MeshLoader::ParseAssimpFile(Geometry *geometry, const std::filesystem::path& file)
{ {
#ifdef ASSIMP_AVAILABLE #ifdef ASSIMP_AVAILABLE
Assimp::Importer importer; Assimp::Importer importer;
@@ -45,9 +38,9 @@ namespace OpenVulkano::Scene
aiProcess_ImproveCacheLocality | aiProcess_RemoveRedundantMaterials | aiProcess_GenUVCoords | aiProcess_TransformUVCoords | aiProcess_ImproveCacheLocality | aiProcess_RemoveRedundantMaterials | aiProcess_GenUVCoords | aiProcess_TransformUVCoords |
aiProcess_ConvertToLeftHanded | aiProcess_PreTransformVertices | aiProcess_OptimizeGraph; aiProcess_ConvertToLeftHanded | aiProcess_PreTransformVertices | aiProcess_OptimizeGraph;
const aiScene* scene = importer.ReadFile(file, flags); const aiScene* scene = importer.ReadFile(file.string().c_str(), flags);
if (!scene) throw std::runtime_error("Failed to load file \"" + file + "\" Error: " + importer.GetErrorString()); if (!scene) throw std::runtime_error(fmt::format("Failed to load file \"{}\" Error: {}", file, importer.GetErrorString()));
if (!scene->HasMeshes()) throw std::runtime_error("File \"" + file + "\" does not have any meshes"); if (!scene->HasMeshes()) throw std::runtime_error(fmt::format("File \"{}\" does not have any meshes", file));
if (scene->mNumMeshes > 1) Logger::DATA->warn("File {0} contains more than one mesh. Only first one will be loaded", file); if (scene->mNumMeshes > 1) Logger::DATA->warn("File {0} contains more than one mesh. Only first one will be loaded", file);
aiMesh *mesh = scene->mMeshes[0]; aiMesh *mesh = scene->mMeshes[0];
@@ -91,15 +84,15 @@ namespace OpenVulkano::Scene
#endif #endif
} }
void MeshLoader::ParseUSDFile(Geometry *geometry, const std::string& file) void MeshLoader::ParseUSDFile(Geometry *geometry, const std::filesystem::path& file)
{ {
tinyusdz::Stage stage; tinyusdz::Stage stage;
std::string warning, err; std::string warning, err;
auto result = tinyusdz::LoadUSDFromFile(file, &stage, &warning, &err); auto result = tinyusdz::LoadUSDFromFile(file.string().c_str(), &stage, &warning, &err);
if (!result) if (!result)
{ {
throw std::runtime_error("Failed to load USD file: " + file); throw std::runtime_error(fmt::format("Failed to load USD file: {}", file));
} }
for (auto &prim : stage.root_prims()) for (auto &prim : stage.root_prims())
@@ -148,14 +141,15 @@ namespace OpenVulkano::Scene
} }
} }
} }
throw std::runtime_error("No mesh found inside a xform in USD file: " + file); throw std::runtime_error(fmt::format("No mesh found inside a xform in USD file: {}", file));
} }
Geometry* MeshLoader::LoadFromFile(const std::string& file) Geometry* MeshLoader::LoadFromFile(const std::filesystem::path& file)
{ {
Geometry* geometry = new Geometry(); Geometry* geometry = new Geometry();
if (ends_with(file, ".usd") || ends_with(file, ".usda") || ends_with(file, ".usdc") || ends_with(file, ".usdz")) const std::filesystem::path ext = file.extension();
if (ext == ".usd" || ext == ".usda" || ext == ".usdc" || ext == ".usdz")
{ {
ParseUSDFile(geometry, file); ParseUSDFile(geometry, file);
} }

View File

@@ -6,6 +6,7 @@
#pragma once #pragma once
#include <filesystem>
#include <string> #include <string>
namespace OpenVulkano::Scene namespace OpenVulkano::Scene
@@ -13,9 +14,9 @@ namespace OpenVulkano::Scene
class Geometry; class Geometry;
class MeshLoader class MeshLoader
{ {
static void ParseAssimpFile(Geometry *geometry, const std::string& file); static void ParseAssimpFile(Geometry *geometry, const std::filesystem::path& file);
static void ParseUSDFile(Geometry *geometry, const std::string& file); static void ParseUSDFile(Geometry *geometry, const std::filesystem::path& file);
public: public:
static Geometry* LoadFromFile(const std::string& file); static Geometry* LoadFromFile(const std::filesystem::path& file);
}; };
} }

View File

@@ -42,7 +42,7 @@ namespace OpenVulkano::Scene
, m_subpixelLayout(subpixelLayout.value_or(SubpixelLayout::UNKNOWN)) , m_subpixelLayout(subpixelLayout.value_or(SubpixelLayout::UNKNOWN))
{ {
} }
void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset, [[deprecated]] void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput = std::nullopt) override; const std::optional<std::string>& pngOutput = std::nullopt) override;
void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset, void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput = std::nullopt) override; const std::optional<std::string>& pngOutput = std::nullopt) override;

View File

@@ -45,6 +45,6 @@ namespace OpenVulkano::Scene
const std::set<uint32_t>& charset = {}) const; const std::set<uint32_t>& charset = {}) const;
private: private:
Array<char> FindFont(const std::string& fontFile) const; [[deprecated]] Array<char> FindFont(const std::string& fontFile) const;
}; };
} }

View File

@@ -20,7 +20,7 @@ namespace OpenVulkano::Scene
{ {
public: public:
virtual ~IFontAtlasGenerator() = default; virtual ~IFontAtlasGenerator() = default;
virtual void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset, [[deprecated]] virtual void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput = std::nullopt) = 0; const std::optional<std::string>& pngOutput = std::nullopt) = 0;
virtual void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset, virtual void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput = std::nullopt) = 0; const std::optional<std::string>& pngOutput = std::nullopt) = 0;

View File

@@ -42,11 +42,12 @@ namespace OpenVulkano::Scene
using Config = SdfFontAtlasGeneratorConfig; using Config = SdfFontAtlasGeneratorConfig;
static constexpr int channelsCount = (Channels == 1 ? 1 : 4); static constexpr int channelsCount = (Channels == 1 ? 1 : 4);
SdfFontAtlasGeneratorGeneric(); SdfFontAtlasGeneratorGeneric();
void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset, [[deprecated]] void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput = std::nullopt) override; const std::optional<std::string>& pngOutput = std::nullopt) override;
void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset, void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput = std::nullopt) override; const std::optional<std::string>& pngOutput = std::nullopt) override;
void GenerateAtlas(const std::string& fontFile, const msdf_atlas::Charset& charset = msdf_atlas::Charset::ASCII, [[deprecated]] void GenerateAtlas(const std::string& fontFile,
const msdf_atlas::Charset& charset = msdf_atlas::Charset::ASCII,
const std::optional<std::string>& pngOutput = std::nullopt); const std::optional<std::string>& pngOutput = std::nullopt);
void GenerateAtlas(const msdfgen::byte* fontData, int length, void GenerateAtlas(const msdfgen::byte* fontData, int length,
const msdf_atlas::Charset& charset = msdf_atlas::Charset::ASCII, const msdf_atlas::Charset& charset = msdf_atlas::Charset::ASCII,

View File

@@ -14,8 +14,9 @@ namespace OpenVulkano
* @param entryPoint - the name of the void function in the shader * @param entryPoint - the name of the void function in the shader
* @param shaderStage - type of the shader that needs to be compiled * @param shaderStage - type of the shader that needs to be compiled
*/ */
static Array<uint32_t> CompileGLSLToSpirv(const std::string& absPath, bool hasIncludes, [[deprecated]] static Array<uint32_t> CompileGLSLToSpirv(const std::string& absPath, bool hasIncludes,
const std::string& incPath = std::string(), const std::string& entryPoint = "main") const std::string& incPath = std::string(),
const std::string& entryPoint = "main")
#if defined(HAS_SHADERC) #if defined(HAS_SHADERC)
; ;
#else #else