Skip to content

Commit

Permalink
Update version to v0.21.36
Browse files Browse the repository at this point in the history
  • Loading branch information
Atraxus committed Oct 2, 2024
1 parent 03c2322 commit b3c2615
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.25.2 FATAL_ERROR)

# ---- Project ----
project(RAYX VERSION 0.21.35)
project(RAYX VERSION 0.21.36)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 20)
Expand Down
12 changes: 6 additions & 6 deletions Intern/rayx-core/src/Data/Locate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
namespace RAYX {

// Check if a file exists
bool ResourceFinder::fileExists(const std::string& path) { return std::filesystem::exists(path); }
bool ResourceFinder::fileExists(const std::filesystem::path& path) { return std::filesystem::exists(path); }
bool ResourceHandler::fileExists(const std::string& path) { return std::filesystem::exists(path); }
bool ResourceHandler::fileExists(const std::filesystem::path& path) { return std::filesystem::exists(path); }

std::filesystem::path ResourceFinder::getExecutablePath() {
std::filesystem::path ResourceHandler::getExecutablePath() {
#if defined(_WIN32)
// Start with a reasonable buffer size
std::vector<char> buffer(MAX_PATH);
Expand Down Expand Up @@ -59,7 +59,7 @@ std::filesystem::path ResourceFinder::getExecutablePath() {
}

// General method to get the full path based on the base directory (e.g., data or font directory)
std::filesystem::path ResourceFinder::getFullPath(const std::string& baseDir, const std::string& relativePath) {
std::filesystem::path ResourceHandler::getFullPath(const std::string& baseDir, const std::string& relativePath) {
#if defined(__linux__)
// First, check in /usr (package install)
std::string path = std::string("/usr/") + baseDir + "/" + relativePath;
Expand Down Expand Up @@ -89,9 +89,9 @@ std::filesystem::path ResourceFinder::getFullPath(const std::string& baseDir, co
}

// Retrieve the full path of a resource based on the platform
std::filesystem::path ResourceFinder::getResourcePath(const std::string& relativePath) { return getFullPath(RAYX_DATA_DIR, relativePath); }
std::filesystem::path ResourceHandler::getResourcePath(const std::string& relativePath) { return getFullPath(RAYX_DATA_DIR, relativePath); }

// Retrieve the full path of a font based on the platform
std::filesystem::path ResourceFinder::getFontPath(const std::string& relativePath) { return getFullPath(RAYX_FONTS_DIR, relativePath); }
std::filesystem::path ResourceHandler::getFontPath(const std::string& relativePath) { return getFullPath(RAYX_FONTS_DIR, relativePath); }

} // namespace RAYX
14 changes: 9 additions & 5 deletions Intern/rayx-core/src/Data/Locate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

#include <filesystem>
#include <string>
#include <vector>
#include <set>

#include "Core.h"

namespace RAYX {

class RAYX_API ResourceFinder {
class RAYX_API ResourceHandler {
public:
static ResourceHandler& getInstance() {
thread_local ResourceHandler instance;
return instance;
}

// Platform-specific implementations for resource path search
std::filesystem::path getExecutablePath();

Expand All @@ -20,16 +25,15 @@ class RAYX_API ResourceFinder {
std::filesystem::path getFontPath(const std::string& relativePath);

private:
ResourceHandler() = default;
bool fileExists(const std::string& path);
bool fileExists(const std::filesystem::path& path);
std::filesystem::path getFullPath(const std::string& baseDir, const std::string& relativePath);

std::vector<std::filesystem::path> lookUpPaths = {
std::set<std::filesystem::path> lookUpPaths = {
#if defined(__linux__)
std::filesystem::path("/usr"), //
std::filesystem::path("/usr/local"), //
#elif defined(_WIN32)
#elif defined(__APPLE__)
#endif
};
};
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Material/NffTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool NffTable::load(const char* element, NffTable* out) {

std::transform(elementString.begin(), elementString.end(), elementString.begin(), [](unsigned char c) { return std::tolower(c); });

std::filesystem::path f = getResourcePath("Data/nff/" + elementString + ".nff");
std::filesystem::path f = ResourceHandler::getInstance().getResourcePath("Data/nff/" + elementString + ".nff");
RAYX_VERB << "Loading NffTable from " << f;
std::ifstream s(f);

Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Material/PalikTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bool PalikTable::load(const char* element, PalikTable* out) {
std::string elementString = element;
std::transform(elementString.begin(), elementString.end(), elementString.begin(), [](unsigned char c) { return std::toupper(c); });

std::filesystem::path f = getResourcePath("Data/PALIK/" + elementString + ".NKP");
std::filesystem::path f = ResourceHandler::getInstance().getResourcePath("Data/PALIK/" + elementString + ".NKP");
RAYX_VERB << "Loading PalikTable from " << f;
std::ifstream s(f);

Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-ui/src/GraphicsCore/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Texture::Texture(const Device& device)
m_layout{VK_IMAGE_LAYOUT_UNDEFINED},
m_usageFlags{VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT},
m_aspectFlags{VK_IMAGE_ASPECT_COLOR_BIT} {
std::vector<uint8_t> data = dataFromPath(RAYX::getResourcePath("Textures/default.png"));
std::vector<uint8_t> data = dataFromPath(RAYX::ResourceHandler::getInstance().getResourcePath("Textures/default.png"));
createImage(VK_IMAGE_TILING_OPTIMAL, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
createImageView();
createSampler();
Expand Down
4 changes: 2 additions & 2 deletions Intern/rayx-ui/src/RenderSystem/GridRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ void GridRenderSystem::render(FrameInfo& frameInfo, [[maybe_unused]] const std::

RenderSystem::Input GridRenderSystem::fillInput(VkRenderPass renderPass) const {
return RenderSystem::Input{.renderPass = renderPass,
.vertShaderPath = RAYX::getResourcePath("Shaders/grid_shader_vert.spv").string(),
.fragShaderPath = RAYX::getResourcePath("Shaders/grid_shader_frag.spv").string(),
.vertShaderPath = RAYX::ResourceHandler::getInstance().getResourcePath("Shaders/grid_shader_vert.spv").string(),
.fragShaderPath = RAYX::ResourceHandler::getInstance().getResourcePath("Shaders/grid_shader_frag.spv").string(),
.bindingDescriptions = std::vector<VkVertexInputBindingDescription>{},
.attributeDescriptions = std::vector<VkVertexInputAttributeDescription>{},
.topology = std::nullopt,
Expand Down
4 changes: 2 additions & 2 deletions Intern/rayx-ui/src/RenderSystem/ObjectRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void ObjectRenderSystem::render(FrameInfo& frameInfo, const std::vector<RenderOb

RenderSystem::Input ObjectRenderSystem::fillInput(VkRenderPass renderPass) const {
return RenderSystem::Input{.renderPass = renderPass,
.vertShaderPath = RAYX::getResourcePath("Shaders/shader_vert.spv").string(),
.fragShaderPath = RAYX::getResourcePath("Shaders/shader_frag.spv").string(),
.vertShaderPath = RAYX::ResourceHandler::getInstance().getResourcePath("Shaders/shader_vert.spv").string(),
.fragShaderPath = RAYX::ResourceHandler::getInstance().getResourcePath("Shaders/shader_frag.spv").string(),
.bindingDescriptions = TextureVertex::getBindingDescriptions(),
.attributeDescriptions = TextureVertex::getAttributeDescriptions(),
.topology = std::nullopt,
Expand Down
4 changes: 2 additions & 2 deletions Intern/rayx-ui/src/RenderSystem/RayRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ void RayRenderSystem::render(FrameInfo& frameInfo, const std::vector<RenderObjec

RenderSystem::Input RayRenderSystem::fillInput(VkRenderPass renderPass) const {
return RenderSystem::Input{.renderPass = renderPass,
.vertShaderPath = RAYX::getResourcePath("Shaders/ray_shader_vert.spv").string(),
.fragShaderPath = RAYX::getResourcePath("Shaders/ray_shader_frag.spv").string(),
.vertShaderPath = RAYX::ResourceHandler::getInstance().getResourcePath("Shaders/ray_shader_vert.spv").string(),
.fragShaderPath = RAYX::ResourceHandler::getInstance().getResourcePath("Shaders/ray_shader_frag.spv").string(),
.bindingDescriptions = ColorVertex::getBindingDescriptions(),
.attributeDescriptions = ColorVertex::getAttributeDescriptions(),
.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST,
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-ui/src/UserInterface/UIHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ UIHandler::UIHandler(const Window& window, const Device& device, VkFormat imageF
// Upload fonts
{
// Setup style
const std::filesystem::path fontPath = RAYX::getFontPath("Fonts/Roboto-Regular.ttf");
const std::filesystem::path fontPath = RAYX::ResourceHandler::getInstance().getFontPath("Fonts/Roboto-Regular.ttf");
m_fonts.push_back(m_IO.Fonts->AddFontFromFileTTF(fontPath.string().c_str(), 8.0f));
m_fonts.push_back(m_IO.Fonts->AddFontFromFileTTF(fontPath.string().c_str(), 16.0f));
m_fonts.push_back(m_IO.Fonts->AddFontFromFileTTF(fontPath.string().c_str(), 32.0f));
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx/src/TerminalApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void TerminalApp::tracePath(const std::filesystem::path& path) {
RAYX_EXIT << "Have you selected .csv exporting?";
}

auto cmd = std::string("python ") + RAYX::getResourcePath("Scripts/plot.py").string() + " " + file;
auto cmd = std::string("python ") + RAYX::ResourceHandler::getInstance().getResourcePath("Scripts/plot.py").string() + " " + file;
auto ret = system(cmd.c_str());
if (ret != 0) {
RAYX_WARN << "received error code while printing";
Expand Down

0 comments on commit b3c2615

Please sign in to comment.