From fca5524c26dd2449e0379b7744a986dd88d51734 Mon Sep 17 00:00:00 2001 From: Chang Geng Date: Sat, 19 Jul 2025 18:02:20 -0500 Subject: [PATCH 1/6] build(debug & release): move build scripts into scripts folder and fix root directory of scripts --- .../windows_build_debug.bat | 25 ++++++++------ scripts/windows_build_release.bat | 34 +++++++++++++++++++ windows_build_release.bat | 32 ----------------- 3 files changed, 48 insertions(+), 43 deletions(-) rename windows_build_debug.bat => scripts/windows_build_debug.bat (50%) create mode 100644 scripts/windows_build_release.bat delete mode 100644 windows_build_release.bat diff --git a/windows_build_debug.bat b/scripts/windows_build_debug.bat similarity index 50% rename from windows_build_debug.bat rename to scripts/windows_build_debug.bat index 00258c9..e3111eb 100644 --- a/windows_build_debug.bat +++ b/scripts/windows_build_debug.bat @@ -1,9 +1,13 @@ @echo off -setlocal +setlocal enabledelayedexpansion -:: Define directories -set "SOURCE_DIR=%~dp0" :: This should be the directory where the script is located -set "BUILD_DIR=%SOURCE_DIR%out\build" +:: Get the directory of the script (Torch/scripts/) +set "SCRIPT_DIR=%~dp0" +:: Go up one level to the project root (Torch/) +for %%I in ("%SCRIPT_DIR%..") do set "SOURCE_DIR=%%~fI" + +:: Define build directory inside the root +set "BUILD_DIR=%SOURCE_DIR%\out\build" :: Create build directory if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%" @@ -11,22 +15,21 @@ if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%" :: Navigate to build directory pushd "%BUILD_DIR%" +:: Debug: Print paths +echo Project root: %SOURCE_DIR% +echo Build dir: %BUILD_DIR% + :: Run CMake to generate build files echo Generating build files with CMake... cmake -DCMAKE_BUILD_TYPE=Debug "%SOURCE_DIR%" -:: Build the project using MSBuild +:: Build the project echo Building the project with MSBuild... cmake --build . --config Debug -:: Optionally, you can also run the executable (uncomment the following line if needed) -:: echo Running the application... -:: "%BUILD_DIR%\bin\Torch.exe" - -:: Return to the original directory +:: Go back popd echo Debug build and configuration completed. - endlocal pause diff --git a/scripts/windows_build_release.bat b/scripts/windows_build_release.bat new file mode 100644 index 0000000..598b603 --- /dev/null +++ b/scripts/windows_build_release.bat @@ -0,0 +1,34 @@ +@echo off +setlocal enabledelayedexpansion + +:: Get absolute path to the project root (one level above this script) +set "SCRIPT_DIR=%~dp0" +for %%I in ("%SCRIPT_DIR%..") do set "SOURCE_DIR=%%~fI" + +:: Define build directory path +set "BUILD_DIR=%SOURCE_DIR%\out\build" + +:: Create build directory if it doesn't exist +if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%" + +:: Navigate to build directory +pushd "%BUILD_DIR%" + +:: Run CMake to configure the project +echo === Generating Release build files === +cmake -DCMAKE_BUILD_TYPE=Release "%SOURCE_DIR%" + +:: Build the project +echo === Building the project in Release mode === +cmake --build . --config Release + +:: Optionally, run the executable (edit path if needed) +:: echo === Running the application === +:: "%BUILD_DIR%\bin\Sandbox.exe" + +:: Return to original directory +popd + +echo === Release build and configuration completed === +endlocal +pause diff --git a/windows_build_release.bat b/windows_build_release.bat deleted file mode 100644 index 96e25f1..0000000 --- a/windows_build_release.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -setlocal - -:: Define directories -set "SOURCE_DIR=%~dp0" :: This should be the directory where the script is located -set "BUILD_DIR=%SOURCE_DIR%out\build" - -:: Create build directory -if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%" - -:: Navigate to build directory -pushd "%BUILD_DIR%" - -:: Run CMake to generate build files -echo Generating build files with CMake... -cmake -DCMAKE_BUILD_TYPE=Release "%SOURCE_DIR%" - -:: Build the project using MSBuild -echo Building the project with MSBuild... -cmake --build . --config Release - -:: Optionally, you can also run the executable (uncomment the following line if needed) -:: echo Running the application... -:: "%BUILD_DIR%\bin\Torch.exe" - -:: Return to the original directory -popd - -echo Release build and configuration completed. - -endlocal -pause From 44a5988b8a53caa9c9d5cadd75b287ba9ee6ffff Mon Sep 17 00:00:00 2001 From: Chang Geng Date: Sat, 19 Jul 2025 18:06:21 -0500 Subject: [PATCH 2/6] ci: add build and release yaml workflow files --- .github/workflows/build.yml | 29 ++++++++++++++++++++++ .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bb26abe --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build Torch (Windows) + +on: + push: + branches: [dev] + pull_request: + branches: [dev] + workflow_dispatch: + +jobs: + build: + name: Build on Windows with MSVC + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup MSVC Developer Command Prompt + uses: ilammy/msvc-dev-cmd@v1 + + - name: Configure project with CMake (Release) + run: | + cmake -B out/build -DCMAKE_BUILD_TYPE=Release -S . + + - name: Build project + run: | + cmake --build out/build --config Release + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d93d954 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Build & Release Torch Engine + +on: + push: + tags: + - 'v*.*.*' # Triggers on version tags like v1.0.0 + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up CMake + uses: lukka/get-cmake@latest + + - name: Configure build (Release) + run: cmake -B out/build -DCMAKE_BUILD_TYPE=Release + + - name: Build project + run: cmake --build out/build --config Release + + - name: Prepare release package + run: | + mkdir release-package + cp out/build/Release/Sandbox.exe release-package/ + cp -r assets release-package/ + cp -r shaders release-package/ + cp LICENSE README.md release-package/ + powershell Compress-Archive -Path release-package\* -DestinationPath torch-release.zip + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: torch-release + path: torch-release.zip + + - name: Publish GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: torch-release.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 103544b89db6549df6bad83e165da39ae0c3acf1 Mon Sep 17 00:00:00 2001 From: Chang Geng Date: Sat, 19 Jul 2025 18:08:42 -0500 Subject: [PATCH 3/6] chore: temporary remove vulkan --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40f9cb8..e6e70b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,14 +36,14 @@ else() message("Platform: Unsupported") endif() -# Find Vulkan package -find_package(Vulkan REQUIRED) - -if(Vulkan_FOUND) - message("----FIND VULKAN----: ", ${Vulkan_INCLUDE_DIRS}) -else() - message("----CANNOT FIND VULKAN----") -endif() +# [TEMPORARILY REMOVED] +# Vulkan detection - DISABLED +# find_package(Vulkan REQUIRED) +# if(Vulkan_FOUND) +# message("----FIND VULKAN----: ${Vulkan_INCLUDE_DIRS}") +# else() +# message("----CANNOT FIND VULKAN----") +# endif() # Include directories include_directories( From 570025744f7d66d57a3230f638d0740de64ea2b9 Mon Sep 17 00:00:00 2001 From: Chang Geng Date: Sat, 19 Jul 2025 18:23:35 -0500 Subject: [PATCH 4/6] chore: remove old imgui submodle --- .gitmodules | 3 --- thirdParty/imgui | 1 - 2 files changed, 4 deletions(-) delete mode 160000 thirdParty/imgui diff --git a/.gitmodules b/.gitmodules index d803941..a4fbfe8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "thirdParty/glfw"] path = thirdParty/glfw url = https://github.com/glfw/glfw -[submodule "thirdParty/imgui"] - path = thirdParty/imgui - url = https://github.com/willproj/imgui [submodule "thirdParty/glm"] path = thirdParty/glm url = https://github.com/icaven/glm diff --git a/thirdParty/imgui b/thirdParty/imgui deleted file mode 160000 index e8aeed5..0000000 --- a/thirdParty/imgui +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e8aeed513cc83b49473f73c9486565cc63d78e1c From c72e54e720e649c9870c2d23ac52dad225af88b6 Mon Sep 17 00:00:00 2001 From: Chang Geng Date: Sat, 19 Jul 2025 18:49:07 -0500 Subject: [PATCH 5/6] fix: fix imgui syntax issue and exclude vulkan in cde --- .gitmodules | 4 + core/CMakeLists.txt | 23 +++-- core/graphics/TorchVulkanContext.h | 116 ++++++++++++------------- core/renderer/Vertex.h | 76 ++++++++--------- editor/CMakeLists.txt | 9 +- editor/EntityPropertiesPanel.cpp | 130 +++++++++++++++++++---------- engine/CMakeLists.txt | 7 +- pch/pch.h | 4 +- sandbox/CMakeLists.txt | 5 +- thirdParty/glad/CMakeLists.txt | 4 +- thirdParty/imgui | 1 + utils/CMakeLists.txt | 8 +- 12 files changed, 221 insertions(+), 166 deletions(-) create mode 160000 thirdParty/imgui diff --git a/.gitmodules b/.gitmodules index a4fbfe8..18eb0f0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -20,3 +20,7 @@ [submodule "thirdParty/ImGuizmo"] path = thirdParty/ImGuizmo url = https://github.com/willproj/ImGuizmo +[submodule "thirdParty/imgui"] + path = thirdParty/imgui + url = https://github.com/TheYangYang/imgui.git + branch = docking diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 16f496e..332259d 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,20 +1,27 @@ # Define the Engine library target add_library(Core STATIC) -# Specify the source files for the Engine library -file(GLOB_RECURSE ENGINE_SOURCES +# Get all .cpp files recursively under Core folder +file(GLOB_RECURSE ALL_ENGINE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp ) -# Add the source files to the Engine library +# Filter out any source files inside a 'vkcore' folder +set(ENGINE_SOURCES "") +foreach(src_file IN LISTS ALL_ENGINE_SOURCES) + if(NOT src_file MATCHES "/vkcore/") + list(APPEND ENGINE_SOURCES ${src_file}) + endif() +endforeach() + +# Add the filtered source files to the Engine library target_sources(Core PRIVATE ${ENGINE_SOURCES}) # Specify the precompiled header target_precompile_headers(Core PRIVATE ${CMAKE_SOURCE_DIR}/pch/pch.h) -# Include directories for the Engine library -target_include_directories(Core PRIVATE ${CMAKE_SOURCE_DIR} ${Vulkan_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) +# Include directories for the Engine library (Vulkan_INCLUDE_DIRS removed) +target_include_directories(Core PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -# Link the Logger library and Vulkan to the Engine library -target_link_libraries(Core PRIVATE Utils glfw glad Vulkan::Vulkan glm tinygltf yaml-cpp::yaml-cpp EnTT::EnTT) +# Link the Logger library and other dependencies (Vulkan removed) +target_link_libraries(Core PRIVATE Utils glfw glad glm tinygltf yaml-cpp::yaml-cpp EnTT::EnTT) diff --git a/core/graphics/TorchVulkanContext.h b/core/graphics/TorchVulkanContext.h index 403827b..269e8b2 100644 --- a/core/graphics/TorchVulkanContext.h +++ b/core/graphics/TorchVulkanContext.h @@ -1,64 +1,64 @@ -#pragma once -#include -#include "TorchGraphicsContext.h" -#include "core/vkcore/instance/VulkanInstance.h" -#include "core/vkcore/validationlayer/VulkanValidationLayers.h" -#include "core/vkcore/devices/VulkanPhysicalDevice.h" -#include "core/vkcore/devices/VulkanLogicDevice.h" -#include "core/vkcore/surface/VulkanWindowSurface.h" -#include "core/vkcore/swapchain/VulkanSwapChain.h" -#include "core/vkcore/imageviews/VulkanImageViews.h" -#include "core/vkcore/pipeline/VulkanGraphicsPipeline.h" -#include "core/vkcore/renderpass/VulkanRenderPass.h" -#include "core/vkcore/framebuffer/VulkanFramebuffer.h" -#include "core/vkcore/command/VulkanCommandBuffer.h" -#include "core/vkcore/command/VulkanCommandPool.h" -#include "core/vkcore/syncobjects/VulkanSyncObjects.h" -//#include "core/renderer/VertexBuffer.h" +// #pragma once +// #include +// #include "TorchGraphicsContext.h" +// #include "core/vkcore/instance/VulkanInstance.h" +// #include "core/vkcore/validationlayer/VulkanValidationLayers.h" +// #include "core/vkcore/devices/VulkanPhysicalDevice.h" +// #include "core/vkcore/devices/VulkanLogicDevice.h" +// #include "core/vkcore/surface/VulkanWindowSurface.h" +// #include "core/vkcore/swapchain/VulkanSwapChain.h" +// #include "core/vkcore/imageviews/VulkanImageViews.h" +// #include "core/vkcore/pipeline/VulkanGraphicsPipeline.h" +// #include "core/vkcore/renderpass/VulkanRenderPass.h" +// #include "core/vkcore/framebuffer/VulkanFramebuffer.h" +// #include "core/vkcore/command/VulkanCommandBuffer.h" +// #include "core/vkcore/command/VulkanCommandPool.h" +// #include "core/vkcore/syncobjects/VulkanSyncObjects.h" +// //#include "core/renderer/VertexBuffer.h" -namespace core -{ - class TorchVulkanContext : public TorchGraphicsContext - { - public: - TorchVulkanContext(); - ~TorchVulkanContext(); - void DrawFrame() override; - void OnUpdate() override; +// namespace core +// { +// class TorchVulkanContext : public TorchGraphicsContext +// { +// public: +// TorchVulkanContext(); +// ~TorchVulkanContext(); +// void DrawFrame() override; +// void OnUpdate() override; - APIType GetAPIType() const override { return APIType::Vulkan; } +// APIType GetAPIType() const override { return APIType::Vulkan; } - // Getter methods - const VulkanInstance &GetInstance() const { return m_Instance; } - const VulkanPhysicalDevice &GetPhysicalDevice() const { return m_PhysicalDevice; } - const VulkanLogicDevice &GetLogicalDevice() const { return m_LogicDevice; } - const VulkanWindowSurface &GetSurface() const { return m_Surface; } - const VulkanSwapChain &GetSwapChain() const { return m_SwapChain; } - const VulkanImageViews &GetImageViews() const { return m_ImageViews; } - const VulkanGraphicsPipeline &GetGraphicsPipeline() const { return m_GraphicsPipeline; } - const VulkanRenderPass &GetRenderPass() const { return m_RenderPass; } - const VulkanFramebuffer &GetFramebuffer() const { return m_Framebuffer; } - const VulkanCommandBuffer &GetCommandBuffer() const { return m_CommandBuffer; } - const VulkanCommandPool &GetCommandPool() const { return m_CommandPool; } - const VulkanSyncObjects &GetSyncObjects() const { return m_SyncObjects; } +// // Getter methods +// const VulkanInstance &GetInstance() const { return m_Instance; } +// const VulkanPhysicalDevice &GetPhysicalDevice() const { return m_PhysicalDevice; } +// const VulkanLogicDevice &GetLogicalDevice() const { return m_LogicDevice; } +// const VulkanWindowSurface &GetSurface() const { return m_Surface; } +// const VulkanSwapChain &GetSwapChain() const { return m_SwapChain; } +// const VulkanImageViews &GetImageViews() const { return m_ImageViews; } +// const VulkanGraphicsPipeline &GetGraphicsPipeline() const { return m_GraphicsPipeline; } +// const VulkanRenderPass &GetRenderPass() const { return m_RenderPass; } +// const VulkanFramebuffer &GetFramebuffer() const { return m_Framebuffer; } +// const VulkanCommandBuffer &GetCommandBuffer() const { return m_CommandBuffer; } +// const VulkanCommandPool &GetCommandPool() const { return m_CommandPool; } +// const VulkanSyncObjects &GetSyncObjects() const { return m_SyncObjects; } - private: - void CreateInstance(); - VulkanInstance m_Instance; - VulkanPhysicalDevice m_PhysicalDevice; - VulkanLogicDevice m_LogicDevice; - VulkanWindowSurface m_Surface; - VulkanSwapChain m_SwapChain; - VulkanImageViews m_ImageViews; - VulkanGraphicsPipeline m_GraphicsPipeline; - VulkanRenderPass m_RenderPass; - VulkanFramebuffer m_Framebuffer; - VulkanCommandBuffer m_CommandBuffer; - VulkanCommandPool m_CommandPool; - VulkanSyncObjects m_SyncObjects; - //VertexBuffer m_VertexBuffer; +// private: +// void CreateInstance(); +// VulkanInstance m_Instance; +// VulkanPhysicalDevice m_PhysicalDevice; +// VulkanLogicDevice m_LogicDevice; +// VulkanWindowSurface m_Surface; +// VulkanSwapChain m_SwapChain; +// VulkanImageViews m_ImageViews; +// VulkanGraphicsPipeline m_GraphicsPipeline; +// VulkanRenderPass m_RenderPass; +// VulkanFramebuffer m_Framebuffer; +// VulkanCommandBuffer m_CommandBuffer; +// VulkanCommandPool m_CommandPool; +// VulkanSyncObjects m_SyncObjects; +// //VertexBuffer m_VertexBuffer; - uint32_t currentFrame = 0; +// uint32_t currentFrame = 0; - }; -} +// }; +// } diff --git a/core/renderer/Vertex.h b/core/renderer/Vertex.h index f34f7f0..78f1ca4 100644 --- a/core/renderer/Vertex.h +++ b/core/renderer/Vertex.h @@ -1,38 +1,38 @@ -#pragma once -#include - - -namespace core -{ - struct Vertex - { - glm::vec2 position; - glm::vec3 color; - - static VkVertexInputBindingDescription GetBindingDescription() - { - VkVertexInputBindingDescription bindingDescription{}; - bindingDescription.binding = 0; - bindingDescription.stride = sizeof(Vertex); - bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - return bindingDescription; - } - - static std::array FetAttributeDescriptions() { - std::array attributeDescriptions{}; - - attributeDescriptions[0].binding = 0; - attributeDescriptions[0].location = 0; - attributeDescriptions[0].format = VK_FORMAT_R32G32_SFLOAT; - attributeDescriptions[0].offset = offsetof(Vertex, position); - - attributeDescriptions[1].binding = 0; - attributeDescriptions[1].location = 1; - attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT; - attributeDescriptions[1].offset = offsetof(Vertex, color); - - return attributeDescriptions; - } - - }; -} \ No newline at end of file +// #pragma once +// #include + + +// namespace core +// { +// struct Vertex +// { +// glm::vec2 position; +// glm::vec3 color; + +// static VkVertexInputBindingDescription GetBindingDescription() +// { +// VkVertexInputBindingDescription bindingDescription{}; +// bindingDescription.binding = 0; +// bindingDescription.stride = sizeof(Vertex); +// bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; +// return bindingDescription; +// } + +// static std::array FetAttributeDescriptions() { +// std::array attributeDescriptions{}; + +// attributeDescriptions[0].binding = 0; +// attributeDescriptions[0].location = 0; +// attributeDescriptions[0].format = VK_FORMAT_R32G32_SFLOAT; +// attributeDescriptions[0].offset = offsetof(Vertex, position); + +// attributeDescriptions[1].binding = 0; +// attributeDescriptions[1].location = 1; +// attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT; +// attributeDescriptions[1].offset = offsetof(Vertex, color); + +// return attributeDescriptions; +// } + +// }; +// } \ No newline at end of file diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index d7e1544..11d6f2d 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -1,4 +1,4 @@ -# Define the Engine library target +# Define the Editor library target add_library(Editor STATIC) # Specify the source files for the Editor library @@ -16,7 +16,8 @@ target_sources(Editor PRIVATE ${ENGINE_SOURCES}) target_precompile_headers(Editor PRIVATE ${CMAKE_SOURCE_DIR}/pch/pch.h) # Include directories for the Editor library -target_include_directories(Editor PRIVATE ${CMAKE_SOURCE_DIR} ${Vulkan_INCLUDE_DIRS}) +# Removed ${Vulkan_INCLUDE_DIRS} +target_include_directories(Editor PRIVATE ${CMAKE_SOURCE_DIR}) -# Link the Utils library and Vulkan to the Editor library -target_link_libraries(Editor PRIVATE Utils glfw glad Vulkan::Vulkan imgui Core yaml-cpp::yaml-cpp EnTT::EnTT ImGuizmo) +# Link the Utils library and other dependencies (Vulkan removed) +target_link_libraries(Editor PRIVATE Utils glfw glad imgui Core yaml-cpp::yaml-cpp EnTT::EnTT ImGuizmo) diff --git a/editor/EntityPropertiesPanel.cpp b/editor/EntityPropertiesPanel.cpp index 0e9dcc5..8947e9e 100644 --- a/editor/EntityPropertiesPanel.cpp +++ b/editor/EntityPropertiesPanel.cpp @@ -28,7 +28,7 @@ namespace editor return; } - m_Entity = { selectedEntityId, &core::SceneManager::GetSceneManager()->GetSceneRef().get() }; + m_Entity = {selectedEntityId, &core::SceneManager::GetSceneManager()->GetSceneRef().get()}; RenderUUIDHeader(); RenderEntityType(); @@ -51,7 +51,7 @@ namespace editor { if (m_Entity.HasComponent()) { - auto& typeComponent = m_Entity.GetComponent(); + auto &typeComponent = m_Entity.GetComponent(); ImGui::Text("Entity Type: %s", typeComponent.entityType == core::EntityType::General ? "General" : "Light"); } } @@ -60,7 +60,7 @@ namespace editor { if (m_Entity.HasComponent()) { - auto& uuidComponent = m_Entity.GetComponent(); + auto &uuidComponent = m_Entity.GetComponent(); ImGui::PushTextWrapPos(ImGui::GetContentRegionAvail().x); ImGui::Text("UUID: %s", uuidComponent.uuid.ToString().c_str()); ImGui::PopTextWrapPos(); @@ -71,7 +71,7 @@ namespace editor { if (m_Entity.HasComponent()) { - auto& labelComponent = m_Entity.GetComponent(); + auto &labelComponent = m_Entity.GetComponent(); static char str0[256]; strncpy(str0, labelComponent.label.c_str(), sizeof(str0) - 1); @@ -90,35 +90,38 @@ namespace editor } void EntityPropertiesPanel::RenderModelHeader() { - auto& modelComponent = m_Entity.GetComponent(); + auto &modelComponent = m_Entity.GetComponent(); ImGui::PushTextWrapPos(ImGui::GetContentRegionAvail().x); - ImGui::Text("Model: "); ImGui::SameLine(); + ImGui::Text("Model: "); + ImGui::SameLine(); if (modelComponent.model != nullptr) { ImGui::Text(modelComponent.model->GetModelPath().c_str()); } ImGui::PopTextWrapPos(); - + if (ImGui::Button("Load Model")) { m_ModelFilePath = utils::FileUtils::OpenFile("GLTF/GLB Files (*.gltf;*.glb)\0*.gltf;*.glb\0All Files (*.*)\0*.*\0"); core::ModelManager::GetInstance()->LoadModel(m_ModelFilePath); if (m_Entity.HasComponent()) { - auto& modelComponent = m_Entity.GetComponent(); + auto &modelComponent = m_Entity.GetComponent(); modelComponent.model = core::ModelManager::GetInstance()->GetModel(m_ModelFilePath); } - } + } ImGui::NewLine(); } void EntityPropertiesPanel::RenderTransformHeader() { if (m_Entity.HasComponent()) { - auto& transform = m_Entity.GetComponent(); + auto &transform = m_Entity.GetComponent(); if (ImGui::CollapsingHeader("Transform Component", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::Spacing(); ImGui::Spacing(); ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); DrawVec3Control("Translation", transform.translation); ImGui::Spacing(); glm::vec3 rotation = glm::degrees(transform.rotation); @@ -126,7 +129,10 @@ namespace editor ImGui::Spacing(); transform.rotation = glm::radians(rotation); DrawVec3Control("Scale", transform.scale, 1.0f); - ImGui::Spacing(); ImGui::Spacing(); ImGui::Spacing(); ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); } } } @@ -134,13 +140,22 @@ namespace editor { if (m_Entity.HasComponent()) { - auto& material = m_Entity.GetComponent(); + auto &material = m_Entity.GetComponent(); if (ImGui::CollapsingHeader("Material Component", ImGuiTreeNodeFlags_DefaultOpen)) { uint32_t imageSize = 100; ImGui::Checkbox("Use Albedo", &material.useAlbedoTexture); - ImGui::PushID(1); - if (ImGui::ImageButton((void*)(intptr_t)(material.albedoTexture == 0 ? m_DefaultTexture : material.albedoTexture), ImVec2(imageSize, imageSize))) + + // Corrected Albedo ImageButton call (removed frame_padding argument) + if (ImGui::ImageButton( + "albedo_texture_button", // String ID + (ImTextureID)(intptr_t)(material.albedoTexture == 0 ? m_DefaultTexture : material.albedoTexture), // Texture ID + ImVec2(imageSize, imageSize), // Size + ImVec2(0, 0), // UV0 + ImVec2(1, 1), // UV1 + // REMOVED: -1, // frame_padding (this was the 8th argument) + ImVec4(0, 0, 0, 0), // Background color + ImVec4(1, 1, 1, 1))) // Tint color { const std::string path = utils::FileUtils::OpenFile("Image Files (*.jpg;*.png)\0*.jpg;*.png\0"); if (!path.empty()) @@ -149,12 +164,19 @@ namespace editor material.albedoTexture = core::Texture::LoadTexture(path); } } - ImGui::PopID(); ImGui::Separator(); ImGui::Checkbox("Use Normal", &material.useNormalTexture); - ImGui::PushID(2); - if (ImGui::ImageButton((void*)(intptr_t)(material.normalTexture == 0 ? m_DefaultTexture : material.normalTexture), ImVec2(imageSize, imageSize))) + // Corrected Normal ImageButton call (removed frame_padding argument) + if (ImGui::ImageButton( + "normal_texture_button", // String ID + (ImTextureID)(intptr_t)(material.normalTexture == 0 ? m_DefaultTexture : material.normalTexture), + ImVec2(imageSize, imageSize), + ImVec2(0, 0), + ImVec2(1, 1), + // REMOVED: -1, // frame_padding + ImVec4(0, 0, 0, 0), + ImVec4(1, 1, 1, 1))) { const std::string path = utils::FileUtils::OpenFile("Image Files (*.jpg;*.png)\0*.jpg;*.png\0"); if (!path.empty()) @@ -163,12 +185,19 @@ namespace editor material.normalTexture = core::Texture::LoadTexture(path); } } - ImGui::PopID(); ImGui::Separator(); ImGui::Checkbox("Use Metallic", &material.useMetallicTexture); - ImGui::PushID(3); - if (ImGui::ImageButton((void*)(intptr_t)(material.metallicTexture == 0 ? m_DefaultTexture : material.metallicTexture), ImVec2(imageSize, imageSize))) + // Corrected Metallic ImageButton call (removed frame_padding argument) + if (ImGui::ImageButton( + "metallic_texture_button", // String ID + (ImTextureID)(intptr_t)(material.metallicTexture == 0 ? m_DefaultTexture : material.metallicTexture), + ImVec2(imageSize, imageSize), + ImVec2(0, 0), + ImVec2(1, 1), + // REMOVED: -1, // frame_padding + ImVec4(0, 0, 0, 0), + ImVec4(1, 1, 1, 1))) { const std::string path = utils::FileUtils::OpenFile("Image Files (*.jpg;*.png)\0*.jpg;*.png\0"); if (!path.empty()) @@ -178,12 +207,19 @@ namespace editor } } ImGui::SliderFloat("Metallic", &material.metallic, 0.0f, 1.0f); - ImGui::PopID(); ImGui::Separator(); ImGui::Checkbox("Use Roughness", &material.useRoughnessTexture); - ImGui::PushID(4); - if (ImGui::ImageButton((void*)(intptr_t)(material.roughnessTexture == 0 ? m_DefaultTexture : material.roughnessTexture), ImVec2(imageSize, imageSize))) + // Corrected Roughness ImageButton call (removed frame_padding argument) + if (ImGui::ImageButton( + "roughness_texture_button", // String ID + (ImTextureID)(intptr_t)(material.roughnessTexture == 0 ? m_DefaultTexture : material.roughnessTexture), + ImVec2(imageSize, imageSize), + ImVec2(0, 0), + ImVec2(1, 1), + // REMOVED: -1, // frame_padding + ImVec4(0, 0, 0, 0), + ImVec4(1, 1, 1, 1))) { const std::string path = utils::FileUtils::OpenFile("Image Files (*.jpg;*.png)\0*.jpg;*.png\0"); if (!path.empty()) @@ -193,12 +229,19 @@ namespace editor } } ImGui::SliderFloat("Roughness", &material.roughness, 0.0f, 10.0f); - ImGui::PopID(); ImGui::Separator(); ImGui::Checkbox("Use AO", &material.useAOTexture); - ImGui::PushID(5); - if (ImGui::ImageButton((void*)(intptr_t)(material.aoTexture == 0 ? m_DefaultTexture : material.aoTexture), ImVec2(imageSize, imageSize))) + // Corrected AO ImageButton call (removed frame_padding argument) + if (ImGui::ImageButton( + "ao_texture_button", // String ID + (ImTextureID)(intptr_t)(material.aoTexture == 0 ? m_DefaultTexture : material.aoTexture), + ImVec2(imageSize, imageSize), + ImVec2(0, 0), + ImVec2(1, 1), + // REMOVED: -1, // frame_padding + ImVec4(0, 0, 0, 0), + ImVec4(1, 1, 1, 1))) { const std::string path = utils::FileUtils::OpenFile("Image Files (*.jpg;*.png)\0*.jpg;*.png\0"); if (!path.empty()) @@ -207,7 +250,6 @@ namespace editor material.aoTexture = core::Texture::LoadTexture(path); } } - ImGui::PopID(); ImGui::Separator(); } } @@ -244,9 +286,9 @@ namespace editor ImGui::EndPopup(); } } - void EntityPropertiesPanel::DrawVec3Control(const std::string& label, glm::vec3& values, float resetValue, float columnWidth) + void EntityPropertiesPanel::DrawVec3Control(const std::string &label, glm::vec3 &values, float resetValue, float columnWidth) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO &io = ImGui::GetIO(); auto boldFont = io.Fonts->Fonts[0]; ImGui::PushID(label.c_str()); @@ -257,16 +299,14 @@ namespace editor ImGui::NextColumn(); ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth()); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 }); - - - - float lineHeight = GImGui->Font->FontSize + GImGui->Style.FramePadding.y * 2.0f; - ImVec2 buttonSize = { lineHeight + 3.0f, lineHeight }; + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{0, 0}); + + float lineHeight = ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.0f; + ImVec2 buttonSize = {lineHeight + 3.0f, lineHeight}; - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f }); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.9f, 0.2f, 0.2f, 1.0f }); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f }); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{0.8f, 0.1f, 0.15f, 1.0f}); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{0.9f, 0.2f, 0.2f, 1.0f}); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{0.8f, 0.1f, 0.15f, 1.0f}); ImGui::PushFont(boldFont); if (ImGui::Button("X", buttonSize)) values.x = resetValue; @@ -278,9 +318,9 @@ namespace editor ImGui::PopItemWidth(); ImGui::SameLine(); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f }); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.3f, 0.8f, 0.3f, 1.0f }); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f }); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{0.2f, 0.7f, 0.2f, 1.0f}); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{0.3f, 0.8f, 0.3f, 1.0f}); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{0.2f, 0.7f, 0.2f, 1.0f}); ImGui::PushFont(boldFont); if (ImGui::Button("Y", buttonSize)) values.y = resetValue; @@ -292,9 +332,9 @@ namespace editor ImGui::PopItemWidth(); ImGui::SameLine(); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f }); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.2f, 0.35f, 0.9f, 1.0f }); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f }); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{0.1f, 0.25f, 0.8f, 1.0f}); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{0.2f, 0.35f, 0.9f, 1.0f}); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{0.1f, 0.25f, 0.8f, 1.0f}); ImGui::PushFont(boldFont); if (ImGui::Button("Z", buttonSize)) values.z = resetValue; diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 681de8f..a34351f 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -16,7 +16,8 @@ target_sources(Engine PRIVATE ${ENGINE_SOURCES}) target_precompile_headers(Engine PRIVATE ${CMAKE_SOURCE_DIR}/pch/pch.h) # Include directories for the Engine library -target_include_directories(Engine PRIVATE ${CMAKE_SOURCE_DIR} ${Vulkan_INCLUDE_DIRS}) +# Removed ${Vulkan_INCLUDE_DIRS} +target_include_directories(Engine PRIVATE ${CMAKE_SOURCE_DIR}) -# Link the Utils library and Vulkan to the Engine library -target_link_libraries(Engine PRIVATE Utils glfw glad Vulkan::Vulkan Core Editor) +# Link the Utils library and other dependencies (Vulkan removed) +target_link_libraries(Engine PRIVATE Utils glfw glad Core Editor) diff --git a/pch/pch.h b/pch/pch.h index 79b3753..5489d78 100644 --- a/pch/pch.h +++ b/pch/pch.h @@ -66,10 +66,10 @@ #include // Vulkan Headers -#include +// #include #include -#include +// #include #include #include diff --git a/sandbox/CMakeLists.txt b/sandbox/CMakeLists.txt index 80ebbf2..5051e72 100644 --- a/sandbox/CMakeLists.txt +++ b/sandbox/CMakeLists.txt @@ -7,5 +7,6 @@ target_precompile_headers(Sandbox PRIVATE ${CMAKE_SOURCE_DIR}/pch/pch.h) # Include directories for the platform target target_include_directories(Sandbox PRIVATE ${CMAKE_SOURCE_DIR}) -# Link Engine, Utils, and Vulkan libraries to the Sandbox executable -target_link_libraries(Sandbox PRIVATE Utils Engine glad glfw Vulkan::Vulkan Core Editor tinygltf) +# Link Engine, Utils, and other libraries to the Sandbox executable +# Removed Vulkan::Vulkan for now +target_link_libraries(Sandbox PRIVATE Utils Engine glad glfw Core Editor tinygltf) diff --git a/thirdParty/glad/CMakeLists.txt b/thirdParty/glad/CMakeLists.txt index d164d78..a9c4714 100644 --- a/thirdParty/glad/CMakeLists.txt +++ b/thirdParty/glad/CMakeLists.txt @@ -13,5 +13,5 @@ target_include_directories(glad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ) -# Linking Vulkan in the glad target -target_link_libraries(glad PRIVATE Vulkan::Vulkan) \ No newline at end of file +# Temporarily disable Vulkan linking +# target_link_libraries(glad PRIVATE Vulkan::Vulkan) diff --git a/thirdParty/imgui b/thirdParty/imgui new file mode 160000 index 0000000..dc9401b --- /dev/null +++ b/thirdParty/imgui @@ -0,0 +1 @@ +Subproject commit dc9401b843753bb17c8013498f6911fb75b44e5b diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 06ac8bf..d690d87 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -7,8 +7,8 @@ target_precompile_headers(Utils PRIVATE ${CMAKE_SOURCE_DIR}/pch/pch.h) # Include directories for Utils target_include_directories(Utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}) -# Link spdlog directly to Utils and Vulkan -target_link_libraries(Utils PUBLIC spdlog::spdlog glad glfw Vulkan::Vulkan Core yaml-cpp::yaml-cpp) -target_include_directories(Utils PRIVATE ${Vulkan_INCLUDE_DIRS}) - +# Link spdlog directly to Utils (removed Vulkan) +target_link_libraries(Utils PUBLIC spdlog::spdlog glad glfw Core yaml-cpp::yaml-cpp) +# Removed Vulkan include directories +# target_include_directories(Utils PRIVATE ${Vulkan_INCLUDE_DIRS}) # Commented out or removed From b3bf9ee51cb21a52a1ef6a363a0b54936a096765 Mon Sep 17 00:00:00 2001 From: Chang Geng Date: Sat, 19 Jul 2025 18:56:38 -0500 Subject: [PATCH 6/6] fix(ci): fix yaml files by enabling submodules --- .github/workflows/build.yml | 5 +++-- .github/workflows/release.yml | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bb26abe..a3744d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + submodules: 'true' - name: Setup MSVC Developer Command Prompt uses: ilammy/msvc-dev-cmd@v1 @@ -25,5 +27,4 @@ jobs: - name: Build project run: | - cmake --build out/build --config Release - + cmake --build out/build --config Release \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d93d954..bc74f0e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Build & Release Torch Engine on: push: tags: - - 'v*.*.*' # Triggers on version tags like v1.0.0 + - 'v*.*.*' # Triggers on version tags like v1.0.0 jobs: build: @@ -12,12 +12,14 @@ jobs: steps: - name: Checkout source uses: actions/checkout@v4 + with: + submodules: 'true' - name: Set up CMake uses: lukka/get-cmake@latest - name: Configure build (Release) - run: cmake -B out/build -DCMAKE_BUILD_TYPE=Release + run: cmake -B out/build -DCMAKE_BUILD_TYPE=Release -S . - name: Build project run: cmake --build out/build --config Release @@ -26,6 +28,7 @@ jobs: run: | mkdir release-package cp out/build/Release/Sandbox.exe release-package/ + # Ensure assets and shaders are indeed simple directories or submodules handled by `submodules: 'true'` cp -r assets release-package/ cp -r shaders release-package/ cp LICENSE README.md release-package/ @@ -42,4 +45,4 @@ jobs: with: files: torch-release.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file