diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..1ac273c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,83 @@ +# Engine +# Copyright 2026 Daynlight +# Licensed under the GNU General, Version 3.0. +# See LICENSE file for details. + + + +name: Tests via CMake + GTests + +on: + push: + branches: [ "*" ] + pull_request: + branches: [ "*" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + + matrix: + os: [ubuntu-latest] # windows-latest + build_type: [Release, Debug] + include: + # - os: windows-latest + # c_compiler: gcc + # cpp_compiler: g++ + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y \ + xvfb \ + mesa-utils \ + libgl1-mesa-dri \ + libwayland-dev \ + wayland-protocols \ + extra-cmake-modules \ + libxkbcommon-dev \ + libx11-dev \ + libxrandr-dev \ + libxinerama-dev \ + libxcursor-dev \ + libxi-dev \ + libxext-dev \ + libgl1-mesa-dev + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure CMake + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -G Ninja + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Test (Linux) + if: runner.os == 'Linux' + run: xvfb-run --auto-servernum ctest --test-dir ${{ steps.strings.outputs.build-output-dir }} -C ${{ matrix.build_type }} --output-on-failure + + - name: Test (Windows) + if: runner.os == 'Windows' + run: ctest --test-dir ${{ steps.strings.outputs.build-output-dir }} -C ${{ matrix.build_type }} --output-on-failure \ No newline at end of file diff --git a/.gitignore b/.gitignore index af38d2e..dbba341 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ build/ Build/ build-*/ +build_*/ # CMake generated files CMakeFiles/ @@ -73,6 +74,11 @@ bin/ build/ *.ini -temp* +*temp* +Examples/**/App Scripts_DLL/ -**/Scripts/ScriptShared/ \ No newline at end of file +**/Scripts/ScriptShared/ +.GameData_back/ +/GameData/ +/Scripts/ +Engine_Bin/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..896f358 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,11 @@ +[submodule "vendor/CWindow"] + path = vendor/CWindow + url = https://github.com/Daynlight/CWindow.git + branch = engine +[submodule "vendor/cmrc"] + path = vendor/cmrc + url = https://github.com/vector-of-bool/cmrc.git + branch = master +[submodule "vendor/googletest"] + path = vendor/googletest + url = https://github.com/google/googletest.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2178880..669582b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Help me I'am Under The Water +# Engine # Copyright 2026 Daynlight # Licensed under the GNU General, Version 3.0. # See LICENSE file for details. @@ -7,58 +7,61 @@ cmake_minimum_required(VERSION 3.15) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(CMAKE_CXX_STANDARD 26) +set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -option(PRODUCTION "Enable production build flags" OFF) -# option(SANDBOX_SCRIPTS "Enable script sandboxing build flags" ON) - -include(FetchContent) +option(PRODUCTION "Enable production build flags" OFF) +option(SANDBOX_SCRIPTS "Enable script sandboxing build flags" OFF) -FetchContent_Declare(CWindow - GIT_REPOSITORY https://github.com/Daynlight/CWindow.git - GIT_TAG under_water - GIT_SHALLOW TRUE +execute_process( + COMMAND git submodule update --init --recursive ) -FetchContent_MakeAvailable(CWindow) -FetchContent_Declare(cmrc - GIT_REPOSITORY https://github.com/vector-of-bool/cmrc.git - GIT_TAG master - GIT_SHALLOW TRUE -) -FetchContent_MakeAvailable(cmrc) +add_subdirectory(vendor/CWindow) +add_subdirectory(vendor/cmrc) +add_subdirectory(vendor/googletest vendor/googletest EXCLUDE_FROM_ALL) -if(PRODUCTION) - file(GLOB_RECURSE GameDataSet CONFIGURE_DEPENDS "GameData/**") - cmrc_add_resource_library(GameData ${GameDataSet}) +set(ENGINE_SRC "${CMAKE_BINARY_DIR}/Engine") +if(DEFINED ENV{XDG_DATA_HOME}) + set(ENGINE_SRC_DIR "$ENV{XDG_DATA_HOME}/Engine") +else() + set(ENGINE_SRC_DIR "$ENV{HOME}/.local/share/Engine") endif() +set(ENGINE_SRC_DEST "${ENGINE_SRC_DIR}/Engine") -file(GLOB_RECURSE ScriptSharedSet CONFIGURE_DEPENDS "ScriptShared/**") -cmrc_add_resource_library(ScriptShared ${ScriptSharedSet}) - +if(NOT PRODUCTION) + file(REMOVE_RECURSE "${ENGINE_SRC_DEST}") + file(MAKE_DIRECTORY "${ENGINE_SRC_DEST}") -add_subdirectory(Engine) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/Engine" + DESTINATION "${ENGINE_SRC_DEST}" + PATTERN "Examples" EXCLUDE) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/vendor" + DESTINATION "${ENGINE_SRC_DEST}" + PATTERN "Examples" EXCLUDE) -if(PRODUCTION) - target_compile_definitions(Engine PRIVATE PRODUCTION) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + DESTINATION "${ENGINE_SRC_DEST}") endif() + + +file(GLOB_RECURSE GameDataSet CONFIGURE_DEPENDS "GameData/**") +cmrc_add_resource_library(GameData ${GameDataSet}) +file(GLOB_RECURSE PROD_SCRIPTS CONFIGURE_DEPENDS "Scripts/*.cpp") -target_compile_definitions(Engine PRIVATE COMPILER_PATH="${CMAKE_CXX_COMPILER}") -message(STATUS "ScriptController uses CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") -message(STATUS "ScriptController uses COMPILER_PATH definition=${CMAKE_CXX_COMPILER}") +add_subdirectory(Engine) +enable_testing() +add_subdirectory(Tests) -# if(SANDBOX_SCRIPTS) -# target_compile_definitions(Engine PRIVATE SANDBOX_SCRIPTS) -# endif() + +install(TARGETS Engine + DESTINATION bin +) diff --git a/Engine/App.cpp b/Engine/App.cpp deleted file mode 100644 index 98e2205..0000000 --- a/Engine/App.cpp +++ /dev/null @@ -1,227 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "App.h" - - - -#if defined(_WIN32) || defined(_WIN64) -#include -extern "C" { - __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; -} -#endif - - - -UW::App::App() - :scene(window) -#ifndef PRODUCTION - , ui(window, fps, scene) -#endif -{ - Logger::get().info("App", "App Initialization"); - - - DataSerializer::get().loadAll(); - initWindow(); - UW::GlobResource::get().input_data = window.getInputData(); - - onLoad(); - - Logger::get().info("App", "App Initialized"); -}; - - - -UW::App::~App(){ - Logger::get().info("App", "App Destroying"); - - onDestroy(); - - Logger::get().info("App", "App Destroyed"); -}; - - - -bool UW::App::isRunning(){ - return !window.getWindowData()->should_close; -}; - - - -void UW::App::run(){ - update(); - fixedUpdate(); - render(); -}; - - - -// ===================================== // -// ========== Core Operations ========== // -// ===================================== // -void UW::App::onLoad(){ - Logger::get().info("App", "App Loading"); - -#ifndef PRODUCTION - ui.onLoad(); - Logger::get().info("App", "UI Loaded"); -#endif - - scene.onLoad(); - Logger::get().info("App", "Scene Loaded"); - - Logger::get().info("App", "App Loaded"); -}; - - - -void UW::App::onDestroy() { - Logger::get().info("App", "Destroying App"); - - -#ifndef PRODUCTION - DataSerializer::get().saveAll(); - Logger::get().info("Scene", "Force saved scene data"); - ui.onDestroy(); - Logger::get().info("App", "UI Destroyed"); -#endif - - scene.onDestroy(); - Logger::get().info("App", "Scene Destroyed"); - - Resources::get().destroy(); - Logger::get().info("App", "Resources Destroyed"); - - Logger::get().info("App", "App Destroyed"); - -#ifndef PRODUCTION - Logger::get().info("App", "Recorded AVG FPS = " + std::to_string(total_fps_acc / total_fps_id)); -#endif -}; - - - -void UW::App::render(){ - scene.render(); - -#ifndef PRODUCTION - ui.render(); -#endif - - window.windowEvents(); - window.swapBuffer(); -}; - - - - -void UW::App::update(){ -#ifndef PRODUCTION - updateFps(); - swapCamera(); -#endif - - scene.onUpdate(window.getWindowData()->delta_time); -}; - - - -void UW::App::fixedUpdate(){ - fixed_update_time_acc += window.getWindowData()->delta_time; - - if(UW::GlobResource::get().FIXED_HZ > UW::Config::MAX_FIXED_HZ) UW::GlobResource::get().FIXED_HZ = UW::Config::MAX_FIXED_HZ; - if(UW::GlobResource::get().FIXED_HZ < UW::Config::MIN_FIXED_HZ) UW::GlobResource::get().FIXED_HZ = UW::Config::MIN_FIXED_HZ; - - float fixed_time_step = 1.0f / UW::GlobResource::get().FIXED_HZ; - - int max_steps = UW::Config::MAX_FIXED_STEPS; - while(fixed_update_time_acc >= fixed_time_step && max_steps-- > 0){ - -#ifndef PRODUCTION - guiSettings.window_width = window.getWindowData()->width; - guiSettings.window_height = window.getWindowData()->height; -#endif - - if(cached_title != UW::GlobResource::get().WINDOW_TITLE) updateTitle(); - if(cached_vsync != UW::GlobResource::get().VSYNC) updateVsync(); - - scene.onFixedUpdate(fixed_time_step); - - fixed_update_time_acc -= fixed_time_step; - }; - - if(max_steps <= 0) fixed_update_time_acc = 0; -}; - - - -// ============================= // -// ========== Helpers ========== // -// ============================= // -void UW::App::initWindow(){ - Logger::get().info("App", "Window Initialization"); - - updateTitle(); - - window.setCursorVisibility(UW::Config::DEFAULT_CURSOR_IS_VISIBLE); - Logger::get().info("App", "Cursor visiblity set to - " + std::string(UW::Config::DEFAULT_CURSOR_IS_VISIBLE == 1 ? "On" : "Off")); - - updateVsync(); - - Logger::get().info("App", "Window Initialized"); -}; - - - -void UW::App::updateTitle(){ - cached_title = UW::GlobResource::get().WINDOW_TITLE; - - window.setWindowTitle(cached_title); - Logger::get().info("App", "Title set to - " + cached_title); -}; - - - -void UW::App::updateVsync(){ - cached_vsync = UW::GlobResource::get().VSYNC; - - window.setVsync(cached_vsync); - Logger::get().info("App", "VSync set to - " + std::string(cached_vsync != 0 ? "On" : "Off")); -}; - - - -#ifndef PRODUCTION -void UW::App::swapCamera(){ - if(window.getInputData()->is_key_down(UW::Config::SWAP_CAMERA_BTN) && camera_swap_cooldown_acc <= 0.0f) { - scene.debug_camera_on = !scene.debug_camera_on; - camera_swap_cooldown_acc = UW::Config::CAMERA_SWAP_COOLDOWN; - - Logger::get().info("App", "Camera Swapped to { "+ std::string(scene.debug_camera_on ? "DEBUG CAMERA" : "NORMAL CAMERA") + " }"); - }; - - if(camera_swap_cooldown_acc >= 0.0f) camera_swap_cooldown_acc -= window.getWindowData()->delta_time; -}; - - - -void UW::App::updateFps(){ - if(fps_id > UW::Config::FPS_SAMPLES){ - fps = fps_id / fps_acc; - fps_acc = 0.0f; - fps_id = 0; - total_fps_acc += fps; - total_fps_id++; - } - else{ - fps_acc += window.getWindowData()->delta_time; - fps_id++; - }; -}; -#endif diff --git a/Engine/App/App/App.cpp b/Engine/App/App/App.cpp new file mode 100644 index 0000000..0a16a8b --- /dev/null +++ b/Engine/App/App/App.cpp @@ -0,0 +1,167 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "App.h" + + + +#if defined(_WIN32) || defined(_WIN64) +#include +extern "C" { + __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; +} +#elif defined(__linux__) +#include +__attribute__((constructor)) void forceLinuxDiscreteGPU() { + setenv("__NV_PRIME_RENDER_OFFLOAD", "1", 1); + setenv("__GLX_VENDOR_LIBRARY_NAME", "nvidia", 1); + setenv("__VK_LAYER_NV_optimus", "NVIDIA_only", 1); + setenv("DRI_PRIME", "1", 1); +} +#endif + + + +Engine::App::App::App() + : viewport_fbo(core.window.getWindowData()->width, core.window.getWindowData()->height) +#ifndef PRODUCTION + , editor(core, fps, viewport_fbo) +#endif +{ + Engine::Utils::Logger::get().info("App", "App Initialization"); + onLoad(); + Engine::Utils::Logger::get().info("App", "App Initialized"); +}; + + + +Engine::App::App::~App(){ + Engine::Utils::Logger::get().info("App", "App Destroying"); + onDestroy(); + Engine::Utils::Logger::get().info("App", "App Destroyed"); +}; + + + +bool Engine::App::App::isRunning(){ + return core.isRunning(); +}; + + + +void Engine::App::App::run(){ + update(); + fixedUpdate(); + render(); +}; + + + +// ===================================== // +// ========== Core Operations ========== // +// ===================================== // +void Engine::App::App::onLoad(){ + Engine::Utils::Logger::get().info("App", "App Loading"); + +#ifndef PRODUCTION + editor.onLoad(); +#endif + + core.onLoad(); + Engine::Utils::Logger::get().info("App", "Scene Loaded"); + + Engine::Utils::Logger::get().info("App", "App Loaded"); +}; + + + +void Engine::App::App::onDestroy() { + Engine::Utils::Logger::get().info("App", "Destroying App"); + + +#ifndef PRODUCTION + editor.onDestroy(); + Engine::Utils::Logger::get().info("App", "UI Destroyed"); +#endif + + core.onDestroy(); + Engine::Utils::Logger::get().info("App", "Core Destroyed"); + + Engine::Utils::Logger::get().info("App", "App Destroyed"); + +#ifndef PRODUCTION + Engine::Utils::Logger::get().info("App", "Recorded AVG FPS = " + std::to_string(total_fps_acc / total_fps_id)); +#endif +}; + + + +void Engine::App::App::render(){ + core.render(); + viewport_fbo = core.get_fbo(); + +#ifndef PRODUCTION + core.window.beginFrame(); + glClearColor(0.1f, 0.1f, 0.1f, 1.0f); + editor.render(); +#else + viewport_fbo.blitToScreen(core.window.getWindowData()->width, core.window.getWindowData()->height); +#endif + + core.swapFrame(); +}; + + + + +void Engine::App::App::update(){ +#ifndef PRODUCTION + updateFps(); +#endif + + core.update(); +}; + + + +void Engine::App::App::fixedUpdate(){ +#ifndef PRODUCTION + fixed_update_time_acc += core.window.getWindowData()->delta_time; + + float fixed_time_step = 1.0f / Engine::ScriptShared::GlobResource::get().FIXED_HZ; + + int max_steps = Engine::Config::MAX_FIXED_STEPS; + while(fixed_update_time_acc >= fixed_time_step && max_steps-- > 0){ + Engine::Editor::guiSettings.window_width = core.window.getWindowData()->width; + Engine::Editor::guiSettings.window_height = core.window.getWindowData()->height; + + fixed_update_time_acc -= fixed_time_step; + }; + if(max_steps <= 0) fixed_update_time_acc = 0; +#endif + + core.fixedUpdate(); +}; + + + + +#ifndef PRODUCTION +void Engine::App::App::updateFps(){ + if(fps_id > Engine::Config::FPS_SAMPLES){ + fps = fps_id / fps_acc; + fps_acc = 0.0f; + fps_id = 0; + total_fps_acc += fps; + total_fps_id++; + } + else{ + fps_acc += core.window.getWindowData()->delta_time; + fps_id++; + }; +}; +#endif diff --git a/Engine/App/App/App.h b/Engine/App/App/App.h new file mode 100644 index 0000000..a9c79b3 --- /dev/null +++ b/Engine/App/App/App.h @@ -0,0 +1,66 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include "Renderer.h" +#include "Core.h" + +#include +#include + +#ifndef PRODUCTION +#include "Editor.h" +#endif + +#include "Utils/config.h" +#include "Utils/Logger.h" +#include "Resources/Resources.h" +#include "ScriptShared/GlobResource.h" +#include "Scene.h" + + + +namespace Engine::App{ +class App{ +private: + Engine::Core::Core core; + CW::Renderer::Framebuffer viewport_fbo; + +#ifndef PRODUCTION + Engine::Editor::Editor editor; + float fps = 0.0f; + float fps_acc = 0.0f; + unsigned int fps_id = 0; + + float total_fps_acc = 0.0f; + unsigned int total_fps_id = 0; + + #endif + + float fixed_update_time_acc = 0.0f; + +public: + App(); + ~App(); + + bool isRunning(); + void run(); + +private: + // core operations + void onLoad(); + void onDestroy(); + void render(); + void update(); + void fixedUpdate(); + +#ifndef PRODUCTION + void updateFps(); +#endif + +}; +}; diff --git a/Engine/main.cpp b/Engine/App/App/main.cpp similarity index 80% rename from Engine/main.cpp rename to Engine/App/App/main.cpp index 9b3d0a9..5294779 100644 --- a/Engine/main.cpp +++ b/Engine/App/App/main.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -10,7 +10,7 @@ int main(){ - UW::App app; + Engine::App::App app; while(app.isRunning()) app.run(); diff --git a/Engine/App/CMakeLists.txt b/Engine/App/CMakeLists.txt new file mode 100644 index 0000000..781088c --- /dev/null +++ b/Engine/App/CMakeLists.txt @@ -0,0 +1,29 @@ +# Engine +# Copyright 2026 Daynlight +# Licensed under the GNU General, Version 3.0. +# See LICENSE file for details. + + + +cmake_minimum_required(VERSION 3.15) + +project(Engine LANGUAGES CXX C) +project(App LANGUAGES CXX C) + + +set(src + "App/main.cpp" + "App/App.cpp" +) + + +add_executable(Engine ${src}) +target_link_libraries(Engine CoreDev) +target_include_directories(Engine PUBLIC "App/") +target_link_libraries(Engine Editor) + + +add_executable(App ${src}) +target_link_libraries(App PRIVATE "-Wl,--whole-archive" Core "-Wl,--no-whole-archive") +target_include_directories(App PUBLIC "App/") +target_compile_definitions(App PRIVATE PRODUCTION) diff --git a/Engine/CMakeLists.txt b/Engine/CMakeLists.txt index a8a8f2e..8b193f9 100644 --- a/Engine/CMakeLists.txt +++ b/Engine/CMakeLists.txt @@ -1,4 +1,4 @@ -# Help me I'am Under The Water +# Engine # Copyright 2026 Daynlight # Licensed under the GNU General, Version 3.0. # See LICENSE file for details. @@ -7,70 +7,14 @@ cmake_minimum_required(VERSION 3.15) -project(Engine LANGUAGES CXX C) +file(GLOB_RECURSE ScriptSharedSet CONFIGURE_DEPENDS "ScriptShared/**") +cmrc_add_resource_library(ScriptShared ${ScriptSharedSet}) -set(src - "main.cpp" - "App.cpp" - "Scene.cpp" - "UI/UI.cpp" - "UI/UI_Logs.cpp" - "UI/UI_Materials.cpp" - "UI/UI_Shaders.cpp" - "UI/UI_Scripts.cpp" - "UI/UI_Objects.cpp" - "UI/UI_Lights.cpp" - "UI/UI_AssetLoader.cpp" - "UI/UI_ShaderEditors.cpp" - "UI/UI_ScriptEditor.cpp" - "UI/UI_Info.cpp" - "Utils/Logger.cpp" - "Camera/Camera.cpp" - "Resources/Resources.cpp" - "Resources/Meshes/Meshes.cpp" - "Resources/Lights/Lights.cpp" - "Resources/Materials/Materials.cpp" - "Objects/Terrain/Terrain.cpp" - "Objects/Water/Water.cpp" - "Objects/Skybox/Skybox.cpp" - "Objects/Meduse/Meduse.cpp" - "Objects/GameObject.cpp" - "Objects/ObjectManager.cpp" - "DataSerializer/GlobResourceSerialization.cpp" - "ScriptController/ScriptController.cpp" - "DataSerializer/DataSerializer.cpp" - "DataSerializer/MeshSerialization.cpp" - "DataSerializer/ObjectsSerialization.cpp" - "DataSerializer/MaterialsSerialization.cpp" - "DataSerializer/LightsSerialization.cpp" - "DataSerializer/ShaderSerialization.cpp" - "DataSerializer/ScriptSerialization.cpp" -) - - - -add_executable(Engine ${src}) - - - -if(PRODUCTION) - target_compile_definitions(Engine PRIVATE PRODUCTION) - file(GLOB_RECURSE PROD_SCRIPTS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../Scripts/*.cpp") - target_sources(Engine PRIVATE ${PROD_SCRIPTS}) -endif() - -target_link_libraries(Engine CWindow) - - - -if(PRODUCTION) - target_link_libraries(Engine GameData) -else() - target_link_libraries(Engine ScriptShared) +add_subdirectory(Utils) +if(NOT PRODUCTION) + add_subdirectory(Editor) endif() - - - -target_include_directories(Engine PUBLIC "." "../ScriptShared") +add_subdirectory(Core) +add_subdirectory(App) diff --git a/Engine/Camera/Camera.cpp b/Engine/Camera/Camera.cpp deleted file mode 100644 index e9c7b04..0000000 --- a/Engine/Camera/Camera.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Camera.h" - - - -UW::Camera::Camera(CW::Renderer::Renderer* renderer, glm::vec3 position, glm::vec3 direction) - : position(position) { - if (glm::length(direction) > 0.0001f) { - this->direction = glm::normalize(direction); - this->orientation = glm::quatLookAt(-this->direction, glm::vec3(0.0f, 1.0f, 0.0f)); - } else { - this->direction = glm::vec3(0.0f, 0.0f, 1.0f); - this->orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); - }; - - resetMouse(); -}; - - - -void UW::Camera::rotate(float xoffset, float yoffset, float zoffset) { - glm::quat qPitch = glm::angleAxis(glm::radians(yoffset * sensitivity), glm::vec3(1.0f, 0.0f, 0.0f)); - glm::quat qYaw = glm::angleAxis(glm::radians(-xoffset * sensitivity), glm::vec3(0.0f, 1.0f, 0.0f)); - glm::quat qRoll = glm::angleAxis(glm::radians(zoffset), glm::vec3(0.0f, 0.0f, 1.0f)); - - orientation = orientation * qPitch * qYaw * qRoll; - orientation = glm::normalize(orientation); - updateDirection(); -}; - - - -void UW::Camera::updateDirection() { - direction = orientation * glm::vec3(0.0f, 0.0f, 1.0f); - direction = glm::normalize(direction); -}; - - - -glm::mat4 UW::Camera::transformation(CW::Renderer::Renderer* renderer){ - return projection(renderer) * view(renderer); -}; - - - -glm::mat4 UW::Camera::view(CW::Renderer::Renderer* renderer){ - glm::vec3 dynamicUp = orientation * glm::vec3(0.0f, 1.0f, 0.0f); - return glm::lookAt(position, position + direction, dynamicUp); -}; - - - -glm::mat4 UW::Camera::projection(CW::Renderer::Renderer* renderer) { - float aspectRatio = renderer->getWindowData()->width / (float)renderer->getWindowData()->height; - - if (is_ortho) { - float orthoSize = UW::Config::CAMERA_ORTHO_SIZE; - float halfWidth = (orthoSize * aspectRatio) * 0.5f; - float halfHeight = orthoSize * 0.5f; - - return glm::ortho(-halfWidth, halfWidth, -halfHeight, halfHeight, UW::Config::CAMERA_NEAR_PLANE, UW::Config::CAMERA_ORTHO_FAR_PLANE); - } else { - return glm::perspective(glm::radians(UW::Config::CAMERA_FOV), aspectRatio, UW::Config::CAMERA_NEAR_PLANE, UW::Config::CAMERA_FAR_PLANE); - }; -}; - - - -void UW::Camera::event(CW::Renderer::Renderer* renderer) { - float dt = renderer->getWindowData()->delta_time; - - if (cursor_lock) renderer->setCursorOn(true); - else renderer->setCursorOn(false); - - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_SWAP_MODE_BTN) && cursor_visible_lock <= 0.0f) { - cursor_lock = !cursor_lock; - cursor_visible_lock = UW::Config::CAMERA_SWAP_COOLDOWN; - resetMouse(); - } - else if (cursor_visible_lock > 0.0f) { - cursor_visible_lock -= dt; - }; - - if (cursor_lock) return; - - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_ACCELERATE)) velocity += UW::Config::CAMERA_ACCELERATION_RATE * dt; - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_DECELERATE)) velocity -= UW::Config::CAMERA_ACCELERATION_RATE * dt; - if (velocity < UW::Config::CAMERA_MIN_VELOCITY) velocity = UW::Config::CAMERA_MIN_VELOCITY; - - glm::vec3 right = orientation * glm::vec3(1.0f, 0.0f, 0.0f); - float target_bank = 0.0f; - - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_MOVE_FORWARD)) position += direction * velocity * dt; - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_MOVE_BACK)) position -= direction * velocity * dt; - - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_MOVE_RIGHT)) { - position -= right * velocity * dt; - target_bank -= UW::Config::CAMERA_TILT_ACCELERATION; - }; - - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_MOVE_LEFT)) { - position += right * velocity * dt; - target_bank += UW::Config::CAMERA_TILT_ACCELERATION; - }; - - float xoffset = renderer->getInputData()->mouse_x - lastMouseX; - float yoffset = renderer->getInputData()->mouse_y - lastMouseY; - lastMouseX = renderer->getInputData()->mouse_x; - lastMouseY = renderer->getInputData()->mouse_y; - - glm::vec3 localUp = glm::inverse(orientation) * glm::vec3(0.0f, 1.0f, 0.0f); - float current_roll = glm::degrees(glm::atan2(localUp.x, localUp.y)); - - float zoffset = 0.0f; - bool manual_roll = false; - - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_ROLL_LEFT)) { - if (current_roll > -UW::Config::CAMERA_MAX_TILT){ - zoffset -= UW::Config::CAMERA_MANUAL_ROLL_SPEED * dt; - manual_roll = true; - }; - }; - if (renderer->getInputData()->is_key_down(UW::Config::CAMERA_ROLL_RIGHT)) { - if (current_roll < UW::Config::CAMERA_MAX_TILT){ - zoffset += UW::Config::CAMERA_MANUAL_ROLL_SPEED * dt; - manual_roll = true; - }; - }; - - if (!manual_roll) zoffset += (target_bank - current_roll) * UW::Config::CAMERA_ROLL_INTERPOLATION_SPEED * dt; - - rotate(mouse_is_active ? xoffset : 0.0f, mouse_is_active ? yoffset : 0.0f, zoffset); - mouse_is_active = true; -}; - - - -void UW::Camera::setOrthographic(bool enable){ - is_ortho = enable; -}; - - - -void UW::Camera::resetMouse(){ - mouse_is_active = false; -}; diff --git a/Engine/Camera/Camera.h b/Engine/Camera/Camera.h deleted file mode 100644 index 8d1ca79..0000000 --- a/Engine/Camera/Camera.h +++ /dev/null @@ -1,56 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#pragma once -#include "Renderer.h" - -#define GLM_ENABLE_EXPERIMENTAL -#include "../vendor/glm/glm/gtx/euler_angles.hpp" -#include "../vendor/glm/glm/gtx/quaternion.hpp" - -#include "../config.h" - - - -namespace UW { -class Camera { -public: - glm::vec3 position = {0.0f, 0.0f, 0.0f}; - glm::vec3 direction = {0.0f, 0.0f, 1.0f}; - float fov = UW::Config::CAMERA_FOV; - -private: - glm::quat orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); - bool is_ortho = false; - - float sensitivity = UW::Config::CAMERA_SENSITIVITY; - float velocity = UW::Config::CAMERA_DEFAULT_VELOCITY; - - float lastMouseX = 0.0f; - float lastMouseY = 0.0f; - bool mouse_is_active = false; - - float cursor_visible_lock = 0.0f; - bool cursor_lock = true; - -public: - Camera(CW::Renderer::Renderer* renderer, glm::vec3 position = {0.0f, 0.0f, 0.0f}, glm::vec3 direction = {0.0f, 0.0f, 1.0f}); - -private: - void rotate(float xoffset, float yoffset, float zoffset); - void updateDirection(); - -public: - glm::mat4 transformation(CW::Renderer::Renderer* renderer); - glm::mat4 projection(CW::Renderer::Renderer* renderer); - glm::mat4 view(CW::Renderer::Renderer* renderer); - void resetMouse(); - void event(CW::Renderer::Renderer* renderer); - void setOrthographic(bool enable); - -}; -}; diff --git a/Engine/Core/CMakeLists.txt b/Engine/Core/CMakeLists.txt new file mode 100644 index 0000000..05c96e1 --- /dev/null +++ b/Engine/Core/CMakeLists.txt @@ -0,0 +1,58 @@ +# Engine +# Copyright 2026 Daynlight +# Licensed under the GNU General, Version 3.0. +# See LICENSE file for details. + + + +cmake_minimum_required(VERSION 3.15) + +project(Core LANGUAGES CXX C) +project(CoreDev LANGUAGES CXX C) + + +set(src + "Core/Core.cpp" + "Core/Scene.cpp" + "Core/Camera/Camera.cpp" + "Core/Camera/CameraController.cpp" + "Core/Resources/Resources.cpp" + "Core/Resources/Lights/Lights.cpp" + "Core/Resources/Materials/Materials.cpp" + "Core/Objects/GameObject.cpp" + "Core/Objects/ObjectManager.cpp" + "Core/DataSerializer/GlobResourceSerialization.cpp" + "Core/ScriptController/ScriptController.cpp" + "Core/DataSerializer/DataSerializer.cpp" + "Core/DataSerializer/MeshSerialization.cpp" + "Core/DataSerializer/ObjectsSerialization.cpp" + "Core/DataSerializer/MaterialsSerialization.cpp" + "Core/DataSerializer/LightsSerialization.cpp" + "Core/DataSerializer/ShaderSerialization.cpp" + "Core/DataSerializer/ScriptSerialization.cpp" + "Core/DataSerializer/TextureSerialization.cpp" +) + + +add_library(Core STATIC ${src} ${PROD_SCRIPTS}) +target_link_libraries(Core CWindow Utils) +target_link_libraries(Core GameData) +target_include_directories(Core PUBLIC "Core/" "../ScriptShared") +target_compile_definitions(Core PRIVATE ENGINE_SRC_DEST="${ENGINE_SRC_DEST}") +target_compile_definitions(Core PRIVATE PRODUCTION) + +add_library(CoreDev STATIC ${src}) +target_link_libraries(CoreDev CWindow UtilsDev) +target_link_libraries(CoreDev GameData) +target_include_directories(CoreDev PUBLIC "Core/" "../ScriptShared") +target_compile_definitions(CoreDev PRIVATE ENGINE_SRC_DEST="${ENGINE_SRC_DEST}") +target_compile_definitions(CoreDev PRIVATE COMPILER_PATH="${CMAKE_CXX_COMPILER}") +message(STATUS "ScriptController uses CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") +message(STATUS "ScriptController uses COMPILER_PATH definition=${CMAKE_CXX_COMPILER}") + + + + +# if(SANDBOX_SCRIPTS) +# target_compile_definitions(Core PRIVATE SANDBOX_SCRIPTS) +# endif() diff --git a/Engine/Core/Core/Camera/Camera.cpp b/Engine/Core/Core/Camera/Camera.cpp new file mode 100644 index 0000000..61b3e59 --- /dev/null +++ b/Engine/Core/Core/Camera/Camera.cpp @@ -0,0 +1,665 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "Camera.h" + + + +//// ====================== //// +//// ==== Constructors ==== //// +//// ====================== //// +//// core +Engine::Core::Camera::Camera() noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::Camera()", "renderer is nullptr"); + }; +}; + + + +Engine::Core::Camera::~Camera() noexcept {}; + + + +Engine::Core::Camera::Camera(CW::Renderer::Renderer* renderer, glm::vec3 position, glm::vec3 direction) noexcept + : renderer(renderer) { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::Camera(CW::Renderer::Renderer* renderer, glm::vec3 position, glm::vec3 direction)", "renderer is nullptr"); + }; + + setPosition(position); + setDirection(direction); +}; + + + +//// copy +Engine::Core::Camera::Camera(const Camera &second) noexcept + :renderer(second.renderer), + position(second.position), + direction(second.direction), + orientation(second.orientation), + mode(second.mode), + fov(second.fov), + ortho_size(second.ortho_size), + transform_mat_ready(second.transform_mat_ready), + transform_mat(second.transform_mat), + view_mat_ready(second.view_mat_ready), + view_mat(second.view_mat), + last_aspect_ratio_orthogonal(second.last_aspect_ratio_orthogonal), + last_aspect_ratio_perspective(second.last_aspect_ratio_perspective), + perspective_near_plane(second.perspective_near_plane), + orthogonal_near_plane(second.orthogonal_near_plane), + perspective_far_plane(second.perspective_far_plane), + orthogonal_far_plane(second.orthogonal_far_plane), + perspective_mat_ready(second.perspective_mat_ready), + orthogonal_mat_ready(second.orthogonal_mat_ready), + perspective_mat(second.perspective_mat), + orthogonal_mat(second.orthogonal_mat), + default_movemement_on(second.default_movemement_on), + sensitivity(second.sensitivity), + velocity(second.velocity), + lastMouseX(second.lastMouseX), + lastMouseY(second.lastMouseY), + mouse_is_active(false), + cursor_visible_lock(second.cursor_visible_lock), + cursor_lock(second.cursor_lock) +{ + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::Camera(const Camera &second)", "renderer is nullptr"); + }; +}; + + + +Engine::Core::Camera &Engine::Core::Camera::operator=(const Camera &second) noexcept { + if (!second.renderer || !second.renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::operator=(const Camera &second)", "renderer is nullptr"); + }; + + if (this == &second) return *this; + + renderer = second.renderer; + position = second.position; + direction = second.direction; + mode = second.mode; + fov = second.fov; + ortho_size = second.ortho_size; + transform_mat_ready = second.transform_mat_ready; + transform_mat = second.transform_mat; + view_mat_ready = second.view_mat_ready; + view_mat = second.view_mat; + last_aspect_ratio_orthogonal = second.last_aspect_ratio_orthogonal; + last_aspect_ratio_perspective = second.last_aspect_ratio_perspective; + perspective_near_plane = second.perspective_near_plane; + orthogonal_near_plane = second.orthogonal_near_plane; + perspective_far_plane = second.perspective_far_plane; + orthogonal_far_plane = second.orthogonal_far_plane; + perspective_mat_ready = second.perspective_mat_ready; + orthogonal_mat_ready = second.orthogonal_mat_ready; + perspective_mat = second.perspective_mat; + orthogonal_mat = second.orthogonal_mat; + default_movemement_on = second.default_movemement_on; + sensitivity = second.sensitivity; + velocity = second.velocity; + lastMouseX = second.lastMouseX; + lastMouseY = second.lastMouseY; + mouse_is_active = false; + cursor_visible_lock = second.cursor_visible_lock; + cursor_lock = second.cursor_lock; + + return *this; +}; + + + +//// move +Engine::Core::Camera::Camera(Camera &&second) noexcept + :renderer(std::move(second.renderer)), + position(std::move(second.position)), + direction(std::move(second.direction)), + orientation(std::move(second.orientation)), + mode(std::move(second.mode)), + fov(std::move(second.fov)), + ortho_size(std::move(second.ortho_size)), + transform_mat_ready(std::move(second.transform_mat_ready)), + transform_mat(std::move(second.transform_mat)), + view_mat_ready(std::move(second.view_mat_ready)), + view_mat(std::move(second.view_mat)), + last_aspect_ratio_orthogonal(std::move(second.last_aspect_ratio_orthogonal)), + last_aspect_ratio_perspective(std::move(second.last_aspect_ratio_perspective)), + perspective_near_plane(std::move(second.perspective_near_plane)), + orthogonal_near_plane(std::move(second.orthogonal_near_plane)), + perspective_far_plane(std::move(second.perspective_far_plane)), + orthogonal_far_plane(std::move(second.orthogonal_far_plane)), + perspective_mat_ready(std::move(second.perspective_mat_ready)), + orthogonal_mat_ready(std::move(second.orthogonal_mat_ready)), + perspective_mat(std::move(second.perspective_mat)), + orthogonal_mat(std::move(second.orthogonal_mat)), + default_movemement_on(std::move(second.default_movemement_on)), + sensitivity(std::move(second.sensitivity)), + velocity(std::move(second.velocity)), + lastMouseX(std::move(second.lastMouseX)), + lastMouseY(std::move(second.lastMouseY)), + mouse_is_active(false), + cursor_visible_lock(std::move(second.cursor_visible_lock)), + cursor_lock(std::move(second.cursor_lock)) +{ + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::Camera(Camera &&second)", "renderer is nullptr"); + }; +}; + + + +Engine::Core::Camera& Engine::Core::Camera::operator=(Camera &&second) noexcept { + if (!second.renderer || !second.renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::operator=(Camera &&second)", "renderer is nullptr"); + }; + + if (this == &second) return *this; + + renderer = std::move(second.renderer); + position = std::move(second.position); + direction = std::move(second.direction); + mode = std::move(second.mode); + fov = std::move(second.fov); + ortho_size = std::move(second.ortho_size); + transform_mat_ready = std::move(second.transform_mat_ready); + transform_mat = std::move(second.transform_mat); + view_mat_ready = std::move(second.view_mat_ready); + view_mat = std::move(second.view_mat); + last_aspect_ratio_orthogonal = std::move(second.last_aspect_ratio_orthogonal); + last_aspect_ratio_perspective = std::move(second.last_aspect_ratio_perspective); + perspective_near_plane = std::move(second.perspective_near_plane); + orthogonal_near_plane = std::move(second.orthogonal_near_plane); + perspective_far_plane = std::move(second.perspective_far_plane); + orthogonal_far_plane = std::move(second.orthogonal_far_plane); + perspective_mat_ready = std::move(second.perspective_mat_ready); + orthogonal_mat_ready = std::move(second.orthogonal_mat_ready); + perspective_mat = std::move(second.perspective_mat); + orthogonal_mat = std::move(second.orthogonal_mat); + default_movemement_on = std::move(second.default_movemement_on); + sensitivity = std::move(second.sensitivity); + velocity = std::move(second.velocity); + lastMouseX = std::move(second.lastMouseX); + lastMouseY = std::move(second.lastMouseY); + mouse_is_active = false; + cursor_visible_lock = std::move(second.cursor_visible_lock); + cursor_lock = std::move(second.cursor_lock); + + return *this; +}; + + + +//// ==================== //// +//// ==== Projection ==== //// +//// ==================== //// +glm::mat4 Engine::Core::Camera::transformation() noexcept { + view(); + projection(); + + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::transformation()", "renderer is nullptr {returning mat4(1.0f)}"); + if(transform_mat_ready) return transform_mat; + return glm::mat4(1.0f); + }; + + + if(!transform_mat_ready){ + if(mode == Engine::ScriptShared::CameraMode::ORTHOGONAL) + transform_mat = orthogonal_mat * view_mat; + else + transform_mat = perspective_mat * view_mat; + transform_mat_ready = true; + }; + + return transform_mat; +}; + + + +glm::mat4 Engine::Core::Camera::view() noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::view()", "renderer is nullptr {returning mat4(1.0f)}"); + if(view_mat_ready) return view_mat; + return glm::mat4(1.0f); + }; + + if(!view_mat_ready){ + glm::vec3 dynamicUp = orientation * glm::vec3(0.0f, 1.0f, 0.0f); + view_mat = glm::lookAt(position, position + direction, dynamicUp); + view_mat_ready = true; + transform_mat_ready = false; + }; + + return view_mat; +}; + + + +glm::mat4 Engine::Core::Camera::projection() noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::projection()", "renderer is nullptr {returning mat4(1.0f)}"); + return glm::mat4(1.0f); + }; + + if (mode == Engine::ScriptShared::CameraMode::ORTHOGONAL) { + return orthogonal_projection(); + } else { + return perspective_projection(); + }; +}; + + + +glm::mat4 Engine::Core::Camera::perspective_projection() noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::perspective_projection()", "renderer is nullptr {returning mat4(1.0f)}"); + if(perspective_mat_ready) return perspective_mat; + return glm::mat4(1.0f); + }; + + float aspect_ratio = renderer->getWindowData()->width / (float)renderer->getWindowData()->height; + if(!perspective_mat_ready || std::abs(last_aspect_ratio_perspective - aspect_ratio) > Engine::Config::EPS){ + last_aspect_ratio_perspective = aspect_ratio; + perspective_mat = glm::perspective(glm::radians(fov), aspect_ratio, perspective_near_plane, perspective_far_plane); + perspective_mat_ready = true; + transform_mat_ready = false; + }; + + return perspective_mat; +}; + + + +glm::mat4 Engine::Core::Camera::orthogonal_projection() noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::orthogonal_projection()", "renderer is nullptr {returning mat4(1.0f)}"); + if(orthogonal_mat_ready) return orthogonal_mat; + return glm::mat4(1.0f); + }; + + float aspect_ratio = renderer->getWindowData()->width / (float)renderer->getWindowData()->height; + if(!orthogonal_mat_ready || std::abs(last_aspect_ratio_orthogonal - aspect_ratio) > Engine::Config::EPS){ + last_aspect_ratio_orthogonal = aspect_ratio; + float half_width = (ortho_size * aspect_ratio) * 0.5f; + float half_height = ortho_size * 0.5f; + orthogonal_mat = glm::ortho(-half_width, half_width, -half_height, half_height, orthogonal_near_plane, orthogonal_far_plane); + orthogonal_mat_ready = true; + transform_mat_ready = false; + }; + + return orthogonal_mat; +}; + + + +//// ========================= //// +//// ==== Setters/Getters ==== //// +//// ========================= //// +glm::vec3 Engine::Core::Camera::getPosition() const noexcept { + return position; +}; + + + +void Engine::Core::Camera::setPosition(glm::vec3 position) noexcept { + view_mat_ready = false; + transform_mat_ready = false; + + this->position = position; +}; + + + +glm::vec3 Engine::Core::Camera::getDirection() const noexcept { + return direction; +}; + + + +void Engine::Core::Camera::setDirection(glm::vec3 direction) noexcept { + view_mat_ready = false; + transform_mat_ready = false; + + if (glm::length(direction) > Engine::Config::EPS) { + this->direction = glm::normalize(direction); + this->orientation = glm::quatLookAt(-this->direction, glm::vec3(0.0f, 1.0f, 0.0f)); + } else { + this->direction = glm::vec3(0.0f, 0.0f, 1.0f); + this->orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); + }; + + resetMouse(); +}; + + + +float Engine::Core::Camera::getFov() const noexcept { + return fov; +}; + + + +void Engine::Core::Camera::setFov(float fov) noexcept { + perspective_mat_ready = false; + transform_mat_ready = false; + this->fov = fov; + if(fov <= Engine::Config::EPS) this->fov = 0.0f; +}; + + + +float Engine::Core::Camera::getOrthoSize() const noexcept { + return ortho_size; +}; + + + +void Engine::Core::Camera::setOrthoSize(float size) noexcept { + orthogonal_mat_ready = false; + transform_mat_ready = false; + this->ortho_size = size; + if(size <= Engine::Config::EPS) this->ortho_size = 0.0f; +}; + + + +float Engine::Core::Camera::getNearPlane() const noexcept{ + if(mode == Engine::ScriptShared::CameraMode::ORTHOGONAL) + return getNearOrthogonalPlane(); + return getNearPerspectivePlane(); +}; + + + +void Engine::Core::Camera::setNearPlane(float near) noexcept{ + if(mode == Engine::ScriptShared::CameraMode::ORTHOGONAL) + setNearOrthogonalPlane(near); + else setNearPerspectivePlane(near); +}; + + + +float Engine::Core::Camera::getFarPlane() const noexcept{ + if(mode == Engine::ScriptShared::CameraMode::ORTHOGONAL) + return getFarOrthogonalPlane(); + return getFarPerspectivePlane(); +}; + + + +void Engine::Core::Camera::setFarPlane(float far) noexcept { + if(mode == Engine::ScriptShared::CameraMode::ORTHOGONAL) + setFarOrthogonalPlane(far); + else setFarPerspectivePlane(far); +}; + + + +float Engine::Core::Camera::getNearPerspectivePlane() const noexcept { + return perspective_near_plane; +}; + + + +void Engine::Core::Camera::setNearPerspectivePlane(float near) noexcept { + perspective_mat_ready = false; + transform_mat_ready = false; + perspective_near_plane = near; + if(perspective_near_plane <= Engine::Config::EPS) this->perspective_near_plane = 0.0f; +}; + + + +float Engine::Core::Camera::getFarPerspectivePlane() const noexcept { + return perspective_far_plane; +}; + + + +void Engine::Core::Camera::setFarPerspectivePlane(float far) noexcept { + perspective_mat_ready = false; + transform_mat_ready = false; + perspective_far_plane = far; + if(perspective_far_plane <= Engine::Config::EPS) this->perspective_far_plane = 0.0f; +}; + + + +float Engine::Core::Camera::getNearOrthogonalPlane() const noexcept { + return orthogonal_near_plane; +}; + + + +void Engine::Core::Camera::setNearOrthogonalPlane(float near) noexcept { + orthogonal_mat_ready = false; + transform_mat_ready = false; + orthogonal_near_plane = near; + if(orthogonal_near_plane <= Engine::Config::EPS) this->orthogonal_near_plane = 0.0f; +}; + + + +float Engine::Core::Camera::getFarOrthogonalPlane() const noexcept { + return orthogonal_far_plane; +}; + + + +void Engine::Core::Camera::setFarOrthogonalPlane(float far) noexcept { + orthogonal_mat_ready = false; + transform_mat_ready = false; + orthogonal_far_plane = far; + if(orthogonal_far_plane <= Engine::Config::EPS) this->orthogonal_far_plane = 0.0f; +}; + + + +Engine::ScriptShared::CameraMode Engine::Core::Camera::getCameraMode() const noexcept { + return mode; +}; + + + +void Engine::Core::Camera::setCameraMode(Engine::ScriptShared::CameraMode mode) noexcept { + transform_mat_ready = false; + this->mode = mode; +}; + + + +bool Engine::Core::Camera::getDefaultMovement() const noexcept { + return default_movemement_on; +}; + + + +void Engine::Core::Camera::setDefaultMovement(bool state) noexcept { + default_movemement_on = state; +}; + + + +float Engine::Core::Camera::getVelocity() const noexcept { + return velocity; +}; + + + +void Engine::Core::Camera::setVelocity(float velocity) noexcept { + this->velocity = velocity; + if(velocity <= Engine::Config::EPS) this->velocity = 0.0f; +}; + + + +float Engine::Core::Camera::getSensitivity() const noexcept { + return sensitivity; +}; + + + +void Engine::Core::Camera::setSensitivity(float sensitivity) noexcept { + this->sensitivity = sensitivity; + if(sensitivity <= Engine::Config::EPS) this->sensitivity = 0.0f; +}; + + + +bool Engine::Core::Camera::getMouseActive() const noexcept{ + return mouse_is_active; +}; + + + +void Engine::Core::Camera::setMouseActive(bool active) noexcept{ + mouse_is_active = active; +}; + + + +//// ================== //// +//// ==== Movement ==== //// +//// ================== //// +void Engine::Core::Camera::event(float delta_time) { + if(!default_movemement_on) return; + + cursorControl(delta_time); + if(cursor_lock) return; + + float target_bank = 0.0f; + velocityButtons(delta_time); + movementButtons(delta_time, target_bank); + rotationButtons(delta_time, target_bank); + + mouse_is_active = true; +}; + + + +void Engine::Core::Camera::resetMouse(){ + mouse_is_active = false; +}; + + + +void Engine::Core::Camera::cursorControl(float delta_time) noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::cursorControl()", "renderer is nullptr skiping"); + return; + }; + + if (cursor_lock) renderer->setCursorOn(true); + else renderer->setCursorOn(false); + + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_SWAP_MODE_BTN) && cursor_visible_lock <= 0.0f) { + cursor_lock = !cursor_lock; + cursor_visible_lock = Engine::Config::CAMERA_SWAP_COOLDOWN; + resetMouse(); + } + else if (cursor_visible_lock > 0.0f) { + cursor_visible_lock -= delta_time; + }; +}; + + + +void Engine::Core::Camera::velocityButtons(float delta_time) noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::velocityButtons()", "renderer is nullptr skiping"); + return; + }; + + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_ACCELERATE)) velocity += Engine::Config::CAMERA_ACCELERATION_RATE * delta_time; + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_DECELERATE)) velocity -= Engine::Config::CAMERA_ACCELERATION_RATE * delta_time; + if (velocity < Engine::Config::CAMERA_MIN_VELOCITY) velocity = Engine::Config::CAMERA_MIN_VELOCITY; +}; + + + +void Engine::Core::Camera::movementButtons(float delta_time, float& target_bank) noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::movementButtons()", "renderer is nullptr skiping"); + return; + }; + + glm::vec3 right = orientation * glm::vec3(1.0f, 0.0f, 0.0f); + + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_MOVE_FORWARD)) position += direction * velocity * delta_time; + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_MOVE_BACK)) position -= direction * velocity * delta_time; + + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_MOVE_RIGHT)) { + position -= right * velocity * delta_time; + target_bank -= Engine::Config::CAMERA_TILT_ACCELERATION; + }; + + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_MOVE_LEFT)) { + position += right * velocity * delta_time; + target_bank += Engine::Config::CAMERA_TILT_ACCELERATION; + }; + + view_mat_ready = false; + transform_mat_ready = false; +}; + + + +void Engine::Core::Camera::rotationButtons(float delta_time, float& target_bank_input) noexcept { + if (!renderer || !renderer->getWindowData()) { + Engine::Utils::Logger::get().warn("Engine::Core::Camera::rotationButtons()", "renderer is nullptr skiping"); + return; + }; + + float xoffset = renderer->getInputData()->mouse_x - lastMouseX; + float yoffset = renderer->getInputData()->mouse_y - lastMouseY; + lastMouseX = renderer->getInputData()->mouse_x; + lastMouseY = renderer->getInputData()->mouse_y; + + if (mouse_is_active) { + glm::vec3 localRight = orientation * glm::vec3(1.0f, 0.0f, 0.0f); + glm::quat qPitch = glm::angleAxis(glm::radians(yoffset * sensitivity), localRight); + + glm::quat qYaw = glm::angleAxis(glm::radians(-xoffset * sensitivity), glm::vec3(0.0f, 1.0f, 0.0f)); + + orientation = qYaw * qPitch * orientation; + orientation = glm::normalize(orientation); + }; + + bool manual_roll = false; + float roll_input = 0.0f; + + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_ROLL_LEFT)) { + roll_input = -Engine::Config::CAMERA_MAX_TILT; + manual_roll = true; + }; + + if (renderer->getInputData()->is_key_down(Engine::Config::CAMERA_ROLL_RIGHT)) { + roll_input = Engine::Config::CAMERA_MAX_TILT; + manual_roll = true; + }; + + if (!manual_roll) { + roll_input = target_bank_input; + }; + + glm::vec3 localForward = orientation * glm::vec3(0.0f, 0.0f, 1.0f); + glm::quat targetBankRot = glm::angleAxis(glm::radians(roll_input), localForward); + + glm::quat targetOrientation = targetBankRot * orientation; + + orientation = glm::slerp(orientation, targetOrientation, Engine::Config::CAMERA_ROLL_INTERPOLATION_SPEED * delta_time); + orientation = glm::normalize(orientation); + + direction = orientation * glm::vec3(0.0f, 0.0f, 1.0f); + + view_mat_ready = false; + transform_mat_ready = false; +}; diff --git a/Engine/Core/Core/Camera/Camera.h b/Engine/Core/Core/Camera/Camera.h new file mode 100644 index 0000000..70d17ef --- /dev/null +++ b/Engine/Core/Core/Camera/Camera.h @@ -0,0 +1,166 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include "Renderer.h" + +#define GLM_ENABLE_EXPERIMENTAL +#include "../vendor/glm/glm/gtx/euler_angles.hpp" +#include "../vendor/glm/glm/gtx/quaternion.hpp" + +#include "ScriptShared/Camera.h" + +#include "Utils/config.h" +#include "Utils/Logger.h" + + + +namespace Engine::Core { +class Camera : public Engine::ScriptShared::ICamera { +//////// ============================================ //////// +//////// ================== Struct ================== //////// +//////// ============================================ //////// +//// ============== //// +//// ==== Core ==== //// +//// ============== //// +private: + CW::Renderer::Renderer* renderer = nullptr; + glm::vec3 position = {0.0f, 0.0f, 0.0f}; + glm::vec3 direction = {0.0f, 0.0f, 1.0f}; + glm::quat orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); + +//// ==================== //// +//// ==== Projection ==== //// +//// ==================== //// +private: + Engine::ScriptShared::CameraMode mode = Engine::ScriptShared::CameraMode::PERSPECTIVE; + + bool transform_mat_ready = false; + glm::mat4 transform_mat = glm::mat4(1.0f); + + bool view_mat_ready = false; + glm::mat4 view_mat = glm::mat4(1.0f); + + float last_aspect_ratio_perspective = -1.0f; + float fov = Engine::Config::CAMERA_FOV; + float perspective_near_plane = Engine::Config::CAMERA_NEAR_PLANE; + float perspective_far_plane = Engine::Config::CAMERA_FAR_PLANE; + bool perspective_mat_ready = false; + glm::mat4 perspective_mat = glm::mat4(1.0f); + + float last_aspect_ratio_orthogonal = -1.0f; + float ortho_size = Engine::Config::CAMERA_ORTHO_SIZE; + float orthogonal_near_plane = Engine::Config::CAMERA_ORTHO_NEAR_PLANE; + float orthogonal_far_plane = Engine::Config::CAMERA_ORTHO_FAR_PLANE; + bool orthogonal_mat_ready = false; + glm::mat4 orthogonal_mat = glm::mat4(1.0f); + +//// ================== //// +//// ==== Movement ==== //// +//// ================== //// +private: + bool default_movemement_on = false; + + float sensitivity = Engine::Config::CAMERA_SENSITIVITY; + float velocity = Engine::Config::CAMERA_DEFAULT_VELOCITY; + + float lastMouseX = 0.0f; + float lastMouseY = 0.0f; + bool mouse_is_active = false; + + float cursor_visible_lock = 0.0f; + bool cursor_lock = true; + + + +//////// =============================================== //////// +//////// ================== Functions ================== //////// +//////// =============================================== //////// +//// ====================== //// +//// ==== Constructors ==== //// +//// ====================== //// +public: +//// core + Camera() noexcept; + ~Camera() noexcept; + Camera(CW::Renderer::Renderer* renderer, glm::vec3 position = {0.0f, 0.0f, 0.0f}, glm::vec3 direction = {0.0f, 0.0f, 1.0f}) noexcept; +//// copy + Camera(const Camera& second) noexcept; + Engine::Core::Camera& operator=(const Camera& second) noexcept; +//// move + Camera(Camera&& second) noexcept; + Engine::Core::Camera& operator=(Camera&& second) noexcept; + +//// ==================== //// +//// ==== Projection ==== //// +//// ==================== //// +public: + glm::mat4 transformation() noexcept; + glm::mat4 view() noexcept; + glm::mat4 projection() noexcept; + +private: + glm::mat4 perspective_projection() noexcept; + glm::mat4 orthogonal_projection() noexcept; + +//// ========================= //// +//// ==== Setters/Getters ==== //// +//// ========================= //// +public: + glm::vec3 getPosition() const noexcept; + void setPosition(glm::vec3 position) noexcept; + glm::vec3 getDirection() const noexcept; + void setDirection(glm::vec3 direction) noexcept; + + float getFov() const noexcept; + void setFov(float fov) noexcept; + float getOrthoSize() const noexcept; + void setOrthoSize(float size) noexcept; + float getNearPlane() const noexcept; + void setNearPlane(float near) noexcept; + float getFarPlane() const noexcept; + void setFarPlane(float far) noexcept; + float getNearPerspectivePlane() const noexcept; + void setNearPerspectivePlane(float near) noexcept; + float getFarPerspectivePlane() const noexcept; + void setFarPerspectivePlane(float far) noexcept; + float getNearOrthogonalPlane() const noexcept; + void setNearOrthogonalPlane(float near) noexcept; + float getFarOrthogonalPlane() const noexcept; + void setFarOrthogonalPlane(float far) noexcept; + + Engine::ScriptShared::CameraMode getCameraMode() const noexcept; + void setCameraMode(Engine::ScriptShared::CameraMode mode) noexcept; + + bool getDefaultMovement() const noexcept; + void setDefaultMovement(bool state) noexcept; + + float getVelocity() const noexcept; + void setVelocity(float velocity) noexcept; + float getSensitivity() const noexcept; + void setSensitivity(float sensitivity) noexcept; + bool getMouseActive() const noexcept; + void setMouseActive(bool active) noexcept; + +//// ================== //// +//// ==== Movement ==== //// +//// ================== //// +public: + void event(float delta_time); + void resetMouse(); + +private: + void cursorControl(float delta_time) noexcept; + void velocityButtons(float delta_time) noexcept; + void movementButtons(float delta_time, float& target_bank) noexcept; + void rotationButtons(float delta_time, float& target_bank) noexcept; + + // [TODO] + // render + // culling +}; +}; diff --git a/Engine/Core/Core/Camera/CameraController.cpp b/Engine/Core/Core/Camera/CameraController.cpp new file mode 100644 index 0000000..bcb499a --- /dev/null +++ b/Engine/Core/Core/Camera/CameraController.cpp @@ -0,0 +1,172 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "CameraController.h" + + + +//// ====================== //// +//// ==== Constructors ==== //// +//// ====================== //// +//// core +Engine::Core::CameraController::CameraController() noexcept { + Engine::Utils::Logger::get().warn("Engine::Core::CameraController::CameraController()", "renderer is nullptr"); +}; + + + +Engine::Core::CameraController::CameraController(CW::Renderer::Renderer *renderer) noexcept + :renderer(renderer){}; + + + +Engine::Core::CameraController::~CameraController() noexcept {}; + + + +//// copy +Engine::Core::CameraController::CameraController(const CameraController &second) noexcept + :renderer(second.renderer), + cameras(second.cameras), + active_camera(second.active_camera) +{ + if(renderer == nullptr){ + Engine::Utils::Logger::get().warn("Engine::Core::CameraController::CameraController(const CameraController &second)", "renderer is nullptr"); + }; +}; + + + +Engine::Core::CameraController &Engine::Core::CameraController::operator=(const CameraController &second) noexcept { + if(second.renderer == nullptr){ + Engine::Utils::Logger::get().warn("Engine::Core::CameraController::operator=(const CameraController &second)", "renderer is nullptr"); + }; + + if (this == &second) return *this; + + renderer = second.renderer; + cameras = second.cameras; + active_camera = second.active_camera; + + return *this; +}; + + + +//// move +Engine::Core::CameraController::CameraController(CameraController &&second) noexcept + :renderer(std::move(second.renderer)), + cameras(std::move(second.cameras)), + active_camera(std::move(second.active_camera)) +{ + if(renderer == nullptr){ + Engine::Utils::Logger::get().warn("Engine::Core::CameraController::CameraController(CameraController &&second)", "renderer is nullptr"); + }; +}; + + + +Engine::Core::CameraController &Engine::Core::CameraController::operator=(CameraController &&second) noexcept{ + if(second.renderer == nullptr){ + Engine::Utils::Logger::get().warn("Engine::Core::CameraController::operator=(CameraController &&second)", "renderer is nullptr"); + }; + + if (this == &second) return *this; + + renderer = std::move(second.renderer); + cameras = std::move(second.cameras); + active_camera = std::move(second.active_camera); + + return *this; +}; + + + +//// ================= //// +//// ==== Control ==== //// +//// ================= //// +void Engine::Core::CameraController::setActiveCamera(const std::string &name) noexcept { + if(!cameraExists(name)){ + Engine::Utils::Logger::get().warn("Engine::Core::CameraController::setActiveCamera(const std::string &name)", "Camera: " + name + " didn't exists (skipping)"); + return; + }; + + active_camera = name; +}; + + + +std::string Engine::Core::CameraController::getActiveCameraName() const noexcept{ + if(!cameraExists(active_camera)){ + Engine::Utils::Logger::get().warn("Engine::Core::CameraController::getActiveCameraName()", "Camera: " + active_camera + " didn't exists (returning '')"); + return ""; + }; + + return active_camera; +}; + + + +Engine::ScriptShared::ICamera &Engine::Core::CameraController::getActiveCamera() { + if(!cameraExists(active_camera)){ + Engine::Utils::Logger::get().erro("Engine::Core::CameraController::getActiveCamera()", "Camera: " + active_camera + " didn't exists (throwing runtime_error)"); + throw std::runtime_error("Engine::Core::CameraController::getActiveCamera() -> Camera: " + active_camera + " didn't exists"); + }; + + return cameras[active_camera]; +}; + + + +void Engine::Core::CameraController::spawnCamera(const std::string &name, glm::vec3 position, glm::vec3 direction) noexcept { + if(cameraExists(name)){ + Engine::Utils::Logger::get().erro("Engine::Core::CameraController::spawnCamera(const std::string &name, glm::vec3 position, glm::vec3 direction)", "Camera: " + name + " exists (skipping)"); + return; + }; + + cameras.try_emplace(name, renderer, position, direction); + + Engine::Utils::Logger::get().info("Engine::Core::CameraController::spawnCamera(const std::string &name, glm::vec3 position, glm::vec3 direction)", "Spawned Camera: " + name); +}; + + + +void Engine::Core::CameraController::deleteCamera(const std::string &name) noexcept { + if(!cameraExists(name)){ + Engine::Utils::Logger::get().erro("Engine::Core::CameraController::deleteCamera(const std::string &name)", "Camera: " + name + " didn't exists (skipping)"); + return; + }; + + cameras.erase(name); + + Engine::Utils::Logger::get().info("Engine::Core::CameraController::deleteCamera(const std::string &name)", "Deleted Camera: " + name); + + if(active_camera == name){ + active_camera.clear(); + Engine::Utils::Logger::get().info("Engine::Core::CameraController::deleteCamera(const std::string &name)", "Active Camera Reset"); + }; +}; + + + + +Engine::ScriptShared::ICamera &Engine::Core::CameraController::getCamera(const std::string &name) { + if(!cameraExists(name)){ + Engine::Utils::Logger::get().erro("Engine::Core::CameraController::getCamera(const std::string &name)", "Camera: " + name + " didn't exists (throwing runtime_error)"); + throw std::runtime_error("Engine::Core::CameraController::getCamera(const std::string &name) -> Camera: " + name + " didn't exists"); + }; + + return cameras[name]; +}; + + + +bool Engine::Core::CameraController::cameraExists(const std::string &name) const noexcept{ + const auto& it = cameras.find(name); + if(it != cameras.end()) return true; + return false; +}; diff --git a/Engine/Core/Core/Camera/CameraController.h b/Engine/Core/Core/Camera/CameraController.h new file mode 100644 index 0000000..39897f0 --- /dev/null +++ b/Engine/Core/Core/Camera/CameraController.h @@ -0,0 +1,67 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include "Renderer.h" + +#define GLM_ENABLE_EXPERIMENTAL +#include "../vendor/glm/glm/gtx/euler_angles.hpp" +#include "../vendor/glm/glm/gtx/quaternion.hpp" + +#include "ScriptShared/CameraController.h" + +#include "Utils/config.h" +#include "Utils/Logger.h" +#include "Camera.h" + + + +namespace Engine::Core { +class CameraController : public Engine::ScriptShared::ICameraController { +//////// ============================================ //////// +//////// ================== Struct ================== //////// +//////// ============================================ //////// +private: + CW::Renderer::Renderer* renderer = nullptr; + std::unordered_map cameras{}; + std::string active_camera = ""; + + + +//////// =============================================== //////// +//////// ================== Functions ================== //////// +//////// =============================================== //////// +//// ====================== //// +//// ==== Constructors ==== //// +//// ====================== //// +public: +//// core + CameraController() noexcept; + CameraController(CW::Renderer::Renderer* renderer) noexcept; + ~CameraController() noexcept; +//// copy + CameraController(const CameraController& second) noexcept; + Engine::Core::CameraController& operator=(const CameraController& second) noexcept; +//// move + CameraController(CameraController&& second) noexcept; + Engine::Core::CameraController& operator=(CameraController&& second) noexcept; + +//// ================= //// +//// ==== Control ==== //// +//// ================= //// + void setActiveCamera(const std::string& name) noexcept; + std::string getActiveCameraName() const noexcept; + Engine::ScriptShared::ICamera& getActiveCamera(); + + void spawnCamera(const std::string& name, glm::vec3 position = {0.0f, 0.0f, 0.0f}, glm::vec3 direction = {0.0f, 0.0f, 1.0f}) noexcept; + void deleteCamera(const std::string& name) noexcept; + + Engine::ScriptShared::ICamera& getCamera(const std::string& name); + bool cameraExists(const std::string& name) const noexcept; + +}; +}; diff --git a/Engine/Core/Core/Core.cpp b/Engine/Core/Core/Core.cpp new file mode 100644 index 0000000..1e739a1 --- /dev/null +++ b/Engine/Core/Core/Core.cpp @@ -0,0 +1,174 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "Core.h" + + + +Engine::Core::Core::Core() + :scene(window) +{ + Engine::Utils::Logger::get().info("Core", "Core Initialized"); +}; + + + +Engine::Core::Core::~Core(){ + Engine::Utils::Logger::get().info("Core", "Core Destroyed"); +}; + + + +bool Engine::Core::Core::isRunning(){ + return !window.getWindowData()->should_close; +}; + + + +// ===================================== // +// ========== Core Operations ========== // +// ===================================== // +void Engine::Core::Core::onLoad(){ + Engine::Utils::Logger::get().info("Core", "Core Loading"); + + DataSerializer::get().loadAll(); + initWindow(); + Engine::ScriptShared::GlobResource::get().input_data = window.getInputData(); + + scene.onLoad(); + Engine::Utils::Logger::get().info("Core", "Scene Loaded"); + + Engine::Utils::Logger::get().info("Core", "Core Loaded"); +}; + + + +void Engine::Core::Core::onDestroy() { + Engine::Utils::Logger::get().info("Core", "Destroying Core"); + + +#ifndef PRODUCTION + DataSerializer::get().saveAll(); + Engine::Utils::Logger::get().info("Scene", "Force saved scene data"); +#endif + + scene.onDestroy(); + Engine::Utils::Logger::get().info("Core", "Scene Destroyed"); + + Engine::Core::Resources::get().destroy(); + Engine::Utils::Logger::get().info("Core", "Resources Destroyed"); + + Engine::Utils::Logger::get().info("Core", "Core Destroyed"); +}; + + + +void Engine::Core::Core::render(){ + scene.render(); +}; + + + +CW::Renderer::Framebuffer& Engine::Core::Core::get_fbo(){ +#ifndef PRODUCTION + if(scene.post_processing_on) return scene.post_fbo; + else return scene.fbo; +#else + return scene.post_fbo; +#endif +}; + + + +void Engine::Core::Core::swapFrame(){ + window.windowEvents(); + window.swapBuffer(); +}; + + + +void Engine::Core::Core::update(){ +#ifndef PRODUCTION + swapCamera(); +#endif + + scene.onUpdate(window.getWindowData()->delta_time); +}; + + + +void Engine::Core::Core::fixedUpdate(){ + fixed_update_time_acc += window.getWindowData()->delta_time; + + if(Engine::ScriptShared::GlobResource::get().FIXED_HZ > Engine::Config::MAX_FIXED_HZ) Engine::ScriptShared::GlobResource::get().FIXED_HZ = Engine::Config::MAX_FIXED_HZ; + if(Engine::ScriptShared::GlobResource::get().FIXED_HZ < Engine::Config::MIN_FIXED_HZ) Engine::ScriptShared::GlobResource::get().FIXED_HZ = Engine::Config::MIN_FIXED_HZ; + + float fixed_time_step = 1.0f / Engine::ScriptShared::GlobResource::get().FIXED_HZ; + + int max_steps = Engine::Config::MAX_FIXED_STEPS; + while(fixed_update_time_acc >= fixed_time_step && max_steps-- > 0){ + if(cached_title != Engine::ScriptShared::GlobResource::get().WINDOW_TITLE) updateTitle(); + if(cached_vsync != Engine::ScriptShared::GlobResource::get().VSYNC) updateVsync(); + + scene.onFixedUpdate(fixed_time_step); + + fixed_update_time_acc -= fixed_time_step; + }; + + if(max_steps <= 0) fixed_update_time_acc = 0; +}; + + + +// ============================= // +// ========== Helpers ========== // +// ============================= // +void Engine::Core::Core::initWindow(){ + Engine::Utils::Logger::get().info("Core", "Window Initialization"); + + updateTitle(); + + window.setCursorVisibility(Engine::Config::DEFAULT_CURSOR_IS_VISIBLE); + Engine::Utils::Logger::get().info("Core", "Cursor visiblity set to - " + std::string(Engine::Config::DEFAULT_CURSOR_IS_VISIBLE == 1 ? "On" : "Off")); + + updateVsync(); + + Engine::Utils::Logger::get().info("Core", "Window Initialized"); +}; + + + +void Engine::Core::Core::updateTitle(){ + cached_title = Engine::ScriptShared::GlobResource::get().WINDOW_TITLE; + + window.setWindowTitle(cached_title); + Engine::Utils::Logger::get().info("Core", "Title set to - " + cached_title); +}; + + + +void Engine::Core::Core::updateVsync(){ + cached_vsync = Engine::ScriptShared::GlobResource::get().VSYNC; + + window.setVsync(cached_vsync); + Engine::Utils::Logger::get().info("Core", "VSync set to - " + std::string(cached_vsync != 0 ? "On" : "Off")); +}; + + + +#ifndef PRODUCTION +void Engine::Core::Core::swapCamera(){ + if(window.getInputData()->is_key_down(Engine::Config::SWAP_CAMERA_BTN) && camera_swap_cooldown_acc <= 0.0f) { + scene.debug_camera_on = !scene.debug_camera_on; + camera_swap_cooldown_acc = Engine::Config::CAMERA_SWAP_COOLDOWN; + + Engine::Utils::Logger::get().info("Core", "Camera Core to { "+ std::string(scene.debug_camera_on ? "DEBUG CAMERA" : "NORMAL CAMERA") + " }"); + }; + + if(camera_swap_cooldown_acc >= 0.0f) camera_swap_cooldown_acc -= window.getWindowData()->delta_time; +}; +#endif diff --git a/Engine/App.h b/Engine/Core/Core/Core.h similarity index 70% rename from Engine/App.h rename to Engine/Core/Core/Core.h index f310237..9ff70aa 100644 --- a/Engine/App.h +++ b/Engine/Core/Core/Core.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,11 +11,7 @@ #include #include -#ifndef PRODUCTION -#include "UI/UI.h" -#endif - -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" #include "Resources/Resources.h" #include "ScriptShared/GlobResource.h" @@ -23,43 +19,38 @@ -namespace UW{ -class App{ +namespace Engine::Core{ +class Core{ +public: + CW::Renderer::Renderer window; + Engine::Core::Scene scene; + private: std::string cached_title = ""; unsigned int cached_vsync = 0; - CW::Renderer::Renderer window; - UW::Scene scene; #ifndef PRODUCTION - UW::UI ui; - float fps = 0.0f; - float fps_acc = 0.0f; - unsigned int fps_id = 0; - - float total_fps_acc = 0.0f; - unsigned int total_fps_id = 0; - float camera_swap_cooldown_acc = 0.0f; #endif float fixed_update_time_acc = 0.0f; public: - App(); - ~App(); + Core(); + ~Core(); bool isRunning(); - void run(); -private: // core operations void onLoad(); void onDestroy(); void render(); + CW::Renderer::Framebuffer& get_fbo(); + void swapFrame(); void update(); void fixedUpdate(); +private: // helpers void initWindow(); void updateTitle(); @@ -67,7 +58,6 @@ class App{ #ifndef PRODUCTION void swapCamera(); - void updateFps(); #endif }; diff --git a/Engine/Core/Core/DataSerializer/DataSerializer.cpp b/Engine/Core/Core/DataSerializer/DataSerializer.cpp new file mode 100644 index 0000000..eb7dbe3 --- /dev/null +++ b/Engine/Core/Core/DataSerializer/DataSerializer.cpp @@ -0,0 +1,207 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "DataSerializer.h" + +#ifdef PRODUCTION +#include +CMRC_DECLARE(GameData); +#endif + +#include "Resources/Resources.h" + + + +Engine::DataSerializer &Engine::DataSerializer::get(){ + static DataSerializer instance; + return instance; +}; + + + +Engine::DataSerializer::DataSerializer(){}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveAllGlobResources() { + glob_serializer.saveAll(); +}; +#endif + + + +void Engine::DataSerializer::loadAllGlobResources() { + glob_serializer.loadAll(); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveAllObjects(std::vector& objects) { + objects_serializer.saveAll(objects); +}; +#endif + + + +void Engine::DataSerializer::loadAllObjects(std::vector& objects) { + objects_serializer.loadAll(objects); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveAllMaterials(Engine::Core::Materials &materials) { + materials_serializer.saveAll(materials); +}; +#endif + + + +void Engine::DataSerializer::loadAllMaterials(Engine::Core::Materials &materials) { + materials_serializer.loadAll(materials); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveAllLights(Engine::Core::Lights &lights) { + lights_serializer.saveAll(lights); +}; +#endif + + + +void Engine::DataSerializer::loadAllLights(Engine::Core::Lights &lights) { + lights_serializer.loadAll(lights); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveMesh(const std::string &name, const CW::Renderer::Mesh& mesh) { + mesh_serializer.save(name, mesh); +}; +#endif + + + +void Engine::DataSerializer::loadMesh(const std::string& path_to_mesh, Engine::Utils::ResourceController &meshes) { + mesh_serializer.load(path_to_mesh, meshes); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveAllMeshes(Engine::Utils::ResourceController &meshes) { + mesh_serializer.saveAll(meshes); +}; +#endif + + + +void Engine::DataSerializer::loadAllMeshes(Engine::Utils::ResourceController &meshes) { + mesh_serializer.loadAll(meshes); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveShaders(const std::string &shader_name, GLuint type){ + std::string source = Engine::Core::Resources::get().getShader(shader_name).getRegisterShader().at(type).getSource(); + shader_serializer.save(shader_name, type, source, Engine::Core::Resources::get().shaders); +}; +#endif + + + +void Engine::DataSerializer::loadShader(const std::string& shader_name){ + shader_serializer.load(shader_name, Engine::Core::Resources::get().shaders); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::saveScript(const std::string &script_name, const std::string& source){ + script_serializer.save(script_name, source); +}; +#endif + + + +std::string Engine::DataSerializer::loadScript(const std::string& script_name){ + #ifndef PRODUCTION + return script_serializer.load(script_name); + #endif +}; + + + +void Engine::DataSerializer::loadTexture(const std::string &texture_name){ + return texture_serializer.load(texture_name, Engine::Core::Resources::get().textures); +}; + + + +#ifndef PRODUCTION +void Engine::DataSerializer::backupGameData() { + Engine::Utils::Logger::get().info("DataSerializer", "Creating backup of GameData..."); + + namespace fs = std::filesystem; + + try { + if (!fs::exists(Engine::Config::GAME_DATA_FOLDER)) { + Engine::Utils::Logger::get().erro("DataSerializer", "Backup failed: Source folder missing."); + return; + }; + + if (fs::exists(Engine::Config::BACKUP_GAME_DATA_FOLDER)) fs::remove_all(Engine::Config::BACKUP_GAME_DATA_FOLDER); + + fs::copy(Engine::Config::GAME_DATA_FOLDER, Engine::Config::BACKUP_GAME_DATA_FOLDER, fs::copy_options::recursive | fs::copy_options::overwrite_existing); + + Engine::Utils::Logger::get().info("DataSerializer", "Game data backup completed successfully."); + + } catch (const fs::filesystem_error& e) { + Engine::Utils::Logger::get().erro("DataSerializer", std::string("Filesystem error during backup: ") + e.what()); + } catch (const std::exception& e) { + Engine::Utils::Logger::get().erro("DataSerializer", std::string("Unexpected error during backup: ") + e.what()); + }; +}; + + + +void Engine::DataSerializer::saveAll() { + Engine::Utils::Logger::get().info("DataSerializer", "Saving all game data..."); + glob_serializer.saveAll(); + objects_serializer.saveAll(ObjectManager::get().objects); + materials_serializer.saveAll(Engine::Core::Resources::get().materials); + lights_serializer.saveAll(Engine::Core::Resources::get().lights); + mesh_serializer.saveAll(Engine::Core::Resources::get().meshes); + Engine::Utils::Logger::get().info("DataSerializer", "All game data has been saved"); +}; +#endif + + + +void Engine::DataSerializer::loadAll() { +#ifndef PRODUCTION + Engine::Utils::Logger::get().info("DataSerializer", "Making Backup..."); + backupGameData(); + Engine::Utils::Logger::get().info("DataSerializer", "Backup done"); +#endif + + Engine::Utils::Logger::get().info("DataSerializer", "Loading all game data..."); + glob_serializer.loadAll(); + mesh_serializer.loadAll(Engine::Core::Resources::get().meshes); + lights_serializer.loadAll(Engine::Core::Resources::get().lights); + materials_serializer.loadAll(Engine::Core::Resources::get().materials); + objects_serializer.loadAll(ObjectManager::get().objects); + shader_serializer.loadAll(Engine::Core::Resources::get().shaders); + texture_serializer.loadAll(Engine::Core::Resources::get().textures); + Engine::Utils::Logger::get().info("DataSerializer", "All game data has been loaded"); +}; diff --git a/Engine/DataSerializer/DataSerializer.h b/Engine/Core/Core/DataSerializer/DataSerializer.h similarity index 64% rename from Engine/DataSerializer/DataSerializer.h rename to Engine/Core/Core/DataSerializer/DataSerializer.h index 206f53d..6fd1aea 100644 --- a/Engine/DataSerializer/DataSerializer.h +++ b/Engine/Core/Core/DataSerializer/DataSerializer.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -13,13 +13,12 @@ #include #include #include -#include #ifdef PRODUCTION #include #endif -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" #include "Objects/Object.h" #include "Objects/GameObject.h" @@ -27,6 +26,7 @@ #include "DataSerializer/MeshSerialization.h" #include "DataSerializer/ObjectsSerialization.h" +#include "DataSerializer/TextureSerialization.h" #include "DataSerializer/MaterialsSerialization.h" #include "DataSerializer/LightsSerialization.h" #include "DataSerializer/ShaderSerialization.h" @@ -35,22 +35,15 @@ -namespace UW { - class GameObject; - class MeshSerialization; - class ObjectsSerialization; -}; - - - -namespace UW{ +namespace Engine{ class DataSerializer{ private: DataSerializer(); ~DataSerializer() = default; - std::unique_ptr mesh_serializer; - std::unique_ptr objects_serializer; + MeshSerialization mesh_serializer; + ObjectsSerialization objects_serializer; + TextureSerialization texture_serializer; MaterialsSerialization materials_serializer; LightsSerialization lights_serializer; ShaderSerialization shader_serializer; @@ -72,29 +65,29 @@ class DataSerializer{ void loadAllGlobResources(); #ifndef PRODUCTION - void saveAllObjects(std::vector& objects); + void saveAllObjects(std::vector& objects); #endif - void loadAllObjects(std::vector& objects); + void loadAllObjects(std::vector& objects); #ifndef PRODUCTION - void saveAllMaterials(UW::Materials &materials); + void saveAllMaterials(Engine::Core::Materials &materials); #endif - void loadAllMaterials(UW::Materials &materials); + void loadAllMaterials(Engine::Core::Materials &materials); #ifndef PRODUCTION - void saveAllLights(UW::Lights &lights); + void saveAllLights(Engine::Core::Lights &lights); #endif - void loadAllLights(UW::Lights &lights); + void loadAllLights(Engine::Core::Lights &lights); #ifndef PRODUCTION void saveMesh(const std::string& name, const CW::Renderer::Mesh& mesh); #endif - void loadMesh(const std::string& path_to_mesh, UW::Meshes &meshes); + void loadMesh(const std::string& path_to_mesh, Engine::Utils::ResourceController &meshes); #ifndef PRODUCTION - void saveAllMeshes(UW::Meshes& meshes); + void saveAllMeshes(Engine::Utils::ResourceController &meshes); #endif - void loadAllMeshes(UW::Meshes& meshes); + void loadAllMeshes(Engine::Utils::ResourceController &meshes); #ifndef PRODUCTION void saveShaders(const std::string& shader_name, GLuint type); @@ -106,13 +99,17 @@ class DataSerializer{ #endif std::string loadScript(const std::string& script_name); - void loadAllTextures(); +// #ifndef PRODUCTION +// void saveTexture(const std::string& script_name, const std::string& source); +// #endif + void loadTexture(const std::string& texture_name); #ifndef PRODUCTION + void backupGameData(); void saveAll(); #endif void loadAll(); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/Core/Core/DataSerializer/GlobResourceSerialization.cpp b/Engine/Core/Core/DataSerializer/GlobResourceSerialization.cpp new file mode 100644 index 0000000..69f96cd --- /dev/null +++ b/Engine/Core/Core/DataSerializer/GlobResourceSerialization.cpp @@ -0,0 +1,118 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "GlobResourceSerialization.h" + +#ifdef PRODUCTION +#include +CMRC_DECLARE(GameData); +#endif + + + +#ifndef PRODUCTION +void Engine::GlobResourceSerialization::saveAll() { + Engine::Utils::Logger::get().info("GlobResourceSerialization", "Saving resources data"); + try { + std::filesystem::path p(Engine::Config::GAME_DATA_FOLDER + Engine::Config::RESOURCES_FILENAME); + if (p.has_parent_path()) + std::filesystem::create_directories(p.parent_path()); + } catch (const std::filesystem::filesystem_error& e) { + Engine::Utils::Logger::get().erro("GlobResourceSerialization", "Filesystem error - " + std::string(e.what())); + return; + } + + std::ofstream outFile(Engine::Config::GAME_DATA_FOLDER + Engine::Config::RESOURCES_FILENAME, std::ios::binary); + if (!outFile.is_open()) { + Engine::Utils::Logger::get().erro("GlobResourceSerialization", "Failed to open file for saving"); + return; + }; + + Engine::GlobResourceRecord record; + record.window_title = Engine::ScriptShared::GlobResource::get().WINDOW_TITLE; + record.Fixed_HZ = Engine::ScriptShared::GlobResource::get().FIXED_HZ; + record.vsync = Engine::ScriptShared::GlobResource::get().VSYNC; + + outFile << record; + + outFile.close(); + Engine::Utils::Logger::get().info("GlobResourceSerialization", "Glob Resources saved"); +}; +#endif + + + +void Engine::GlobResourceSerialization::loadAll() { + Engine::Utils::Logger::get().info("GlobResourceSerialization", "Loading all Resources..."); + try { + std::string resourcePath = Engine::Config::GAME_DATA_FOLDER + Engine::Config::RESOURCES_FILENAME; + +#ifndef PRODUCTION + std::ifstream inFile(resourcePath, std::ios::binary); + + if (!inFile.is_open()) { + Engine::Utils::Logger::get().erro("GlobResourceSerialization", "Failed to open file for loading - " + resourcePath); + return; + }; +#else + auto fs = cmrc::GameData::get_filesystem(); + + if (!fs.exists(resourcePath)) { + Engine::Utils::Logger::get().erro("GlobResourceSerialization", "CMRC - File not found - " + resourcePath); + return; + }; + + auto embeddedFile = fs.open(resourcePath); + std::string dataStr(embeddedFile.begin(), embeddedFile.end()); + std::stringstream inFile(dataStr); +#endif + + Engine::GlobResourceRecord record; + if (inFile >> record) { + Engine::ScriptShared::GlobResource::get().WINDOW_TITLE = record.window_title; + Engine::ScriptShared::GlobResource::get().FIXED_HZ = record.Fixed_HZ; + Engine::ScriptShared::GlobResource::get().VSYNC = record.vsync; + + + Engine::Utils::Logger::get().info("GlobResourceSerialization", "Glob Resources Loaded"); + } else { + Engine::Utils::Logger::get().erro("GlobResourceSerialization", "File format is corrupted"); + }; + + } catch(const std::exception& e) { + Engine::Utils::Logger::get().erro("GlobResourceSerialization", "Exception - " + std::string(e.what())); + }; +}; + + + +#ifndef PRODUCTION +std::ostream& Engine::operator<<(std::ostream& os, const Engine::GlobResourceRecord& record) { + uint32_t window_title_sz = static_cast(record.window_title.size()); + os.write(reinterpret_cast(&window_title_sz), sizeof(window_title_sz)); + if (window_title_sz > 0) os.write(record.window_title.data(), window_title_sz); + + os.write(reinterpret_cast(&record.Fixed_HZ), sizeof(float)); + os.write(reinterpret_cast(&record.vsync), sizeof(unsigned int)); + + return os; +}; +#endif + + + +std::istream& Engine::operator>>(std::istream& is, Engine::GlobResourceRecord& record) { + uint32_t window_title_sz = 0; + if (!is.read(reinterpret_cast(&window_title_sz), sizeof(window_title_sz))) return is; + record.window_title.resize(window_title_sz); + if (window_title_sz > 0) is.read(&record.window_title[0], window_title_sz); + + is.read(reinterpret_cast(&record.Fixed_HZ), sizeof(float)); + is.read(reinterpret_cast(&record.vsync), sizeof(unsigned int)); + + return is; +}; diff --git a/Engine/DataSerializer/GlobResourceSerialization.h b/Engine/Core/Core/DataSerializer/GlobResourceSerialization.h similarity index 92% rename from Engine/DataSerializer/GlobResourceSerialization.h rename to Engine/Core/Core/DataSerializer/GlobResourceSerialization.h index 5513afa..8d64177 100644 --- a/Engine/DataSerializer/GlobResourceSerialization.h +++ b/Engine/Core/Core/DataSerializer/GlobResourceSerialization.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -19,12 +19,12 @@ -namespace UW { +namespace Engine { }; -namespace UW { +namespace Engine { struct GlobResourceRecord { std::string window_title = ""; float Fixed_HZ = 16; @@ -52,4 +52,4 @@ class GlobResourceSerialization { #endif friend std::istream& operator>>(std::istream& is, GlobResourceSerialization& record); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/DataSerializer/LightsSerialization.cpp b/Engine/Core/Core/DataSerializer/LightsSerialization.cpp similarity index 51% rename from Engine/DataSerializer/LightsSerialization.cpp rename to Engine/Core/Core/DataSerializer/LightsSerialization.cpp index 1e90636..2f6144b 100644 --- a/Engine/DataSerializer/LightsSerialization.cpp +++ b/Engine/Core/Core/DataSerializer/LightsSerialization.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -15,34 +15,34 @@ CMRC_DECLARE(GameData); #ifndef PRODUCTION -void UW::LightsSerialization::save(const std::string& name, const UW::Light& light) { +void Engine::LightsSerialization::save(const std::string& name, const Engine::Core::Light& light) { }; #endif -void UW::LightsSerialization::load(const std::string& name, UW::Light& light) { +void Engine::LightsSerialization::load(const std::string& name, Engine::Core::Light& light) { }; #ifndef PRODUCTION -void UW::LightsSerialization::saveAll(UW::Lights& lights) { - Logger::get().info("LightsSerialization", "Saving all lights..."); +void Engine::LightsSerialization::saveAll(Engine::Core::Lights& lights) { + Engine::Utils::Logger::get().info("LightsSerialization", "Saving all lights..."); try { - std::filesystem::path p(UW::Config::GAME_DATA_FOLDER + UW::Config::LIGHTS_FILENAME); + std::filesystem::path p(Engine::Config::GAME_DATA_FOLDER + Engine::Config::LIGHTS_FILENAME); if (p.has_parent_path()) std::filesystem::create_directories(p.parent_path()); } catch (const std::filesystem::filesystem_error& e) { - Logger::get().erro("LightsSerialization", "Filesystem error - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("LightsSerialization", "Filesystem error - " + std::string(e.what())); return; } - std::ofstream outFile(UW::Config::GAME_DATA_FOLDER + UW::Config::LIGHTS_FILENAME, std::ios::binary); + std::ofstream outFile(Engine::Config::GAME_DATA_FOLDER + Engine::Config::LIGHTS_FILENAME, std::ios::binary); if (!outFile.is_open()) { - Logger::get().erro("LightsSerialization", "Failed to open file for saving"); + Engine::Utils::Logger::get().erro("LightsSerialization", "Failed to open file for saving"); return; } @@ -51,8 +51,8 @@ void UW::LightsSerialization::saveAll(UW::Lights& lights) { outFile.write(reinterpret_cast(&size), sizeof(size)); for(int i = 0; i < lights.size(); i++){ - UW::Light light = lights.get(i); - UW::LightsRecord record; + Engine::Core::Light light = lights.get(i); + Engine::LightsRecord record; record.position = light.position; record.color = light.color; @@ -62,29 +62,29 @@ void UW::LightsSerialization::saveAll(UW::Lights& lights) { }; outFile.close(); - Logger::get().info("LightsSerialization", "All lights have been saved"); + Engine::Utils::Logger::get().info("LightsSerialization", "All lights have been saved"); }; #endif -void UW::LightsSerialization::loadAll(UW::Lights& lights) { - Logger::get().info("LightsSerialization", "Loading all lights..."); +void Engine::LightsSerialization::loadAll(Engine::Core::Lights& lights) { + Engine::Utils::Logger::get().info("LightsSerialization", "Loading all lights..."); try { - std::string resourcePath = UW::Config::GAME_DATA_FOLDER + UW::Config::LIGHTS_FILENAME; + std::string resourcePath = Engine::Config::GAME_DATA_FOLDER + Engine::Config::LIGHTS_FILENAME; #ifndef PRODUCTION std::ifstream inFile(resourcePath, std::ios::binary); if (!inFile.is_open()) { - Logger::get().erro("LightsSerialization", "Failed to open file for loading - " + resourcePath); + Engine::Utils::Logger::get().erro("LightsSerialization", "Failed to open file for loading - " + resourcePath); return; } #else auto fs = cmrc::GameData::get_filesystem(); if (!fs.exists(resourcePath)) { - Logger::get().erro("LightsSerialization", "CMRC - File not found - " + resourcePath); + Engine::Utils::Logger::get().erro("LightsSerialization", "CMRC - File not found - " + resourcePath); return; } @@ -99,28 +99,28 @@ void UW::LightsSerialization::loadAll(UW::Lights& lights) { lights.clear(); for (unsigned int i = 0; i < lightCount; ++i) { - UW::LightsRecord record; + Engine::LightsRecord record; if (inFile >> record) { - UW::Light light(record.position, record.color, record.strength); + Engine::Core::Light light(record.position, record.color, record.strength); lights.emplace_back(light); } else { - Logger::get().erro("LightsSerialization", "File format corrupted at index " + std::to_string(i)); + Engine::Utils::Logger::get().erro("LightsSerialization", "File format corrupted at index " + std::to_string(i)); break; }; }; lights.compile(); - Logger::get().info("LightsSerialization", "All lights have been loaded"); + Engine::Utils::Logger::get().info("LightsSerialization", "All lights have been loaded"); } catch(const std::exception& e) { - Logger::get().erro("LightsSerialization", "Exception - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("LightsSerialization", "Exception - " + std::string(e.what())); }; }; #ifndef PRODUCTION -std::ostream& UW::operator<<(std::ostream& os, const UW::LightsRecord& record) { +std::ostream& Engine::operator<<(std::ostream& os, const Engine::LightsRecord& record) { os.write(reinterpret_cast(&record.position), sizeof(glm::vec3)); os.write(reinterpret_cast(&record.color), sizeof(glm::vec3)); os.write(reinterpret_cast(&record.strength), sizeof(float)); @@ -131,7 +131,7 @@ std::ostream& UW::operator<<(std::ostream& os, const UW::LightsRecord& record) { -std::istream& UW::operator>>(std::istream& is, UW::LightsRecord& record) { +std::istream& Engine::operator>>(std::istream& is, Engine::LightsRecord& record) { is.read(reinterpret_cast(&record.position), sizeof(glm::vec3)); is.read(reinterpret_cast(&record.color), sizeof(glm::vec3)); is.read(reinterpret_cast(&record.strength), sizeof(float)); diff --git a/Engine/DataSerializer/LightsSerialization.h b/Engine/Core/Core/DataSerializer/LightsSerialization.h similarity index 74% rename from Engine/DataSerializer/LightsSerialization.h rename to Engine/Core/Core/DataSerializer/LightsSerialization.h index 98d9d6c..884c554 100644 --- a/Engine/DataSerializer/LightsSerialization.h +++ b/Engine/Core/Core/DataSerializer/LightsSerialization.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -8,7 +8,7 @@ #pragma once #include "Renderer.h" -#include "Resources/Lights/Lights.h" + #include #include #include @@ -16,11 +16,12 @@ #include #include "Utils/Logger.h" -#include "config.h" +#include "Utils/config.h" +#include "Resources/Lights/Lights.h" -namespace UW { +namespace Engine { struct LightsRecord { glm::vec3 position; glm::vec3 color; @@ -38,14 +39,14 @@ class LightsSerialization { ~LightsSerialization() = default; #ifndef PRODUCTION - void save(const std::string& name, const UW::Light& light); + void save(const std::string& name, const Engine::Core::Light& light); #endif - void load(const std::string& name, UW::Light& light); + void load(const std::string& name, Engine::Core::Light& light); #ifndef PRODUCTION - void saveAll(UW::Lights& lights); + void saveAll(Engine::Core::Lights& lights); #endif - void loadAll(UW::Lights& lights); + void loadAll(Engine::Core::Lights& lights); private: #ifndef PRODUCTION @@ -53,4 +54,4 @@ class LightsSerialization { #endif friend std::istream& operator>>(std::istream& is, LightsRecord& record); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/DataSerializer/MaterialsSerialization.cpp b/Engine/Core/Core/DataSerializer/MaterialsSerialization.cpp similarity index 61% rename from Engine/DataSerializer/MaterialsSerialization.cpp rename to Engine/Core/Core/DataSerializer/MaterialsSerialization.cpp index bf5f16b..0f99859 100644 --- a/Engine/DataSerializer/MaterialsSerialization.cpp +++ b/Engine/Core/Core/DataSerializer/MaterialsSerialization.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -15,34 +15,34 @@ CMRC_DECLARE(GameData); #ifndef PRODUCTION -void UW::MaterialsSerialization::save(const UW::Material& material) { +void Engine::MaterialsSerialization::save(const Engine::Core::Material& material) { }; #endif -void UW::MaterialsSerialization::load(UW::Material& material) { +void Engine::MaterialsSerialization::load(Engine::Core::Material& material) { }; #ifndef PRODUCTION -void UW::MaterialsSerialization::saveAll(UW::Materials& materials) { - Logger::get().info("MaterialsSerialization", "Saving all materials..."); +void Engine::MaterialsSerialization::saveAll(Engine::Core::Materials& materials) { + Engine::Utils::Logger::get().info("MaterialsSerialization", "Saving all materials..."); try { - std::filesystem::path p(UW::Config::GAME_DATA_FOLDER + UW::Config::MATERIALS_FILENAME); + std::filesystem::path p(Engine::Config::GAME_DATA_FOLDER + Engine::Config::MATERIALS_FILENAME); if (p.has_parent_path()) std::filesystem::create_directories(p.parent_path()); } catch (const std::filesystem::filesystem_error& e) { - Logger::get().erro("MaterialsSerialization", "Filesystem error - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("MaterialsSerialization", "Filesystem error - " + std::string(e.what())); return; } - std::ofstream outFile(UW::Config::GAME_DATA_FOLDER + UW::Config::MATERIALS_FILENAME, std::ios::binary); + std::ofstream outFile(Engine::Config::GAME_DATA_FOLDER + Engine::Config::MATERIALS_FILENAME, std::ios::binary); if (!outFile.is_open()) { - Logger::get().erro("MaterialsSerialization", "Failed to open file for saving"); + Engine::Utils::Logger::get().erro("MaterialsSerialization", "Failed to open file for saving"); return; }; @@ -50,8 +50,8 @@ void UW::MaterialsSerialization::saveAll(UW::Materials& materials) { outFile.write(reinterpret_cast(&mat_size), sizeof(mat_size)); for (auto& el : materials.getMaterialReg()) { - UW::MaterialsRecord record; - UW::Material material = el.second; + Engine::MaterialsRecord record; + Engine::Core::Material material = el.second; record.name = el.first; record.albedo = material.albedo; @@ -62,33 +62,33 @@ void UW::MaterialsSerialization::saveAll(UW::Materials& materials) { record.ambient_occlusion = material.ambient_occlusion; outFile << record; - Logger::get().info("MaterialsSerialization", "Material saved { " + el.first + " }"); + Engine::Utils::Logger::get().info("MaterialsSerialization", "Material saved { " + el.first + " }"); }; outFile.close(); - Logger::get().info("MaterialsSerialization", "All Materials Had Been Saved"); + Engine::Utils::Logger::get().info("MaterialsSerialization", "All Materials Had Been Saved"); }; #endif -void UW::MaterialsSerialization::loadAll(UW::Materials& materials) { - Logger::get().info("MaterialsSerialization", "Loading all materials..."); +void Engine::MaterialsSerialization::loadAll(Engine::Core::Materials& materials) { + Engine::Utils::Logger::get().info("MaterialsSerialization", "Loading all materials..."); try { - std::string resourcePath = UW::Config::GAME_DATA_FOLDER + UW::Config::MATERIALS_FILENAME; + std::string resourcePath = Engine::Config::GAME_DATA_FOLDER + Engine::Config::MATERIALS_FILENAME; #ifndef PRODUCTION std::ifstream inFile(resourcePath, std::ios::binary); if (!inFile.is_open()) { - Logger::get().erro("MaterialsSerialization", "Failed to open file for loading - " + resourcePath); + Engine::Utils::Logger::get().erro("MaterialsSerialization", "Failed to open file for loading - " + resourcePath); return; } #else auto fs = cmrc::GameData::get_filesystem(); if (!fs.exists(resourcePath)) { - Logger::get().erro("MaterialsSerialization", "CMRC - File not found - " + resourcePath); + Engine::Utils::Logger::get().erro("MaterialsSerialization", "CMRC - File not found - " + resourcePath); return; } @@ -103,9 +103,9 @@ void UW::MaterialsSerialization::loadAll(UW::Materials& materials) { inFile.read(reinterpret_cast(&materialCount), sizeof(materialCount)); for (size_t i = 0; i < materialCount; ++i) { - UW::MaterialsRecord record; + Engine::MaterialsRecord record; if (inFile >> record) { - Material material; + Engine::Core::Material material; material.albedo = record.albedo; material.metallic = record.metallic; material.roughness = record.roughness; @@ -114,22 +114,22 @@ void UW::MaterialsSerialization::loadAll(UW::Materials& materials) { material.ambient_occlusion = record.ambient_occlusion; materials.emplace_back(record.name, std::move(material)); - Logger::get().info("MaterialsSerialization", "Material loaded { " + record.name + " }"); + Engine::Utils::Logger::get().info("MaterialsSerialization", "Material loaded { " + record.name + " }"); } else { - Logger::get().erro("MaterialsSerialization", "File format corrupted at index " + std::to_string(i)); + Engine::Utils::Logger::get().erro("MaterialsSerialization", "File format corrupted at index " + std::to_string(i)); break; }; }; - Logger::get().info("MaterialsSerialization", "All materials have been loaded"); + Engine::Utils::Logger::get().info("MaterialsSerialization", "All materials have been loaded"); } catch(const std::exception& e) { - Logger::get().erro("MaterialsSerialization", "Exception - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("MaterialsSerialization", "Exception - " + std::string(e.what())); }; }; #ifndef PRODUCTION -std::ostream& UW::operator<<(std::ostream& os, const UW::MaterialsRecord& record) { +std::ostream& Engine::operator<<(std::ostream& os, const Engine::MaterialsRecord& record) { size_t name_sz = record.name.size(); os.write(reinterpret_cast(&name_sz), sizeof(size_t)); if(name_sz > 0) os.write(reinterpret_cast(record.name.data()), name_sz); @@ -147,7 +147,7 @@ std::ostream& UW::operator<<(std::ostream& os, const UW::MaterialsRecord& record -std::istream& UW::operator>>(std::istream& is, UW::MaterialsRecord& record) { +std::istream& Engine::operator>>(std::istream& is, Engine::MaterialsRecord& record) { size_t name_sz = 0; if (!is.read(reinterpret_cast(&name_sz), sizeof(name_sz))) return is; record.name.resize(name_sz); diff --git a/Engine/DataSerializer/MaterialsSerialization.h b/Engine/Core/Core/DataSerializer/MaterialsSerialization.h similarity index 79% rename from Engine/DataSerializer/MaterialsSerialization.h rename to Engine/Core/Core/DataSerializer/MaterialsSerialization.h index d87b5bf..4990a7e 100644 --- a/Engine/DataSerializer/MaterialsSerialization.h +++ b/Engine/Core/Core/DataSerializer/MaterialsSerialization.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -6,9 +6,8 @@ #pragma once - #include "Renderer.h" -#include "Resources/Materials/Materials.h" + #include #include #include @@ -16,11 +15,12 @@ #include #include "Utils/Logger.h" -#include "config.h" +#include "Utils/config.h" +#include "Resources/Materials/Materials.h" -namespace UW { +namespace Engine { struct MaterialsRecord { std::string name = ""; glm::vec3 albedo = glm::vec3(1.0f); @@ -42,14 +42,14 @@ class MaterialsSerialization { ~MaterialsSerialization() = default; #ifndef PRODUCTION - void save(const UW::Material& material); + void save(const Engine::Core::Material& material); #endif - void load(UW::Material& material); + void load(Engine::Core::Material& material); #ifndef PRODUCTION - void saveAll(UW::Materials& materials); + void saveAll(Engine::Core::Materials& materials); #endif - void loadAll(UW::Materials& materials); + void loadAll(Engine::Core::Materials& materials); private: #ifndef PRODUCTION @@ -57,4 +57,4 @@ class MaterialsSerialization { #endif friend std::istream& operator>>(std::istream& is, MaterialsRecord& record); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/DataSerializer/MeshSerialization.cpp b/Engine/Core/Core/DataSerializer/MeshSerialization.cpp similarity index 68% rename from Engine/DataSerializer/MeshSerialization.cpp rename to Engine/Core/Core/DataSerializer/MeshSerialization.cpp index 3d4f91c..2666672 100644 --- a/Engine/DataSerializer/MeshSerialization.cpp +++ b/Engine/Core/Core/DataSerializer/MeshSerialization.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -15,17 +15,17 @@ CMRC_DECLARE(GameData); #ifndef PRODUCTION -void UW::MeshSerialization::save(const std::string& name, const CW::Renderer::Mesh& mesh) { - Logger::get().info("MeshSerialization", "Saving mesh: " + name); - std::string folder_path = UW::Config::GAME_DATA_FOLDER + UW::Config::ASSETS_FOLDER + UW::Config::MESHES_FOLDER; - std::string file_path = folder_path + name + UW::Config::MESH_EXTENSION; +void Engine::MeshSerialization::save(const std::string& name, const CW::Renderer::Mesh& mesh) { + Engine::Utils::Logger::get().info("MeshSerialization", "Saving mesh: " + name); + std::string folder_path = Engine::Config::GAME_DATA_FOLDER + Engine::Config::ASSETS_FOLDER + Engine::Config::MESHES_FOLDER; + std::string file_path = folder_path + name + Engine::Config::MESH_EXTENSION; std::filesystem::create_directories(folder_path); std::ofstream outFile(file_path, std::ios::binary); if (!outFile.is_open()) return; - UW::MeshRecord record; + Engine::MeshRecord record; record.name = name; record.indices = mesh.getIndices(); @@ -34,7 +34,7 @@ void UW::MeshSerialization::save(const std::string& name, const CW::Renderer::Me record.mesh_data.reserve(reg.size()); for (const auto& [location, mesh_data_instance] : reg) { - UW::MeshRecord::MeshDataRecord e; + Engine::MeshRecord::MeshDataRecord e; e.key = location; e.dimension = mesh_data_instance.getDimension(); e.size_of_element = mesh_data_instance.getSizeOfElement(); @@ -49,20 +49,20 @@ void UW::MeshSerialization::save(const std::string& name, const CW::Renderer::Me }; outFile << record; - Logger::get().info("MeshSerialization", "Mesh saved: " + name); + Engine::Utils::Logger::get().info("MeshSerialization", "Mesh saved: " + name); }; #endif -void UW::MeshSerialization::load(const std::string& path_to_mesh, UW::Meshes& meshes) { - Logger::get().info("MeshSerialization", "Loading mesh: " + path_to_mesh); +void Engine::MeshSerialization::load(const std::string& path_to_mesh, Engine::Utils::ResourceController& meshes) { + Engine::Utils::Logger::get().info("MeshSerialization", "Loading mesh: " + path_to_mesh); try { #ifndef PRODUCTION std::ifstream inFile(path_to_mesh, std::ios::binary); if (!inFile.is_open()) { - Logger::get().erro("MeshSerialization", "Failed to open file for loading - " + path_to_mesh); + Engine::Utils::Logger::get().erro("MeshSerialization", "Failed to open file for loading - " + path_to_mesh); return; } #else @@ -72,7 +72,7 @@ void UW::MeshSerialization::load(const std::string& path_to_mesh, UW::Meshes& me std::stringstream inFile(data_str); #endif - UW::MeshRecord record; + Engine::MeshRecord record; if (!(inFile >> record)) return; CW::Renderer::Mesh engine_mesh; @@ -90,78 +90,78 @@ void UW::MeshSerialization::load(const std::string& path_to_mesh, UW::Meshes& me std::memcpy(vertices.data(), e.data.data(), e.data.size()); engine_mesh.addVertices(vertices, e.dimension, e.key); } else { - UW::Utils::uploadBufferByType(engine_mesh, e.type, e.data, e.dimension, e.key); + Engine::Utils::uploadBufferByType(engine_mesh, e.type, e.data, e.dimension, e.key); }; }; meshes.emplace_back(record.name, std::move(engine_mesh)); - Logger::get().info("MeshSerialization", "Mesh loaded: " + record.name); + Engine::Utils::Logger::get().info("MeshSerialization", "Mesh loaded: " + record.name); } catch (const std::exception& e) { - Logger::get().erro("MeshSerialization", "CMRC EXCEPTION: " + std::string(e.what())); + Engine::Utils::Logger::get().erro("MeshSerialization", "CMRC EXCEPTION: " + std::string(e.what())); }; }; #ifndef PRODUCTION -void UW::MeshSerialization::saveAll(UW::Meshes& meshes) { - Logger::get().info("MeshSerialization", "Saving all meshes..."); +void Engine::MeshSerialization::saveAll(Engine::Utils::ResourceController& meshes) { + Engine::Utils::Logger::get().info("MeshSerialization", "Saving all meshes..."); std::vector> meshes_to_save; - for (const auto& pair : meshes.getMeshIDs()) + for (const auto& pair : meshes.getIDs()) meshes_to_save.push_back(pair); for (const auto& [mesh_name, mesh_id] : meshes_to_save) save(mesh_name, meshes[mesh_id]); - Logger::get().info("MeshSerialization", "All meshes have been saved"); + Engine::Utils::Logger::get().info("MeshSerialization", "All meshes have been saved"); }; #endif -void UW::MeshSerialization::loadAll(UW::Meshes& meshes) { - Logger::get().info("MeshSerialization", "Loading all meshes..."); +void Engine::MeshSerialization::loadAll(Engine::Utils::ResourceController& meshes) { + Engine::Utils::Logger::get().info("MeshSerialization", "Loading all meshes..."); try { - std::string meshes_root = UW::Config::GAME_DATA_FOLDER + UW::Config::ASSETS_FOLDER + UW::Config::MESHES_FOLDER; + std::string meshes_root = Engine::Config::GAME_DATA_FOLDER + Engine::Config::ASSETS_FOLDER + Engine::Config::MESHES_FOLDER; std::vector mesh_files; #ifndef PRODUCTION if (std::filesystem::exists(meshes_root) && std::filesystem::is_directory(meshes_root)) { for (const auto& entry : std::filesystem::recursive_directory_iterator(meshes_root)) { - if (entry.is_regular_file() && entry.path().extension() == UW::Config::MESH_EXTENSION) { + if (entry.is_regular_file() && entry.path().extension() == Engine::Config::MESH_EXTENSION) { mesh_files.push_back(entry.path().string()); } } } else { - Logger::get().erro("MeshSerialization", "Filesystem - Directory not found: " + meshes_root); + Engine::Utils::Logger::get().erro("MeshSerialization", "Filesystem - Directory not found: " + meshes_root); return; } #else auto fs = cmrc::GameData::get_filesystem(); if (!fs.exists(meshes_root)) { - Logger::get().erro("MeshSerialization", "CMRC - Directory not found: " + meshes_root); + Engine::Utils::Logger::get().erro("MeshSerialization", "CMRC - Directory not found: " + meshes_root); return; } - UW::Utils::scanCmrcDirectory(fs, meshes_root, "\\.msh$", mesh_files); + Engine::Utils::scanCmrcDirectory(fs, meshes_root, "\\.msh$", mesh_files); #endif for (const auto& file_path : mesh_files) load(file_path, meshes); meshes.compileAll(); - Logger::get().info("MeshSerialization", "All meshes have been loaded"); + Engine::Utils::Logger::get().info("MeshSerialization", "All meshes have been loaded"); } catch (const std::exception& e) { - Logger::get().erro("MeshSerialization", "CMRC EXCEPTION: " + std::string(e.what())); + Engine::Utils::Logger::get().erro("MeshSerialization", "CMRC EXCEPTION: " + std::string(e.what())); }; }; #ifndef PRODUCTION -std::ostream& UW::operator<<(std::ostream& os, const UW::MeshRecord& record){ +std::ostream& Engine::operator<<(std::ostream& os, const Engine::MeshRecord& record){ size_t name_size = record.name.size(); os.write(reinterpret_cast(&name_size), sizeof(name_size)); if (name_size > 0) os.write(record.name.data(), name_size); @@ -191,7 +191,7 @@ std::ostream& UW::operator<<(std::ostream& os, const UW::MeshRecord& record){ -std::istream& UW::operator>>(std::istream& is, UW::MeshRecord& record){ +std::istream& Engine::operator>>(std::istream& is, Engine::MeshRecord& record){ size_t name_size = 0; if (!is.read(reinterpret_cast(&name_size), sizeof(name_size))) return is; diff --git a/Engine/DataSerializer/MeshSerialization.h b/Engine/Core/Core/DataSerializer/MeshSerialization.h similarity index 77% rename from Engine/DataSerializer/MeshSerialization.h rename to Engine/Core/Core/DataSerializer/MeshSerialization.h index a3c536f..404f433 100644 --- a/Engine/DataSerializer/MeshSerialization.h +++ b/Engine/Core/Core/DataSerializer/MeshSerialization.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -8,6 +8,7 @@ #pragma once #include "Renderer.h" + #include #include #include @@ -22,13 +23,13 @@ #endif #include "Utils/Logger.h" -#include "Resources/Resources.h" -#include "config.h" +#include "Utils/config.h" #include "Utils/utils.h" +#include "Utils/Resource/ResourceController.h" -namespace UW { +namespace Engine { struct MeshRecord { std::string name = ""; struct MeshDataRecord { @@ -57,12 +58,12 @@ class MeshSerialization { #ifndef PRODUCTION void save(const std::string& name, const CW::Renderer::Mesh& mesh); #endif - void load(const std::string& path_to_mesh, UW::Meshes& meshes); + void load(const std::string& path_to_mesh, Engine::Utils::ResourceController& meshes); #ifndef PRODUCTION - void saveAll(UW::Meshes& meshes); + void saveAll(Engine::Utils::ResourceController& meshes); #endif - void loadAll(UW::Meshes& meshes); + void loadAll(Engine::Utils::ResourceController& meshes); private: #ifndef PRODUCTION @@ -71,4 +72,4 @@ class MeshSerialization { friend std::istream& operator>>(std::istream& is, MeshRecord& record); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/DataSerializer/ObjectsSerialization.cpp b/Engine/Core/Core/DataSerializer/ObjectsSerialization.cpp similarity index 55% rename from Engine/DataSerializer/ObjectsSerialization.cpp rename to Engine/Core/Core/DataSerializer/ObjectsSerialization.cpp index 43dbcfa..38236da 100644 --- a/Engine/DataSerializer/ObjectsSerialization.cpp +++ b/Engine/Core/Core/DataSerializer/ObjectsSerialization.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -12,28 +12,31 @@ CMRC_DECLARE(GameData); #endif +#include "Objects/Object.h" +#include "Objects/GameObject.h" + #ifndef PRODUCTION -void UW::ObjectsSerialization::save(const UW::GameObject& object) { - Logger::get().info("ObjectsSerialization", "Saving object: " + object.game_object_data.name); +void Engine::ObjectsSerialization::save(const Engine::Core::GameObject& object) { + Engine::Utils::Logger::get().info("ObjectsSerialization", "Saving object: " + object.game_object_data.name); try { - std::filesystem::path p(UW::Config::GAME_DATA_FOLDER + UW::Config::OBJECTS_FILENAME); + std::filesystem::path p(Engine::Config::GAME_DATA_FOLDER + Engine::Config::OBJECTS_FILENAME); if (p.has_parent_path()) std::filesystem::create_directories(p.parent_path()); } catch (const std::filesystem::filesystem_error& e) { - Logger::get().erro("ObjectsSerialization", "Filesystem error - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "Filesystem error - " + std::string(e.what())); return; }; - std::ofstream outFile(UW::Config::GAME_DATA_FOLDER + UW::Config::OBJECTS_FILENAME, std::ios::binary | std::ios::app); + std::ofstream outFile(Engine::Config::GAME_DATA_FOLDER + Engine::Config::OBJECTS_FILENAME, std::ios::binary | std::ios::app); if (!outFile.is_open()) { - Logger::get().erro("ObjectsSerialization", "Failed to open file for saving"); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "Failed to open file for saving"); return; }; - UW::GameObjectRecord record; + Engine::GameObjectRecord record; record.name = object.game_object_data.name; record.mesh = object.game_object_data.mesh; record.shader = object.game_object_data.shader; @@ -43,38 +46,45 @@ void UW::ObjectsSerialization::save(const UW::GameObject& object) { record.textures = object.game_object_data.textures; record.materials = object.game_object_data.materials; record.parameters = object.game_object_data.parameters; + record.uniforms = object.game_object_data.uniforms; + record.culling_on = object.game_object_data.culling_on; + record.dont_write_to_depth_mask = object.game_object_data.dont_write_to_depth_mask; + record.gl_depth_lequal = object.game_object_data.gl_depth_lequal; + record.gl_draw_patches = object.game_object_data.gl_draw_patches; + record.gl_blend = object.game_object_data.gl_blend; + record.gl_nearest = object.game_object_data.gl_nearest; for(auto script : object.scripts) record.scripts.emplace_back(std::pair(script.getPath(), script.script_on)); outFile << record; outFile.close(); - Logger::get().info("ObjectsSerialization", "Object saved { " + object.game_object_data.name + " }"); + Engine::Utils::Logger::get().info("ObjectsSerialization", "Object saved { " + object.game_object_data.name + " }"); }; #endif -void UW::ObjectsSerialization::load(UW::GameObject& object) { +void Engine::ObjectsSerialization::load(Engine::Core::GameObject& object) { }; #ifndef PRODUCTION -void UW::ObjectsSerialization::saveAll(std::vector& objects) { - Logger::get().info("ObjectsSerialization", "Saving all objects..."); +void Engine::ObjectsSerialization::saveAll(std::vector& objects) { + Engine::Utils::Logger::get().info("ObjectsSerialization", "Saving all objects..."); try { - std::filesystem::path p(UW::Config::GAME_DATA_FOLDER + UW::Config::OBJECTS_FILENAME); + std::filesystem::path p(Engine::Config::GAME_DATA_FOLDER + Engine::Config::OBJECTS_FILENAME); if (p.has_parent_path()) std::filesystem::create_directories(p.parent_path()); } catch (const std::filesystem::filesystem_error& e) { - Logger::get().erro("ObjectsSerialization", "Filesystem error - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "Filesystem error - " + std::string(e.what())); return; } - std::ofstream outFile(UW::Config::GAME_DATA_FOLDER + UW::Config::OBJECTS_FILENAME, std::ios::binary); + std::ofstream outFile(Engine::Config::GAME_DATA_FOLDER + Engine::Config::OBJECTS_FILENAME, std::ios::binary); if (!outFile.is_open()) { - Logger::get().erro("ObjectsSerialization", "Failed to open file for saving"); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "Failed to open file for saving"); return; }; @@ -82,7 +92,7 @@ void UW::ObjectsSerialization::saveAll(std::vector& objects) { outFile.write(reinterpret_cast(&obj_size), sizeof(obj_size)); for (const auto& object : objects) { - UW::GameObjectRecord record; + Engine::GameObjectRecord record; record.name = object.game_object_data.name; record.mesh = object.game_object_data.mesh; record.shader = object.game_object_data.shader; @@ -92,36 +102,43 @@ void UW::ObjectsSerialization::saveAll(std::vector& objects) { record.textures = object.game_object_data.textures; record.materials = object.game_object_data.materials; record.parameters = object.game_object_data.parameters; + record.uniforms = object.game_object_data.uniforms; + record.culling_on = object.game_object_data.culling_on; + record.dont_write_to_depth_mask = object.game_object_data.dont_write_to_depth_mask; + record.gl_depth_lequal = object.game_object_data.gl_depth_lequal; + record.gl_draw_patches = object.game_object_data.gl_draw_patches; + record.gl_blend = object.game_object_data.gl_blend; + record.gl_nearest = object.game_object_data.gl_nearest; for(auto script : object.scripts) record.scripts.emplace_back(std::pair(script.getPath(), script.script_on)); outFile << record; - Logger::get().info("ObjectsSerialization", "Object saved { " + object.game_object_data.name + " }"); + Engine::Utils::Logger::get().info("ObjectsSerialization", "Object saved { " + object.game_object_data.name + " }"); }; outFile.close(); - Logger::get().info("ObjectsSerialization", "All Objects Had Been Saved"); + Engine::Utils::Logger::get().info("ObjectsSerialization", "All Objects Had Been Saved"); }; #endif -void UW::ObjectsSerialization::loadAll(std::vector& objects) { - Logger::get().info("ObjectsSerialization", "Loading all objects..."); +void Engine::ObjectsSerialization::loadAll(std::vector& objects) { + Engine::Utils::Logger::get().info("ObjectsSerialization", "Loading all objects..."); try { - std::string resourcePath = UW::Config::GAME_DATA_FOLDER + UW::Config::OBJECTS_FILENAME; + std::string resourcePath = Engine::Config::GAME_DATA_FOLDER + Engine::Config::OBJECTS_FILENAME; #ifndef PRODUCTION std::ifstream inFile(resourcePath, std::ios::binary); if (!inFile.is_open()) { - Logger::get().erro("ObjectsSerialization", "Failed to open file for loading - " + resourcePath); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "Failed to open file for loading - " + resourcePath); return; }; #else auto fs = cmrc::GameData::get_filesystem(); if (!fs.exists(resourcePath)) { - Logger::get().erro("ObjectsSerialization", "CMRC - File not found - " + resourcePath); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "CMRC - File not found - " + resourcePath); return; }; @@ -136,37 +153,45 @@ void UW::ObjectsSerialization::loadAll(std::vector& objects) { inFile.read(reinterpret_cast(&objectCount), sizeof(objectCount)); for (size_t i = 0; i < objectCount; ++i) { - UW::GameObjectRecord record; + Engine::GameObjectRecord record; if (inFile >> record) { - GameObject object(record.name, record.mesh, record.shader); + Engine::Core::GameObject object(record.name, record.mesh, record.shader); object.game_object_data.position = record.position; object.game_object_data.rotation = record.rotation; object.game_object_data.scale = record.scale; + object.game_object_data.culling_on = record.culling_on; + object.game_object_data.dont_write_to_depth_mask= record.dont_write_to_depth_mask; + object.game_object_data.gl_depth_lequal = record.gl_depth_lequal; + object.game_object_data.gl_draw_patches = record.gl_draw_patches; + object.game_object_data.gl_blend = record.gl_blend; + object.game_object_data.gl_nearest = record.gl_nearest; object.game_object_data.textures = std::move(record.textures); object.game_object_data.materials = std::move(record.materials); object.game_object_data.parameters = std::move(record.parameters); + object.game_object_data.uniforms = std::move(record.uniforms); + for(auto& script : record.scripts) { object.scripts.emplace_back(script.first); object.scripts[object.scripts.size() - 1].script_on = script.second; }; objects.push_back(std::move(object)); - Logger::get().info("ObjectsSerialization", "Object loaded { " + record.name + " }"); + Engine::Utils::Logger::get().info("ObjectsSerialization", "Object loaded { " + record.name + " }"); } else { - Logger::get().erro("ObjectsSerialization", "File format corrupted at index " + std::to_string(i)); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "File format corrupted at index " + std::to_string(i)); break; }; }; - Logger::get().info("ObjectsSerialization", "All objects have been loaded"); + Engine::Utils::Logger::get().info("ObjectsSerialization", "All objects have been loaded"); } catch(const std::exception& e) { - Logger::get().erro("ObjectsSerialization", "Exception - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("ObjectsSerialization", "Exception - " + std::string(e.what())); }; }; #ifndef PRODUCTION -std::ostream& UW::operator<<(std::ostream& os, const UW::GameObjectRecord& record) { +std::ostream& Engine::operator<<(std::ostream& os, const Engine::GameObjectRecord& record) { size_t name_sz = record.name.size(); os.write(reinterpret_cast(&name_sz), sizeof(name_sz)); if (name_sz > 0) os.write(record.name.data(), name_sz); @@ -182,6 +207,12 @@ std::ostream& UW::operator<<(std::ostream& os, const UW::GameObjectRecord& recor os.write(reinterpret_cast(&record.position), sizeof(glm::vec3)); os.write(reinterpret_cast(&record.rotation), sizeof(glm::vec3)); os.write(reinterpret_cast(&record.scale), sizeof(glm::vec3)); + os.write(reinterpret_cast(&record.culling_on), sizeof(bool)); + os.write(reinterpret_cast(&record.dont_write_to_depth_mask), sizeof(bool)); + os.write(reinterpret_cast(&record.gl_depth_lequal), sizeof(bool)); + os.write(reinterpret_cast(&record.gl_draw_patches), sizeof(bool)); + os.write(reinterpret_cast(&record.gl_blend), sizeof(bool)); + os.write(reinterpret_cast(&record.gl_nearest), sizeof(bool)); size_t tex_count = record.textures.size(); os.write(reinterpret_cast(&tex_count), sizeof(tex_count)); @@ -239,13 +270,42 @@ std::ostream& UW::operator<<(std::ostream& os, const UW::GameObjectRecord& recor }, param_var); }; + + size_t uni_count = record.uniforms.size(); + os.write(reinterpret_cast(&uni_count), sizeof(uni_count)); + + for (const auto& [uni_name, uni_var] : record.uniforms) { + size_t name_sz = uni_name.size(); + os.write(reinterpret_cast(&name_sz), sizeof(name_sz)); + if (name_sz > 0) os.write(uni_name.data(), name_sz); + + size_t type_idx = uni_var.index(); + os.write(reinterpret_cast(&type_idx), sizeof(type_idx)); + + std::visit([&os](auto&& arg) { + using T = std::decay_t; + + if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) { + os.write(reinterpret_cast(&arg), sizeof(T)); + } + else if constexpr (std::is_same_v || std::is_same_v) { + os.write(reinterpret_cast(&arg), sizeof(T)); + } + else if constexpr (std::is_same_v) { + size_t str_sz = arg.size(); + os.write(reinterpret_cast(&str_sz), sizeof(str_sz)); + if (str_sz > 0) os.write(arg.data(), str_sz); + } + }, uni_var); + }; + return os; }; #endif -std::istream& UW::operator>>(std::istream& is, UW::GameObjectRecord& record) { +std::istream& Engine::operator>>(std::istream& is, Engine::GameObjectRecord& record) { size_t name_sz = 0; if (!is.read(reinterpret_cast(&name_sz), sizeof(name_sz))) return is; record.name.resize(name_sz); @@ -264,6 +324,12 @@ std::istream& UW::operator>>(std::istream& is, UW::GameObjectRecord& record) { is.read(reinterpret_cast(&record.position), sizeof(glm::vec3)); is.read(reinterpret_cast(&record.rotation), sizeof(glm::vec3)); is.read(reinterpret_cast(&record.scale), sizeof(glm::vec3)); + is.read(reinterpret_cast(&record.culling_on), sizeof(bool)); + is.read(reinterpret_cast(&record.dont_write_to_depth_mask), sizeof(bool)); + is.read(reinterpret_cast(&record.gl_depth_lequal), sizeof(bool)); + is.read(reinterpret_cast(&record.gl_draw_patches), sizeof(bool)); + is.read(reinterpret_cast(&record.gl_blend), sizeof(bool)); + is.read(reinterpret_cast(&record.gl_nearest), sizeof(bool)); size_t tex_count = 0; is.read(reinterpret_cast(&tex_count), sizeof(tex_count)); @@ -335,7 +401,7 @@ std::istream& UW::operator>>(std::istream& is, UW::GameObjectRecord& record) { size_t type_idx = 0; is.read(reinterpret_cast(&type_idx), sizeof(type_idx)); - UW::GameObjectParameterType param_var; + Engine::ScriptShared::GameObjectParameterType param_var; switch (type_idx) { case 0: { // int int val = 0; @@ -385,5 +451,75 @@ std::istream& UW::operator>>(std::istream& is, UW::GameObjectRecord& record) { record.parameters[param_name] = std::move(param_var); }; + + size_t uni_count = 0; + if (!is.read(reinterpret_cast(&uni_count), sizeof(uni_count))) return is; + + if (uni_count > 10000) { + is.setstate(std::ios::failbit); + return is; + }; + + record.uniforms.clear(); + for (size_t i = 0; i < uni_count; ++i) { + size_t name_sz = 0; + is.read(reinterpret_cast(&name_sz), sizeof(name_sz)); + std::string uni_name; + uni_name.resize(name_sz); + if (name_sz > 0) is.read(&uni_name[0], name_sz); + + size_t type_idx = 0; + is.read(reinterpret_cast(&type_idx), sizeof(type_idx)); + + Engine::ScriptShared::GameObjectParameterType uni_var; + switch (type_idx) { + case 0: { // int + int val = 0; + is.read(reinterpret_cast(&val), sizeof(val)); + uni_var = val; + break; + } + case 1: { // float + float val = 0.0f; + is.read(reinterpret_cast(&val), sizeof(val)); + uni_var = val; + break; + } + case 2: { // bool + bool val = false; + is.read(reinterpret_cast(&val), sizeof(val)); + uni_var = val; + break; + } + case 3: { // glm::vec2 + glm::vec2 val(0.0f); + is.read(reinterpret_cast(&val), sizeof(val)); + uni_var = val; + break; + } + case 4: { // glm::vec3 + glm::vec3 val(0.0f); + is.read(reinterpret_cast(&val), sizeof(val)); + uni_var = val; + break; + } + case 5: { // std::string + size_t str_sz = 0; + is.read(reinterpret_cast(&str_sz), sizeof(str_sz)); + std::string val; + val.resize(str_sz); + if (str_sz > 0) is.read(&val[0], str_sz); + uni_var = val; + break; + } + default: { + is.setstate(std::ios::failbit); + return is; + }; + }; + + record.uniforms[uni_name] = std::move(uni_var); + }; + return is; }; diff --git a/Engine/DataSerializer/ObjectsSerialization.h b/Engine/Core/Core/DataSerializer/ObjectsSerialization.h similarity index 61% rename from Engine/DataSerializer/ObjectsSerialization.h rename to Engine/Core/Core/DataSerializer/ObjectsSerialization.h index e95d323..23a738b 100644 --- a/Engine/DataSerializer/ObjectsSerialization.h +++ b/Engine/Core/Core/DataSerializer/ObjectsSerialization.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -6,6 +6,7 @@ #pragma once +#include "Renderer.h" #include #include @@ -13,20 +14,18 @@ #include #include -#include "Renderer.h" -#include "Objects/Object.h" -#include "Objects/GameObject.h" #include "Utils/Logger.h" +#include "ScriptShared/GameObjectData.h" -namespace UW { - class GameObject; +namespace Engine::Core { + class GameObject; }; -namespace UW { +namespace Engine { struct GameObjectRecord { std::string name = ""; std::string mesh = ""; @@ -37,7 +36,14 @@ struct GameObjectRecord { std::vector textures; std::vector materials; std::vector> scripts; - std::unordered_map parameters; + std::unordered_map parameters; + std::unordered_map uniforms; + bool culling_on = true; + bool dont_write_to_depth_mask = false; + bool gl_depth_lequal = false; + bool gl_draw_patches = false; + bool gl_blend = false; + bool gl_nearest = false; friend std::ostream& operator<<(std::ostream& os, const GameObjectRecord& record); friend std::istream& operator>>(std::istream& is, GameObjectRecord& record); @@ -51,14 +57,14 @@ class ObjectsSerialization { ~ObjectsSerialization() = default; #ifndef PRODUCTION - void save(const UW::GameObject& object); + void save(const Engine::Core::GameObject& object); #endif - void load(UW::GameObject& object); + void load(Engine::Core::GameObject& object); #ifndef PRODUCTION - void saveAll(std::vector& objects); + void saveAll(std::vector& objects); #endif - void loadAll(std::vector& objects); + void loadAll(std::vector& objects); private: #ifndef PRODUCTION @@ -66,4 +72,4 @@ class ObjectsSerialization { #endif friend std::istream& operator>>(std::istream& is, GameObjectRecord& record); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/Core/Core/DataSerializer/ScriptSerialization.cpp b/Engine/Core/Core/DataSerializer/ScriptSerialization.cpp new file mode 100644 index 0000000..9eac456 --- /dev/null +++ b/Engine/Core/Core/DataSerializer/ScriptSerialization.cpp @@ -0,0 +1,62 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "ScriptSerialization.h" + + + +namespace fs = std::filesystem; + + + +#ifndef PRODUCTION +void Engine::ScriptSerialization::save(const std::string& script_name, const std::string& source) { + Engine::Utils::Logger::get().info("ScriptSerialization", "Saving script: " + Engine::Config::SCRIPTS_FOLDER + script_name); + + std::string folder_path = Engine::Config::SCRIPTS_FOLDER; + std::string file_path = folder_path + script_name; + + try { + if (!fs::exists(folder_path)) fs::create_directories(folder_path); + + std::ofstream outFile(file_path); + if (!outFile.is_open()) { + Engine::Utils::Logger::get().erro("ScriptSerialization", "Failed to open file: " + file_path); + return; + }; + + outFile << source; + outFile.close(); + + Engine::Utils::Logger::get().info("ScriptSerialization", "Script saved: " + file_path); + } catch (const fs::filesystem_error& e) { + Engine::Utils::Logger::get().erro("ScriptSerialization", "Filesystem error: " + std::string(e.what())); + }; +}; + + + +std::string Engine::ScriptSerialization::load(const std::string& script_name) { + std::string file_path = Engine::Config::SCRIPTS_FOLDER + script_name; + + if (!fs::exists(file_path)) { + Engine::Utils::Logger::get().warn("ScriptSerialization", "Script file not found: " + file_path); + return ""; + }; + + std::ifstream inFile(file_path); + if (!inFile.is_open()) { + Engine::Utils::Logger::get().erro("ScriptSerialization", "Failed to open file: " + file_path); + return ""; + }; + + std::string source((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); + + inFile.close(); + return source; +}; +#endif \ No newline at end of file diff --git a/Engine/DataSerializer/ScriptSerialization.h b/Engine/Core/Core/DataSerializer/ScriptSerialization.h similarity index 87% rename from Engine/DataSerializer/ScriptSerialization.h rename to Engine/Core/Core/DataSerializer/ScriptSerialization.h index 5c15e48..570f9fe 100644 --- a/Engine/DataSerializer/ScriptSerialization.h +++ b/Engine/Core/Core/DataSerializer/ScriptSerialization.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -6,6 +6,7 @@ #pragma once +#include "Renderer.h" #include #include @@ -17,13 +18,12 @@ #include #endif -#include "Renderer.h" -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" -namespace UW { +namespace Engine { class ScriptSerialization { public: ScriptSerialization() = default; @@ -35,4 +35,4 @@ class ScriptSerialization { #endif }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/Core/Core/DataSerializer/ShaderSerialization.cpp b/Engine/Core/Core/DataSerializer/ShaderSerialization.cpp new file mode 100644 index 0000000..6c73cb6 --- /dev/null +++ b/Engine/Core/Core/DataSerializer/ShaderSerialization.cpp @@ -0,0 +1,123 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "ShaderSerialization.h" + +#ifdef PRODUCTION +#include +CMRC_DECLARE(GameData); +#endif + + + +#ifndef PRODUCTION +void Engine::ShaderSerialization::save(const std::string &shader_name, GLuint type, const std::string& source, std::unordered_map& shaders){ + Engine::Utils::Logger::get().info("ShaderSerialization", "Saving shader: " + shader_name + " type=" + std::to_string(type)); + std::string local_path = Engine::Config::GAME_DATA_FOLDER + Engine::Config::ASSETS_FOLDER + Engine::Config::SHADERS_FOLDER + shader_name + "/" + Engine::Config::SHADER_TYPE_TO_NAME[type]; + + try { + std::filesystem::path p(local_path); + if (p.has_parent_path()) + std::filesystem::create_directories(p.parent_path()); + } catch (const std::filesystem::filesystem_error& e) { + Engine::Utils::Logger::get().erro("ShaderSerialization", "Filesystem error while creating directories - " + std::string(e.what())); + return; + }; + + std::ofstream outFile(local_path); + if (!outFile.is_open()) { + Engine::Utils::Logger::get().erro("ShaderSerialization", "Failed to open file for saving - " + local_path); + return; + }; + + outFile << source << "\n"; + + outFile.close(); + Engine::Utils::Logger::get().info("ShaderSerialization", "Shader saved: " + shader_name); +}; +#endif + + + +void Engine::ShaderSerialization::load(const std::string& shader_name, std::unordered_map& shaders){ + Engine::Utils::Logger::get().info("ShaderSerialization", "Loading shader: " + shader_name); + std::string local_path = Engine::Config::GAME_DATA_FOLDER + Engine::Config::ASSETS_FOLDER + Engine::Config::SHADERS_FOLDER + shader_name; + CW::Renderer::Shader shader; + + for(const auto& [type_name, type_enum] : Engine::Config::SHADER_NAME_TO_TYPE){ + std::string file_path = local_path + "/" + type_name; + +#ifndef PRODUCTION + std::ifstream inFile(file_path); + if (inFile.is_open()) { + std::string source((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); + shader.setShader(source, type_enum); + continue; + } +#else + try { + auto fs = cmrc::GameData::get_filesystem(); + if (fs.exists(file_path)) { + auto file = fs.open(file_path); + std::string source(file.begin(), file.end()); + shader.setShader(source, type_enum); + continue; + } + } catch (const std::exception& e) { + Engine::Utils::Logger::get().warn("ShaderSerialization", "[LoadShader] CMRC Exception: " + std::string(e.what())); + } +#endif + }; + + if(shader.getRegisterShader().size() != 0){ + shaders[shader_name] = std::move(shader); + shaders[shader_name].compile(); + Engine::Utils::Logger::get().info("ShaderSerialization", "Shader loaded: " + shader_name); + } else { + Engine::Utils::Logger::get().info("ShaderSerialization", "No shader source found for: " + shader_name); + }; +}; + + + +void Engine::ShaderSerialization::loadAll(std::unordered_map& shaders) { + Engine::Utils::Logger::get().info("ShaderSerialization", "Scanning and loading all shaders..."); + + std::string root_path = Engine::Config::GAME_DATA_FOLDER + Engine::Config::ASSETS_FOLDER + Engine::Config::SHADERS_FOLDER; + + if (!root_path.empty() && root_path.back() == '/') root_path.pop_back(); + + try { + +#ifndef PRODUCTION + if (std::filesystem::exists(root_path) && std::filesystem::is_directory(root_path)) { + for (const auto& entry : std::filesystem::directory_iterator(root_path)) { + if (entry.is_directory()) { + load(entry.path().filename().string(), shaders); + } + } + } else { + Engine::Utils::Logger::get().erro("ShaderSerialization", "Filesystem - Directory not found: " + root_path); + } +#else + auto fs = cmrc::GameData::get_filesystem(); + if (fs.exists(root_path)) { + for (auto&& entry : fs.iterate_directory(root_path)) { + if (entry.is_directory()) { + load(entry.filename(), shaders); + } + } + } else { + Engine::Utils::Logger::get().erro("ShaderSerialization", "CMRC - Directory not found: " + root_path); + } +#endif + + Engine::Utils::Logger::get().info("ShaderSerialization", "Finished loading all shaders."); + } catch (const std::exception& e) { + Engine::Utils::Logger::get().erro("ShaderSerialization", "[LoadAll] CMRC Exception: " + std::string(e.what())); + }; +}; \ No newline at end of file diff --git a/Engine/DataSerializer/ShaderSerialization.h b/Engine/Core/Core/DataSerializer/ShaderSerialization.h similarity index 53% rename from Engine/DataSerializer/ShaderSerialization.h rename to Engine/Core/Core/DataSerializer/ShaderSerialization.h index 4f520a8..bb41a0b 100644 --- a/Engine/DataSerializer/ShaderSerialization.h +++ b/Engine/Core/Core/DataSerializer/ShaderSerialization.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -6,6 +6,7 @@ #pragma once +#include "Renderer.h" #include #include @@ -17,23 +18,22 @@ #include #endif -#include "Renderer.h" -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" -namespace UW { +namespace Engine { class ShaderSerialization { public: ShaderSerialization() = default; ~ShaderSerialization() = default; #ifndef PRODUCTION - void save(const std::string& shader_name, GLuint type); + void save(const std::string& shader_name, GLuint type, const std::string& source, std::unordered_map& shaders); #endif - void load(const std::string& shader_name); + void load(const std::string& shader_name, std::unordered_map& shaders); - void loadAll(); + void loadAll(std::unordered_map& shaders); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/Core/Core/DataSerializer/TextureSerialization.cpp b/Engine/Core/Core/DataSerializer/TextureSerialization.cpp new file mode 100644 index 0000000..7a9c9f4 --- /dev/null +++ b/Engine/Core/Core/DataSerializer/TextureSerialization.cpp @@ -0,0 +1,164 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "TextureSerialization.h" + + +#ifdef PRODUCTION +#include +CMRC_DECLARE(GameData); +#endif + + +namespace fs = std::filesystem; + + + +#ifndef PRODUCTION +void Engine::TextureSerialization::save(const std::string& texture_name, const CW::Renderer::Texture& source) { + // Engine::Utils::Logger::get().info("ScriptSerialization", "Saving script: " + Engine::Config::TEXTURES_FOLDER + texture_name); + + // std::string folder_path = Engine::Config::GAME_DATA_FOLDER + Engine::Config::TEXTURES_FOLDER; + // std::string file_path = folder_path + texture_name; + + // try { + // if (!fs::exists(folder_path)) fs::create_directories(folder_path); + + // std::ofstream outFile(file_path); + // if (!outFile.is_open()) { + // Engine::Utils::Logger::get().erro("ScriptSerialization", "Failed to open file: " + file_path); + // return; + // }; + + // outFile << source; + // outFile.close(); + + // Engine::Utils::Logger::get().info("ScriptSerialization", "Script saved: " + file_path); + // } catch (const fs::filesystem_error& e) { + // Engine::Utils::Logger::get().erro("ScriptSerialization", "Filesystem error: " + std::string(e.what())); + // }; +}; + +#endif + + +void Engine::TextureSerialization::load(const std::string& texture_name, std::unordered_map& textures) { + std::string file_path = Engine::Config::GAME_DATA_FOLDER + Engine::Config::ASSETS_FOLDER + Engine::Config::TEXTURES_FOLDER + texture_name; + +#ifndef PRODUCTION + if (!fs::exists(file_path)) { + Engine::Utils::Logger::get().warn("TextureSerialization", "Texture file not found: " + file_path); + return; + }; + + std::ifstream inFile(file_path); + if (!inFile.is_open()) { + Engine::Utils::Logger::get().erro("TextureSerialization", "Failed to open file: " + file_path); + return; + }; + + if (!std::filesystem::is_directory(file_path)) { + CW::Renderer::TextureLoader loader = CW::Renderer::TextureLoader(file_path); + + textures.emplace(texture_name, CW::Renderer::Texture()).first; + textures[texture_name].compile(loader.data); + } +#else + try { + auto fs = cmrc::GameData::get_filesystem(); + + if (fs.exists(file_path)) { + auto file = fs.open(file_path); + + const unsigned char* data_ptr = reinterpret_cast(file.begin()); + CW::Renderer::TextureLoader loader(data_ptr, file.size()); + + textures.emplace(texture_name, CW::Renderer::Texture()).first; + textures[texture_name].compile(loader.data); + } else { + Engine::Utils::Logger::get().warn("TextureSerialization", "Texture file not found in CMRC: " + file_path); + } + } catch (const std::exception& e) { + Engine::Utils::Logger::get().warn("Resources", "[getTexture] CMRC Exception: " + std::string(e.what())); + }; +#endif +}; + + + +void Engine::TextureSerialization::loadAll(std::unordered_map& textures){ + Engine::Utils::Logger::get().info("DataSerializer", "Scanning and loading all textures..."); + + std::string root_path = Engine::Config::GAME_DATA_FOLDER + Engine::Config::ASSETS_FOLDER + Engine::Config::TEXTURES_FOLDER; + + if (!root_path.empty() && root_path.back() == '/') root_path.pop_back(); + +#ifndef PRODUCTION + try { + if (std::filesystem::exists(root_path) && std::filesystem::is_directory(root_path)) { + for (const auto& entry : std::filesystem::directory_iterator(root_path)) { + if (entry.is_regular_file()) { + std::string file_name = entry.path().filename().string(); + + if (textures.find(file_name) != textures.end()) continue; + + std::ifstream file(entry.path(), std::ios::binary | std::ios::ate); + if (file.is_open()) { + std::streamsize size = file.tellg(); + file.seekg(0, std::ios::beg); + + std::vector buffer(size); + if (file.read(reinterpret_cast(buffer.data()), size)) { + CW::Renderer::TextureLoader loader(buffer.data(), size); + + auto it = textures.emplace(file_name, CW::Renderer::Texture()).first; + it->second.compile(loader.data); + + Engine::Utils::Logger::get().info("DataSerializer", "Loaded texture from Disk: " + file_name); + }; + }; + }; + }; + } else { + Engine::Utils::Logger::get().warn("DataSerializer", "Filesystem - Directory not found: " + root_path); + } + } catch (const std::filesystem::filesystem_error& e) { + Engine::Utils::Logger::get().warn("DataSerializer", "[Filesystem] Could not scan local textures folder: " + std::string(e.what())); + }; +#else + try { + auto fs = cmrc::GameData::get_filesystem(); + + if (fs.exists(root_path)) { + for (auto&& entry : fs.iterate_directory(root_path)) { + if (entry.is_file()) { + std::string file_name = entry.filename(); + + if (textures.find(file_name) != textures.end()) continue; + + std::string full_cmrc_path = root_path + "/" + file_name; + auto file = fs.open(full_cmrc_path); + const unsigned char* data_ptr = reinterpret_cast(file.begin()); + + CW::Renderer::TextureLoader loader(data_ptr, file.size()); + + auto it = textures.emplace(file_name, CW::Renderer::Texture()).first; + it->second.compile(loader.data); + + Engine::Utils::Logger::get().info("DataSerializer", "Loaded texture from CMRC: " + file_name); + }; + }; + } else { + Engine::Utils::Logger::get().warn("DataSerializer", "CMRC - Directory not found: " + root_path); + } + } catch (const std::exception& e) { + Engine::Utils::Logger::get().warn("DataSerializer", "[CMRC] Could not scan textures folder: " + std::string(e.what())); + }; +#endif + + Engine::Utils::Logger::get().info("DataSerializer", "Finished loading all textures."); +}; \ No newline at end of file diff --git a/Engine/Core/Core/DataSerializer/TextureSerialization.h b/Engine/Core/Core/DataSerializer/TextureSerialization.h new file mode 100644 index 0000000..ce420b8 --- /dev/null +++ b/Engine/Core/Core/DataSerializer/TextureSerialization.h @@ -0,0 +1,39 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include "Renderer.h" + +#include +#include +#include +#include +#include + +#ifdef PRODUCTION +#include +#endif + +#include "Utils/config.h" +#include "Utils/Logger.h" + + + +namespace Engine { +class TextureSerialization { +public: + TextureSerialization() = default; + ~TextureSerialization() = default; + +#ifndef PRODUCTION + void save(const std::string& texture_path, const CW::Renderer::Texture& source); +#endif + void load(const std::string& texture_path, std::unordered_map& textures); + + void loadAll(std::unordered_map& textures); +}; +}; // namespace Engine diff --git a/Engine/Objects/GameObject.cpp b/Engine/Core/Core/Objects/GameObject.cpp similarity index 51% rename from Engine/Objects/GameObject.cpp rename to Engine/Core/Core/Objects/GameObject.cpp index 61ebadf..7adc2d3 100644 --- a/Engine/Objects/GameObject.cpp +++ b/Engine/Core/Core/Objects/GameObject.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -9,7 +9,7 @@ -void PatchScriptPointers(std::vector& scripts, UW::GameObjectData* new_data_ptr) { +void PatchScriptPointers(std::vector& scripts, Engine::ScriptShared::GameObjectData* new_data_ptr) { for (auto& record : scripts) { if (record.script) { record.script->game_object_data = new_data_ptr; @@ -19,10 +19,9 @@ void PatchScriptPointers(std::vector& scripts, UW::G -UW::GameObject::GameObject(const std::string& name, const std::string& mesh, const std::string& shader, const std::vector& materials, const std::vector& textures, const std::vector& scripts, glm::vec3 position, glm::vec3 rotation, glm::vec3 scale) - : scripts(scripts) { - UW::Logger::get().info("GameObject", "GameObject Constructor Called!"); - mesh_id = Resources::get().meshes.get_id(mesh); +Engine::Core::GameObject::GameObject(const std::string& name, const std::string& mesh, const std::string& shader, const std::vector& materials, const std::vector& textures, const std::vector& scripts, glm::vec3 position, glm::vec3 rotation, glm::vec3 scale) + : scripts(scripts), mesh(mesh, &Engine::Core::Resources::get().meshes) { + Engine::Utils::Logger::get().info("GameObject", "GameObject Constructor Called!"); game_object_data.name = name; game_object_data.mesh = mesh; game_object_data.shader = shader; @@ -32,14 +31,15 @@ UW::GameObject::GameObject(const std::string& name, const std::string& mesh, con game_object_data.rotation = rotation; game_object_data.scale = scale; copy_game_object_data = game_object_data; + this->mesh.setName(copy_game_object_data.mesh); - onLoad(); + // onLoad(); }; -UW::GameObject::GameObject(const std::string& name, const GameObject& other){ - UW::Logger::get().info("GameObject", "GameObject Duplicating"); +Engine::Core::GameObject::GameObject(const std::string& name, const GameObject& other){ + Engine::Utils::Logger::get().info("GameObject", "GameObject Duplicating"); for(const auto& script : other.scripts) scripts.emplace_back(script.getPath()); game_object_data = other.game_object_data; @@ -47,43 +47,45 @@ UW::GameObject::GameObject(const std::string& name, const GameObject& other){ game_object_data.name = name; copy_game_object_data = game_object_data; - mesh_id = Resources::get().meshes.get_id(other.copy_game_object_data.mesh); + mesh = other.mesh; PatchScriptPointers(this->scripts, &this->copy_game_object_data); - onLoad(); + // onLoad(); }; -UW::GameObject::~GameObject(){ +Engine::Core::GameObject::~GameObject(){ onDestroy(); }; -UW::GameObject::GameObject(const GameObject& other) +Engine::Core::GameObject::GameObject(const GameObject& other) : Object(other), uniform(other.uniform), scripts(other.scripts), - mesh_last(other.mesh_last), mesh_id(other.mesh_id), mesh_version(other.mesh_version), - game_object_data(other.game_object_data) + mesh_last(other.mesh_last), + game_object_data(other.game_object_data), + mesh(other.mesh) { copy_game_object_data = game_object_data; + mesh.setName(copy_game_object_data.name); PatchScriptPointers(this->scripts, &this->copy_game_object_data); } -UW::GameObject& UW::GameObject::operator=(const GameObject& other) { +Engine::Core::GameObject& Engine::Core::GameObject::operator=(const GameObject& other) { if (this == &other) return *this; Object::operator=(other); uniform = other.uniform; scripts = other.scripts; mesh_last = other.mesh_last; - mesh_id = other.mesh_id; - mesh_version = other.mesh_version; + mesh = other.mesh; game_object_data = other.game_object_data; copy_game_object_data = game_object_data; + mesh.setName(copy_game_object_data.name); PatchScriptPointers(this->scripts, &this->copy_game_object_data); return *this; @@ -91,28 +93,30 @@ UW::GameObject& UW::GameObject::operator=(const GameObject& other) { -UW::GameObject::GameObject(GameObject&& other) noexcept +Engine::Core::GameObject::GameObject(GameObject&& other) noexcept : Object(std::move(other)), uniform(std::move(other.uniform)), scripts(std::move(other.scripts)), - mesh_last(std::move(other.mesh_last)), mesh_id(other.mesh_id), mesh_version(other.mesh_version), - game_object_data(std::move(other.game_object_data)) + mesh_last(std::move(other.mesh_last)), + game_object_data(std::move(other.game_object_data)), + mesh(std::move(other.mesh)) { copy_game_object_data = game_object_data; + mesh.setName(copy_game_object_data.name); PatchScriptPointers(this->scripts, &this->copy_game_object_data); }; -UW::GameObject& UW::GameObject::operator=(GameObject&& other) noexcept { +Engine::Core::GameObject& Engine::Core::GameObject::operator=(GameObject&& other) noexcept { if (this == &other) return *this; Object::operator=(std::move(other)); uniform = std::move(other.uniform); scripts = std::move(other.scripts); mesh_last = std::move(other.mesh_last); - mesh_id = other.mesh_id; - mesh_version = other.mesh_version; + mesh = std::move(other.mesh); game_object_data = std::move(other.game_object_data); copy_game_object_data = game_object_data; + mesh.setName(copy_game_object_data.name); PatchScriptPointers(this->scripts, &this->copy_game_object_data); return *this; @@ -120,45 +124,45 @@ UW::GameObject& UW::GameObject::operator=(GameObject&& other) noexcept { -void UW::GameObject::stopScript(unsigned int index){ +void Engine::Core::GameObject::stopScript(unsigned int index){ scripts[index].onDestroy(); scripts[index].removeModule(); }; -void UW::GameObject::startScript(unsigned int index){ +void Engine::Core::GameObject::startScript(unsigned int index, Engine::Core::Scene& scene){ scripts[index].loadModule(); copy_game_object_data = game_object_data; - scripts[index].onLoad(©_game_object_data); + scripts[index].onLoad(©_game_object_data, scene); }; -void UW::GameObject::stopScripts(){ +void Engine::Core::GameObject::stopScripts(){ for(int i = 0; i < scripts.size(); i++) stopScript(i); }; -void UW::GameObject::startScripts(){ +void Engine::Core::GameObject::startScripts(Engine::Core::Scene& scene){ for(int i = 0; i < scripts.size(); i++) - startScript(i); + startScript(i, scene); }; -void UW::GameObject::onLoad(){ +void Engine::Core::GameObject::onLoad(Engine::Core::Scene& scene){ for(auto& script : scripts) { script.loadModule(); - script.onLoad(©_game_object_data); + script.onLoad(©_game_object_data, scene); }; }; -void UW::GameObject::onDestroy(){ +void Engine::Core::GameObject::onDestroy(){ for(auto& script : scripts) { script.onDestroy(); script.removeModule(); @@ -167,8 +171,8 @@ void UW::GameObject::onDestroy(){ -void UW::GameObject::onUpdate(float delta_time){ - if(Resources::get().simulation_mode){ +void Engine::Core::GameObject::onUpdate(float delta_time){ + if(Engine::Core::Resources::get().simulation_mode){ for(auto& script : scripts) { if(!script.script_on) continue; script.syncPointer(©_game_object_data); @@ -179,12 +183,12 @@ void UW::GameObject::onUpdate(float delta_time){ -void UW::GameObject::onFixedUpdate(float fixed_delta_time){ - if(Resources::get().simulation_mode){ +void Engine::Core::GameObject::onFixedUpdate(float fixed_delta_time, Engine::Core::Scene& scene){ + if(Engine::Core::Resources::get().simulation_mode){ for(auto& script : scripts) { if(!script.script_on) continue; script.syncPointer(©_game_object_data); - script.observe(©_game_object_data); + script.observe(©_game_object_data, scene); script.onFixedUpdate(fixed_delta_time); }; }; @@ -192,24 +196,25 @@ void UW::GameObject::onFixedUpdate(float fixed_delta_time){ -void UW::GameObject::render(CW::Renderer::Renderer *renderer, Camera &culling_camera, Camera &render_camera, CW::Renderer::Uniform& shadows_uniform){ +void Engine::Core::GameObject::render(CW::Renderer::Renderer *renderer, Engine::ScriptShared::ICamera &culling_camera, Engine::ScriptShared::ICamera &render_camera, CW::Renderer::Uniform& shadows_uniform){ if(copy_game_object_data.mesh == "empty") return; if(scripts.size() == 0) copy_game_object_data = game_object_data; - if(Resources::get().meshes.validateVersion(mesh_version) || mesh_last != copy_game_object_data.mesh){ - mesh_version = Resources::get().meshes.getLatestsVersion(); - mesh_id = Resources::get().meshes.get_id(this->copy_game_object_data.mesh); + if(mesh_last != copy_game_object_data.mesh){ + mesh.setName(copy_game_object_data.mesh); mesh_last = copy_game_object_data.mesh; }; - if(Resources::get().meshes.size() <= mesh_id) return; + CW::Renderer::Mesh* mesh = this->mesh.get(); + if(!mesh) return; - uniform["projection"]->set(render_camera.projection(renderer)); - uniform["view"]->set(render_camera.view(renderer)); + uniform["projection"]->set(render_camera.projection()); + uniform["view"]->set(render_camera.view()); - uniform["cameraPosition"]->set(culling_camera.position); - uniform["lightCount"]->set(Resources::get().lights.size()); + uniform["cameraPosition"]->set(culling_camera.getPosition()); + uniform["lightCount"]->set(Engine::Core::Resources::get().lights.size()); + uniform["window_size"]->set({renderer->getWindowData()->width, renderer->getWindowData()->height}); glm::vec3 pivotOffset = glm::vec3(0.0f, 0.0f, 0.0f); glm::mat4 translationMat = glm::translate(glm::mat4(1.0f), copy_game_object_data.position); @@ -219,48 +224,93 @@ void UW::GameObject::render(CW::Renderer::Renderer *renderer, Camera &culling_ca glm::mat4 postRotate = glm::translate(glm::mat4(1.0f), pivotOffset); glm::mat4 model = translationMat * postRotate * rotationMat * preRotate * scaleMat; - if(Resources::get().simulation_mode){ + for(auto& el : copy_game_object_data.uniforms) { + std::visit([&](auto&& arg) { + using T = std::decay_t; + + if constexpr (std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v) uniform[el.first]->set(arg); + }, el.second); + }; + + if(Engine::Core::Resources::get().simulation_mode){ for(auto& script : scripts) { if(!script.script_on) continue; script.onRender(); }; }; - if(isVisible(culling_camera.transformation(renderer), model, Resources::get().meshes[mesh_id])){ + if(!copy_game_object_data.culling_on || isVisible(culling_camera.transformation(), model, *mesh)){ + if(copy_game_object_data.gl_depth_lequal) + glDepthFunc(GL_LEQUAL); + if(copy_game_object_data.dont_write_to_depth_mask) + glDepthMask(GL_FALSE); + if(copy_game_object_data.gl_draw_patches) + glPatchParameteri(GL_PATCH_VERTICES, 4); + if(copy_game_object_data.gl_blend){ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + }; + uniform["model"]->set(model); for(unsigned int i = 0; i < copy_game_object_data.textures.size(); i++){ - Resources::get().getTexture(this->copy_game_object_data.textures[i]).bind(i); + Engine::Core::Resources::get().getTexture(this->copy_game_object_data.textures[i]).bind(i); uniform["texture" + std::to_string(i)]->set(i); + + + if(this->copy_game_object_data.gl_nearest){ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + else{ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + }; }; - Resources::get().getShader(this->copy_game_object_data.shader).getUniforms().emplace_back(&uniform); - Resources::get().getShader(this->copy_game_object_data.shader).getUniforms().emplace_back(&shadows_uniform); + Engine::Core::Resources::get().getShader(this->copy_game_object_data.shader).getUniforms().emplace_back(&shadows_uniform); + Engine::Core::Resources::get().getShader(this->copy_game_object_data.shader).getUniforms().emplace_back(&uniform); - Resources::get().getShader(this->copy_game_object_data.shader).bind(); + Engine::Core::Resources::get().getShader(this->copy_game_object_data.shader).bind(); std::vector translation; for(std::string el : copy_game_object_data.materials){ - translation.emplace_back(Resources::get().materials.translate_material(el)); + translation.emplace_back(Engine::Core::Resources::get().materials.translate_material(el)); }; - GLint loc = glGetUniformLocation(Resources::get().getShader(copy_game_object_data.shader).getShaderProgram(), "mat_translate"); + GLint loc = glGetUniformLocation(Engine::Core::Resources::get().getShader(copy_game_object_data.shader).getShaderProgram(), "mat_translate"); glUniform1iv(loc, translation.size(), translation.data()); - - Resources::get().meshes[mesh_id].render(); - - Resources::get().getShader(this->copy_game_object_data.shader).unbind(); - for(unsigned int i = 0; i < copy_game_object_data.textures.size(); i++) - Resources::get().getTexture(this->copy_game_object_data.textures[i]).unbind(); - Resources::get().getShader(this->copy_game_object_data.shader).getUniforms().clear(); + if(copy_game_object_data.gl_draw_patches) + mesh->render(GL_PATCHES); + else + mesh->render(); + + Engine::Core::Resources::get().getShader(this->copy_game_object_data.shader).unbind(); + + for(unsigned int i = 0; i < copy_game_object_data.textures.size(); i++) { + Engine::Core::Resources::get().getTexture(this->copy_game_object_data.textures[i]).unbind(); + if(this->copy_game_object_data.gl_nearest){ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + }; + }; + + Engine::Core::Resources::get().getShader(this->copy_game_object_data.shader).getUniforms().clear(); + + if(copy_game_object_data.gl_depth_lequal) + glDepthFunc(GL_LESS); + if(copy_game_object_data.dont_write_to_depth_mask) + glDepthMask(GL_TRUE); + if(copy_game_object_data.gl_blend) + glDisable(GL_BLEND); }; }; -bool UW::GameObject::isVisible(glm::mat4 culling_camera_transform, glm::mat4 model, const CW::Renderer::Mesh& mesh){ +bool Engine::Core::GameObject::isVisible(glm::mat4 culling_camera_transform, glm::mat4 model, const CW::Renderer::Mesh& mesh){ auto cullingBox = mesh.getCullingBox(); glm::vec3 localMin = glm::vec3(cullingBox[0][0], cullingBox[0][1], cullingBox[0][2]); glm::vec3 localMax = glm::vec3(cullingBox[1][0], cullingBox[1][1], cullingBox[1][2]); diff --git a/Engine/Objects/GameObject.h b/Engine/Core/Core/Objects/GameObject.h similarity index 52% rename from Engine/Objects/GameObject.h rename to Engine/Core/Core/Objects/GameObject.h index f7824f9..189afbe 100644 --- a/Engine/Objects/GameObject.h +++ b/Engine/Core/Core/Objects/GameObject.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -18,30 +18,37 @@ #include "Resources/Resources.h" #include "ScriptShared/GameObjectData.h" #include "ScriptController/ScriptController.h" +#include "Utils/Resource/Resource.h" -namespace UW{ -class GameObjectScriptRecord; +namespace Engine::Core{ + class Scene; +}; + + +namespace Engine::Core::Script{ + class GameObjectScriptRecord; +}; -class GameObject : public Object{ +namespace Engine::Core{ +class GameObject : public Engine::Core::Object{ private: CW::Renderer::Uniform uniform; public: - std::vector scripts; + std::vector scripts; std::string mesh_last = ""; - unsigned int mesh_id = -1; - unsigned int mesh_version = -1; + Engine::Utils::Resource mesh; - UW::GameObjectData game_object_data; - UW::GameObjectData copy_game_object_data; + Engine::ScriptShared::GameObjectData game_object_data; + Engine::ScriptShared::GameObjectData copy_game_object_data; public: - GameObject(const std::string& name, const std::string& mesh, const std::string& shader, const std::vector& materials = {}, const std::vector& textures = {}, const std::vector& scripts = {}, glm::vec3 position = glm::vec3(0.0f), glm::vec3 rotation = glm::vec3(0.0f), glm::vec3 scale = glm::vec3(1.0f)); + GameObject(const std::string& name, const std::string& mesh, const std::string& shader, const std::vector& materials = {}, const std::vector& textures = {}, const std::vector& scripts = {}, glm::vec3 position = glm::vec3(0.0f), glm::vec3 rotation = glm::vec3(0.0f), glm::vec3 scale = glm::vec3(1.0f)); GameObject(const std::string& name, const GameObject& other); ~GameObject(); GameObject(const GameObject& other); @@ -50,15 +57,15 @@ class GameObject : public Object{ GameObject& operator=(GameObject&& other) noexcept; void stopScript(unsigned int index); - void startScript(unsigned int index); + void startScript(unsigned int index, Engine::Core::Scene& scene); void stopScripts(); - void startScripts(); + void startScripts(Engine::Core::Scene& scene); - void onLoad() override; + void onLoad(Engine::Core::Scene& scene) override; void onDestroy() override; void onUpdate(float delta_time) override; - void onFixedUpdate(float fixed_delta_time) override; - void render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform) override; + void onFixedUpdate(float fixed_delta_time, Engine::Core::Scene& scene) override; + void render(CW::Renderer::Renderer* renderer, Engine::ScriptShared::ICamera& culling_camera, Engine::ScriptShared::ICamera& render_camera, CW::Renderer::Uniform& shadows_uniform) override; bool isVisible(glm::mat4 culling_camera_transform, glm::mat4 model, const CW::Renderer::Mesh& mesh); diff --git a/Engine/Core/Core/Objects/Object.h b/Engine/Core/Core/Objects/Object.h new file mode 100644 index 0000000..0cb5a18 --- /dev/null +++ b/Engine/Core/Core/Objects/Object.h @@ -0,0 +1,31 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include "Renderer.h" + +#include "../Camera/Camera.h" + + + +namespace Engine::Core{ + class Scene; +}; + + + +namespace Engine::Core{ +class Object{ +public: + virtual void onLoad(Engine::Core::Scene& scene) = 0; + virtual void onDestroy() = 0; + virtual void onUpdate(float delta_time) = 0; + virtual void onFixedUpdate(float fixed_delta_time, Engine::Core::Scene& scene) = 0; + virtual void render(CW::Renderer::Renderer* renderer, Engine::ScriptShared::ICamera& culling_camera, Engine::ScriptShared::ICamera& render_camera, CW::Renderer::Uniform& shadows_uniform) = 0; + +}; +}; diff --git a/Engine/Core/Core/Objects/ObjectManager.cpp b/Engine/Core/Core/Objects/ObjectManager.cpp new file mode 100644 index 0000000..53187b1 --- /dev/null +++ b/Engine/Core/Core/Objects/ObjectManager.cpp @@ -0,0 +1,159 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "ObjectManager.h" + + + +Engine::ObjectManager &Engine::ObjectManager::get(){ + static ObjectManager instance; + return instance; +}; + + + +void Engine::ObjectManager::emplace_back(const std::string &name){ + objects.emplace_back(Engine::Core::GameObject(name, "empty", "Default")); +}; + + + +void Engine::ObjectManager::erase(const std::string &name) { + for (auto it = objects.begin(); it != objects.end(); ) { + if (it->game_object_data.name == name) { + it->onDestroy(); + it->scripts.clear(); + // it->mesh_id = -1; + it = objects.erase(it); + + } else { + ++it; + }; + }; +}; + + + +Engine::ScriptShared::GameObjectData *Engine::ObjectManager::getGameObjectData(const std::string &name){ + for(auto& object : objects) + if(object.game_object_data.name == name) + return &object.copy_game_object_data; + + return nullptr; +}; + + + +void Engine::ObjectManager::addScript(const std::string &object_name, const std::string &path){ + for (auto& obj : objects) { + if (obj.game_object_data.name == object_name) { + obj.scripts.emplace_back(path); + return; + }; + }; + Engine::Utils::Logger::get().erro("ObjectManager", "Could not find object: " + object_name); +}; + + + +void Engine::ObjectManager::removeScript(const std::string &object_name, const std::string &path) { + for (auto& obj : objects) { + if (obj.game_object_data.name == object_name) { + obj.scripts.erase( + std::remove_if(obj.scripts.begin(), obj.scripts.end(), + [&](const Engine::Core::Script::GameObjectScriptRecord& record) { + return record.getPath() == path; + }), + obj.scripts.end() + ); + return; + }; + }; + Engine::Utils::Logger::get().erro("ObjectManager", "Could not find object: " + object_name); +}; + + + +void Engine::ObjectManager::saveRuntime(const std::string& object_name){ + for (auto& obj : objects) { + if (obj.game_object_data.name == object_name) { + obj.game_object_data = obj.copy_game_object_data; + }; + }; +}; + + + +void Engine::ObjectManager::emplace_backObjectScript(const std::string &name){ + script_objects.emplace_back(Engine::Core::GameObject(name, "empty", "Default")); +}; + + + +void Engine::ObjectManager::eraseObjectScript(const std::string &name) { + for (auto it = script_objects.begin(); it != script_objects.end(); ) { + if (it->game_object_data.name == name) { + it->onDestroy(); + it->scripts.clear(); + // it->mesh_id = -1; + it = script_objects.erase(it); + + } else { + ++it; + }; + }; +}; + + + +Engine::ScriptShared::GameObjectData *Engine::ObjectManager::getGameObjectDataObjectScript(const std::string &name){ + for(auto& object : script_objects) + if(object.game_object_data.name == name) + return &object.copy_game_object_data; + + return nullptr; +}; + + + +void Engine::ObjectManager::addScriptObjectScript(const std::string &object_name, const std::string &path){ + for (auto& obj : script_objects) { + if (obj.game_object_data.name == object_name) { + obj.scripts.emplace_back(path); + return; + }; + }; + Engine::Utils::Logger::get().erro("ObjectManager", "Could not find object: " + object_name); +}; + + + +void Engine::ObjectManager::removeScriptObjectScript(const std::string &object_name, const std::string &path) { + for (auto& obj : script_objects) { + if (obj.game_object_data.name == object_name) { + obj.scripts.erase( + std::remove_if(obj.scripts.begin(), obj.scripts.end(), + [&](const Engine::Core::Script::GameObjectScriptRecord& record) { + return record.getPath() == path; + }), + obj.scripts.end() + ); + return; + }; + }; + Engine::Utils::Logger::get().erro("ObjectManager", "Could not find object: " + object_name); +}; + + + +void Engine::ObjectManager::saveRuntimeObjectScript(const std::string& object_name){ + for (auto& obj : script_objects) { + if (obj.game_object_data.name == object_name) { + obj.game_object_data = obj.copy_game_object_data; + }; + }; +}; \ No newline at end of file diff --git a/Engine/Objects/ObjectManager.h b/Engine/Core/Core/Objects/ObjectManager.h similarity index 53% rename from Engine/Objects/ObjectManager.h rename to Engine/Core/Core/Objects/ObjectManager.h index 3b2f951..42d1a93 100644 --- a/Engine/Objects/ObjectManager.h +++ b/Engine/Core/Core/Objects/ObjectManager.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,7 +11,7 @@ #include #include -#include "config.h" +#include "Utils/config.h" #include "DataSerializer/DataSerializer.h" #include "Objects/Object.h" #include "Objects/GameObject.h" @@ -19,12 +19,13 @@ -namespace UW{ -class GameObject; - +namespace Engine::Core{ + class GameObject; +}; -class ObjectManager : public IObjectManager{ +namespace Engine{ +class ObjectManager : public Engine::ScriptShared::IObjectManager{ private: public: @@ -40,14 +41,22 @@ class ObjectManager : public IObjectManager{ ~ObjectManager() = default; public: - std::vector objects; + std::vector objects; + std::vector script_objects; void emplace_back(const std::string& name); void erase(const std::string& name); - GameObjectData* getGameObjectData(const std::string& name); + Engine::ScriptShared::GameObjectData* getGameObjectData(const std::string& name); void addScript(const std::string& object_name, const std::string& path); void removeScript(const std::string& object_name, const std::string& path); void saveRuntime(const std::string& object_name); + + void emplace_backObjectScript(const std::string& name); + void eraseObjectScript(const std::string& name); + Engine::ScriptShared::GameObjectData* getGameObjectDataObjectScript(const std::string& name); + void addScriptObjectScript(const std::string& object_name, const std::string& path); + void removeScriptObjectScript(const std::string& object_name, const std::string& path); + void saveRuntimeObjectScript(const std::string& object_name); }; -}; // namespace UW +}; // namespace Engine diff --git a/Engine/Resources/Lights/Lights.cpp b/Engine/Core/Core/Resources/Lights/Lights.cpp similarity index 52% rename from Engine/Resources/Lights/Lights.cpp rename to Engine/Core/Core/Resources/Lights/Lights.cpp index 5a20e12..48ca17b 100644 --- a/Engine/Resources/Lights/Lights.cpp +++ b/Engine/Core/Core/Resources/Lights/Lights.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -9,25 +9,25 @@ -UW::Light::Light(glm::vec3 position, glm::vec3 color, float strength) +Engine::Core::Light::Light(glm::vec3 position, glm::vec3 color, float strength) :position(position), color(color), strength(strength) {}; -UW::Lights::Lights(std::initializer_list lights) +Engine::Core::Lights::Lights(std::initializer_list lights) : lights(lights) { compile(); }; -UW::Lights::~Lights(){ +Engine::Core::Lights::~Lights(){ destroy(); }; -void UW::Lights::compile(){ +void Engine::Core::Lights::compile(){ buffer.create(); buffer.set(lights); is_compiled = true; @@ -35,14 +35,14 @@ void UW::Lights::compile(){ -void UW::Lights::destroy(){ +void Engine::Core::Lights::destroy(){ buffer.destroy(); is_compiled = false; }; -void UW::Lights::bind(GLuint socket){ +void Engine::Core::Lights::bind(GLuint socket){ if(!is_compiled) compile(); buffer.bind(socket); @@ -50,7 +50,7 @@ void UW::Lights::bind(GLuint socket){ -void UW::Lights::unbind(){ +void Engine::Core::Lights::unbind(){ if(!is_compiled) return; buffer.unbind(); @@ -58,47 +58,47 @@ void UW::Lights::unbind(){ -UW::Light& UW::Lights::operator[](unsigned int index){ +Engine::Core::Light& Engine::Core::Lights::operator[](unsigned int index){ is_compiled = false; return lights[index]; }; -UW::Light UW::Lights::get(unsigned int index) const{ +Engine::Core::Light Engine::Core::Lights::get(unsigned int index) const{ return lights[index]; }; -void UW::Lights::clear(){ +void Engine::Core::Lights::clear(){ is_compiled = false; lights.clear(); }; -void UW::Lights::erase(unsigned int index){ +void Engine::Core::Lights::erase(unsigned int index){ is_compiled = false; lights.erase(lights.begin() + index); }; -unsigned int UW::Lights::size() const { +unsigned int Engine::Core::Lights::size() const { return lights.size(); }; -void UW::Lights::emplace_back(Light light){ +void Engine::Core::Lights::emplace_back(Light light){ is_compiled = false; lights.emplace_back(light); }; -void UW::Lights::emplace_back(std::initializer_list lights){ +void Engine::Core::Lights::emplace_back(std::initializer_list lights){ is_compiled = false; for (Light el : lights) this->lights.emplace_back(el); }; diff --git a/Engine/Resources/Lights/Lights.h b/Engine/Core/Core/Resources/Lights/Lights.h similarity index 95% rename from Engine/Resources/Lights/Lights.h rename to Engine/Core/Core/Resources/Lights/Lights.h index 29b35fc..2185c2b 100644 --- a/Engine/Resources/Lights/Lights.h +++ b/Engine/Core/Core/Resources/Lights/Lights.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -14,7 +14,7 @@ -namespace UW{ +namespace Engine::Core{ struct Light{ alignas(16) glm::vec3 position; alignas(16) glm::vec3 color; diff --git a/Engine/Resources/Materials/Materials.cpp b/Engine/Core/Core/Resources/Materials/Materials.cpp similarity index 59% rename from Engine/Resources/Materials/Materials.cpp rename to Engine/Core/Core/Resources/Materials/Materials.cpp index e6ff84d..ea8f76b 100644 --- a/Engine/Resources/Materials/Materials.cpp +++ b/Engine/Core/Core/Resources/Materials/Materials.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -9,7 +9,7 @@ -UW::Material::Material( +Engine::Core::Material::Material( glm::vec3 albedo, float metallic, float roughness, @@ -25,13 +25,13 @@ UW::Material::Material( -UW::Materials::~Materials(){ +Engine::Core::Materials::~Materials(){ destroy(); }; -void UW::Materials::genVectors(){ +void Engine::Core::Materials::genVectors(){ materials.clear(); material_translate.clear(); @@ -43,7 +43,7 @@ void UW::Materials::genVectors(){ -void UW::Materials::compile(){ +void Engine::Core::Materials::compile(){ buffer.create(); genVectors(); buffer.set(materials); @@ -52,14 +52,14 @@ void UW::Materials::compile(){ -void UW::Materials::destroy(){ +void Engine::Core::Materials::destroy(){ buffer.destroy(); is_compiled = false; }; -void UW::Materials::bind(GLuint socket){ +void Engine::Core::Materials::bind(GLuint socket){ if(!is_compiled) compile(); buffer.bind(socket); @@ -67,7 +67,7 @@ void UW::Materials::bind(GLuint socket){ -void UW::Materials::unbind(){ +void Engine::Core::Materials::unbind(){ if(!is_compiled) return; buffer.unbind(); @@ -75,26 +75,26 @@ void UW::Materials::unbind(){ -unsigned int UW::Materials::translate_material(const std::string& name){ +unsigned int Engine::Core::Materials::translate_material(const std::string& name){ return material_translate[name]; }; -UW::Material& UW::Materials::operator[](const std::string& name){ +Engine::Core::Material& Engine::Core::Materials::operator[](const std::string& name){ is_compiled = false; return material_reg[name]; }; -const std::unordered_map& UW::Materials::getMaterialReg(){ +const std::unordered_map& Engine::Core::Materials::getMaterialReg(){ return material_reg; }; -bool UW::Materials::find(const std::string& name){ +bool Engine::Core::Materials::find(const std::string& name){ auto it = material_reg.find(name); if(it == material_reg.end()) return false; return true; @@ -102,13 +102,13 @@ bool UW::Materials::find(const std::string& name){ -UW::Material UW::Materials::getMaterial(const std::string& name){ +Engine::Core::Material Engine::Core::Materials::getMaterial(const std::string& name){ return material_reg[name]; }; -void UW::Materials::clear(){ +void Engine::Core::Materials::clear(){ is_compiled = false; material_reg.clear(); materials.clear(); @@ -116,27 +116,27 @@ void UW::Materials::clear(){ -void UW::Materials::erase(const std::string& name){ +void Engine::Core::Materials::erase(const std::string& name){ is_compiled = false; material_reg.erase(name); }; -unsigned int UW::Materials::size() const { +unsigned int Engine::Core::Materials::size() const { return material_reg.size(); }; -void UW::Materials::emplace_back(const std::string& name, Material material){ +void Engine::Core::Materials::emplace_back(const std::string& name, Material material){ is_compiled = false; material_reg[name] = material; }; -void UW::Materials::emplace_back(std::initializer_list> materials){ +void Engine::Core::Materials::emplace_back(std::initializer_list> materials){ is_compiled = false; for (std::pair el : materials) this->material_reg[el.first] = el.second; }; diff --git a/Engine/Resources/Materials/Materials.h b/Engine/Core/Core/Resources/Materials/Materials.h similarity index 97% rename from Engine/Resources/Materials/Materials.h rename to Engine/Core/Core/Resources/Materials/Materials.h index 1ff6d2d..af9255f 100644 --- a/Engine/Resources/Materials/Materials.h +++ b/Engine/Core/Core/Resources/Materials/Materials.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -13,7 +13,7 @@ -namespace UW{ +namespace Engine::Core{ struct Material{ alignas(16) glm::vec3 albedo = glm::vec3(1.0f); alignas(4) float metallic = 0.0f; diff --git a/Engine/Resources/Resources.cpp b/Engine/Core/Core/Resources/Resources.cpp similarity index 65% rename from Engine/Resources/Resources.cpp rename to Engine/Core/Core/Resources/Resources.cpp index 7d7cc37..a42f749 100644 --- a/Engine/Resources/Resources.cpp +++ b/Engine/Core/Core/Resources/Resources.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -15,27 +15,27 @@ CMRC_DECLARE(GameData); -UW::Resources& UW::Resources::get(){ - static Resources instance; +Engine::Core::Resources& Engine::Core::Resources::get(){ + static Engine::Core::Resources instance; return instance; }; -UW::Resources::Resources(){ +Engine::Core::Resources::Resources(){ initMeshes(); initLights(); }; -UW::Resources::~Resources(){ +Engine::Core::Resources::~Resources(){ destroy(); }; -void UW::Resources::destroy(){ +void Engine::Core::Resources::destroy(){ meshes.clear(); textures.clear(); shaders.clear(); @@ -46,60 +46,21 @@ void UW::Resources::destroy(){ -CW::Renderer::Texture &UW::Resources::getTexture(const std::string &path_to_asset){ +CW::Renderer::Texture &Engine::Core::Resources::getTexture(const std::string &path_to_asset){ auto it = textures.find(path_to_asset); - - if (it != textures.end()) { - return it->second; - } + if (it != textures.end()) return it->second; - std::string local_path = UW::Config::GAME_DATA_FOLDER + UW::Config::ASSETS_FOLDER + UW::Config::TEXTURES_FOLDER + path_to_asset; - -#ifndef PRODUCTION - if (std::filesystem::exists(local_path) && !std::filesystem::is_directory(local_path)) { - std::ifstream file(local_path, std::ios::binary | std::ios::ate); - if (file.is_open()) { - std::streamsize size = file.tellg(); - file.seekg(0, std::ios::beg); - - std::vector buffer(size); - if (file.read(reinterpret_cast(buffer.data()), size)) { - CW::Renderer::TextureLoader loader(buffer.data(), size); - - it = textures.emplace(path_to_asset, CW::Renderer::Texture()).first; - it->second.compile(loader.data); - return it->second; - } - } else { - Logger::get().erro("Resources", "Failed to open texture file: " + local_path); - } - } -#else - try { - auto fs = cmrc::GameData::get_filesystem(); - - if (fs.exists(local_path)) { - auto file = fs.open(local_path); - - const unsigned char* data_ptr = reinterpret_cast(file.begin()); - CW::Renderer::TextureLoader loader(data_ptr, file.size()); - - it = textures.emplace(path_to_asset, CW::Renderer::Texture()).first; - it->second.compile(loader.data); - - return it->second; - } - } catch (const std::exception& e) { - Logger::get().warn("Resources", "[getTexture] CMRC Exception: " + std::string(e.what())); - } -#endif + DataSerializer::get().loadTexture(path_to_asset); + + auto ita = textures.find(path_to_asset); + if (ita != textures.end()) return ita->second; - return textures[UW::Config::DEFAULT_TEXTURE]; + return textures[Engine::Config::DEFAULT_TEXTURE]; }; -CW::Renderer::Shader &UW::Resources::getShader(const std::string &path_to_asset){ +CW::Renderer::Shader &Engine::Core::Resources::getShader(const std::string &path_to_asset){ auto it = shaders.find(path_to_asset); if (it != shaders.end()) { @@ -114,12 +75,12 @@ CW::Renderer::Shader &UW::Resources::getShader(const std::string &path_to_asset) return ita->second; }; - return shaders[UW::Config::DEFAULT_SHADER]; + return shaders[Engine::Config::DEFAULT_SHADER]; }; -void UW::Resources::initMeshes(){ +void Engine::Core::Resources::initMeshes(){ // ============================= // // ========== Empty ============ // // ============================= // @@ -263,14 +224,14 @@ void UW::Resources::initMeshes(){ default_mesh.setData(uvs, 2, 2); default_mesh.setData(mat_id, 1, 3); default_mesh.addIndices(indices); - meshes.emplace_back(UW::Config::DEFAULT_MESH, std::move(default_mesh)); + meshes.emplace_back(Engine::Config::DEFAULT_MESH, std::move(default_mesh)); }; -void UW::Resources::initLights(){ - UW::Light light(glm::vec3(0, 1000, 0), glm::vec3(1.0f, 1.0f,1.0f), 2.0f); +void Engine::Core::Resources::initLights(){ + Engine::Core::Light light(glm::vec3(0, 1000, 0), glm::vec3(1.0f, 1.0f,1.0f), 2.0f); lights.emplace_back({light}); lights.compile(); }; diff --git a/Engine/Resources/Resources.h b/Engine/Core/Core/Resources/Resources.h similarity index 86% rename from Engine/Resources/Resources.h rename to Engine/Core/Core/Resources/Resources.h index 35b0f79..926f08c 100644 --- a/Engine/Resources/Resources.h +++ b/Engine/Core/Core/Resources/Resources.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -18,15 +18,15 @@ #include #include "Utils/utils.h" -#include "config.h" +#include "Utils/config.h" #include "Lights/Lights.h" #include "Materials/Materials.h" -#include "Resources/Meshes/Meshes.h" #include "ScriptController/ScriptController.h" +#include "Utils/Resource/ResourceController.h" -namespace UW{ +namespace Engine::Core{ class Resources{ public: std::unordered_map scripts_last_time_write; @@ -41,9 +41,9 @@ class Resources{ std::unordered_map textures; std::unordered_map shaders; - UW::Meshes meshes; - UW::Lights lights; - UW::Materials materials; + Engine::Utils::ResourceController meshes; + Engine::Core::Lights lights; + Engine::Core::Materials materials; bool simulation_mode = true; public: diff --git a/Engine/Core/Core/Scene.cpp b/Engine/Core/Core/Scene.cpp new file mode 100644 index 0000000..3ffb2c5 --- /dev/null +++ b/Engine/Core/Core/Scene.cpp @@ -0,0 +1,319 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "Scene.h" + + + +Engine::Core::Scene::Scene(CW::Renderer::Renderer& window) + : window(window), camera_controller(&window), light_camera(&window), fbo(1920, 1080), post_fbo(1920, 1080), shadows_fbo(1920 * 5, 1080 * 5), screen_quad("screen_quad", &Engine::Core::Resources::get().meshes) +#ifndef PRODUCTION + , debug_camera(&window) +#endif +{ + Engine::Utils::Logger::get().info("Scene", "Scene Initialized"); +}; + + + +Engine::Core::Scene::~Scene(){ + Engine::Utils::Logger::get().info("Scene", "Scene Destroyed"); +}; + + + +void Engine::Core::Scene::onLoad(){ + Engine::Utils::Logger::get().info("Scene", "Loading Scene"); + + Engine::Utils::Logger::get().info("Scene", "Data Loaded from DataSerializer"); + + + post_uniform["u_water_height"]->set(Engine::Config::WATER_HEIGHT); + post_uniform["u_Near"]->set(Engine::Config::CAMERA_NEAR_PLANE); + post_uniform["u_Far"]->set(Engine::Config::CAMERA_ORTHO_FAR_PLANE); + post_uniform["u_FogDensity"]->set(Engine::Config::FOG_DENSITY); + post_uniform["u_FogColor"]->set(Engine::Config::FOG_COLOR); + Engine::Utils::Logger::get().info("Scene", "PostProcessing Uniforms Initialized"); + + + light_camera.setCameraMode(Engine::ScriptShared::CameraMode::PERSPECTIVE); + light_camera.setFov(110.0f); + last_light_camera_fov = light_camera.getFov(); + light_camera.setPosition(Engine::Core::Resources::get().lights[0].position); + last_light_camera_pos = light_camera.getPosition(); + light_camera.setDirection(glm::normalize(-Engine::Core::Resources::get().lights[0].position)); + last_light_camera_dir = light_camera.getDirection(); + light_space_matrix = light_camera.transformation(); + + shadows_uniform_off["u_ShadowEnabled"]->set(0); + shadows_uniform_off["u_ShadowDepthTexture"]->set(16); + shadows_uniform_off["u_LightSpaceMatrix"]->set(light_space_matrix); + shadows_uniform_on["u_ShadowEnabled"]->set(1); + shadows_uniform_on["u_ShadowDepthTexture"]->set(16); + shadows_uniform_on["u_LightSpaceMatrix"]->set(light_space_matrix); + Engine::Utils::Logger::get().info("Scene", "Shadows Camera and Uniform Initialized"); + + + camera_controller.spawnCamera( + "Main", + {174.780f, 26.939f, -80.027f}, + {-0.847f, -0.466f, -0.256f} + ); + camera_controller.setActiveCamera("Main"); + + Engine::Utils::Logger::get().info("Scene", "Main Camera Initialized"); + + +#ifndef PRODUCTION + debug_camera.setPosition({453.198f, 250.233f, -26.842f}); + debug_camera.setDirection({-0.668f, -0.734f, -0.122f}); + debug_camera.setDefaultMovement(true); + Engine::Utils::Logger::get().info("Scene", "Debug Camera Initialized"); +#endif + + + compileShadows(); + Engine::Utils::Logger::get().info("Scene", "Shadows Compiled"); +}; + + + +void Engine::Core::Scene::onUpdate(float delta_time){ + camera_controller.getActiveCamera().event(delta_time); + + unsigned int size = Engine::ObjectManager::get().objects.size(); + for(int i = 0; i < size; i++){ + Engine::ObjectManager::get().objects[i].onUpdate(delta_time); + if(size > Engine::ObjectManager::get().objects.size()){ + size = Engine::ObjectManager::get().objects.size(); + i--; + if(size == 0) break; + }; + }; + + size = Engine::ObjectManager::get().script_objects.size(); + for(int i = 0; i < size; i++){ + Engine::ObjectManager::get().script_objects[i].onUpdate(delta_time); + if(size > Engine::ObjectManager::get().script_objects.size()){ + size = Engine::ObjectManager::get().script_objects.size(); + i--; + if(size == 0) break; + }; + }; +}; + + + +void Engine::Core::Scene::onFixedUpdate(float fixed_delta_time){ +#ifndef PRODUCTION + save_acc += fixed_delta_time; + + if(save_acc >= Engine::Config::SAVE_TIMESTAMP){ + save_acc -= Engine::Config::SAVE_TIMESTAMP; + DataSerializer::get().saveAll(); + Engine::Utils::Logger::get().info("Scene", "Auto-Save scene data"); + }; +#endif + + unsigned int size = Engine::ObjectManager::get().objects.size(); + for(int i = 0; i < size; i++){ + Engine::ObjectManager::get().objects[i].onFixedUpdate(fixed_delta_time, (*this)); + if(size > Engine::ObjectManager::get().objects.size()){ + size = Engine::ObjectManager::get().objects.size(); + i--; + if(size == 0) break; + }; + }; + + size = Engine::ObjectManager::get().script_objects.size(); + for(int i = 0; i < size; i++){ + Engine::ObjectManager::get().script_objects[i].onFixedUpdate(fixed_delta_time, (*this)); + if(size > Engine::ObjectManager::get().script_objects.size()){ + size = Engine::ObjectManager::get().script_objects.size(); + i--; + if(size == 0) break; + }; + }; +}; + + + +void Engine::Core::Scene::onDestroy() { + Engine::Utils::Logger::get().info("Scene", "Destroying Scene"); + + unsigned int size = Engine::ObjectManager::get().objects.size(); + for(int i = 0; i < size; i++){ + Engine::ObjectManager::get().objects[i].onDestroy(); + if(size > Engine::ObjectManager::get().objects.size()){ + size = Engine::ObjectManager::get().objects.size(); + i--; + if(size == 0) break; + }; + }; + + size = Engine::ObjectManager::get().script_objects.size(); + for(int i = 0; i < size; i++){ + Engine::ObjectManager::get().script_objects[i].onDestroy(); + if(size > Engine::ObjectManager::get().script_objects.size()){ + size = Engine::ObjectManager::get().script_objects.size(); + i--; + if(size == 0) break; + }; + }; + + Engine::Utils::Logger::get().info("Scene", "Objects onDestroy"); + + Engine::ObjectManager::get().objects.clear(); + Engine::ObjectManager::get().script_objects.clear(); + Engine::Utils::Logger::get().info("Scene", "Objects Removed"); + + Engine::Utils::Logger::get().info("Scene", "Destroyed Scene"); +}; + + + +void Engine::Core::Scene::compileShadows(){ + shadows_fbo.bind(); + + if(last_light_camera_pos != light_camera.getPosition()){ + light_camera.setFov(110.0f); + last_light_camera_fov = light_camera.getFov(); + + light_camera.setPosition(Engine::Core::Resources::get().lights[0].position); + last_light_camera_pos = light_camera.getPosition(); + + light_camera.setDirection(glm::normalize(-Engine::Core::Resources::get().lights[0].position)); + last_light_camera_dir = light_camera.getDirection(); + + light_space_matrix = light_camera.transformation(); + shadows_uniform_off["u_LightSpaceMatrix"]->set(light_space_matrix); + shadows_uniform_on["u_LightSpaceMatrix"]->set(light_space_matrix); + }; + + window.beginFrame(); + + for(Engine::Core::GameObject& object : Engine::ObjectManager::get().objects) object.render(&window, light_camera, light_camera, shadows_uniform_off); + for(Engine::Core::GameObject& object : Engine::ObjectManager::get().script_objects) object.render(&window, light_camera, light_camera, shadows_uniform_off); + + shadows_fbo.unbind(); +}; + + + +void Engine::Core::Scene::render(){ + Engine::Core::Resources::get().lights.bind(0); + Engine::Core::Resources::get().materials.bind(1); + + +#ifndef PRODUCTION + if(!shadows_on){ + shadows_fbo.bind(); + window.beginFrame(); + shadows_fbo.unbind(); + } + else +#endif + compileShadows(); + + + fbo.bind(); + +#ifndef PRODUCTION + if(debug_camera_on) + renderFrame(debug_camera); + else +#endif + renderFrame(this->camera_controller.getActiveCamera()); + + fbo.unbind(); + + + Engine::Core::Resources::get().materials.unbind(); + Engine::Core::Resources::get().lights.unbind(); + + + window.beginFrame(); + + + // fbo.blitToScreen(window.getWindowData()->width, window.getWindowData()->height); + // else + // #endif + +#ifndef PRODUCTION + if(post_processing_on) +#endif + postProcessing(); +}; + + + +void Engine::Core::Scene::renderFrame(Engine::ScriptShared::ICamera& camera){ + window.beginFrame(); + + glActiveTexture(GL_TEXTURE16); + glBindTexture(GL_TEXTURE_2D, shadows_fbo.getDepthTexture()); + + for(Engine::Core::GameObject& object : Engine::ObjectManager::get().script_objects) object.render(&window, this->camera_controller.getActiveCamera(), camera, shadows_uniform_on); + for(Engine::Core::GameObject& object : Engine::ObjectManager::get().objects) object.render(&window, this->camera_controller.getActiveCamera(), camera, shadows_uniform_on); + + + glActiveTexture(GL_TEXTURE16); + glBindTexture(GL_TEXTURE_2D, 0); +}; + + + +void Engine::Core::Scene::postProcessing(){ + CW::Renderer::Mesh* screen_mesh = screen_quad.get(); + if(!screen_mesh) return; + + post_fbo.bind(); + + window.beginFrame(); + + glDisable(GL_DEPTH_TEST); + + std::string shader_name = "PostProcessing"; + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, fbo.getColorTexture()); + post_uniform["u_SceneColorTexture"]->set(0); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, fbo.getDepthTexture()); + post_uniform["u_SceneDepthTexture"]->set(1); + +#ifndef PRODUCTION + if(debug_camera_on){ + glm::mat4 invViewProj = glm::inverse(debug_camera.projection() * debug_camera.view()); + post_uniform["u_InvViewProj"]->set(invViewProj); + post_uniform["u_CamPos"]->set(debug_camera.getPosition()); + } + else{ +#endif + glm::mat4 invViewProj = glm::inverse(camera_controller.getActiveCamera().projection() * camera_controller.getActiveCamera().view()); + post_uniform["u_InvViewProj"]->set(invViewProj); + post_uniform["u_CamPos"]->set(camera_controller.getActiveCamera().getPosition()); +#ifndef PRODUCTION + } +#endif + + Engine::Core::Resources::get().getShader(shader_name).getUniforms().emplace_back(&post_uniform); + Engine::Core::Resources::get().getShader(shader_name).bind(); + + screen_mesh->render(); + + Engine::Core::Resources::get().getShader(shader_name).unbind(); + Engine::Core::Resources::get().getShader(shader_name).getUniforms().clear(); + + glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); + + glEnable(GL_DEPTH_TEST); + + post_fbo.unbind(); +}; diff --git a/Engine/Scene.h b/Engine/Core/Core/Scene.h similarity index 58% rename from Engine/Scene.h rename to Engine/Core/Core/Scene.h index fae1c40..27e7da7 100644 --- a/Engine/Scene.h +++ b/Engine/Core/Core/Scene.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -10,44 +10,44 @@ #include -#include "Camera/Camera.h" +#include "Camera/CameraController.h" #include "Objects/Object.h" #include "Objects/GameObject.h" #include "Objects/ObjectManager.h" #include "DataSerializer/DataSerializer.h" +#include "Utils/Resource/Resource.h" -#include "Objects/Terrain/Terrain.h" -#include "Objects/Water/Water.h" -#include "Objects/Skybox/Skybox.h" -#include "Objects/Meduse/Meduse.h" - -namespace UW{ +namespace Engine::Core{ class Scene{ +public: + CW::Renderer::Framebuffer post_fbo; + CW::Renderer::Framebuffer fbo; + Engine::Core::CameraController camera_controller; + #ifndef PRODUCTION public: #else private: #endif CW::Renderer::Renderer& window; - CW::Renderer::Framebuffer fbo; CW::Renderer::Framebuffer shadows_fbo; - UW::Camera camera; #ifndef PRODUCTION - UW::Camera debug_camera; - bool debug_camera_on = UW::Config::DEFAULT_DEBUG_CAMERA_ON; - bool post_processing_on = UW::Config::DEFAULT_POST_PROCESSING_ON; - bool shadows_on = UW::Config::DEFAULT_SHADOWS_ON; + Engine::Core::Camera debug_camera; + bool debug_camera_on = Engine::Config::DEFAULT_DEBUG_CAMERA_ON; + bool shadows_on = Engine::Config::DEFAULT_SHADOWS_ON; float save_acc = 0.0f; - #endif - - bool water_on = false; - bool terrain_on = true; + +public: + bool post_processing_on = Engine::Config::DEFAULT_POST_PROCESSING_ON; + +private: +#endif - UW::Camera light_camera; + Engine::Core::Camera light_camera; CW::Renderer::Uniform shadows_uniform_on; CW::Renderer::Uniform shadows_uniform_off; glm::mat4 light_space_matrix; @@ -55,15 +55,9 @@ class Scene{ glm::vec3 last_light_camera_dir = glm::vec3(0.0f); float last_light_camera_fov = 1.0f; - unsigned int screen_quad_mesh_id = 0; - unsigned int meshes_version = -1; + Engine::Utils::Resource screen_quad; CW::Renderer::Uniform post_uniform; - UW::Terrain terrain; - UW::Water water; - UW::Skybox skybox; - std::vector meduses; - public: Scene(CW::Renderer::Renderer& window); ~Scene(); @@ -77,8 +71,7 @@ class Scene{ private: void postProcessing(); void compileShadows(); - void renderFrame(UW::Camera& camera); - void renderSFD(UW::Camera& camera); + void renderFrame(Engine::ScriptShared::ICamera& camera); }; }; diff --git a/Engine/ScriptController/ScriptController.cpp b/Engine/Core/Core/ScriptController/ScriptController.cpp similarity index 52% rename from Engine/ScriptController/ScriptController.cpp rename to Engine/Core/Core/ScriptController/ScriptController.cpp index ff07734..74e5eaf 100644 --- a/Engine/ScriptController/ScriptController.cpp +++ b/Engine/Core/Core/ScriptController/ScriptController.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -16,68 +16,72 @@ CMRC_DECLARE(ScriptShared); -void UW::GameObjectScriptRecord::initSharedFolder() { -#ifndef PRODUCTION - auto efs = cmrc::ScriptShared::get_filesystem(); - std::filesystem::path dest_folder = UW::Config::SCRIPTS_SRC_FOLDER; +void Engine::Core::Script::GameObjectScriptRecord::initSharedFolder() { +// #ifndef PRODUCTION +// auto efs = cmrc::ScriptShared::get_filesystem(); +// std::filesystem::path dest_folder = Engine::Config::SCRIPTS_SRC_FOLDER; - auto extract_dir = [&](auto& self, const std::string& virtual_path, const std::filesystem::path& physical_path) -> void { - if (!std::filesystem::exists(physical_path)) std::filesystem::create_directories(physical_path); +// auto extract_dir = [&](auto& self, const std::string& virtual_path, const std::filesystem::path& physical_path) -> void { +// if (!std::filesystem::exists(physical_path)) std::filesystem::create_directories(physical_path); - for (auto&& entry : efs.iterate_directory(virtual_path)) { - std::string current_v_path = virtual_path.empty() ? entry.filename() : virtual_path + "/" + entry.filename(); - std::filesystem::path current_p_path = physical_path / entry.filename(); - if(std::filesystem::exists(current_p_path)) continue; +// for (auto&& entry : efs.iterate_directory(virtual_path)) { +// std::string current_v_path = virtual_path.empty() ? entry.filename() : virtual_path + "/" + entry.filename(); +// std::filesystem::path current_p_path = physical_path / entry.filename(); +// if(std::filesystem::exists(current_p_path)) continue; - if (entry.is_directory()) self(self, current_v_path, current_p_path); - else if (entry.is_file()) { - auto file = efs.open(current_v_path); - bool should_write = true; +// if (entry.is_directory()) self(self, current_v_path, current_p_path); +// else if (entry.is_file()) { +// auto file = efs.open(current_v_path); +// bool should_write = true; - if (std::filesystem::exists(current_p_path) && std::filesystem::file_size(current_p_path) == file.size()) should_write = false; +// if (std::filesystem::exists(current_p_path) && std::filesystem::file_size(current_p_path) == file.size()) should_write = false; - if (should_write) { - std::ofstream out(current_p_path, std::ios::binary); - if (out) out.write(file.begin(), file.size()); - else UW::Logger::get().erro("Script Controller", "Failed to write extracted file: " + current_p_path.string()); - }; - }; - }; - }; +// if (should_write) { +// std::ofstream out(current_p_path, std::ios::binary); +// if (out) out.write(file.begin(), file.size()); +// else Engine::Utils::Logger::get().erro("Script Controller", "Failed to write extracted file: " + current_p_path.string()); +// }; +// }; +// }; +// }; - extract_dir(extract_dir, "", dest_folder); - UW::Logger::get().info("Script Controller", "Shared folder successfully initialized from cmrc."); -#else - UW::Logger::get().info("Script Controller", "In PRODUCTION mode: cmrc extraction skipped."); -#endif +// extract_dir(extract_dir, "", dest_folder); +// Engine::Utils::Logger::get().info("Script Controller", "Shared folder successfully initialized from cmrc."); +// #else +// Engine::Utils::Logger::get().info("Script Controller", "In PRODUCTION mode: cmrc extraction skipped."); +// #endif }; -UW::GameObjectScriptRecord::GameObjectScriptRecord(const std::string &path) +Engine::Core::Script::GameObjectScriptRecord::GameObjectScriptRecord(const std::string &path) : path(path), - cpp_file(UW::Config::SCRIPTS_SRC_FOLDER + path + ".cpp"), + cpp_file(Engine::Config::SCRIPTS_SRC_FOLDER + path + ".cpp"), #if defined(_WIN32) || defined(_WIN64) - so_file(UW::Config::SCRIPTS_DLL_FOLDER + path + ".dll") + so_file(Engine::Config::TEMP_BIN_FOLDER + Engine::Config::SCRIPTS_DLL_FOLDER + path + ".dll") #else - so_file(UW::Config::SCRIPTS_DLL_FOLDER + path + ".so") + so_file(Engine::Config::TEMP_BIN_FOLDER + Engine::Config::SCRIPTS_DLL_FOLDER + path + ".so") #endif { - UW::Logger::get().info("Script Controller", "Script Initialized"); - initSharedFolder(); + Engine::Utils::Logger::get().info("Script Controller", "Script Initialized"); + +#ifndef PRODUCTION + if(!std::filesystem::exists(Engine::Config::TEMP_BIN_FOLDER)) std::filesystem::create_directories(Engine::Config::TEMP_BIN_FOLDER); +#endif + // initSharedFolder(); }; -UW::GameObjectScriptRecord::~GameObjectScriptRecord(){ - UW::Logger::get().info("Script Controller", "Script Destroying"); +Engine::Core::Script::GameObjectScriptRecord::~GameObjectScriptRecord(){ + Engine::Utils::Logger::get().info("Script Controller", "Script Destroying"); removeModule(); - UW::Logger::get().info("Script Controller", "Script Destroyed"); + Engine::Utils::Logger::get().info("Script Controller", "Script Destroyed"); }; -UW::GameObjectScriptRecord::GameObjectScriptRecord(const GameObjectScriptRecord& other) +Engine::Core::Script::GameObjectScriptRecord::GameObjectScriptRecord(const GameObjectScriptRecord& other) : path(other.path), cpp_file(other.cpp_file), so_file(other.so_file), log_observe_lock(other.log_observe_lock) { script_handler = nullptr; script = nullptr; @@ -86,7 +90,7 @@ UW::GameObjectScriptRecord::GameObjectScriptRecord(const GameObjectScriptRecord& -UW::GameObjectScriptRecord& UW::GameObjectScriptRecord::operator=(const GameObjectScriptRecord& other) { +Engine::Core::Script::GameObjectScriptRecord& Engine::Core::Script::GameObjectScriptRecord::operator=(const GameObjectScriptRecord& other) { if (this != &other) { removeModule(); path = other.path; @@ -102,7 +106,7 @@ UW::GameObjectScriptRecord& UW::GameObjectScriptRecord::operator=(const GameObje -UW::GameObjectScriptRecord::GameObjectScriptRecord(GameObjectScriptRecord&& other) noexcept +Engine::Core::Script::GameObjectScriptRecord::GameObjectScriptRecord(GameObjectScriptRecord&& other) noexcept : path(std::move(other.path)), cpp_file(std::move(other.cpp_file)), so_file(std::move(other.so_file)), log_observe_lock(other.log_observe_lock), script_handler(other.script_handler), script(other.script) { @@ -113,7 +117,7 @@ UW::GameObjectScriptRecord::GameObjectScriptRecord(GameObjectScriptRecord&& othe -UW::GameObjectScriptRecord& UW::GameObjectScriptRecord::operator=(GameObjectScriptRecord&& other) noexcept { +Engine::Core::Script::GameObjectScriptRecord& Engine::Core::Script::GameObjectScriptRecord::operator=(GameObjectScriptRecord&& other) noexcept { if (this != &other) { removeModule(); path = std::move(other.path); @@ -132,36 +136,37 @@ UW::GameObjectScriptRecord& UW::GameObjectScriptRecord::operator=(GameObjectScri -void UW::GameObjectScriptRecord::syncPointer(GameObjectData* data) { +void Engine::Core::Script::GameObjectScriptRecord::syncPointer(Engine::ScriptShared::GameObjectData* data) { if (script) script->game_object_data = data; }; -void UW::GameObjectScriptRecord::observe(GameObjectData *data){ +void Engine::Core::Script::GameObjectScriptRecord::observe(Engine::ScriptShared::GameObjectData *data, Engine::Core::Scene& scene){ #ifndef PRODUCTION if(compiling) { checkLastWrite(); - updateScript(data); + updateScript(data, scene); return; }; - if(checkLastWrite()) updateScript(data); + if(checkLastWrite()) updateScript(data, scene); #else if(!module_initialized) if(!loadModule()) - onLoad(data); + onLoad(data, scene); #endif }; -void UW::GameObjectScriptRecord::onLoad(GameObjectData* data) { +void Engine::Core::Script::GameObjectScriptRecord::onLoad(Engine::ScriptShared::GameObjectData* data, Engine::Core::Scene& scene) { if(script){ script->game_object_data = data; - script->glob_res = &UW::GlobResource::get(); - script->logger = static_cast(&UW::Logger::get()); - script->object_manager = static_cast(&UW::ObjectManager::get()); + script->glob_res = &Engine::ScriptShared::GlobResource::get(); + script->logger = static_cast(&Engine::Utils::Logger::get()); + script->object_manager = static_cast(&Engine::ObjectManager::get()); + script->camera_controller = static_cast(&scene.camera_controller); #ifndef PRODUCTION #ifdef SANDBOX_SCRIPTS @@ -177,7 +182,7 @@ void UW::GameObjectScriptRecord::onLoad(GameObjectData* data) { waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - UW::Logger::get().erro("Script Controller", std::to_string(status) + " - Init failed!"); + Engine::Utils::Logger::get().erro("Script Controller", std::to_string(status) + " - Init failed!"); return; }; }; @@ -191,7 +196,7 @@ void UW::GameObjectScriptRecord::onLoad(GameObjectData* data) { -void UW::GameObjectScriptRecord::onUpdate(float delta_time) { +void Engine::Core::Script::GameObjectScriptRecord::onUpdate(float delta_time) { if(!script_on) return; if(script){ @@ -210,7 +215,7 @@ void UW::GameObjectScriptRecord::onUpdate(float delta_time) { waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - UW::Logger::get().erro("Script Controller", std::to_string(status) + " - Update failed!"); + Engine::Utils::Logger::get().erro("Script Controller", std::to_string(status) + " - Update failed!"); return; }; }; @@ -224,7 +229,7 @@ void UW::GameObjectScriptRecord::onUpdate(float delta_time) { -void UW::GameObjectScriptRecord::onFixedUpdate(float fixed_delta_time) { +void Engine::Core::Script::GameObjectScriptRecord::onFixedUpdate(float fixed_delta_time) { if(!script_on) return; if(script){ @@ -243,7 +248,7 @@ void UW::GameObjectScriptRecord::onFixedUpdate(float fixed_delta_time) { waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - UW::Logger::get().erro("Script Controller", std::to_string(status) + " - FixedUpdate failed!"); + Engine::Utils::Logger::get().erro("Script Controller", std::to_string(status) + " - FixedUpdate failed!"); return; }; }; @@ -257,7 +262,7 @@ void UW::GameObjectScriptRecord::onFixedUpdate(float fixed_delta_time) { -void UW::GameObjectScriptRecord::onRender() { +void Engine::Core::Script::GameObjectScriptRecord::onRender() { if(!script_on) return; if(script){ @@ -276,7 +281,7 @@ void UW::GameObjectScriptRecord::onRender() { waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - UW::Logger::get().erro("Script Controller", std::to_string(status) + " - Render failed!"); + Engine::Utils::Logger::get().erro("Script Controller", std::to_string(status) + " - Render failed!"); return; }; }; @@ -290,7 +295,7 @@ void UW::GameObjectScriptRecord::onRender() { -void UW::GameObjectScriptRecord::onDestroy() { +void Engine::Core::Script::GameObjectScriptRecord::onDestroy() { if(script){ #ifndef PRODUCTION @@ -307,7 +312,7 @@ void UW::GameObjectScriptRecord::onDestroy() { waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - UW::Logger::get().erro("Script Controller", std::to_string(status) + " - Destroy failed!"); + Engine::Utils::Logger::get().erro("Script Controller", std::to_string(status) + " - Destroy failed!"); return; }; }; @@ -321,27 +326,27 @@ void UW::GameObjectScriptRecord::onDestroy() { -std::string UW::GameObjectScriptRecord::getPath() const { +std::string Engine::Core::Script::GameObjectScriptRecord::getPath() const { return path; }; -int UW::GameObjectScriptRecord::loadModule() { - UW::Logger::get().info("Script Controller", "Module loading"); +int Engine::Core::Script::GameObjectScriptRecord::loadModule() { + Engine::Utils::Logger::get().info("Script Controller", "Module loading"); removeModule(); #ifdef PRODUCTION - script = UW::ScriptRegistry::get().createScript(path); + script = Engine::ScriptShared::ScriptRegistry::get().createScript(path); if (!script) { - UW::Logger::get().erro("Script Controller", "Script not found in registry: " + path); + Engine::Utils::Logger::get().erro("Script Controller", "Script not found in registry: " + path); return -1; }; module_initialized = 1; - UW::Logger::get().info("Script Controller", "Module Loaded statically"); + Engine::Utils::Logger::get().info("Script Controller", "Module Loaded statically"); return 0; #else @@ -352,7 +357,7 @@ int UW::GameObjectScriptRecord::loadModule() { #if defined(_WIN32) || defined(_WIN64) script_handler = LoadLibraryA(so_file.c_str()); if (!script_handler) { - Logger::get().erro("Script Controller", "Failed to load DLL - Error Code: " + std::to_string(GetLastError())); + Engine::Utils::Logger::get().erro("Script Controller", "Failed to load DLL - Error Code: " + std::to_string(GetLastError())); return -1; } @@ -360,7 +365,7 @@ int UW::GameObjectScriptRecord::loadModule() { GetScriptFunc getScript = (GetScriptFunc)GetProcAddress((HMODULE)script_handler, "GetScript"); if (!getScript) { - Logger::get().erro("Script Controller", "Cannot load symbol 'GetScript' - Error Code: " + std::to_string(GetLastError())); + Engine::Utils::Logger::get().erro("Script Controller", "Cannot load symbol 'GetScript' - Error Code: " + std::to_string(GetLastError())); removeModule(); return -1; } @@ -368,18 +373,18 @@ int UW::GameObjectScriptRecord::loadModule() { script_handler = dlopen((so_file).c_str(), RTLD_NOW); if (!script_handler) { - Logger::get().erro("Script Controller", "Failed to load script - " + std::string(dlerror())); + Engine::Utils::Logger::get().erro("Script Controller", "Failed to load script - " + std::string(dlerror())); return -1; }; dlerror(); - typedef GameObjectScriptInterface* (*GetScriptFunc)(); + typedef Engine::ScriptShared::GameObjectScriptInterface* (*GetScriptFunc)(); GetScriptFunc getScript = (GetScriptFunc)dlsym(script_handler, "GetScript"); const char* dlsym_error = dlerror(); if (dlsym_error || !getScript) { - Logger::get().erro("Script Controller", "Cannot load symbol 'GetScript' - " + std::string(dlsym_error)); + Engine::Utils::Logger::get().erro("Script Controller", "Cannot load symbol 'GetScript' - " + std::string(dlsym_error)); removeModule(); return -1; }; @@ -389,20 +394,20 @@ int UW::GameObjectScriptRecord::loadModule() { if(!script){ removeModule(); - UW::Logger::get().erro("Script Controller", "Script load failed"); + Engine::Utils::Logger::get().erro("Script Controller", "Script load failed"); return -1; }; #endif - Logger::get().info("Script Controller", "Module Loaded"); + Engine::Utils::Logger::get().info("Script Controller", "Module Loaded"); return 0; }; -void UW::GameObjectScriptRecord::removeModule(){ - UW::Logger::get().info("Script Controller", "Module destroying"); +void Engine::Core::Script::GameObjectScriptRecord::removeModule(){ + Engine::Utils::Logger::get().info("Script Controller", "Module destroying"); #ifdef PRODUCTION if (script) { @@ -417,7 +422,7 @@ void UW::GameObjectScriptRecord::removeModule(){ if (!script_handler) { script = nullptr; - UW::Logger::get().info("Script Controller", "Module doesn't exists"); + Engine::Utils::Logger::get().info("Script Controller", "Module doesn't exists"); return; }; @@ -430,7 +435,7 @@ void UW::GameObjectScriptRecord::removeModule(){ DeleteScriptFunc deleteScript = (DeleteScriptFunc)GetProcAddress((HMODULE)script_handler, "DeleteScript"); if (!deleteScript) { - Logger::get().warn("Script Controller", "DeleteScript not found or invalid"); + Engine::Utils::Logger::get().warn("Script Controller", "DeleteScript not found or invalid"); script = nullptr; } else { deleteScript(script); @@ -438,12 +443,12 @@ void UW::GameObjectScriptRecord::removeModule(){ } #else dlerror(); - using DeleteScriptFunc = void (*)(GameObjectScriptInterface*); + using DeleteScriptFunc = void (*)(Engine::ScriptShared::GameObjectScriptInterface*); DeleteScriptFunc deleteScript = (DeleteScriptFunc)dlsym(script_handler, "DeleteScript"); const char* dlsym_error = dlerror(); if (dlsym_error || !deleteScript) { - Logger::get().warn("Script Controller", "DeleteScript not found or invalid - " + std::string(dlsym_error ? dlsym_error : "null")); + Engine::Utils::Logger::get().warn("Script Controller", "DeleteScript not found or invalid - " + std::string(dlsym_error ? dlsym_error : "null")); script = nullptr; } else{ @@ -464,19 +469,19 @@ void UW::GameObjectScriptRecord::removeModule(){ #endif - UW::Logger::get().info("Script Controller", "Module destroyed"); + Engine::Utils::Logger::get().info("Script Controller", "Module destroyed"); }; -bool UW::GameObjectScriptRecord::checkLastWrite(){ +bool Engine::Core::Script::GameObjectScriptRecord::checkLastWrite(){ #ifndef PRODUCTION bool file_exist = std::filesystem::exists(cpp_file); bool changed = 0; if(log_observe_lock && !file_exist){ - UW::Logger::get().erro("Script Controller", "No file named: " + cpp_file); + Engine::Utils::Logger::get().erro("Script Controller", "No file named: " + cpp_file); log_observe_lock = 0; }; @@ -488,14 +493,14 @@ bool UW::GameObjectScriptRecord::checkLastWrite(){ try{ currentWriteTime = std::filesystem::last_write_time(cpp_file); } catch(const std::filesystem::filesystem_error& e){ - UW::Logger::get().erro("Script Controller", "Filesystem error - " + std::string(e.what())); + Engine::Utils::Logger::get().erro("Script Controller", "Filesystem error - " + std::string(e.what())); return false; }; if(currentWriteTime != lastWriteTime){ changed = 1; lastWriteTime = currentWriteTime; - Logger::get().info("Script Controller", "Script changed lastWriteTime != currentWriteTime"); + Engine::Utils::Logger::get().info("Script Controller", "Script changed lastWriteTime != currentWriteTime"); }; return changed; @@ -507,18 +512,18 @@ bool UW::GameObjectScriptRecord::checkLastWrite(){ -void UW::GameObjectScriptRecord::updateScript(GameObjectData* data) { +void Engine::Core::Script::GameObjectScriptRecord::updateScript(Engine::ScriptShared::GameObjectData* data, Engine::Core::Scene& scene) { #ifndef PRODUCTION - UW::Logger::get().info("Script Controller", "Script is Updating..."); + Engine::Utils::Logger::get().info("Script Controller", "Script is Updating..."); removeModule(); int compile_state = compile(); if(compile_state == 0) { if(!loadModule()) - onLoad(data); + onLoad(data, scene); else{ - UW::Logger::get().info("Script Controller", "loadModule failed"); + Engine::Utils::Logger::get().info("Script Controller", "loadModule failed"); return; }; @@ -528,19 +533,19 @@ void UW::GameObjectScriptRecord::updateScript(GameObjectData* data) { compiling = 1; } else{ - UW::Logger::get().info("Script Controller", "compilation failed"); + Engine::Utils::Logger::get().info("Script Controller", "compilation failed"); return; }; - UW::Logger::get().info("Script Controller", "Script Updated"); + Engine::Utils::Logger::get().info("Script Controller", "Script Updated"); #endif }; -int UW::GameObjectScriptRecord::compile() { +int Engine::Core::Script::GameObjectScriptRecord::compile() { #ifndef PRODUCTION - auto& resources = Resources::get(); + auto& resources = Engine::Core::Resources::get(); { std::lock_guard lock(resources.compiler_mutex); @@ -558,26 +563,26 @@ int UW::GameObjectScriptRecord::compile() { if (is_up_to_date) { if (is_compiling) { - Logger::get().info("Script Controller", "Compilation Exist Check: Still working in background..."); + Engine::Utils::Logger::get().info("Script Controller", "Compilation Exist Check: Still working in background..."); return 1; } else { - Logger::get().info("Script Controller", "Compilation Exist Check: Up to date, skipping."); + Engine::Utils::Logger::get().info("Script Controller", "Compilation Exist Check: Up to date, skipping."); return 0; }; } else { if (is_compiling) { - Logger::get().info("Script Controller", "Compilation Reload: New changes saved while compiling! Waiting for current pass..."); + Engine::Utils::Logger::get().info("Script Controller", "Compilation Reload: New changes saved while compiling! Waiting for current pass..."); return 1; } else { - Logger::get().info("Script Controller", "Compilation Start: Kicking off new compilation thread."); + Engine::Utils::Logger::get().info("Script Controller", "Compilation Start: Kicking off new compilation thread."); resources.script_active_compilers[path] = std::jthread([this]() { int status = compile_thread(); - auto& res = Resources::get(); + auto& res = Engine::Core::Resources::get(); if (status == 0) { std::lock_guard lock(res.compiler_mutex); res.scripts_last_time_write[this->path] = this->lastWriteTime; @@ -595,7 +600,8 @@ int UW::GameObjectScriptRecord::compile() { -int UW::GameObjectScriptRecord::compile_thread(){ +int Engine::Core::Script::GameObjectScriptRecord::compile_thread(){ +#ifndef PRODUCTION std::filesystem::path p(so_file); std::filesystem::path dir = p.parent_path(); @@ -612,9 +618,9 @@ int UW::GameObjectScriptRecord::compile_thread(){ PROCESS_INFORMATION pi = { 0 }; std::string cmd = compiler.string() + " -shared -o \"" + temp_so.string() + "\" \"" + cpp.string() + "\""; - Logger::get().warn("Script Controller", "Compile command: " + cmd); + Engine::Utils::Logger::get().warn("Script Controller", "Compile command: " + cmd); - UW::Logger::get().info("Script Controller", "Compiling on Windows: " + cmd); + Engine::Utils::Logger::get().info("Script Controller", "Compiling on Windows: " + cmd); char* cmd_buffer = _strdup(cmd.c_str()); @@ -638,11 +644,13 @@ int UW::GameObjectScriptRecord::compile_thread(){ return -1; #else + std::string engine_include_dir = ENGINE_SRC_DEST; const char* command = compiler.c_str(); const char* argv[] = { compiler.c_str(), "-rdynamic", "-shared", + "-I", engine_include_dir.c_str(), "-fPIC", "-o", so.c_str(), cpp.c_str(), @@ -652,7 +660,7 @@ int UW::GameObjectScriptRecord::compile_thread(){ pid_t pid = fork(); if(pid == 0){ execvp(command, const_cast(argv)); - Logger::get().erro("Script Controller", "Failed to exec g++"); + Engine::Utils::Logger::get().erro("Script Controller", "Failed to exec g++"); exit(-1); } else if(pid > 0){ @@ -661,16 +669,17 @@ int UW::GameObjectScriptRecord::compile_thread(){ waitpid(pid, &status, 0); if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { - UW::Logger::get().info("Script Controller", "successful compilation"); + Engine::Utils::Logger::get().info("Script Controller", "successful compilation"); return 0; } else { - UW::Logger::get().erro("Script Controller", "Compilation failed!"); + Engine::Utils::Logger::get().erro("Script Controller", "Compilation failed!"); return -1; }; }; - UW::Logger::get().erro("Script Controller", "Failed to fork()"); + Engine::Utils::Logger::get().erro("Script Controller", "Failed to fork()"); return -1; #endif +#endif }; diff --git a/Engine/ScriptController/ScriptController.h b/Engine/Core/Core/ScriptController/ScriptController.h similarity index 73% rename from Engine/ScriptController/ScriptController.h rename to Engine/Core/Core/ScriptController/ScriptController.h index 6b8d26b..9dec596 100644 --- a/Engine/ScriptController/ScriptController.h +++ b/Engine/Core/Core/ScriptController/ScriptController.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -24,17 +24,20 @@ #include #include "ScriptShared/GameObjectScriptInterface.h" + +#include "Scene.h" #include "Utils/Logger.h" #include "Objects/ObjectManager.h" -#include "config.h" - +#include "Utils/config.h" -namespace UW{ -class GameObjectData; +namespace Engine{ + class GameObjectData; +}; +namespace Engine::Core::Script{ class GameObjectScriptRecord{ std::filesystem::file_time_type lastWriteTime{}; std::string path = ""; @@ -50,7 +53,7 @@ class GameObjectScriptRecord{ void* script_handler = nullptr; public: - GameObjectScriptInterface* script = nullptr; + Engine::ScriptShared::GameObjectScriptInterface* script = nullptr; bool script_on = true; public: @@ -61,11 +64,11 @@ class GameObjectScriptRecord{ GameObjectScriptRecord& operator=(const GameObjectScriptRecord& other); GameObjectScriptRecord(GameObjectScriptRecord&& other) noexcept; GameObjectScriptRecord& operator=(GameObjectScriptRecord&& other) noexcept; - void syncPointer(GameObjectData* data); + void syncPointer(Engine::ScriptShared::GameObjectData* data); - void observe(GameObjectData* data); + void observe(Engine::ScriptShared::GameObjectData* data, Engine::Core::Scene& scene); - void onLoad(GameObjectData* data); + void onLoad(Engine::ScriptShared::GameObjectData* data, Engine::Core::Scene& scene); void onUpdate(float delta_time); void onFixedUpdate(float fixed_delta_time); void onRender(); @@ -79,7 +82,7 @@ class GameObjectScriptRecord{ private: void initSharedFolder(); bool checkLastWrite(); - void updateScript(GameObjectData* data); + void updateScript(Engine::ScriptShared::GameObjectData* data, Engine::Core::Scene& scene); int compile(); int compile_thread(); diff --git a/Engine/DataSerializer/DataSerializer.cpp b/Engine/DataSerializer/DataSerializer.cpp deleted file mode 100644 index e52bc65..0000000 --- a/Engine/DataSerializer/DataSerializer.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "DataSerializer.h" - -#ifdef PRODUCTION -#include -CMRC_DECLARE(GameData); -#endif - -#include "Resources/Resources.h" - - - -UW::DataSerializer &UW::DataSerializer::get(){ - static DataSerializer instance; - return instance; -}; - - - -UW::DataSerializer::DataSerializer() - : mesh_serializer(std::make_unique()), - objects_serializer(std::make_unique()){}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveAllGlobResources() { - glob_serializer.saveAll(); -}; -#endif - - - -void UW::DataSerializer::loadAllGlobResources() { - glob_serializer.loadAll(); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveAllObjects(std::vector& objects) { - objects_serializer->saveAll(objects); -}; -#endif - - - -void UW::DataSerializer::loadAllObjects(std::vector& objects) { - objects_serializer->loadAll(objects); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveAllMaterials(UW::Materials &materials) { - materials_serializer.saveAll(materials); -}; -#endif - - - -void UW::DataSerializer::loadAllMaterials(UW::Materials &materials) { - materials_serializer.loadAll(materials); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveAllLights(UW::Lights &lights) { - lights_serializer.saveAll(lights); -}; -#endif - - - -void UW::DataSerializer::loadAllLights(UW::Lights &lights) { - lights_serializer.loadAll(lights); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveMesh(const std::string &name, const CW::Renderer::Mesh &mesh) { - mesh_serializer->save(name, mesh); -}; -#endif - - - -void UW::DataSerializer::loadMesh(const std::string& path_to_mesh, UW::Meshes &meshes) { - mesh_serializer->load(path_to_mesh, meshes); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveAllMeshes(UW::Meshes &meshes) { - mesh_serializer->saveAll(meshes); -}; -#endif - - - -void UW::DataSerializer::loadAllMeshes(UW::Meshes &meshes) { - mesh_serializer->loadAll(meshes); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveShaders(const std::string &shader_name, GLuint type){ - shader_serializer.save(shader_name, type); -}; -#endif - - - -void UW::DataSerializer::loadShader(const std::string& shader_name){ - shader_serializer.load(shader_name); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveScript(const std::string &script_name, const std::string& source){ - script_serializer.save(script_name, source); -}; -#endif - - - -std::string UW::DataSerializer::loadScript(const std::string& script_name){ - #ifndef PRODUCTION - return script_serializer.load(script_name); - #endif -}; - - - -void UW::DataSerializer::loadAllTextures() { - Logger::get().info("DataSerializer", "Scanning and loading all textures..."); - - std::string root_path = UW::Config::GAME_DATA_FOLDER + UW::Config::ASSETS_FOLDER + UW::Config::TEXTURES_FOLDER; - - if (!root_path.empty() && root_path.back() == '/') root_path.pop_back(); - -#ifndef PRODUCTION - try { - if (std::filesystem::exists(root_path) && std::filesystem::is_directory(root_path)) { - for (const auto& entry : std::filesystem::directory_iterator(root_path)) { - if (entry.is_regular_file()) { - std::string file_name = entry.path().filename().string(); - - if (Resources::get().textures.find(file_name) != Resources::get().textures.end()) continue; - - std::ifstream file(entry.path(), std::ios::binary | std::ios::ate); - if (file.is_open()) { - std::streamsize size = file.tellg(); - file.seekg(0, std::ios::beg); - - std::vector buffer(size); - if (file.read(reinterpret_cast(buffer.data()), size)) { - CW::Renderer::TextureLoader loader(buffer.data(), size); - - auto it = Resources::get().textures.emplace(file_name, CW::Renderer::Texture()).first; - it->second.compile(loader.data); - - Logger::get().info("DataSerializer", "Loaded texture from Disk: " + file_name); - }; - }; - }; - }; - } else { - Logger::get().warn("DataSerializer", "Filesystem - Directory not found: " + root_path); - } - } catch (const std::filesystem::filesystem_error& e) { - Logger::get().warn("DataSerializer", "[Filesystem] Could not scan local textures folder: " + std::string(e.what())); - }; -#else - try { - auto fs = cmrc::GameData::get_filesystem(); - - if (fs.exists(root_path)) { - for (auto&& entry : fs.iterate_directory(root_path)) { - if (entry.is_file()) { - std::string file_name = entry.filename(); - - if (Resources::get().textures.find(file_name) != Resources::get().textures.end()) continue; - - std::string full_cmrc_path = root_path + "/" + file_name; - auto file = fs.open(full_cmrc_path); - const unsigned char* data_ptr = reinterpret_cast(file.begin()); - - CW::Renderer::TextureLoader loader(data_ptr, file.size()); - - auto it = Resources::get().textures.emplace(file_name, CW::Renderer::Texture()).first; - it->second.compile(loader.data); - - Logger::get().info("DataSerializer", "Loaded texture from CMRC: " + file_name); - }; - }; - } else { - Logger::get().warn("DataSerializer", "CMRC - Directory not found: " + root_path); - } - } catch (const std::exception& e) { - Logger::get().warn("DataSerializer", "[CMRC] Could not scan textures folder: " + std::string(e.what())); - }; -#endif - - Logger::get().info("DataSerializer", "Finished loading all textures."); -}; - - - -#ifndef PRODUCTION -void UW::DataSerializer::saveAll() { - Logger::get().info("DataSerializer", "Saving all game data..."); - glob_serializer.saveAll(); - objects_serializer->saveAll(ObjectManager::get().objects); - materials_serializer.saveAll(Resources::get().materials); - lights_serializer.saveAll(Resources::get().lights); - mesh_serializer->saveAll(Resources::get().meshes); - Logger::get().info("DataSerializer", "All game data has been saved"); -}; -#endif - - - -void UW::DataSerializer::loadAll() { - Logger::get().info("DataSerializer", "Loading all game data..."); - glob_serializer.loadAll(); - mesh_serializer->loadAll(Resources::get().meshes); - lights_serializer.loadAll(Resources::get().lights); - materials_serializer.loadAll(Resources::get().materials); - objects_serializer->loadAll(ObjectManager::get().objects); - shader_serializer.loadAll(); - loadAllTextures(); - Logger::get().info("DataSerializer", "All game data has been loaded"); -}; diff --git a/Engine/DataSerializer/GlobResourceSerialization.cpp b/Engine/DataSerializer/GlobResourceSerialization.cpp deleted file mode 100644 index 4cf831f..0000000 --- a/Engine/DataSerializer/GlobResourceSerialization.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "GlobResourceSerialization.h" - -#ifdef PRODUCTION -#include -CMRC_DECLARE(GameData); -#endif - - - -#ifndef PRODUCTION -void UW::GlobResourceSerialization::saveAll() { - Logger::get().info("GlobResourceSerialization", "Saving resources data"); - try { - std::filesystem::path p(UW::Config::GAME_DATA_FOLDER + UW::Config::RESOURCES_FILENAME); - if (p.has_parent_path()) - std::filesystem::create_directories(p.parent_path()); - } catch (const std::filesystem::filesystem_error& e) { - Logger::get().erro("GlobResourceSerialization", "Filesystem error - " + std::string(e.what())); - return; - } - - std::ofstream outFile(UW::Config::GAME_DATA_FOLDER + UW::Config::RESOURCES_FILENAME, std::ios::binary); - if (!outFile.is_open()) { - Logger::get().erro("GlobResourceSerialization", "Failed to open file for saving"); - return; - }; - - UW::GlobResourceRecord record; - record.window_title = UW::GlobResource::get().WINDOW_TITLE; - record.Fixed_HZ = UW::GlobResource::get().FIXED_HZ; - record.vsync = UW::GlobResource::get().VSYNC; - - outFile << record; - - outFile.close(); - Logger::get().info("GlobResourceSerialization", "Glob Resources saved"); -}; -#endif - - - -void UW::GlobResourceSerialization::loadAll() { - Logger::get().info("GlobResourceSerialization", "Loading all Resources..."); - try { - std::string resourcePath = UW::Config::GAME_DATA_FOLDER + UW::Config::RESOURCES_FILENAME; - -#ifndef PRODUCTION - std::ifstream inFile(resourcePath, std::ios::binary); - - if (!inFile.is_open()) { - Logger::get().erro("GlobResourceSerialization", "Failed to open file for loading - " + resourcePath); - return; - }; -#else - auto fs = cmrc::GameData::get_filesystem(); - - if (!fs.exists(resourcePath)) { - Logger::get().erro("GlobResourceSerialization", "CMRC - File not found - " + resourcePath); - return; - }; - - auto embeddedFile = fs.open(resourcePath); - std::string dataStr(embeddedFile.begin(), embeddedFile.end()); - std::stringstream inFile(dataStr); -#endif - - UW::GlobResourceRecord record; - if (inFile >> record) { - UW::GlobResource::get().WINDOW_TITLE = record.window_title; - UW::GlobResource::get().FIXED_HZ = record.Fixed_HZ; - UW::GlobResource::get().VSYNC = record.vsync; - - - Logger::get().info("GlobResourceSerialization", "Glob Resources Loaded"); - } else { - Logger::get().erro("GlobResourceSerialization", "File format is corrupted"); - }; - - } catch(const std::exception& e) { - Logger::get().erro("GlobResourceSerialization", "Exception - " + std::string(e.what())); - }; -}; - - - -#ifndef PRODUCTION -std::ostream& UW::operator<<(std::ostream& os, const UW::GlobResourceRecord& record) { - uint32_t window_title_sz = static_cast(record.window_title.size()); - os.write(reinterpret_cast(&window_title_sz), sizeof(window_title_sz)); - if (window_title_sz > 0) os.write(record.window_title.data(), window_title_sz); - - os.write(reinterpret_cast(&record.Fixed_HZ), sizeof(float)); - os.write(reinterpret_cast(&record.vsync), sizeof(unsigned int)); - - return os; -}; -#endif - - - -std::istream& UW::operator>>(std::istream& is, UW::GlobResourceRecord& record) { - uint32_t window_title_sz = 0; - if (!is.read(reinterpret_cast(&window_title_sz), sizeof(window_title_sz))) return is; - record.window_title.resize(window_title_sz); - if (window_title_sz > 0) is.read(&record.window_title[0], window_title_sz); - - is.read(reinterpret_cast(&record.Fixed_HZ), sizeof(float)); - is.read(reinterpret_cast(&record.vsync), sizeof(unsigned int)); - - return is; -}; diff --git a/Engine/DataSerializer/ScriptSerialization.cpp b/Engine/DataSerializer/ScriptSerialization.cpp deleted file mode 100644 index 8b2d8b8..0000000 --- a/Engine/DataSerializer/ScriptSerialization.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "ScriptSerialization.h" - - - -namespace fs = std::filesystem; - - - -#ifndef PRODUCTION -void UW::ScriptSerialization::save(const std::string& script_name, const std::string& source) { - Logger::get().info("ScriptSerialization", "Saving script: " + UW::Config::SCRIPTS_FOLDER + script_name); - - std::string folder_path = UW::Config::SCRIPTS_FOLDER; - std::string file_path = folder_path + script_name; - - try { - if (!fs::exists(folder_path)) fs::create_directories(folder_path); - - std::ofstream outFile(file_path); - if (!outFile.is_open()) { - Logger::get().erro("ScriptSerialization", "Failed to open file: " + file_path); - return; - }; - - outFile << source; - outFile.close(); - - Logger::get().info("ScriptSerialization", "Script saved: " + file_path); - } catch (const fs::filesystem_error& e) { - Logger::get().erro("ScriptSerialization", "Filesystem error: " + std::string(e.what())); - }; -}; - - - -std::string UW::ScriptSerialization::load(const std::string& script_name) { - std::string file_path = UW::Config::SCRIPTS_FOLDER + script_name; - - if (!fs::exists(file_path)) { - Logger::get().warn("ScriptSerialization", "Script file not found: " + file_path); - return ""; - }; - - std::ifstream inFile(file_path); - if (!inFile.is_open()) { - Logger::get().erro("ScriptSerialization", "Failed to open file: " + file_path); - return ""; - }; - - std::string source((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); - - inFile.close(); - return source; -}; -#endif \ No newline at end of file diff --git a/Engine/DataSerializer/ShaderSerialization.cpp b/Engine/DataSerializer/ShaderSerialization.cpp deleted file mode 100644 index 26eb11f..0000000 --- a/Engine/DataSerializer/ShaderSerialization.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "ShaderSerialization.h" - -#ifdef PRODUCTION -#include -CMRC_DECLARE(GameData); -#endif - -#include "Resources/Resources.h" - - - -#ifndef PRODUCTION -void UW::ShaderSerialization::save(const std::string &shader_name, GLuint type){ - Logger::get().info("ShaderSerialization", "Saving shader: " + shader_name + " type=" + std::to_string(type)); - std::string local_path = UW::Config::GAME_DATA_FOLDER + UW::Config::ASSETS_FOLDER + UW::Config::SHADERS_FOLDER + shader_name + "/" + UW::Config::SHADER_TYPE_TO_NAME[type]; - std::string source = Resources::get().getShader(shader_name).getRegisterShader().at(type).getSource(); - - try { - std::filesystem::path p(local_path); - if (p.has_parent_path()) - std::filesystem::create_directories(p.parent_path()); - } catch (const std::filesystem::filesystem_error& e) { - Logger::get().erro("ShaderSerialization", "Filesystem error while creating directories - " + std::string(e.what())); - return; - }; - - std::ofstream outFile(local_path); - if (!outFile.is_open()) { - Logger::get().erro("ShaderSerialization", "Failed to open file for saving - " + local_path); - return; - }; - - outFile << source << "\n"; - - outFile.close(); - Logger::get().info("ShaderSerialization", "Shader saved: " + shader_name); -}; -#endif - - - -void UW::ShaderSerialization::load(const std::string& shader_name){ - Logger::get().info("ShaderSerialization", "Loading shader: " + shader_name); - std::string local_path = UW::Config::GAME_DATA_FOLDER + UW::Config::ASSETS_FOLDER + UW::Config::SHADERS_FOLDER + shader_name; - CW::Renderer::Shader shader; - - for(const auto& [type_name, type_enum] : UW::Config::SHADER_NAME_TO_TYPE){ - std::string file_path = local_path + "/" + type_name; - -#ifndef PRODUCTION - std::ifstream inFile(file_path); - if (inFile.is_open()) { - std::string source((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); - shader.setShader(source, type_enum); - continue; - } -#else - try { - auto fs = cmrc::GameData::get_filesystem(); - if (fs.exists(file_path)) { - auto file = fs.open(file_path); - std::string source(file.begin(), file.end()); - shader.setShader(source, type_enum); - continue; - } - } catch (const std::exception& e) { - Logger::get().warn("ShaderSerialization", "[LoadShader] CMRC Exception: " + std::string(e.what())); - } -#endif - }; - - if(shader.getRegisterShader().size() != 0){ - Resources::get().shaders[shader_name] = std::move(shader); - Resources::get().shaders[shader_name].compile(); - Logger::get().info("ShaderSerialization", "Shader loaded: " + shader_name); - } else { - Logger::get().info("ShaderSerialization", "No shader source found for: " + shader_name); - }; -}; - - - -void UW::ShaderSerialization::loadAll() { - Logger::get().info("ShaderSerialization", "Scanning and loading all shaders..."); - - std::string root_path = UW::Config::GAME_DATA_FOLDER + UW::Config::ASSETS_FOLDER + UW::Config::SHADERS_FOLDER; - - if (!root_path.empty() && root_path.back() == '/') root_path.pop_back(); - - try { - -#ifndef PRODUCTION - if (std::filesystem::exists(root_path) && std::filesystem::is_directory(root_path)) { - for (const auto& entry : std::filesystem::directory_iterator(root_path)) { - if (entry.is_directory()) { - load(entry.path().filename().string()); - } - } - } else { - Logger::get().erro("ShaderSerialization", "Filesystem - Directory not found: " + root_path); - } -#else - auto fs = cmrc::GameData::get_filesystem(); - if (fs.exists(root_path)) { - for (auto&& entry : fs.iterate_directory(root_path)) { - if (entry.is_directory()) { - load(entry.filename()); - } - } - } else { - Logger::get().erro("ShaderSerialization", "CMRC - Directory not found: " + root_path); - } -#endif - - Logger::get().info("ShaderSerialization", "Finished loading all shaders."); - } catch (const std::exception& e) { - Logger::get().erro("ShaderSerialization", "[LoadAll] CMRC Exception: " + std::string(e.what())); - }; -}; \ No newline at end of file diff --git a/Engine/Editor/CMakeLists.txt b/Engine/Editor/CMakeLists.txt new file mode 100644 index 0000000..60e5102 --- /dev/null +++ b/Engine/Editor/CMakeLists.txt @@ -0,0 +1,34 @@ +# Engine +# Copyright 2026 Daynlight +# Licensed under the GNU General, Version 3.0. +# See LICENSE file for details. + + + +cmake_minimum_required(VERSION 3.15) + +project(Editor LANGUAGES CXX C) + + +set(src + "Editor/Editor.cpp" + "Editor/UI/UI.cpp" + "Editor/UI/UI_Logs.cpp" + "Editor/UI/UI_Materials.cpp" + "Editor/UI/UI_Shaders.cpp" + "Editor/UI/UI_Scripts.cpp" + "Editor/UI/UI_Objects.cpp" + "Editor/UI/UI_Lights.cpp" + "Editor/UI/UI_AssetLoader.cpp" + "Editor/UI/UI_ShaderEditors.cpp" + "Editor/UI/UI_ScriptEditor.cpp" + "Editor/UI/UI_Info.cpp" + "Editor/UI/UI_Viewport.cpp" +) + + +add_library(Editor STATIC ${src}) +target_link_libraries(Editor CWindow UtilsDev) +target_include_directories(Editor PUBLIC "Editor/" "../Core/Core" "../ScriptShared") +target_compile_definitions(Editor PRIVATE ENGINE_SRC_DEST="${ENGINE_SRC_DEST}") +target_compile_definitions(Editor PRIVATE GENERATOR="${CMAKE_GENERATOR}") diff --git a/Engine/Editor/Editor/Editor.cpp b/Engine/Editor/Editor/Editor.cpp new file mode 100644 index 0000000..f21aa69 --- /dev/null +++ b/Engine/Editor/Editor/Editor.cpp @@ -0,0 +1,47 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "Editor.h" + + + +Engine::Editor::Editor::Editor(Engine::Core::Core& core, float& fps, CW::Renderer::Framebuffer& viewport_fbo) + :core(core), ui(core.window, fps, core.scene, viewport_fbo) +{ + Engine::Utils::Logger::get().info("Editor", "Editor Initialized"); +}; + + + +Engine::Editor::Editor::~Editor(){ + Engine::Utils::Logger::get().info("Editor", "Editor Destroyed"); +}; + + + +// ===================================== // +// ========== Editor Operations ========== // +// ===================================== // +void Engine::Editor::Editor::onLoad(){ + Engine::Utils::Logger::get().info("Editor", "Editor Loading"); + ui.onLoad(); + Engine::Utils::Logger::get().info("Editor", "Editor Loaded"); +}; + + + +void Engine::Editor::Editor::onDestroy() { + Engine::Utils::Logger::get().info("Editor", "Destroying Editor"); + ui.onDestroy(); + Engine::Utils::Logger::get().info("Editor", "Editor Destroyed"); +}; + + + +void Engine::Editor::Editor::render(){ + ui.render(); +}; diff --git a/Engine/Editor/Editor/Editor.h b/Engine/Editor/Editor/Editor.h new file mode 100644 index 0000000..d06101d --- /dev/null +++ b/Engine/Editor/Editor/Editor.h @@ -0,0 +1,40 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include "Renderer.h" +#include "Core.h" + +#include +#include +#include "UI/UI.h" + +#include "Utils/config.h" +#include "Utils/Logger.h" +#include "Resources/Resources.h" +#include "ScriptShared/GlobResource.h" +#include "Scene.h" + + + +namespace Engine::Editor{ +class Editor{ +private: + Engine::Core::Core& core; + UI ui; + +public: + Editor(Engine::Core::Core& core, float& fps, CW::Renderer::Framebuffer& viewport_fbo); + ~Editor(); + + // Editor operations + void onLoad(); + void onDestroy(); + void render(); + +}; +}; diff --git a/Engine/UI/Settings.h b/Engine/Editor/Editor/UI/Settings.h similarity index 80% rename from Engine/UI/Settings.h rename to Engine/Editor/Editor/UI/Settings.h index 4ccdee2..7f0169f 100644 --- a/Engine/UI/Settings.h +++ b/Engine/Editor/Editor/UI/Settings.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -12,14 +12,15 @@ #include #include -#include "config.h" +#include "Utils/config.h" -namespace UW{ +namespace Engine::Editor{ struct GuiSettings{ bool infoWindowOn = false; bool logWindowOn = false; + bool viewportWindowOn = true; bool materialExplorerOn = false; bool materialEditorOn = false; bool shaderExplorerWindowOn = false; @@ -31,8 +32,8 @@ struct GuiSettings{ bool mesh_mode_on = false; bool assetLoaderWindowOn = false; bool lightsExplorerOn = false; - std::string material_name = UW::Config::DEFAULT_GUI_MATERIAL; - unsigned int object_id = UW::Config::DEFAULT_GUI_OBJECT; + std::string material_name = Engine::Config::DEFAULT_GUI_MATERIAL; + unsigned int object_id = Engine::Config::DEFAULT_GUI_OBJECT; std::vector> shader_editors_reg; std::vector scripts_editors_reg; int window_width = 800; diff --git a/Engine/Editor/Editor/UI/UI.cpp b/Engine/Editor/Editor/UI/UI.cpp new file mode 100644 index 0000000..a39e586 --- /dev/null +++ b/Engine/Editor/Editor/UI/UI.cpp @@ -0,0 +1,454 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "UI.h" +#ifndef PRODUCTION + + + +Engine::Editor::UI::UI(CW::Renderer::Renderer &window, float &fps, Engine::Core::Scene& scene, CW::Renderer::Framebuffer& viewport_fbo) + :window(window), gui(&window), scene(scene), + info_ui(gui, fps, scene), + log_ui(gui), + materials_ui(gui), + objects_ui(gui, window, scene), + lights_ui(gui), + shader_ui(gui), + asset_loader_ui(gui, scene), + scripts_ui(gui), + viewport_ui(gui, viewport_fbo){ + Engine::Utils::Logger::get().info("UI", "Initializing UI"); + + gui.setWorkspace(appWorkspace()); +}; + + + +Engine::Editor::UI::~UI(){ + onDestroy(); +}; + + + +void Engine::Editor::UI::onLoad(){ + Engine::Utils::Logger::get().info("UI", "Loading UI"); + + uiLoad(); + window.setSize(guiSettings.window_width, Engine::Editor::guiSettings.window_height); + Engine::Utils::Logger::get().info("UI", "Window Size Setted { "+ std::to_string(guiSettings.window_width) + " x " + std::to_string(guiSettings.window_height) +" }"); +}; + + + +void Engine::Editor::UI::render(){ + gui.render(); +}; + + + +void Engine::Editor::UI::onDestroy() { + Engine::Utils::Logger::get().info("UI", "Destroying UI"); + scripts_ui.saveScriptEditors(); + shader_ui.saveShaderEditors(); +}; + + + +// ========================= // +// ========== GUI ========== // +// ========================= // +void Engine::Editor::UI::uiLoad(){ + configControl(); + static std::string path_to_ini = Engine::Config::TEMP_BIN_FOLDER + ImGui::GetIO().IniFilename; + + if(!std::filesystem::exists(Engine::Config::TEMP_BIN_FOLDER)) std::filesystem::create_directories(Engine::Config::TEMP_BIN_FOLDER); + + ImGui::GetIO().IniFilename = path_to_ini.c_str(); + ImGui::LoadIniSettingsFromDisk(ImGui::GetIO().IniFilename); + + Engine::Utils::Logger::get().info("UI", "Loading UI Data from disck"); + + Engine::Core::Resources::get().simulation_mode = Engine::Editor::guiSettings.simulation_mode; + + shader_ui.loadShaderEditors(); + scripts_ui.loadScriptEditors(); + + uiControl(); +}; + + +void Engine::Editor::UI::configControl(){ + ImGuiSettingsHandler handler; + handler.TypeName = "GuiSettings"; + handler.TypeHash = ImHashStr("GuiSettings"); + + handler.ReadOpenFn = [](ImGuiContext*, ImGuiSettingsHandler*, const char*){ + return (void*)&Engine::Editor::guiSettings; + }; + + handler.ReadLineFn = [](ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line){ + Engine::Editor::GuiSettings* s = (Engine::Editor::GuiSettings*)entry; + + int value; + if (sscanf(line, "InfoWindowOn=%d", &value) == 1) s->infoWindowOn = value; + if (sscanf(line, "LogWindowOn=%d", &value) == 1) s->logWindowOn = value; + if (sscanf(line, "viewportWindowOn=%d", &value) == 1) s->viewportWindowOn = value; + if (sscanf(line, "MaterialExplorerOn=%d", &value) == 1) s->materialExplorerOn = value; + if (sscanf(line, "LightsExplorerOn=%d", &value) == 1) s->lightsExplorerOn = value; + if (sscanf(line, "MaterialEditorOn=%d", &value) == 1) s->materialEditorOn = value; + if (sscanf(line, "ShaderExplorerWindowOn=%d", &value) == 1) s->shaderExplorerWindowOn = value; + if (sscanf(line, "ScriptsExplorerWindowOn=%d", &value) == 1) s->scriptsExplorerWindowOn= value; + if (sscanf(line, "ShaderEditorWindowOn=%d", &value) == 1) s->shaderEditorWindowOn = value; + if (sscanf(line, "ScriptEditorWindowOn=%d", &value) == 1) s->scriptEditorWindowOn = value; + if (sscanf(line, "ObjectExplorerWindowOn=%d", &value) == 1) s->objectExplorerWindowOn = value; + if (sscanf(line, "ObjectEditorWindowOn=%d", &value) == 1) s->objectEditorWindowOn = value; + if (sscanf(line, "Object_ID=%d", &value) == 1) s->object_id = value; + if (sscanf(line, "Mesh_Mode_On=%d", &value) == 1) s->mesh_mode_on = value; + if (sscanf(line, "Window_Width=%d", &value) == 1) s->window_width = value; + if (sscanf(line, "Window_Height=%d", &value) == 1) s->window_height = value; + if (sscanf(line, "Simulation_Mode=%d", &value) == 1) s->simulation_mode = value; + + char value_str[256]; + if (sscanf(line, "Material_ID=%255s", &value_str) == 1) s->material_name = std::string(value_str); + + char name[256]; + unsigned int type; + + if (sscanf(line, "ShaderEditor=%255[^,],%u", name, &type) == 2){ + s->shader_editors_reg.emplace_back(name, type); + }; + + if (sscanf(line, "ScriptEditor=%255[^,]", name) == 1){ + s->scripts_editors_reg.emplace_back(name); + }; + }; + + handler.WriteAllFn = [](ImGuiContext*, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf){ + out_buf->appendf("[%s][Main]\n", handler->TypeName); + out_buf->appendf("InfoWindowOn=%d\n", Engine::Editor::guiSettings.infoWindowOn); + out_buf->appendf("LogWindowOn=%d\n", Engine::Editor::guiSettings.logWindowOn); + out_buf->appendf("viewportWindowOn=%d\n", Engine::Editor::guiSettings.viewportWindowOn); + out_buf->appendf("MaterialExplorerOn=%d\n", Engine::Editor::guiSettings.materialExplorerOn); + out_buf->appendf("LightsExplorerOn=%d\n", Engine::Editor::guiSettings.lightsExplorerOn); + out_buf->appendf("MaterialEditorOn=%d\n", Engine::Editor::guiSettings.materialEditorOn); + out_buf->appendf("ShaderExplorerWindowOn=%d\n", Engine::Editor::guiSettings.shaderExplorerWindowOn); + out_buf->appendf("ScriptsExplorerWindowOn=%d\n", Engine::Editor::guiSettings.scriptsExplorerWindowOn); + out_buf->appendf("ShaderEditorWindowOn=%d\n", Engine::Editor::guiSettings.shaderEditorWindowOn); + out_buf->appendf("ScriptEditorWindowOn=%d\n", Engine::Editor::guiSettings.scriptEditorWindowOn); + out_buf->appendf("ObjectExplorerWindowOn=%d\n", Engine::Editor::guiSettings.objectExplorerWindowOn); + out_buf->appendf("ObjectEditorWindowOn=%d\n", Engine::Editor::guiSettings.objectEditorWindowOn); + out_buf->appendf("Object_ID=%d\n", Engine::Editor::guiSettings.object_id); + out_buf->appendf("Mesh_Mode_On=%d\n", Engine::Editor::guiSettings.mesh_mode_on); + out_buf->appendf("Window_Width=%d\n", Engine::Editor::guiSettings.window_width); + out_buf->appendf("Window_Height=%d\n", Engine::Editor::guiSettings.window_height); + out_buf->appendf("Material_ID=%s\n", Engine::Editor::guiSettings.material_name.c_str()); + out_buf->appendf("Simulation_Mode=%d\n", Engine::Editor::guiSettings.simulation_mode); + + out_buf->appendf("ShaderEditorCount=%zu\n", Engine::Editor::guiSettings.shader_editors_reg.size()); + + for (size_t i = 0; i < Engine::Editor::guiSettings.shader_editors_reg.size(); ++i){ + out_buf->appendf( + "ShaderEditor=%s,%u\n", + Engine::Editor::guiSettings.shader_editors_reg[i].first.c_str(), + Engine::Editor::guiSettings.shader_editors_reg[i].second + ); + }; + + out_buf->appendf("ScriptEditorCount=%zu\n", Engine::Editor::guiSettings.scripts_editors_reg.size()); + + for (size_t i = 0; i < Engine::Editor::guiSettings.scripts_editors_reg.size(); ++i){ + out_buf->appendf( + "ScriptEditor=%s\n", + Engine::Editor::guiSettings.scripts_editors_reg[i].c_str() + ); + }; + + out_buf->append("\n"); + }; + + ImGui::GetCurrentContext()->SettingsHandlers.push_back(handler); +}; + + + +void Engine::Editor::UI::uiControl(){ + info_ui.uiControl(); + log_ui.uiControl(); + materials_ui.uiControl(); + objects_ui.uiControl(); + lights_ui.uiControl(); + shader_ui.uiControl(); + asset_loader_ui.uiControl(); + scripts_ui.uiControl(); + viewport_ui.uiControl(); +}; + + + +void Engine::Editor::UI::menuBarGui(){ + if (ImGui::BeginMenuBar()) { + if (ImGui::BeginMenu("Window")) { + if(ImGui::MenuItem("Info")){ + Engine::Editor::guiSettings.infoWindowOn = !Engine::Editor::guiSettings.infoWindowOn; + uiControl(); + }; + if(ImGui::MenuItem("Logs")){ + Engine::Editor::guiSettings.logWindowOn = !Engine::Editor::guiSettings.logWindowOn; + uiControl(); + }; + if(ImGui::MenuItem("Material Explorer")){ + Engine::Editor::guiSettings.materialExplorerOn = !Engine::Editor::guiSettings.materialExplorerOn; + uiControl(); + }; + if(ImGui::MenuItem("Material Editor")){ + Engine::Editor::guiSettings.materialEditorOn = !Engine::Editor::guiSettings.materialEditorOn; + uiControl(); + }; + if(ImGui::MenuItem("Lights Explorer")){ + Engine::Editor::guiSettings.lightsExplorerOn = !Engine::Editor::guiSettings.lightsExplorerOn; + uiControl(); + }; + if(ImGui::MenuItem("Shader Explorer")){ + Engine::Editor::guiSettings.shaderExplorerWindowOn = !Engine::Editor::guiSettings.shaderExplorerWindowOn; + uiControl(); + }; + if(ImGui::MenuItem("Script Explorer")){ + Engine::Editor::guiSettings.scriptsExplorerWindowOn = !Engine::Editor::guiSettings.scriptsExplorerWindowOn; + uiControl(); + }; + if(ImGui::MenuItem("Object Explorer")){ + Engine::Editor::guiSettings.objectExplorerWindowOn = !Engine::Editor::guiSettings.objectExplorerWindowOn; + uiControl(); + }; + if(ImGui::MenuItem("Object Editor")){ + Engine::Editor::guiSettings.objectEditorWindowOn = !Engine::Editor::guiSettings.objectEditorWindowOn; + uiControl(); + }; + if(ImGui::MenuItem("Viewport")){ + Engine::Editor::guiSettings.viewportWindowOn = !Engine::Editor::guiSettings.viewportWindowOn; + uiControl(); + }; + ImGui::EndMenu(); + }; + + if(ImGui::BeginMenu("Assets")){ + if(ImGui::MenuItem("Asset Loader")){ + Engine::Editor::guiSettings.assetLoaderWindowOn = !Engine::Editor::guiSettings.assetLoaderWindowOn; + uiControl(); + }; + ImGui::EndMenu(); + }; + + if(ImGui::BeginMenu("Properties")){ + char title_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE] = {}; + memcpy(title_buffer, Engine::ScriptShared::GlobResource::get().WINDOW_TITLE.data(), Engine::ScriptShared::GlobResource::get().WINDOW_TITLE.size()); + if(ImGui::InputText("Window Title", title_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + Engine::ScriptShared::GlobResource::get().WINDOW_TITLE = std::string(title_buffer); + }; + + bool vsync_on = Engine::ScriptShared::GlobResource::get().VSYNC; + if(ImGui::Checkbox("Vsync", &vsync_on)) Engine::ScriptShared::GlobResource::get().VSYNC = vsync_on; + + float fixed_hz = Engine::ScriptShared::GlobResource::get().FIXED_HZ; + if(ImGui::InputFloat("Fixed_HZ", &fixed_hz)){ + Engine::ScriptShared::GlobResource::get().FIXED_HZ = fixed_hz; + }; + + ImGui::EndMenu(); + }; + + bool new_simulation_mode = Engine::Core::Resources::get().simulation_mode; + if(ImGui::Checkbox("Simulation", &new_simulation_mode)){ + Engine::Core::Resources::get().simulation_mode = new_simulation_mode; + Engine::Editor::guiSettings.simulation_mode = new_simulation_mode; + }; + + if(ImGui::Button("Build")) buildProject(); + if(ImGui::Button("Run")) runProject(); + + ImGui::EndMenuBar(); + }; +}; + + + +void Engine::Editor::UI::buildProject(){ + #ifndef PRODUCTION + Engine::Utils::Logger::get().info("UI", "Building ..."); + + std::filesystem::path dest_folder = Engine::Config::TEMP_BIN_FOLDER; + if(!std::filesystem::exists(Engine::Config::TEMP_BIN_FOLDER)) std::filesystem::create_directories(Engine::Config::TEMP_BIN_FOLDER); + + std::string build_dir = (dest_folder / "build-prod").string(); + if(!std::filesystem::exists(build_dir)) std::filesystem::create_directories(build_dir); + + + // clean stage + if(std::filesystem::exists(dest_folder)){ + std::filesystem::remove_all(dest_folder / Engine::Config::GAME_DATA_FOLDER); + std::filesystem::remove_all(dest_folder / Engine::Config::SCRIPTS_SRC_FOLDER); + } + + // copying game data + std::filesystem::copy( + Engine::Config::GAME_DATA_FOLDER, + dest_folder / Engine::Config::GAME_DATA_FOLDER, + std::filesystem::copy_options::recursive | + std::filesystem::copy_options::overwrite_existing + ); + + std::filesystem::copy( + Engine::Config::SCRIPTS_SRC_FOLDER, + dest_folder / Engine::Config::SCRIPTS_SRC_FOLDER, + std::filesystem::copy_options::recursive | + std::filesystem::copy_options::overwrite_existing + ); + + // compilation stage + std::filesystem::path engine_src_dir = std::filesystem::path(ENGINE_SRC_DEST); + std::string generator = GENERATOR; + const char* config[] = { + "cmake", + "-S", + engine_src_dir.c_str(), + "-B", + build_dir.c_str(), + "-G", + generator.c_str(), + "-DPRODUCTION=ON", + nullptr + }; + + const char* build[] = { + "cmake", + "--build", + build_dir.c_str(), + "--target", + "App", + nullptr + }; + + pid_t pid = fork(); + if(pid == 0){ + execvp("cmake", const_cast(config)); + Engine::Utils::Logger::get().erro("UI", "Failed to exec g++"); + exit(-1); + } + else if(pid > 0){ + int status = 0; + + waitpid(pid, &status, 0); + + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { + Engine::Utils::Logger::get().info("UI", "successful compilation"); + } + else { + Engine::Utils::Logger::get().erro("UI", "Compilation failed!"); + return; + }; + }; + + pid_t pid1 = fork(); + if(pid1 == 0){ + execvp("cmake", const_cast(build)); + Engine::Utils::Logger::get().erro("UI", "Failed to exec g++"); + exit(-1); + } + else if(pid1 > 0){ + int status = 0; + + waitpid(pid1, &status, 0); + + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { + Engine::Utils::Logger::get().info("UI", "successful compilation"); + // return; + } + else { + Engine::Utils::Logger::get().erro("UI", "Compilation failed!"); + return; + }; + }; + + std::filesystem::copy(dest_folder / "build-prod" / "Engine" / "App" / "App", "App", std::filesystem::copy_options::overwrite_existing); + + + Engine::Utils::Logger::get().info("UI", "Project Builded"); +#else + Engine::Utils::Logger::get().info("UI", "In PRODUCTION mode: cmrc extraction skipped."); +#endif +}; + + + +void Engine::Editor::UI::runProject(){ + Engine::DataSerializer::get().saveAll(); + + buildProject(); + + const char* run[] = { + "./App", + nullptr + }; + + pid_t pid1 = fork(); + if(pid1 == 0){ + execvp("./App", const_cast(run)); + Engine::Utils::Logger::get().erro("UI", "Failed to exec g++"); + exit(-1); + } + else if(pid1 > 0){ + int status = 0; + + waitpid(pid1, &status, 0); + + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { + Engine::Utils::Logger::get().info("UI", "successful compilation"); + // return; + } + else { + Engine::Utils::Logger::get().erro("UI", "Compilation failed!"); + return; + }; + }; +}; + + + +std::function render_windows)> Engine::Editor::UI::appWorkspace() { + return [this](std::function render_windows){ + ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_MenuBar; + + const ImGuiViewport* viewport = ImGui::GetMainViewport(); + ImGui::SetNextWindowPos(viewport->WorkPos); + ImGui::SetNextWindowSize(viewport->WorkSize); + ImGui::SetNextWindowViewport(viewport->ID); + + window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | + ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus; + + ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + + ImGui::Begin("Window DockSpace", nullptr, window_flags); + + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(); + + menuBarGui(); + + ImGuiID docspace_id = ImGui::GetID("MyDockSpace"); + ImGui::DockSpace(docspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode); + + render_windows(); + + ImGui::End(); + }; +}; + +#endif diff --git a/Engine/UI/UI.h b/Engine/Editor/Editor/UI/UI.h similarity index 61% rename from Engine/UI/UI.h rename to Engine/Editor/Editor/UI/UI.h index 1f7ba14..99cec61 100644 --- a/Engine/UI/UI.h +++ b/Engine/Editor/Editor/UI/UI.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -16,7 +16,7 @@ #include "imgui.h" #include "imgui_internal.h" -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" #include "Objects/ObjectManager.h" #include "DataSerializer/DataSerializer.h" @@ -29,46 +29,50 @@ #include "UI/UI_AssetLoader.h" #include "UI/UI_ShaderEditors.h" #include "UI/UI_Info.h" -#include "UI/UI_Log.h" +#include "UI/UI_Logs.h" #include "UI/UI_Materials.h" #include "UI/UI_Objects.h" #include "UI/UI_Lights.h" #include "UI/UI_Shaders.h" #include "UI/UI_Scripts.h" #include "UI/UI_ScriptEditor.h" +#include "UI/UI_Viewport.h" -namespace UW{ +namespace Engine::Editor{ class UI{ private: CW::Gui::Gui gui; CW::Renderer::Renderer& window; - UW::Scene& scene; + Engine::Core::Scene& scene; - UW::UI_AssetLoader asset_loader_ui; - UW::UI_Info info_ui; - UW::UI_Log log_ui; - UW::UI_Materials materials_ui; - UW::UI_Objects objects_ui; - UW::UI_Lights lights_ui; - UW::UI_Shaders shader_ui; - UW::UI_Scripts scripts_ui; + Engine::Editor::UI_AssetLoader asset_loader_ui; + Engine::Editor::UI_Info info_ui; + Engine::Editor::UI_Log log_ui; + Engine::Editor::UI_Materials materials_ui; + Engine::Editor::UI_Objects objects_ui; + Engine::Editor::UI_Lights lights_ui; + Engine::Editor::UI_Shaders shader_ui; + Engine::Editor::UI_Scripts scripts_ui; + Engine::Editor::UI_Viewport viewport_ui; public: - UI(CW::Renderer::Renderer &window, float &fps, UW::Scene& scene); + UI(CW::Renderer::Renderer &window, float &fps, Engine::Core::Scene& scene, CW::Renderer::Framebuffer& viewport_fbo); ~UI(); void onLoad(); void render(); void onDestroy(); private: -// gui + // gui void uiLoad(); void configControl(); void uiControl(); void menuBarGui(); + void buildProject(); + void runProject(); std::function render_windows)> appWorkspace(); diff --git a/Engine/UI/UI_AssetLoader.cpp b/Engine/Editor/Editor/UI/UI_AssetLoader.cpp similarity index 81% rename from Engine/UI/UI_AssetLoader.cpp rename to Engine/Editor/Editor/UI/UI_AssetLoader.cpp index 0f21712..32e6069 100644 --- a/Engine/UI/UI_AssetLoader.cpp +++ b/Engine/Editor/Editor/UI/UI_AssetLoader.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,22 +11,22 @@ -UW::UI_AssetLoader::UI_AssetLoader(CW::Gui::Gui& gui, UW::Scene& scene) +Engine::Editor::UI_AssetLoader::UI_AssetLoader(CW::Gui::Gui& gui, Engine::Core::Scene& scene) : gui(gui), scene(scene) { - Logger::get().info("UI_AssetLoader", "Initialized Asset Loader"); + Engine::Utils::Logger::get().info("UI_AssetLoader", "Initialized Asset Loader"); }; -UW::UI_AssetLoader::~UI_AssetLoader() { +Engine::Editor::UI_AssetLoader::~UI_AssetLoader() { clearTemporaryData(); }; -void UW::UI_AssetLoader::uiControl(){ - if(guiSettings.assetLoaderWindowOn){ - Logger::get().info("UI", "Opening Asset Loader GUI"); +void Engine::Editor::UI_AssetLoader::uiControl(){ + if(Engine::Editor::guiSettings.assetLoaderWindowOn){ + Engine::Utils::Logger::get().info("UI", "Opening Asset Loader GUI"); gui.addWindow("Asset Loader", assetLoaderGui()); } else { gui.deleteWindow("Asset Loader"); @@ -35,7 +35,7 @@ void UW::UI_AssetLoader::uiControl(){ -void UW::UI_AssetLoader::clearTemporaryData() { +void Engine::Editor::UI_AssetLoader::clearTemporaryData() { importer.FreeScene(); current_scene = nullptr; temp_meshes.clear(); @@ -51,7 +51,7 @@ void UW::UI_AssetLoader::clearTemporaryData() { -void UW::UI_AssetLoader::loadModelFromFile(const std::string& path) { +void Engine::Editor::UI_AssetLoader::loadModelFromFile(const std::string& path) { clearTemporaryData(); current_scene = importer.ReadFile(path, @@ -62,11 +62,11 @@ void UW::UI_AssetLoader::loadModelFromFile(const std::string& path) { if (!current_scene || current_scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !current_scene->mRootNode) { load_error_msg = importer.GetErrorString(); - Logger::get().erro("UI_AssetLoader", "Failed to load model: " + load_error_msg); + Engine::Utils::Logger::get().erro("UI_AssetLoader", "Failed to load model: " + load_error_msg); return; }; - Logger::get().info("UI_AssetLoader", "Successfully loaded model: " + path); + Engine::Utils::Logger::get().info("UI_AssetLoader", "Successfully loaded model: " + path); for (unsigned int i = 0; i < current_scene->mNumMaterials; i++) { aiString matName; @@ -76,7 +76,7 @@ void UW::UI_AssetLoader::loadModelFromFile(const std::string& path) { matData.original_name = matName.C_Str(); if (matData.original_name.empty()) matData.original_name = "Material_" + std::to_string(i); - strncpy(matData.new_name, matData.original_name.c_str(), UW::Config::OBJECT_NAME_BUFFER_SIZE); + strncpy(matData.new_name, matData.original_name.c_str(), Engine::Config::OBJECT_NAME_BUFFER_SIZE); temp_materials.push_back(matData); material_import_toggles.push_back(true); @@ -87,7 +87,7 @@ void UW::UI_AssetLoader::loadModelFromFile(const std::string& path) { meshData.original_name = current_scene->mMeshes[i]->mName.C_Str(); if (meshData.original_name.empty()) meshData.original_name = "Mesh_" + std::to_string(i); - strncpy(meshData.new_name, meshData.original_name.c_str(), UW::Config::OBJECT_NAME_BUFFER_SIZE); + strncpy(meshData.new_name, meshData.original_name.c_str(), Engine::Config::OBJECT_NAME_BUFFER_SIZE); temp_meshes.push_back(meshData); mesh_import_toggles.push_back(true); @@ -99,7 +99,7 @@ void UW::UI_AssetLoader::loadModelFromFile(const std::string& path) { -void UW::UI_AssetLoader::guiAssetLoader() { +void Engine::Editor::UI_AssetLoader::guiAssetLoader() { ImGui::SeparatorText("Load Model File"); ImGui::InputText("File Path", file_path_buffer, sizeof(file_path_buffer)); @@ -137,7 +137,7 @@ void UW::UI_AssetLoader::guiAssetLoader() { ImGui::Text("Orig: %s", temp_materials[i].original_name.c_str()); ImGui::SameLine(180.0f); ImGui::SetNextItemWidth(-1); - ImGui::InputText("##NewMatName", temp_materials[i].new_name, UW::Config::OBJECT_NAME_BUFFER_SIZE); + ImGui::InputText("##NewMatName", temp_materials[i].new_name, Engine::Config::OBJECT_NAME_BUFFER_SIZE); ImGui::PopID(); }; }; @@ -154,7 +154,7 @@ void UW::UI_AssetLoader::guiAssetLoader() { ImGui::SameLine(); ImGui::SetNextItemWidth(120.0f); - ImGui::InputText("##NewMeshName", temp_meshes[i].new_name, UW::Config::OBJECT_NAME_BUFFER_SIZE); + ImGui::InputText("##NewMeshName", temp_meshes[i].new_name, Engine::Config::OBJECT_NAME_BUFFER_SIZE); ImGui::SameLine(); if (!temp_materials.empty()) { @@ -208,8 +208,8 @@ void UW::UI_AssetLoader::guiAssetLoader() { -void UW::UI_AssetLoader::finalizeImport() { - Logger::get().info("UI_AssetLoader", "Finalizing Separate Import..."); +void Engine::Editor::UI_AssetLoader::finalizeImport() { + Engine::Utils::Logger::get().info("UI_AssetLoader", "Finalizing Separate Import..."); std::vector oldToNew = finalizeMaterials(); @@ -227,10 +227,10 @@ void UW::UI_AssetLoader::finalizeImport() { std::string assigned_mat_name = temp_materials[finalMatIdx].new_name; - UW::GameObject new_obj( + Engine::Core::GameObject new_obj( final_mesh_name, final_mesh_name, - UW::Config::DEFAULT_SHADER, + Engine::Config::DEFAULT_SHADER, { assigned_mat_name }, {}, {}, @@ -239,17 +239,17 @@ void UW::UI_AssetLoader::finalizeImport() { glm::vec3(1.0f) ); - UW::ObjectManager::get().objects.push_back(new_obj); + Engine::ObjectManager::get().objects.push_back(new_obj); }; - Logger::get().info("UI_AssetLoader", "Separate Import successful!"); + Engine::Utils::Logger::get().info("UI_AssetLoader", "Separate Import successful!"); clearTemporaryData(); }; -void UW::UI_AssetLoader::finalizeImportMerged(const std::string& merged_name) { - Logger::get().info("UI_AssetLoader", "Finalizing Merged Import..."); +void Engine::Editor::UI_AssetLoader::finalizeImportMerged(const std::string& merged_name) { + Engine::Utils::Logger::get().info("UI_AssetLoader", "Finalizing Merged Import..."); std::vector oldToNew = finalizeMaterials(); @@ -319,12 +319,12 @@ void UW::UI_AssetLoader::finalizeImportMerged(const std::string& merged_name) { temp_mesh.setData(mat_ids, 1, 3); temp_mesh.addIndices(indices); - Resources::get().meshes.emplace_back(final_merged_name, std::move(temp_mesh)); + Engine::Core::Resources::get().meshes.emplace_back(final_merged_name, std::move(temp_mesh)); - UW::GameObject new_obj( + Engine::Core::GameObject new_obj( final_merged_name, final_merged_name, - UW::Config::DEFAULT_SHADER, + Engine::Config::DEFAULT_SHADER, assigned_materials, {}, {}, @@ -333,16 +333,16 @@ void UW::UI_AssetLoader::finalizeImportMerged(const std::string& merged_name) { glm::vec3(1.0f) ); - UW::ObjectManager::get().objects.push_back(new_obj); + Engine::ObjectManager::get().objects.push_back(new_obj); - Logger::get().info("UI_AssetLoader", "Merged Import successful!"); + Engine::Utils::Logger::get().info("UI_AssetLoader", "Merged Import successful!"); clearTemporaryData(); }; -std::vector UW::UI_AssetLoader::finalizeMaterials(){ - Logger::get().info("UI_AssetLoader", "Finalizing Materials..."); +std::vector Engine::Editor::UI_AssetLoader::finalizeMaterials(){ + Engine::Utils::Logger::get().info("UI_AssetLoader", "Finalizing Materials..."); std::vector oldToNewMap(temp_materials.size(), -1); int newIndex = 0; @@ -351,7 +351,7 @@ std::vector UW::UI_AssetLoader::finalizeMaterials(){ if (!material_import_toggles[i]) continue; std::string final_mat_name = temp_materials[i].new_name; - UW::Material new_mat; + Engine::Core::Material new_mat; aiMaterial* material = current_scene->mMaterials[i]; @@ -383,18 +383,18 @@ std::vector UW::UI_AssetLoader::finalizeMaterials(){ #endif new_mat.ambient_occlusion = ambient_occlusion; - Resources::get().materials.emplace_back(final_mat_name, new_mat); + Engine::Core::Resources::get().materials.emplace_back(final_mat_name, new_mat); oldToNewMap[i] = newIndex; newIndex++; }; - Logger::get().info("UI_AssetLoader", "Materials Import successful!"); + Engine::Utils::Logger::get().info("UI_AssetLoader", "Materials Import successful!"); return oldToNewMap; }; -void UW::UI_AssetLoader::finalizeMesh(aiMesh* aMesh, const std::string& final_mesh_name, int custom_mat_id){ +void Engine::Editor::UI_AssetLoader::finalizeMesh(aiMesh* aMesh, const std::string& final_mesh_name, int custom_mat_id){ std::vector positions; std::vector normals; std::vector uvs; @@ -447,12 +447,12 @@ void UW::UI_AssetLoader::finalizeMesh(aiMesh* aMesh, const std::string& final_me temp_mesh.setData(mat_ids, 1, 3); temp_mesh.addIndices(indices); - Resources::get().meshes.emplace_back(final_mesh_name, std::move(temp_mesh)); + Engine::Core::Resources::get().meshes.emplace_back(final_mesh_name, std::move(temp_mesh)); }; -std::function UW::UI_AssetLoader::assetLoaderGui() { +std::function Engine::Editor::UI_AssetLoader::assetLoaderGui() { return [this](CW::Renderer::iRenderer *window) { guiAssetLoader(); }; diff --git a/Engine/UI/UI_AssetLoader.h b/Engine/Editor/Editor/UI/UI_AssetLoader.h similarity index 86% rename from Engine/UI/UI_AssetLoader.h rename to Engine/Editor/Editor/UI/UI_AssetLoader.h index 8566f2b..7f286a5 100644 --- a/Engine/UI/UI_AssetLoader.h +++ b/Engine/Editor/Editor/UI/UI_AssetLoader.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -24,17 +24,17 @@ #include "Resources/Resources.h" #include "Objects/ObjectManager.h" -#include "config.h" +#include "Utils/config.h" #include "UI/Settings.h" #include "Scene.h" -namespace UW { +namespace Engine::Editor { struct TempAssetData { std::string original_name; - char new_name[UW::Config::OBJECT_NAME_BUFFER_SIZE]; + char new_name[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; }; @@ -42,7 +42,7 @@ struct TempAssetData { class UI_AssetLoader { private: CW::Gui::Gui& gui; - UW::Scene& scene; + Engine::Core::Scene& scene; Assimp::Importer importer; const aiScene* current_scene = nullptr; @@ -59,7 +59,7 @@ class UI_AssetLoader { std::vector temp_materials; public: - UI_AssetLoader(CW::Gui::Gui& gui, UW::Scene& scene); + UI_AssetLoader(CW::Gui::Gui& gui, Engine::Core::Scene& scene); ~UI_AssetLoader(); void uiControl(); @@ -74,6 +74,6 @@ class UI_AssetLoader { void finalizeMesh(aiMesh* aMesh, const std::string& final_mesh_name, int custom_mat_id); void finalizeImportMerged(const std::string& final_merged_name); }; -}; // namespace UW +}; // namespace Engine #endif diff --git a/Engine/Editor/Editor/UI/UI_Info.cpp b/Engine/Editor/Editor/UI/UI_Info.cpp new file mode 100644 index 0000000..c60fc0a --- /dev/null +++ b/Engine/Editor/Editor/UI/UI_Info.cpp @@ -0,0 +1,98 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "UI_Info.h" + +#ifndef PRODUCTION + + + +Engine::Editor::UI_Info::UI_Info(CW::Gui::Gui& gui, float &fps, Engine::Core::Scene& scene) + :gui(gui), fps(fps), scene(scene){}; + + + +Engine::Editor::UI_Info::~UI_Info(){}; + + + +void Engine::Editor::UI_Info::uiControl(){ + if(Engine::Editor::guiSettings.infoWindowOn){ + Engine::Utils::Logger::get().info("UI", "Opening Info Gui"); + gui.addWindow("Info Gui", ui()); + } + else{ + Engine::Utils::Logger::get().info("UI", "Closing Info GUI"); + gui.deleteWindow("Info Gui"); + }; +}; + + + +inline void Engine::Editor::UI_Info::guiInfo(){ + ImGui::SeparatorText("Info"); + ImGui::Text("FPS: %f", fps); + + ImGui::Text("Current camera: %s", scene.debug_camera_on ? "Debug" : "Normal"); + + ImGui::Text("Camera:"); + ImGui::Text("Name: %s", scene.camera_controller.getActiveCameraName().c_str()); + ImGui::InputFloat3("Camera POS: [%f, %f, %f]", &scene.camera_controller.getActiveCamera().getPosition()[0]); + ImGui::SliderFloat3("Camera DIR: [%f, %f, %f]", &scene.camera_controller.getActiveCamera().getDirection()[0], -1, 1); + + ImGui::Text("Debug Camera:"); + glm::vec3 debug_cam_pos = scene.debug_camera.getPosition(); + glm::vec3 debug_cam_dir = scene.debug_camera.getDirection(); + + ImGui::InputFloat3("Debug POS: [%f, %f, %f]", &debug_cam_pos[0]); + ImGui::SliderFloat3("Debug DIR: [%f, %f, %f]", &debug_cam_dir[0], -1, 1); + + scene.debug_camera.setPosition(debug_cam_pos); + scene.debug_camera.setDirection(debug_cam_dir); + + if(ImGui::Checkbox("Mesh mode", &Engine::Editor::guiSettings.mesh_mode_on)) mesh_mode_is_updated = false; + if(!mesh_mode_is_updated){ + mesh_mode_is_updated = true; + if(Engine::Editor::guiSettings.mesh_mode_on){ + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + Engine::Utils::Logger::get().info("UI", "Changed Draw Mode To Mesh"); + } + else{ + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + Engine::Utils::Logger::get().info("UI", "Changed Draw Mode To Normal"); + }; + }; + + if(ImGui::Checkbox("Post Processing", &scene.post_processing_on)); + if(ImGui::Checkbox("Shadows", &scene.shadows_on)); +}; + + + +void Engine::Editor::UI_Info::guiControlsInfo(){ + ImGui::SeparatorText("Controls Info"); + + ImGui::Text("- Swap Camera: %s", Engine::Config::SWAP_CAMERA_BTN.c_str()); + ImGui::Text("- Swap Camera Mode: %s", Engine::Config::CAMERA_SWAP_MODE_BTN.c_str()); + ImGui::Text("- Camera Accelerate: %s", Engine::Config::CAMERA_ACCELERATE.c_str()); + ImGui::Text("- Camera Decelerate: %s", Engine::Config::CAMERA_DECELERATE.c_str()); + ImGui::Text("- Move Forward: %s", Engine::Config::CAMERA_MOVE_FORWARD.c_str()); + ImGui::Text("- Move Back: %s", Engine::Config::CAMERA_MOVE_BACK.c_str()); + ImGui::Text("- Move Right: %s", Engine::Config::CAMERA_MOVE_RIGHT.c_str()); + ImGui::Text("- Move Left: %s", Engine::Config::CAMERA_MOVE_LEFT.c_str()); +}; + + + +inline std::function Engine::Editor::UI_Info::ui(){ +return [this](CW::Renderer::iRenderer *window){ + guiControlsInfo(); + guiInfo(); +}; +}; + +#endif diff --git a/Engine/UI/UI_Info.h b/Engine/Editor/Editor/UI/UI_Info.h similarity index 80% rename from Engine/UI/UI_Info.h rename to Engine/Editor/Editor/UI/UI_Info.h index 5a70331..d3d4c00 100644 --- a/Engine/UI/UI_Info.h +++ b/Engine/Editor/Editor/UI/UI_Info.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -19,17 +19,17 @@ #include "Scene.h" -namespace UW{ +namespace Engine::Editor{ class UI_Info{ private: float &fps; bool mesh_mode_is_updated = false; - UW::Scene& scene; + Engine::Core::Scene& scene; CW::Gui::Gui& gui; public: - UI_Info(CW::Gui::Gui& gui, float &fps, UW::Scene& scene); + UI_Info(CW::Gui::Gui& gui, float &fps, Engine::Core::Scene& scene); ~UI_Info(); void uiControl(); diff --git a/Engine/UI/UI_Lights.cpp b/Engine/Editor/Editor/UI/UI_Lights.cpp similarity index 50% rename from Engine/UI/UI_Lights.cpp rename to Engine/Editor/Editor/UI/UI_Lights.cpp index fa31206..2b6b9af 100644 --- a/Engine/UI/UI_Lights.cpp +++ b/Engine/Editor/Editor/UI/UI_Lights.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,35 +11,35 @@ -UW::UI_Lights::UI_Lights(CW::Gui::Gui& gui) +Engine::Editor::UI_Lights::UI_Lights(CW::Gui::Gui& gui) :gui(gui){}; -UW::UI_Lights::~UI_Lights(){ +Engine::Editor::UI_Lights::~UI_Lights(){ }; -void UW::UI_Lights::uiControl(){ - if(guiSettings.lightsExplorerOn){ - Logger::get().info("UI", "Opening Lights Explorer GUI"); +void Engine::Editor::UI_Lights::uiControl(){ + if(Engine::Editor::guiSettings.lightsExplorerOn){ + Engine::Utils::Logger::get().info("UI", "Opening Lights Explorer GUI"); gui.addWindow("Lights Editor", ui()); } else{ - Logger::get().info("UI", "Closing Lights Explorer GUI"); + Engine::Utils::Logger::get().info("UI", "Closing Lights Explorer GUI"); gui.deleteWindow("Lights Editor"); }; }; -void UW::UI_Lights::guiLights(){ +void Engine::Editor::UI_Lights::guiLights(){ ImGui::SeparatorText("Lights"); bool lights_updated = false; - for(unsigned int i = 0; i < Resources::get().lights.size(); i++){ - UW::Light& light = Resources::get().lights[i]; + for(unsigned int i = 0; i < Engine::Core::Resources::get().lights.size(); i++){ + Engine::Core::Light& light = Engine::Core::Resources::get().lights[i]; std::string label = "light: (" + std::to_string(i) + ")"; ImGui::Text(label.c_str()); if(ImGui::InputFloat3(("position: [%f, %f, %f] ##" + std::to_string(i)).c_str(), &light.position[0])) lights_updated = true; @@ -48,30 +48,30 @@ void UW::UI_Lights::guiLights(){ std::string delete_light_label = "Delete ##(" + std::to_string(i) + ")"; if(ImGui::Button(delete_light_label.c_str())) { - Resources::get().lights.erase(i); - Logger::get().info("UI", "Deleted Light at {" + std::to_string(i) + "}"); + Engine::Core::Resources::get().lights.erase(i); + Engine::Utils::Logger::get().info("UI", "Deleted Light at {" + std::to_string(i) + "}"); lights_updated = true; }; ImGui::Separator(); }; - std::string add_light_label = "Add Light ##(" + std::to_string(Resources::get().lights.size()) + ")"; + std::string add_light_label = "Add Light ##(" + std::to_string(Engine::Core::Resources::get().lights.size()) + ")"; if(ImGui::Button(add_light_label.c_str())) { - Resources::get().lights.emplace_back(UW::Light({0, 0, 0}, {1, 1, 1}, 1)); - Logger::get().info("UI", "Added Light at {" + std::to_string(Resources::get().lights.size()) + "}"); + Engine::Core::Resources::get().lights.emplace_back(Engine::Core::Light({0, 0, 0}, {1, 1, 1}, 1)); + Engine::Utils::Logger::get().info("UI", "Added Light at {" + std::to_string(Engine::Core::Resources::get().lights.size()) + "}"); lights_updated = true; }; if(lights_updated){ - DataSerializer::get().saveAllLights(Resources::get().lights); - Logger::get().info("UI", "Lights saved"); + DataSerializer::get().saveAllLights(Engine::Core::Resources::get().lights); + Engine::Utils::Logger::get().info("UI", "Lights saved"); }; }; -std::function UW::UI_Lights::ui(){ +std::function Engine::Editor::UI_Lights::ui(){ return [this](CW::Renderer::iRenderer *window){ guiLights(); }; diff --git a/Engine/UI/UI_Lights.h b/Engine/Editor/Editor/UI/UI_Lights.h similarity index 89% rename from Engine/UI/UI_Lights.h rename to Engine/Editor/Editor/UI/UI_Lights.h index 73af461..44f2f15 100644 --- a/Engine/UI/UI_Lights.h +++ b/Engine/Editor/Editor/UI/UI_Lights.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -13,7 +13,7 @@ #include -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" #include "Resources/Resources.h" #include "DataSerializer/DataSerializer.h" @@ -22,7 +22,7 @@ -namespace UW{ +namespace Engine::Editor{ class UI_Lights{ private: CW::Gui::Gui& gui; diff --git a/Engine/UI/UI_Logs.cpp b/Engine/Editor/Editor/UI/UI_Logs.cpp similarity index 53% rename from Engine/UI/UI_Logs.cpp rename to Engine/Editor/Editor/UI/UI_Logs.cpp index 2aa4d32..4eea251 100644 --- a/Engine/UI/UI_Logs.cpp +++ b/Engine/Editor/Editor/UI/UI_Logs.cpp @@ -1,41 +1,41 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. -#include "UI_Log.h" +#include "UI_Logs.h" #ifndef PRODUCTION -UW::UI_Log::UI_Log(CW::Gui::Gui &gui) +Engine::Editor::UI_Log::UI_Log(CW::Gui::Gui &gui) :gui(gui){}; -UW::UI_Log::~UI_Log(){ +Engine::Editor::UI_Log::~UI_Log(){ }; -void UW::UI_Log::uiControl(){ - if(guiSettings.logWindowOn){ - Logger::get().info("UI", "Opening Log GUI"); +void Engine::Editor::UI_Log::uiControl(){ + if(Engine::Editor::guiSettings.logWindowOn){ + Engine::Utils::Logger::get().info("UI", "Opening Log GUI"); gui.addWindow("Log Gui", ui()); } else{ - Logger::get().info("UI", "Closing Log GUI"); + Engine::Utils::Logger::get().info("UI", "Closing Log GUI"); gui.deleteWindow("Log Gui"); }; }; -void UW::UI_Log::guiLogs() { - const auto& logs = Logger::get().getLogs(); +void Engine::Editor::UI_Log::guiLogs() { + const auto& logs = Engine::Utils::Logger::get().getLogs(); int totalItems = static_cast(logs.size()); ImGuiListClipper clipper; @@ -44,7 +44,8 @@ void UW::UI_Log::guiLogs() { while (clipper.Step()) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { const auto& entry = logs[i]; - ImGui::PushStyleColor(ImGuiCol_Text, entry.getLogColor()); + std::array color = entry.getLogColor(); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(color[0], color[1], color[2], color[3])); ImGui::TextUnformatted(entry.getText().c_str()); ImGui::PopStyleColor(); }; @@ -55,7 +56,7 @@ void UW::UI_Log::guiLogs() { -std::function UW::UI_Log::ui(){ +std::function Engine::Editor::UI_Log::ui(){ return [this](CW::Renderer::iRenderer *window){ guiLogs(); }; diff --git a/Engine/UI/UI_Log.h b/Engine/Editor/Editor/UI/UI_Logs.h similarity index 91% rename from Engine/UI/UI_Log.h rename to Engine/Editor/Editor/UI/UI_Logs.h index 79add08..37568eb 100644 --- a/Engine/UI/UI_Log.h +++ b/Engine/Editor/Editor/UI/UI_Logs.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -19,7 +19,7 @@ -namespace UW{ +namespace Engine::Editor{ class UI_Log{ private: CW::Gui::Gui& gui; diff --git a/Engine/Editor/Editor/UI/UI_Materials.cpp b/Engine/Editor/Editor/UI/UI_Materials.cpp new file mode 100644 index 0000000..58cbdc0 --- /dev/null +++ b/Engine/Editor/Editor/UI/UI_Materials.cpp @@ -0,0 +1,119 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "UI_Materials.h" + +#ifndef PRODUCTION + + + +Engine::Editor::UI_Materials::UI_Materials(CW::Gui::Gui& gui) + :gui(gui){}; + + + +Engine::Editor::UI_Materials::~UI_Materials(){ +}; + + + +void Engine::Editor::UI_Materials::uiControl(){ + if(Engine::Editor::guiSettings.materialExplorerOn){ + Engine::Utils::Logger::get().info("UI", "Opening Materials Explorer GUI"); + gui.addWindow("Material Explorer", materialExplorerGui()); + } + else{ + Engine::Utils::Logger::get().info("UI", "Closing Materials Explorer GUI"); + gui.deleteWindow("Material Explorer"); + }; + + if(Engine::Editor::guiSettings.materialEditorOn){ + Engine::Utils::Logger::get().info("UI", "Opening Materials Editor GUI"); + gui.addWindow("Material Editor", materialEditorGui()); + } + else{ + Engine::Utils::Logger::get().info("UI", "Closing Materials Editor GUI"); + gui.deleteWindow("Material Editor"); + }; +}; + + + +inline void Engine::Editor::UI_Materials::guiMaterialList(){ + ImGui::SeparatorText("Materials List"); + + for (std::pair el : Engine::Core::Resources::get().materials.getMaterialReg()) { + std::string button_label = "- " + el.first; + if (ImGui::Button(button_label.c_str())) Engine::Editor::guiSettings.material_name = el.first; + + button_label = "Delete ##" + el.first; + ImGui::SameLine(); + if (ImGui::Button(button_label.c_str())) { + Engine::Core::Resources::get().materials.erase(el.first); + Engine::Utils::Logger::get().warn("UI", "Deleted Material { " + el.first + " }"); + break; + }; + }; + + std::string button_label = "Add " + std::to_string(Engine::Core::Resources::get().materials.size()); + if (ImGui::Button(button_label.c_str())) { + Engine::Core::Resources::get().materials.emplace_back("new material", Engine::Core::Material()); + Engine::Utils::Logger::get().info("UI", "Added new Material { new material }"); + }; +}; + + + +inline std::function Engine::Editor::UI_Materials::materialExplorerGui(){ +return [this](CW::Renderer::iRenderer *window){ + guiMaterialList(); +}; +}; + + + +inline void Engine::Editor::UI_Materials::guiMaterialParameters(){ + ImGui::SeparatorText("Materials Parameters"); + ImGui::Text("Material id: %s", Engine::Editor::guiSettings.material_name.c_str()); + + if(!Engine::Core::Resources::get().materials.find(guiSettings.material_name)) return; + + Engine::Core::Material temp_mat = Engine::Core::Resources::get().materials.getMaterial(guiSettings.material_name); + + char name_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; + memcpy(name_buffer, guiSettings.material_name.data(), guiSettings.material_name.size()); + name_buffer[guiSettings.material_name.size()] = '\0'; + if(ImGui::InputText("name", name_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + Engine::Core::Resources::get().materials.erase(guiSettings.material_name); + guiSettings.material_name = std::string(name_buffer + '\0'); + Engine::Core::Resources::get().materials.emplace_back(guiSettings.material_name, temp_mat); + }; + + if(ImGui::ColorEdit3("Albedo: ", &temp_mat.albedo[0])) material_is_updated = true; + if(ImGui::SliderFloat("Roughness: ", &temp_mat.roughness, 0.0f, 1.0f)) material_is_updated = true; + if(ImGui::SliderFloat("Metallic: ", &temp_mat.metallic, 0.0f, 1.0f)) material_is_updated = true; + if(ImGui::ColorEdit3("Emission Color: ", &temp_mat.emission_color[0])) material_is_updated = true; + if(ImGui::SliderFloat("Emission Strength: ", &temp_mat.emission_strength, 0.0f, 1.0f)) material_is_updated = true; + if(ImGui::SliderFloat("Ambient Occlusion: ", &temp_mat.ambient_occlusion, 0.0f, 1.0f)) material_is_updated = true; + + if(material_is_updated){ + Engine::Utils::Logger::get().info("UI", "Updating Material { " + guiSettings.material_name + " }"); + material_is_updated = false; + Engine::Core::Resources::get().materials[guiSettings.material_name] = temp_mat; + Engine::Core::Resources::get().materials.compile(); + }; +}; + + + +std::function Engine::Editor::UI_Materials::materialEditorGui(){ + return [this](CW::Renderer::iRenderer *window){ + guiMaterialParameters(); + }; +}; + +#endif diff --git a/Engine/UI/UI_Materials.h b/Engine/Editor/Editor/UI/UI_Materials.h similarity index 93% rename from Engine/UI/UI_Materials.h rename to Engine/Editor/Editor/UI/UI_Materials.h index 42a7d3a..bcb8241 100644 --- a/Engine/UI/UI_Materials.h +++ b/Engine/Editor/Editor/UI/UI_Materials.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -18,7 +18,7 @@ -namespace UW{ +namespace Engine::Editor{ class UI_Materials{ private: CW::Gui::Gui& gui; diff --git a/Engine/Editor/Editor/UI/UI_Objects.cpp b/Engine/Editor/Editor/UI/UI_Objects.cpp new file mode 100644 index 0000000..f4d9a65 --- /dev/null +++ b/Engine/Editor/Editor/UI/UI_Objects.cpp @@ -0,0 +1,613 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "UI_Objects.h" + +#ifndef PRODUCTION + + + +Engine::Editor::UI_Objects::UI_Objects(CW::Gui::Gui& gui, CW::Renderer::Renderer& window, Engine::Core::Scene& scene) + :gui(gui), window(window), scene(scene) {}; + + + +Engine::Editor::UI_Objects::~UI_Objects(){ +}; + + + +void Engine::Editor::UI_Objects::uiControl(){ + if(Engine::Editor::guiSettings.objectExplorerWindowOn){ + Engine::Utils::Logger::get().info("UI", "Opening Object Explorer GUI"); + gui.addWindow("Object Explorer", objectExplorerGui()); + } + else{ + Engine::Utils::Logger::get().info("UI", "Closing Object Explorer GUI"); + gui.deleteWindow("Object Explorer"); + }; + + if(Engine::Editor::guiSettings.objectEditorWindowOn){ + Engine::Utils::Logger::get().info("UI", "Opening Object Editor GUI"); + gui.addWindow("Object Editor", objectEditorGui()); + } + else{ + Engine::Utils::Logger::get().info("UI", "Closing Object Explorer GUI"); + gui.deleteWindow("Object Editor"); + }; +}; + + + +void Engine::Editor::UI_Objects::guiObjectList(){ + ImGui::SeparatorText("Object List"); + + for(unsigned int id = 0; id < Engine::ObjectManager::get().objects.size(); id++){ + if(Engine::ObjectManager::get().objects[id].copy_game_object_data.hidden) continue; + + std::string label = "- " + Engine::ObjectManager::get().objects[id].game_object_data.name + "##(" + std::to_string(id) + ")"; + if(ImGui::Button(label.c_str())) guiSettings.object_id = id; + + label = "Delete##" + std::to_string(id); + ImGui::SameLine(); + if(ImGui::Button(label.c_str())) { + Engine::ObjectManager::get().objects.erase(Engine::ObjectManager::get().objects.begin() + id); + Engine::Utils::Logger::get().warn("UI", "Deleted Object { " + Engine::ObjectManager::get().objects[id].game_object_data.name + " }"); + }; + + label = "Duplicate##" + std::to_string(id); + ImGui::SameLine(); + if(ImGui::Button(label.c_str())) { + Engine::ObjectManager::get().objects.emplace_back(Engine::Core::GameObject(Engine::ObjectManager::get().objects[id].game_object_data.name + "_copy", Engine::ObjectManager::get().objects[id])); + Engine::Utils::Logger::get().warn("UI", "Duplicated Object { " + Engine::ObjectManager::get().objects[id].game_object_data.name + " }"); + }; + }; + + if(ImGui::Button("Add new")) { + Engine::ObjectManager::get().objects.emplace_back(Engine::Core::GameObject("new object", "testing", "testing", {}, {}, {}, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f), glm::vec3(1.0f))); + Engine::Utils::Logger::get().info("UI", "Added New Object { new object }"); + }; +}; + + + +std::function Engine::Editor::UI_Objects::objectExplorerGui(){ +return [this](CW::Renderer::iRenderer *window){ + guiObjectList(); +}; +}; + + + +void Engine::Editor::UI_Objects::guiObjectEditor(){ + ImGui::SeparatorText("Object Editor"); + if(guiSettings.object_id >= Engine::ObjectManager::get().objects.size()) return; + + Engine::Core::GameObject& object = Engine::ObjectManager::get().objects[guiSettings.object_id]; + + char name_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; + memcpy(name_buffer, object.game_object_data.name.data(), object.game_object_data.name.size()); + name_buffer[object.game_object_data.name.size()] = '\0'; + if(ImGui::InputText("name", name_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + object.stopScripts(); + object.game_object_data.name = std::string(name_buffer + '\0'); + object.startScripts(scene); + }; + + char mesh_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; + memcpy(mesh_buffer, object.game_object_data.mesh.data(), object.game_object_data.mesh.size()); + mesh_buffer[object.game_object_data.mesh.size()] = '\0'; + if(ImGui::InputText("mesh", mesh_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + if(!Engine::Core::Resources::get().meshes.exists(mesh_buffer)) return; + object.stopScripts(); + object.game_object_data.mesh = std::string(mesh_buffer + '\0'); + object.startScripts(scene); + }; + + char shader_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; + memcpy(shader_buffer, object.game_object_data.shader.data(), object.game_object_data.shader.size()); + shader_buffer[object.game_object_data.shader.size()] = '\0'; + if(ImGui::InputText("shader", shader_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + auto its = Engine::Core::Resources::get().shaders.find(shader_buffer); + if(its == Engine::Core::Resources::get().shaders.end()) return; + object.stopScripts(); + object.game_object_data.shader = std::string(shader_buffer + '\0'); + object.startScripts(scene); + }; + + + glm::vec3 new_position = object.game_object_data.position; + if(ImGui::InputFloat3("position: ", &new_position[0])) { + object.stopScripts(); + object.game_object_data.position = new_position; + object.startScripts(scene); + }; + + glm::vec3 position_offset = glm::vec3(0.0f); + if(ImGui::SliderFloat3("position slider: ", &position_offset[0], -10.0f, 10.0f)){ + object.stopScripts(); + object.game_object_data.position += position_offset * window.getWindowData()->delta_time; + object.startScripts(scene); + }; + + glm::vec3 new_rotation = object.game_object_data.rotation; + if(ImGui::InputFloat3("rotate: ", &new_rotation[0])){ + object.stopScripts(); + object.game_object_data.rotation = new_rotation; + object.startScripts(scene); + }; + + glm::vec3 rotate_offset = glm::vec3(0.0f); + if(ImGui::SliderFloat3("rotate slider: ", &rotate_offset[0], -1.0f, 1.0f)){ + object.stopScripts(); + object.game_object_data.rotation += rotate_offset * window.getWindowData()->delta_time; + object.startScripts(scene); + }; + + glm::vec3 new_scale = object.game_object_data.scale; + if(ImGui::InputFloat3("scale: ", &new_scale[0])){ + object.stopScripts(); + object.game_object_data.scale = new_scale; + object.startScripts(scene); + }; + + glm::vec3 scale_offset = glm::vec3(0.0f); + if(ImGui::SliderFloat3("scale slider: ", &scale_offset[0], -100.0f, 100.0f)){ + object.stopScripts(); + object.game_object_data.scale += scale_offset * window.getWindowData()->delta_time; + object.startScripts(scene); + }; + + bool culling_on = object.game_object_data.culling_on; + if(ImGui::Checkbox("Culling", &culling_on)){ + object.stopScripts(); + object.game_object_data.culling_on = culling_on; + object.startScripts(scene); + }; + + bool dont_write_to_depth_mask = object.game_object_data.dont_write_to_depth_mask; + if(ImGui::Checkbox("DontWriteToDepth", &dont_write_to_depth_mask)){ + object.stopScripts(); + object.game_object_data.dont_write_to_depth_mask = dont_write_to_depth_mask; + object.startScripts(scene); + }; + + bool gl_depth_lequal = object.game_object_data.gl_depth_lequal; + if(ImGui::Checkbox("DepthLEQ", &gl_depth_lequal)){ + object.stopScripts(); + object.game_object_data.gl_depth_lequal = gl_depth_lequal; + object.startScripts(scene); + }; + + bool gl_draw_patches = object.game_object_data.gl_draw_patches; + if(ImGui::Checkbox("DrawPatches", &gl_draw_patches)){ + object.stopScripts(); + object.game_object_data.gl_draw_patches = gl_draw_patches; + object.startScripts(scene); + }; + + bool gl_blend = object.game_object_data.gl_blend; + if(ImGui::Checkbox("Blend", &gl_blend)){ + object.stopScripts(); + object.game_object_data.gl_blend = gl_blend; + object.startScripts(scene); + }; + + bool gl_nearest = object.game_object_data.gl_nearest; + if(ImGui::Checkbox("Nearest", &gl_nearest)){ + object.stopScripts(); + object.game_object_data.gl_nearest = gl_nearest; + object.startScripts(scene); + }; + + + ImGui::SeparatorText("Textures: "); + for(int i = 0; i < object.game_object_data.textures.size(); i++){ + std::string label = "- texture (" + std::to_string(i) + ")"; + char texture_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; + memcpy(texture_buffer, object.game_object_data.textures[i].data(), object.game_object_data.textures[i].size()); + texture_buffer[object.game_object_data.textures[i].size()] = '\0'; + if(ImGui::InputText(label.c_str(), texture_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + object.stopScripts(); + object.game_object_data.textures[i] = std::string(texture_buffer + '\0'); + object.startScripts(scene); + }; + + ImGui::SameLine(); + label = "Delete texture##(" + std::to_string(i) + ")"; + if(ImGui::Button(label.c_str())) { + object.stopScripts(); + object.game_object_data.textures.erase(object.game_object_data.textures.begin() + i); + object.startScripts(scene); + }; + }; + + std::string label = "Add Texture (" + std::to_string(object.game_object_data.textures.size()) + ")"; + if(ImGui::Button(label.c_str())) { + object.stopScripts(); + object.game_object_data.textures.emplace_back(""); + object.startScripts(scene); + }; + + + ImGui::SeparatorText("Materials: "); + for(int i = 0; i < object.game_object_data.materials.size(); i++){ + std::string label = "- material (" + std::to_string(i) + ")"; + + char material_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; + memcpy(material_buffer, object.game_object_data.materials[i].data(), object.game_object_data.materials[i].size()); + material_buffer[object.game_object_data.materials[i].size()] = '\0'; + if(ImGui::InputText(label.c_str(), material_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + object.stopScripts(); + if(!Engine::Core::Resources::get().materials.find(material_buffer)) return; + object.game_object_data.materials[i] = std::string(material_buffer + '\0'); + object.startScripts(scene); + }; + + ImGui::SameLine(); + label = "Delete material##(" + std::to_string(i) + ")"; + if(ImGui::Button(label.c_str())) { + object.stopScripts(); + object.game_object_data.materials.erase(object.game_object_data.materials.begin() + i); + object.startScripts(scene); + } + }; + + label = "Add material (" + std::to_string(object.game_object_data.materials.size()) + ")"; + if(ImGui::Button(label.c_str())) { + object.stopScripts(); + object.game_object_data.materials.emplace_back("new material"); + object.startScripts(scene); + }; + + + ImGui::SeparatorText("Scripts: "); + for(int i = 0; i < object.scripts.size(); i++){ + bool new_script_on = object.scripts[i].script_on; + if(ImGui::Checkbox(std::string("##ScriptOn(" + std::to_string(i) + ")").c_str(), &new_script_on)){ + object.stopScripts(); + object.scripts[i].script_on = new_script_on; + object.startScripts(scene); + }; + + ImGui::SameLine(); + std::string label = "- script (" + std::to_string(i) + ")"; + + char script_buffer[Engine::Config::OBJECT_NAME_BUFFER_SIZE]; + memcpy(script_buffer, object.scripts[i].getPath().data(), object.scripts[i].getPath().size()); + script_buffer[object.scripts[i].getPath().size()] = '\0'; + if(ImGui::InputText(label.c_str(), script_buffer, Engine::Config::OBJECT_NAME_BUFFER_SIZE)){ + object.stopScripts(); + object.scripts[i] = Engine::Core::Script::GameObjectScriptRecord(std::string(script_buffer + '\0')); + object.scripts[i].script_on = new_script_on; + object.startScripts(scene); + } + + ImGui::SameLine(); + label = "Delete scripts##(" + std::to_string(i) + ")"; + if(ImGui::Button(label.c_str())) { + object.stopScripts(); + object.scripts.erase(object.scripts.begin() + i); + object.startScripts(scene); + }; + }; + + label = "Add script (" + std::to_string(object.scripts.size()) + ")"; + if(ImGui::Button(label.c_str())) { + object.stopScripts(); + object.scripts.emplace_back(Engine::Core::Script::GameObjectScriptRecord("new script")); + object.startScripts(scene); + }; + + + ImGui::SeparatorText("Parameters"); + + auto& params = object.game_object_data.parameters; + + for (auto it = params.begin(); it != params.end();) { + const std::string& current_name = it->first; + auto& param_value = it->second; + + ImGui::PushID(current_name.c_str()); + + bool delete_triggered = false; + bool rename_triggered = false; + char name_buffer[128]; + strncpy(name_buffer, current_name.c_str(), sizeof(name_buffer) - 1); + name_buffer[sizeof(name_buffer) - 1] = '\0'; + + ImGui::SetNextItemWidth(120.0f); + if (ImGui::InputText("##ParamName", name_buffer, sizeof(name_buffer), ImGuiInputTextFlags_EnterReturnsTrue)) { + rename_triggered = true; + } + if (ImGui::IsItemDeactivatedAfterEdit()) { + rename_triggered = true; + } + + ImGui::SameLine(); + + int current_type_idx = static_cast(param_value.index()); + ImGui::SetNextItemWidth(70.0f); + if (ImGui::Combo("##ParamType", ¤t_type_idx, Engine::ScriptShared::gameObjectParameterTypeName, IM_ARRAYSIZE(Engine::ScriptShared::gameObjectParameterTypeName))) { + object.stopScripts(); + switch (current_type_idx) { + case 0: param_value = 0; break; + case 1: param_value = 0.0f; break; + case 2: param_value = false; break; + case 3: param_value = glm::vec2(0.0f); break; + case 4: param_value = glm::vec3(0.0f); break; + case 5: param_value = std::string(""); break; + } + object.startScripts(scene); + ImGui::PopID(); + break; + } + + ImGui::SameLine(); + + std::visit([&object, this](auto&& arg) { + using T = std::decay_t; + ImGui::SetNextItemWidth(150.0f); + + if constexpr (std::is_same_v) { + int new_arg = arg; + if(ImGui::InputInt("##val", &new_arg)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + float new_arg = arg; + if(ImGui::DragFloat("##val", &new_arg, 0.05f)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + bool new_arg = arg; + if(ImGui::Checkbox("##val", &new_arg)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + glm::vec2 new_arg = arg; + if(ImGui::DragFloat2("##val", &new_arg.x, 0.05f)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + glm::vec3 new_arg = arg; + if(ImGui::DragFloat3("##val", &new_arg.x, 0.05f)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + char str_buffer[256]; + strncpy(str_buffer, arg.c_str(), sizeof(str_buffer) - 1); + str_buffer[sizeof(str_buffer) - 1] = '\0'; + if (ImGui::InputText("##val", str_buffer, sizeof(str_buffer))) { + object.stopScripts(); + arg = std::string(str_buffer); + object.startScripts(scene); + } + } + }, param_value); + + ImGui::SameLine(); + + if (ImGui::Button("Delete")) { + delete_triggered = true; + } + + ImGui::PopID(); + + if (delete_triggered) { + object.stopScripts(); + it = params.erase(it); + object.startScripts(scene); + } + else if (rename_triggered && std::string(name_buffer) != current_name && !std::string(name_buffer).empty()) { + std::string new_key = name_buffer; + + object.stopScripts(); + if (params.find(new_key) == params.end()) { + params[new_key] = std::move(param_value); + it = params.erase(it); + } else { + ++it; + } + object.startScripts(scene); + } + else { + ++it; + } + } + + ImGui::Spacing(); + + std::string add_label = "Add Parameter (" + std::to_string(params.size()) + ")"; + if (ImGui::Button(add_label.c_str())) { + object.stopScripts(); + std::string unique_new_name = "NewParameter_" + std::to_string(params.size()); + + int safety_counter = 0; + while(params.find(unique_new_name) != params.end()) { + unique_new_name = "NewParameter_" + std::to_string(params.size() + (++safety_counter)); + } + + params[unique_new_name] = 0; + object.startScripts(scene); + } + + + + ImGui::SeparatorText("Uniforms"); + + auto& uniforms = object.game_object_data.uniforms; + + for (auto it = uniforms.begin(); it != uniforms.end();) { + const std::string& current_name = it->first; + auto& uniform_value = it->second; + + ImGui::PushID(current_name.c_str()); + + bool delete_triggered = false; + bool rename_triggered = false; + char name_buffer[128]; + strncpy(name_buffer, current_name.c_str(), sizeof(name_buffer) - 1); + name_buffer[sizeof(name_buffer) - 1] = '\0'; + + ImGui::SetNextItemWidth(120.0f); + if (ImGui::InputText("##UniformName", name_buffer, sizeof(name_buffer), ImGuiInputTextFlags_EnterReturnsTrue)) { + rename_triggered = true; + } + if (ImGui::IsItemDeactivatedAfterEdit()) { + rename_triggered = true; + } + + ImGui::SameLine(); + + int current_type_idx = static_cast(uniform_value.index()); + ImGui::SetNextItemWidth(70.0f); + if (ImGui::Combo("##UniformType", ¤t_type_idx, Engine::ScriptShared::gameObjectParameterTypeName, IM_ARRAYSIZE(Engine::ScriptShared::gameObjectParameterTypeName))) { + object.stopScripts(); + switch (current_type_idx) { + case 0: uniform_value = 0; break; + case 1: uniform_value = 0.0f; break; + case 2: uniform_value = false; break; + case 3: uniform_value = glm::vec2(0.0f); break; + case 4: uniform_value = glm::vec3(0.0f); break; + case 5: uniform_value = std::string(""); break; + } + object.startScripts(scene); + + ImGui::PopID(); + break; + } + + ImGui::SameLine(); + + std::visit([&object, this](auto&& arg) { + using T = std::decay_t; + ImGui::SetNextItemWidth(150.0f); + + if constexpr (std::is_same_v) { + int new_arg = arg; + if(ImGui::InputInt("##val", &new_arg)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + float new_arg = arg; + if(ImGui::DragFloat("##val", &new_arg, 0.05f)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + bool new_arg = arg; + if(ImGui::Checkbox("##val", &new_arg)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + glm::vec2 new_arg = arg; + if(ImGui::DragFloat2("##val", &new_arg.x, 0.05f)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + glm::vec3 new_arg = arg; + if(ImGui::DragFloat3("##val", &new_arg.x, 0.05f)){ + object.stopScripts(); + arg = new_arg; + object.startScripts(scene); + } + } + else if constexpr (std::is_same_v) { + char str_buffer[256]; + strncpy(str_buffer, arg.c_str(), sizeof(str_buffer) - 1); + str_buffer[sizeof(str_buffer) - 1] = '\0'; + if (ImGui::InputText("##val", str_buffer, sizeof(str_buffer))) { + object.stopScripts(); + arg = std::string(str_buffer); + object.startScripts(scene); + } + } + }, uniform_value); + + ImGui::SameLine(); + + if (ImGui::Button("Delete")) { + delete_triggered = true; + } + + ImGui::PopID(); + + if (delete_triggered) { + object.stopScripts(); + it = uniforms.erase(it); + object.startScripts(scene); + } + else if (rename_triggered && std::string(name_buffer) != current_name && !std::string(name_buffer).empty()) { + std::string new_key = name_buffer; + + object.stopScripts(); + if (uniforms.find(new_key) == uniforms.end()) { + uniforms[new_key] = std::move(uniform_value); + it = uniforms.erase(it); + } else { + ++it; + } + object.startScripts(scene); + } + else { + ++it; + } + } + + ImGui::Spacing(); + + std::string uniform_add_label = "Add Uniform (" + std::to_string(uniforms.size()) + ")"; + if (ImGui::Button(uniform_add_label.c_str())) { + object.stopScripts(); + std::string unique_new_name = "NewUniform_" + std::to_string(uniforms.size()); + + int safety_counter = 0; + while(uniforms.find(unique_new_name) != uniforms.end()) { + unique_new_name = "NewUniform_" + std::to_string(uniforms.size() + (++safety_counter)); + } + + uniforms[unique_new_name] = 0; + object.startScripts(scene); + } +}; + + + +std::function Engine::Editor::UI_Objects::objectEditorGui(){ + return [this](CW::Renderer::iRenderer *window){ + guiObjectEditor(); + }; +}; + +#endif diff --git a/Engine/UI/UI_Objects.h b/Engine/Editor/Editor/UI/UI_Objects.h similarity index 88% rename from Engine/UI/UI_Objects.h rename to Engine/Editor/Editor/UI/UI_Objects.h index 45a7fb6..3af6c07 100644 --- a/Engine/UI/UI_Objects.h +++ b/Engine/Editor/Editor/UI/UI_Objects.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -22,16 +22,16 @@ -namespace UW{ +namespace Engine::Editor{ class UI_Objects{ private: CW::Renderer::Renderer& window; CW::Gui::Gui& gui; - UW::Scene& scene; + Engine::Core::Scene& scene; public: - UI_Objects(CW::Gui::Gui& gui, CW::Renderer::Renderer& window, UW::Scene& scene); + UI_Objects(CW::Gui::Gui& gui, CW::Renderer::Renderer& window, Engine::Core::Scene& scene); ~UI_Objects(); void uiControl(); diff --git a/Engine/UI/UI_ScriptEditor.cpp b/Engine/Editor/Editor/UI/UI_ScriptEditor.cpp similarity index 55% rename from Engine/UI/UI_ScriptEditor.cpp rename to Engine/Editor/Editor/UI/UI_ScriptEditor.cpp index d378696..7d50288 100644 --- a/Engine/UI/UI_ScriptEditor.cpp +++ b/Engine/Editor/Editor/UI/UI_ScriptEditor.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -10,12 +10,12 @@ -UW::UI_ScriptEditor::UI_ScriptEditor(CW::Gui::Gui& gui, const std::string& name) +Engine::Editor::UI_ScriptEditor::UI_ScriptEditor(CW::Gui::Gui& gui, const std::string& name) :gui(gui), script_name(name){ - Logger::get().info("UI_ScriptEditor", "Opened { " + script_name + " }"); + Engine::Utils::Logger::get().info("UI_ScriptEditor", "Opened { " + script_name + " }"); - save_cooldown_duration = std::chrono::milliseconds(static_cast(UW::Config::SCRIPT_SAVE_COOLDOWN * 1000.0f)); + save_cooldown_duration = std::chrono::milliseconds(static_cast(Engine::Config::SCRIPT_SAVE_COOLDOWN * 1000.0f)); last_save_time = std::chrono::steady_clock::now(); gui.addWindow("Script Editor " + script_name, ScriptEditorGui()); @@ -23,44 +23,44 @@ UW::UI_ScriptEditor::UI_ScriptEditor(CW::Gui::Gui& gui, const std::string& name) -UW::UI_ScriptEditor::~UI_ScriptEditor(){ +Engine::Editor::UI_ScriptEditor::~UI_ScriptEditor(){ if (script_is_updated) { DataSerializer::get().saveScript(script_name, buffer); - Logger::get().info("UI_ScriptEditor", "Force saved on close: { " + script_name + " }"); + Engine::Utils::Logger::get().info("UI_ScriptEditor", "Force saved on close: { " + script_name + " }"); }; gui.deleteWindow("Script Editor " + script_name); - Logger::get().info("UI_ScriptEditor", "Closed { " + script_name + " }"); + Engine::Utils::Logger::get().info("UI_ScriptEditor", "Closed { " + script_name + " }"); }; -void UW::UI_ScriptEditor::guiScriptLoad(const std::string& name){ +void Engine::Editor::UI_ScriptEditor::guiScriptLoad(const std::string& name){ if(script_is_loaded) return; script_name = name; - memset(buffer, '\0', UW::Config::SCRIPT_EDITOR_BUFFER_SIZE); + memset(buffer, '\0', Engine::Config::SCRIPT_EDITOR_BUFFER_SIZE); std::string source = DataSerializer::get().loadScript(name); - size_t copy_size = std::min(source.size(), static_cast(UW::Config::SCRIPT_EDITOR_BUFFER_SIZE) - 1); + size_t copy_size = std::min(source.size(), static_cast(Engine::Config::SCRIPT_EDITOR_BUFFER_SIZE) - 1); memcpy(buffer, source.data(), copy_size); buffer[copy_size] = '\0'; - Logger::get().info("UI_ScriptEditor", "Loaded { " + script_name + " }"); + Engine::Utils::Logger::get().info("UI_ScriptEditor", "Loaded { " + script_name + " }"); script_is_loaded = true; }; -void UW::UI_ScriptEditor::guiScriptEditor(){ +void Engine::Editor::UI_ScriptEditor::guiScriptEditor(){ float width = ImGui::GetContentRegionAvail().x; float height = ImGui::GetContentRegionAvail().y - 50.0f; ImGui::SeparatorText("Script Editor"); ImGui::Text("Script: %s", script_name.c_str()); - if(ImGui::InputTextMultiline("##Script Content", buffer, UW::Config::SCRIPT_EDITOR_BUFFER_SIZE, ImVec2(width, height), ImGuiInputTextFlags_WordWrap)){ + if(ImGui::InputTextMultiline("##Script Content", buffer, Engine::Config::SCRIPT_EDITOR_BUFFER_SIZE, ImVec2(width, height), ImGuiInputTextFlags_WordWrap)){ script_is_updated = true; last_save_time = std::chrono::steady_clock::now(); }; @@ -71,7 +71,7 @@ void UW::UI_ScriptEditor::guiScriptEditor(){ if (now - last_save_time >= save_cooldown_duration) { DataSerializer::get().saveScript(script_name, buffer); - Logger::get().info("UI_ScriptEditor", "Auto-Saved { " + script_name + " }"); + Engine::Utils::Logger::get().info("UI_ScriptEditor", "Auto-Saved { " + script_name + " }"); last_save_time = now; script_is_updated = false; } @@ -80,7 +80,7 @@ void UW::UI_ScriptEditor::guiScriptEditor(){ -inline std::function UW::UI_ScriptEditor::ScriptEditorGui(){ +inline std::function Engine::Editor::UI_ScriptEditor::ScriptEditorGui(){ return [this](CW::Renderer::iRenderer *window){ guiScriptLoad(script_name); guiScriptEditor(); @@ -89,7 +89,7 @@ inline std::function UW::UI_ScriptEditor: -std::string UW::UI_ScriptEditor::getName(){ +std::string Engine::Editor::UI_ScriptEditor::getName(){ return script_name; }; diff --git a/Engine/UI/UI_ScriptEditor.h b/Engine/Editor/Editor/UI/UI_ScriptEditor.h similarity index 87% rename from Engine/UI/UI_ScriptEditor.h rename to Engine/Editor/Editor/UI/UI_ScriptEditor.h index f3758ce..d509e96 100644 --- a/Engine/UI/UI_ScriptEditor.h +++ b/Engine/Editor/Editor/UI/UI_ScriptEditor.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -14,20 +14,20 @@ #include #include -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" #include "Resources/Resources.h" #include "DataSerializer/DataSerializer.h" -namespace UW{ +namespace Engine::Editor{ class UI_ScriptEditor{ private: CW::Gui::Gui& gui; bool script_is_loaded = false; bool script_is_updated = false; - char buffer[UW::Config::SCRIPT_EDITOR_BUFFER_SIZE] = {0}; + char buffer[Engine::Config::SCRIPT_EDITOR_BUFFER_SIZE] = {0}; std::string script_name = ""; std::chrono::steady_clock::time_point last_save_time; std::chrono::steady_clock::duration save_cooldown_duration; diff --git a/Engine/UI/UI_Scripts.cpp b/Engine/Editor/Editor/UI/UI_Scripts.cpp similarity index 59% rename from Engine/UI/UI_Scripts.cpp rename to Engine/Editor/Editor/UI/UI_Scripts.cpp index 25ef5a3..9ba64ad 100644 --- a/Engine/UI/UI_Scripts.cpp +++ b/Engine/Editor/Editor/UI/UI_Scripts.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,7 +11,7 @@ -UW::UI_Scripts::UI_Scripts(CW::Gui::Gui& gui) +Engine::Editor::UI_Scripts::UI_Scripts(CW::Gui::Gui& gui) :gui(gui){ script_editors.reserve(20); @@ -19,41 +19,41 @@ UW::UI_Scripts::UI_Scripts(CW::Gui::Gui& gui) -UW::UI_Scripts::~UI_Scripts(){ +Engine::Editor::UI_Scripts::~UI_Scripts(){ }; -void UW::UI_Scripts::uiControl(){ - if(guiSettings.scriptsExplorerWindowOn){ - Logger::get().info("UI_Scripts", "Opening Script Explorer GUI"); +void Engine::Editor::UI_Scripts::uiControl(){ + if(Engine::Editor::guiSettings.scriptsExplorerWindowOn){ + Engine::Utils::Logger::get().info("UI_Scripts", "Opening Script Explorer GUI"); gui.addWindow("Script Explorer", scriptExplorerGui()); } else{ - Logger::get().info("UI_Scripts", "Closing Script Explorer GUI"); + Engine::Utils::Logger::get().info("UI_Scripts", "Closing Script Explorer GUI"); gui.deleteWindow("Script Explorer"); }; }; -void UW::UI_Scripts::loadScriptEditors(){ - Logger::get().info("UI_Scripts", "Loading Scripts Editors"); +void Engine::Editor::UI_Scripts::loadScriptEditors(){ + Engine::Utils::Logger::get().info("UI_Scripts", "Loading Scripts Editors"); script_editors.clear(); - for(std::string el : guiSettings.scripts_editors_reg){ + for(std::string el : Engine::Editor::guiSettings.scripts_editors_reg){ script_editors.emplace_back(std::make_unique(gui, el)); }; }; -void UW::UI_Scripts::saveScriptEditors(){ - Logger::get().info("UI_Scripts", "Saving Scripts Editors"); +void Engine::Editor::UI_Scripts::saveScriptEditors(){ + Engine::Utils::Logger::get().info("UI_Scripts", "Saving Scripts Editors"); - guiSettings.scripts_editors_reg.clear(); + Engine::Editor::guiSettings.scripts_editors_reg.clear(); for(const auto& el : script_editors){ if(el) guiSettings.scripts_editors_reg.emplace_back(el->getName()); }; @@ -61,11 +61,11 @@ void UW::UI_Scripts::saveScriptEditors(){ -std::vector UW::UI_Scripts::getAvailableScripts() { +std::vector Engine::Editor::UI_Scripts::getAvailableScripts() { std::vector script_files; - if (fs::exists(UW::Config::SCRIPTS_FOLDER) && fs::is_directory(UW::Config::SCRIPTS_FOLDER)) { - for (const auto& entry : fs::directory_iterator(UW::Config::SCRIPTS_FOLDER)) { + if (fs::exists(Engine::Config::SCRIPTS_FOLDER) && fs::is_directory(Engine::Config::SCRIPTS_FOLDER)) { + for (const auto& entry : fs::directory_iterator(Engine::Config::SCRIPTS_FOLDER)) { if (entry.is_regular_file() && entry.path().extension() == ".cpp") { script_files.push_back(entry.path().filename().string()); }; @@ -77,7 +77,7 @@ std::vector UW::UI_Scripts::getAvailableScripts() { -void UW::UI_Scripts::guiScriptList() { +void Engine::Editor::UI_Scripts::guiScriptList() { ImGui::SeparatorText("Scripts List"); auto available_scripts = getAvailableScripts(); @@ -112,7 +112,7 @@ void UW::UI_Scripts::guiScriptList() { -inline std::function UW::UI_Scripts::scriptExplorerGui(){ +inline std::function Engine::Editor::UI_Scripts::scriptExplorerGui(){ return [this](CW::Renderer::iRenderer *window){ guiScriptList(); }; diff --git a/Engine/UI/UI_Scripts.h b/Engine/Editor/Editor/UI/UI_Scripts.h similarity index 94% rename from Engine/UI/UI_Scripts.h rename to Engine/Editor/Editor/UI/UI_Scripts.h index ae71bf3..ea925f2 100644 --- a/Engine/UI/UI_Scripts.h +++ b/Engine/Editor/Editor/UI/UI_Scripts.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -28,7 +28,7 @@ namespace fs = std::filesystem; -namespace UW{ +namespace Engine::Editor{ class UI_Scripts{ private: CW::Gui::Gui& gui; diff --git a/Engine/Editor/Editor/UI/UI_ShaderEditors.cpp b/Engine/Editor/Editor/UI/UI_ShaderEditors.cpp new file mode 100644 index 0000000..b0874b3 --- /dev/null +++ b/Engine/Editor/Editor/UI/UI_ShaderEditors.cpp @@ -0,0 +1,105 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "UI_ShaderEditors.h" +#ifndef PRODUCTION + + + +Engine::Editor::UI_ShaderEditor::UI_ShaderEditor(CW::Gui::Gui& gui, const std::string& name, GLenum type) + :gui(gui), shader_name(name), shader_type(type){ + + Engine::Utils::Logger::get().info("UI_ShaderEditor", "Opened { " + shader_name + " : " + Engine::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); + gui.addWindow("Shader Editor " + shader_name + " : " + Engine::Config::SHADER_TYPE_TO_NAME[shader_type], shaderEditorGui()); +}; + + + +Engine::Editor::UI_ShaderEditor::~UI_ShaderEditor(){ + gui.deleteWindow("Shader Editor " + shader_name + " : " + Engine::Config::SHADER_TYPE_TO_NAME[shader_type]); + Engine::Utils::Logger::get().info("UI_ShaderEditor", "Closed { " + shader_name + " : " + Engine::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); +}; + + + +void Engine::Editor::UI_ShaderEditor::guiShaderLoad(const std::string& name, GLenum type){ + if(shader_is_loaded) return; + + shader_name = name; + shader_type = type; + memset(buffer, '\0', Engine::Config::SHADER_EDITOR_BUFFER_SIZE); + + auto it = Engine::Core::Resources::get().shaders.find(name); + if(it == Engine::Core::Resources::get().shaders.end()) return; + + const std::unordered_map& reg = Engine::Core::Resources::get().getShader(name).getRegisterShader(); + auto ita = reg.find(type); + if(ita == reg.end()) return; + + std::string source = reg.at(type).getSource(); + memcpy(buffer, source.data(), source.size()); + + + Engine::Utils::Logger::get().info("UI_ShaderEditor", "Loaded { " + shader_name + " : " + Engine::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); + shader_is_loaded = true; +}; + + + +void Engine::Editor::UI_ShaderEditor::guiShaderEditor(){ + float width = ImGui::GetContentRegionAvail().x; + float height = ImGui::GetContentRegionAvail().y - 50.0f; + + ImGui::SeparatorText("Shader Editor"); + ImGui::Text("Shader: %s : %s", shader_name.c_str(), Engine::Config::SHADER_TYPE_TO_NAME[shader_type].c_str()); + + ImGui::InputTextMultiline("##Shader Content", buffer, Engine::Config::SHADER_EDITOR_BUFFER_SIZE, ImVec2(width, height), ImGuiInputTextFlags_WordWrap); + + auto it = Engine::Core::Resources::get().shaders.find(shader_name); + if(it == Engine::Core::Resources::get().shaders.end()) return; + + auto& reg = Engine::Core::Resources::get().getShader(shader_name).getRegisterShader(); + auto it2 = reg.find(shader_type); + if(it2 == reg.end()) return; + + if(strcmp(buffer, reg.at(shader_type).getSource().c_str()) != 0) shader_is_updated = true; + + if(shader_is_updated){ + shader_is_updated = false; + + Engine::Core::Resources::get().getShader(shader_name).destroy(); + Engine::Core::Resources::get().getShader(shader_name).removeShaders(shader_type); + Engine::Core::Resources::get().getShader(shader_name).setShader(buffer, shader_type); + Engine::Core::Resources::get().getShader(shader_name).compile(); + DataSerializer::get().saveShaders(shader_name, shader_type); + + Engine::Utils::Logger::get().info("UI_ShaderEditor", "Saved { " + shader_name + " : " + Engine::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); + }; +}; + + + +inline std::function Engine::Editor::UI_ShaderEditor::shaderEditorGui(){ +return [this](CW::Renderer::iRenderer *window){ + guiShaderLoad(shader_name, shader_type); + guiShaderEditor(); +}; +}; + + + +std::string Engine::Editor::UI_ShaderEditor::getName(){ + return shader_name; +}; + + + +GLenum Engine::Editor::UI_ShaderEditor::getType(){ + return shader_type; +}; + +#endif diff --git a/Engine/UI/UI_ShaderEditors.h b/Engine/Editor/Editor/UI/UI_ShaderEditors.h similarity index 86% rename from Engine/UI/UI_ShaderEditors.h rename to Engine/Editor/Editor/UI/UI_ShaderEditors.h index dbe1c06..86febe5 100644 --- a/Engine/UI/UI_ShaderEditors.h +++ b/Engine/Editor/Editor/UI/UI_ShaderEditors.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -13,20 +13,20 @@ #include -#include "config.h" +#include "Utils/config.h" #include "Utils/Logger.h" #include "Resources/Resources.h" #include "DataSerializer/DataSerializer.h" -namespace UW{ +namespace Engine::Editor{ class UI_ShaderEditor{ private: CW::Gui::Gui& gui; bool shader_is_loaded = false; bool shader_is_updated = false; - char buffer[UW::Config::SHADER_EDITOR_BUFFER_SIZE] = {0}; + char buffer[Engine::Config::SHADER_EDITOR_BUFFER_SIZE] = {0}; std::string shader_name = ""; GLenum shader_type = 0; diff --git a/Engine/UI/UI_Shaders.cpp b/Engine/Editor/Editor/UI/UI_Shaders.cpp similarity index 57% rename from Engine/UI/UI_Shaders.cpp rename to Engine/Editor/Editor/UI/UI_Shaders.cpp index 8c9090a..a10ad9f 100644 --- a/Engine/UI/UI_Shaders.cpp +++ b/Engine/Editor/Editor/UI/UI_Shaders.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,7 +11,7 @@ -UW::UI_Shaders::UI_Shaders(CW::Gui::Gui& gui) +Engine::Editor::UI_Shaders::UI_Shaders(CW::Gui::Gui& gui) :gui(gui){ shader_editors.reserve(20); @@ -19,40 +19,40 @@ UW::UI_Shaders::UI_Shaders(CW::Gui::Gui& gui) -UW::UI_Shaders::~UI_Shaders(){ +Engine::Editor::UI_Shaders::~UI_Shaders(){ }; -void UW::UI_Shaders::uiControl(){ - if(guiSettings.shaderExplorerWindowOn){ - Logger::get().info("UI", "Opening Shader Explorer GUI"); +void Engine::Editor::UI_Shaders::uiControl(){ + if(Engine::Editor::guiSettings.shaderExplorerWindowOn){ + Engine::Utils::Logger::get().info("UI", "Opening Shader Explorer GUI"); gui.addWindow("Shader Explorer", shaderExplorerGui()); } else{ - Logger::get().info("UI", "Closing Shader Explorer GUI"); + Engine::Utils::Logger::get().info("UI", "Closing Shader Explorer GUI"); gui.deleteWindow("Shader Explorer"); }; }; -void UW::UI_Shaders::loadShaderEditors(){ - Logger::get().info("UI", "Loading Shader Editors"); +void Engine::Editor::UI_Shaders::loadShaderEditors(){ + Engine::Utils::Logger::get().info("UI", "Loading Shader Editors"); shader_editors.clear(); - for(std::pair el : guiSettings.shader_editors_reg){ + for(std::pair el : Engine::Editor::guiSettings.shader_editors_reg){ shader_editors.emplace_back(std::make_unique(gui, el.first, el.second)); }; }; -void UW::UI_Shaders::saveShaderEditors(){ - Logger::get().info("UI", "Saving Shader Editors"); +void Engine::Editor::UI_Shaders::saveShaderEditors(){ + Engine::Utils::Logger::get().info("UI", "Saving Shader Editors"); - guiSettings.shader_editors_reg.clear(); + Engine::Editor::guiSettings.shader_editors_reg.clear(); for(const auto& el : shader_editors){ guiSettings.shader_editors_reg.emplace_back(el->getName(), el->getType()); }; @@ -60,18 +60,18 @@ void UW::UI_Shaders::saveShaderEditors(){ -void UW::UI_Shaders::guiShaderList(){ +void Engine::Editor::UI_Shaders::guiShaderList(){ ImGui::SeparatorText("Shader List"); if(ImGui::Button("reset")) { - Logger::get().info("UI", "Refreshing Shaders"); - Resources::get().shaders.clear(); + Engine::Utils::Logger::get().info("UI", "Refreshing Shaders"); + Engine::Core::Resources::get().shaders.clear(); }; - for (const auto& [ key, values ] : Resources::get().shaders) { + for (const auto& [ key, values ] : Engine::Core::Resources::get().shaders) { if(ImGui::CollapsingHeader(key.c_str())){ for (const auto& [key_s, values_s] : values.getRegisterShader()){ - std::string button_label = UW::Config::SHADER_TYPE_TO_NAME[key_s] + "##-" + key; + std::string button_label = Engine::Config::SHADER_TYPE_TO_NAME[key_s] + "##-" + key; if (ImGui::Button(button_label.c_str())){ bool exists = std::any_of( shader_editors.begin(), @@ -96,7 +96,7 @@ void UW::UI_Shaders::guiShaderList(){ }; }; -inline std::function UW::UI_Shaders::shaderExplorerGui(){ +inline std::function Engine::Editor::UI_Shaders::shaderExplorerGui(){ return [this](CW::Renderer::iRenderer *window){ guiShaderList(); }; diff --git a/Engine/UI/UI_Shaders.h b/Engine/Editor/Editor/UI/UI_Shaders.h similarity index 94% rename from Engine/UI/UI_Shaders.h rename to Engine/Editor/Editor/UI/UI_Shaders.h index ce330b4..8453da9 100644 --- a/Engine/UI/UI_Shaders.h +++ b/Engine/Editor/Editor/UI/UI_Shaders.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -22,7 +22,7 @@ -namespace UW{ +namespace Engine::Editor{ class UI_Shaders{ private: CW::Gui::Gui& gui; diff --git a/Engine/Editor/Editor/UI/UI_Viewport.cpp b/Engine/Editor/Editor/UI/UI_Viewport.cpp new file mode 100644 index 0000000..a3e4f02 --- /dev/null +++ b/Engine/Editor/Editor/UI/UI_Viewport.cpp @@ -0,0 +1,57 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "UI_Viewport.h" + +#ifndef PRODUCTION + + + +Engine::Editor::UI_Viewport::UI_Viewport(CW::Gui::Gui &gui, CW::Renderer::Framebuffer& viewport_fbo) + :viewport_fbo(viewport_fbo), gui(gui){}; + + + +Engine::Editor::UI_Viewport::~UI_Viewport(){ +}; + + + +void Engine::Editor::UI_Viewport::uiControl(){ + if(Engine::Editor::guiSettings.viewportWindowOn){ + Engine::Utils::Logger::get().info("UI", "Opening Viewport Gui"); + gui.addWindow("Viewport Gui", ui()); + } + else{ + Engine::Utils::Logger::get().info("UI", "Closing Viewport Gui"); + gui.deleteWindow("Viewport Gui"); + }; +}; + + + +void Engine::Editor::UI_Viewport::guiViewport() { + uint32_t textureID = viewport_fbo.getColorTexture(); + ImVec2 viewportPanelSize = ImGui::GetContentRegionAvail(); + + ImGui::Image( + reinterpret_cast(static_cast(textureID)), + viewportPanelSize, + ImVec2{ 0.0f, 1.0f }, // uv0 + ImVec2{ 1.0f, 0.0f } // uv1 + ); +}; + + + +std::function Engine::Editor::UI_Viewport::ui(){ + return [this](CW::Renderer::iRenderer *window){ + guiViewport(); + }; +}; + +#endif diff --git a/Engine/Editor/Editor/UI/UI_Viewport.h b/Engine/Editor/Editor/UI/UI_Viewport.h new file mode 100644 index 0000000..02c52e2 --- /dev/null +++ b/Engine/Editor/Editor/UI/UI_Viewport.h @@ -0,0 +1,40 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once + +#ifndef PRODUCTION +#include "Renderer.h" +#include "Gui.h" + +#include + +#include "Utils/Logger.h" + +#include "UI/Settings.h" + + + +namespace Engine::Editor{ +class UI_Viewport{ +private: + CW::Gui::Gui& gui; + CW::Renderer::Framebuffer& viewport_fbo; + +public: + UI_Viewport(CW::Gui::Gui& gui, CW::Renderer::Framebuffer& viewport_fbo); + ~UI_Viewport(); + void uiControl(); + +private: + void guiViewport(); + std::function ui(); + +}; +}; + +#endif diff --git a/Engine/Objects/Meduse/Meduse.cpp b/Engine/Objects/Meduse/Meduse.cpp deleted file mode 100644 index dbaa035..0000000 --- a/Engine/Objects/Meduse/Meduse.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Meduse.h" - - - -UW::Meduse::Meduse(){ - onLoad(); -}; - - - -UW::Meduse::~Meduse(){ - onDestroy(); -}; - - - -void UW::Meduse::Meduse::onLoad(){ - screen_quad_mesh_id = Resources::get().meshes.get_id("screen_quad"); - meshes_version = Resources::get().meshes.getLatestsVersion(); -}; - - - -void UW::Meduse::Meduse::onDestroy(){ - -}; - - - -void UW::Meduse::Meduse::onUpdate(float delta_time){ - -}; - - - -void UW::Meduse::Meduse::onFixedUpdate(float fixed_delta_time) { - if (path.size() < 3) return; - - glm::vec3 p0 = path[0]; - glm::vec3 p1 = path[1]; - glm::vec3 p2 = path[2]; - - glm::vec3 raw_tangent = (4.0f * t - 3.0f) * p0 - - (8.0f * t - 4.0f) * p1 - + (4.0f * t - 1.0f) * p2; - - float tangent_len = glm::length(raw_tangent); - if (tangent_len < 0.001f) tangent_len = 0.001f; - - float dt_pct = (speed * fixed_delta_time) / tangent_len; - bool segment_swapped = false; - - if (t + dt_pct >= 0.5f) { - float t_needed = 0.5f - t; - float dt_used = (t_needed * tangent_len) / speed; - float dt_remaining = glm::max(0.0f, fixed_delta_time - dt_used); - - t = 0.0f; - path.push_back(path.front()); - path.pop_front(); - - if (path.size() < 3) return; - p0 = path[0]; - p1 = path[1]; - p2 = path[2]; - - raw_tangent = (4.0f * t - 3.0f) * p0 - - (8.0f * t - 4.0f) * p1 - + (4.0f * t - 1.0f) * p2; - - tangent_len = glm::length(raw_tangent); - if (tangent_len < 0.001f) tangent_len = 0.001f; - - t += (speed * dt_remaining) / tangent_len; - segment_swapped = true; - } else { - t += dt_pct; - } - - position = 2.0f * (t - 0.5f) * (t - 1.0f) * p0 - - 4.0f * t * (t - 1.0f) * p1 - + 2.0f * t * (t - 0.5f) * p2; - - if (glm::length(raw_tangent) > 0.001f) { - glm::vec3 current_tangent = glm::normalize(raw_tangent); - - if (glm::length(last_tangent) < 0.1f || segment_swapped) { - last_tangent = current_tangent; - } - - glm::vec3 axis = glm::cross(last_tangent, current_tangent); - float dot_prod = glm::clamp(glm::dot(last_tangent, current_tangent), -1.0f, 1.0f); - - if (glm::length(axis) > 0.0001f) { - float angle = std::acos(dot_prod); - glm::quat delta_rot = glm::angleAxis(angle, glm::normalize(axis)); - - orientation = delta_rot * orientation; - orientation = glm::normalize(orientation); - } - - last_tangent = current_tangent; - }; -}; - - - -void UW::Meduse::Meduse::render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform){ - if(meshes_version != Resources::get().meshes.getLatestsVersion()){ - screen_quad_mesh_id = Resources::get().meshes.get_id("screen_quad"); - meshes_version = Resources::get().meshes.getLatestsVersion(); - }; - - glm::vec3 pivotOffset = glm::vec3(0.0f, 0.0f, 0.0f); - glm::mat4 translationMat = glm::translate(glm::mat4(1.0f), position); - glm::mat4 rotationMat = glm::mat4_cast(orientation); - glm::mat4 scaleMat = glm::scale(glm::mat4(1.0f), scale); - glm::mat4 preRotate = glm::translate(glm::mat4(1.0f), -pivotOffset); - glm::mat4 postRotate = glm::translate(glm::mat4(1.0f), pivotOffset); - - glm::mat4 model = translationMat * postRotate * rotationMat * preRotate * scaleMat; - sdf_uniform["model"]->set(model); - - - sdf_uniform["material_id"]->set(Resources::get().materials.translate_material("SDF")); - sdf_uniform["lightCount"]->set(Resources::get().lights.size()); - sdf_uniform["transformation"]->set(render_camera.transformation(renderer)); - sdf_uniform["cameraPosition"]->set(render_camera.position); - - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - Resources::get().getShader("SDF").getUniforms().emplace_back(&sdf_uniform); - Resources::get().getShader("SDF").bind(); - - Resources::get().meshes[screen_quad_mesh_id].render(); - - Resources::get().getShader("SDF").unbind(); - Resources::get().getShader("SDF").getUniforms().clear(); - - glDisable(GL_BLEND); - glEnable(GL_DEPTH_TEST); - glDepthMask(GL_TRUE); -}; - - - -void UW::Meduse::Meduse::setPosition(glm::vec3 position){ - this->position = position; -}; - - - -void UW::Meduse::Meduse::setOrientation(glm::vec3 rotation){ - this->orientation = glm::quat(rotation); -}; - - - -void UW::Meduse::Meduse::setScale(glm::vec3 scale){ - this->scale = scale; -}; - - - -void UW::Meduse::Meduse::setSpeed(float speed){ - this->speed = speed; -}; - - - -void UW::Meduse::Meduse::setPath(std::deque path){ - this->path = path; - - if (path.size() >= 3) { - glm::vec3 p0 = path[0]; - glm::vec3 p1 = path[1]; - glm::vec3 p2 = path[2]; - - glm::vec3 initial_tangent = (-3.0f * p0) - (-4.0f * p1) + (-1.0f * p2); - - if (glm::length(initial_tangent) > 0.001f) { - initial_tangent = glm::normalize(initial_tangent); - - glm::vec3 world_up = glm::vec3(0.0f, 1.0f, 0.0f); - - if (glm::abs(glm::dot(initial_tangent, world_up)) > 0.999f) world_up = glm::vec3(0.0f, 0.0f, 1.0f); - - orientation = glm::quatLookAt(initial_tangent, world_up); - - last_tangent = initial_tangent; - }; - } -}; - - - -void UW::Meduse::Meduse::genRandom(int i, glm::vec3 position_min, glm::vec3 position_max, glm::vec3 center, glm::vec3 rotation_min, glm::vec3 rotation_max, float scale_min, float scale_max){ - std::mt19937 gen(UW::Utils::hash(UW::Config::SEED + i)); - - std::uniform_real_distribution distPos; - std::uniform_real_distribution distRot; - std::uniform_real_distribution distScale(scale_min, scale_max); - - setPosition(glm::vec3( - std::uniform_real_distribution(position_min.x, position_max.x)(gen), - std::uniform_real_distribution(position_min.y, position_max.y)(gen), - std::uniform_real_distribution(position_min.z, position_max.z)(gen) - ) + center); - - setOrientation(glm::vec3( - std::uniform_real_distribution(rotation_min.x, rotation_max.x)(gen), - std::uniform_real_distribution(rotation_min.y, rotation_max.y)(gen), - std::uniform_real_distribution(rotation_min.z, rotation_max.z)(gen) - )); - - float s = distScale(gen); - setScale(glm::vec3(s, s, s)); -}; diff --git a/Engine/Objects/Meduse/Meduse.h b/Engine/Objects/Meduse/Meduse.h deleted file mode 100644 index 7508df8..0000000 --- a/Engine/Objects/Meduse/Meduse.h +++ /dev/null @@ -1,61 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#pragma once -#include "Renderer.h" -#include - -#include -#include -#include - -#include "config.h" -#include "Utils/utils.h" -#include "Camera/Camera.h" -#include "Resources/Resources.h" -#include "Objects/Object.h" - - - -namespace UW{ -class Meduse : public Object{ -private: - CW::Renderer::Uniform sdf_uniform; - std::deque path; - - glm::vec3 position = {153.0f, 28.0f, -116.0f}; - glm::vec3 scale = {0.5f, 0.5f, 0.5f}; - - glm::vec3 last_tangent = glm::vec3(0.0f); - glm::quat orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); - - float t = 0.0f; - float speed = 10.0f; - - unsigned int screen_quad_mesh_id = 0; - unsigned int meshes_version = -1; - -public: - Meduse(); - ~Meduse(); - - void onLoad() override; - void onDestroy() override; - void onUpdate(float delta_time) override; - void onFixedUpdate(float fixed_delta_time) override; - void render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform) override; - - void setPosition(glm::vec3 position); - void setOrientation(glm::vec3 rotation); - void setScale(glm::vec3 scale); - void setSpeed(float speed); - void setPath(std::deque path); - - void genRandom(int i, glm::vec3 position_min, glm::vec3 position_max, glm::vec3 center, glm::vec3 rotation_min, glm::vec3 rotation_max, float scale_min, float scale_max); - -}; -}; diff --git a/Engine/Objects/Object.h b/Engine/Objects/Object.h deleted file mode 100644 index ee03879..0000000 --- a/Engine/Objects/Object.h +++ /dev/null @@ -1,25 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#pragma once -#include "Renderer.h" - -#include "../Camera/Camera.h" - - - -namespace UW{ -class Object{ -public: - virtual void onLoad() = 0; - virtual void onDestroy() = 0; - virtual void onUpdate(float delta_time) = 0; - virtual void onFixedUpdate(float fixed_delta_time) = 0; - virtual void render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform) = 0; - -}; -}; diff --git a/Engine/Objects/ObjectManager.cpp b/Engine/Objects/ObjectManager.cpp deleted file mode 100644 index 007ac65..0000000 --- a/Engine/Objects/ObjectManager.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "ObjectManager.h" - - - -UW::ObjectManager &UW::ObjectManager::get(){ - static ObjectManager instance; - return instance; -}; - - - -void UW::ObjectManager::emplace_back(const std::string &name){ - objects.emplace_back(UW::GameObject(name, "empty", "Default")); -}; - - - -void UW::ObjectManager::erase(const std::string &name) { - for (auto it = objects.begin(); it != objects.end(); ) { - if (it->game_object_data.name == name) { - it->onDestroy(); - it->scripts.clear(); - it->mesh_id = -1; - it = objects.erase(it); - - } else { - ++it; - }; - }; -}; - - - -UW::GameObjectData *UW::ObjectManager::getGameObjectData(const std::string &name){ - for(auto& object : objects) - if(object.game_object_data.name == name) - return &object.copy_game_object_data; - - return nullptr; -}; - - - -void UW::ObjectManager::addScript(const std::string &object_name, const std::string &path){ - for (auto& obj : objects) { - if (obj.game_object_data.name == object_name) { - obj.scripts.emplace_back(path); - return; - }; - }; - Logger::get().erro("ObjectManager", "Could not find object: " + object_name); -}; - - - -void UW::ObjectManager::removeScript(const std::string &object_name, const std::string &path) { - for (auto& obj : objects) { - if (obj.game_object_data.name == object_name) { - obj.scripts.erase( - std::remove_if(obj.scripts.begin(), obj.scripts.end(), - [&](const GameObjectScriptRecord& record) { - return record.getPath() == path; - }), - obj.scripts.end() - ); - return; - }; - }; - Logger::get().erro("ObjectManager", "Could not find object: " + object_name); -}; - - - -void UW::ObjectManager::saveRuntime(const std::string& object_name){ - for (auto& obj : objects) { - if (obj.game_object_data.name == object_name) { - obj.game_object_data = obj.copy_game_object_data; - }; - }; -}; \ No newline at end of file diff --git a/Engine/Objects/Skybox/Skybox.cpp b/Engine/Objects/Skybox/Skybox.cpp deleted file mode 100644 index d1061cd..0000000 --- a/Engine/Objects/Skybox/Skybox.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Skybox.h" - - - -UW::Skybox::Skybox(){ - mesh_id = Resources::get().meshes.get_id("sky_box"); - onLoad(); -}; - - - -UW::Skybox::~Skybox(){ - onDestroy(); -}; - - - -void UW::Skybox::onLoad(){ - -}; - - - -void UW::Skybox::onDestroy(){ - -}; - - - -void UW::Skybox::onUpdate(float delta_time){ - -}; - - - -void UW::Skybox::onFixedUpdate(float fixed_delta_time){ - -}; - - - -void UW::Skybox::render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform){ - if(Resources::get().meshes.validateVersion(mesh_version)){ - mesh_version = Resources::get().meshes.getLatestsVersion(); - mesh_id = Resources::get().meshes.get_id("sky_box"); - }; - - glDepthFunc(GL_LEQUAL); - - uniform["projection"]->set(render_camera.projection(renderer)); - uniform["view"]->set(render_camera.view(renderer)); - uniform["skyboxTex"]->set(0); - - Resources::get().getShader("Skybox").getUniforms().emplace_back(&uniform); - Resources::get().getShader("Skybox").getUniforms().emplace_back(&shadows_uniform); - - Resources::get().getTexture("Skybox/Skybox.png").bind(0); - Resources::get().getShader("Skybox").bind(); - - Resources::get().meshes[mesh_id].render(); - - Resources::get().getShader("Skybox").unbind(); - Resources::get().getTexture("Skybox/Skybox.png").unbind(); - - Resources::get().getShader("Skybox").getUniforms().clear(); - - glDepthFunc(GL_LESS); -}; diff --git a/Engine/Objects/Skybox/Skybox.h b/Engine/Objects/Skybox/Skybox.h deleted file mode 100644 index e847edc..0000000 --- a/Engine/Objects/Skybox/Skybox.h +++ /dev/null @@ -1,38 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#pragma once -#include -#include - -#include "Renderer.h" - -#include "Resources/Resources.h" -#include "Camera/Camera.h" -#include "Objects/Object.h" -#include "Utils/utils.h" - - - -namespace UW { -class Skybox : public Object { -private: - CW::Renderer::Uniform uniform; - unsigned int mesh_id = 0; - unsigned int mesh_version = -1; - -public: - Skybox(); - ~Skybox(); - - void onLoad() override; - void onDestroy() override; - void onUpdate(float delta_time) override; - void onFixedUpdate(float fixed_delta_time) override; - void render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform) override; -}; -}; // namespace UW diff --git a/Engine/Objects/Terrain/Terrain.cpp b/Engine/Objects/Terrain/Terrain.cpp deleted file mode 100644 index de79f2b..0000000 --- a/Engine/Objects/Terrain/Terrain.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Terrain.h" - - - -UW::Terrain::Terrain(){ - generateChunks(); - mesh_id = Resources::get().meshes.get_id("terrain_chunk"); - onLoad(); -}; - - - -UW::Terrain::~Terrain(){ - onDestroy(); -}; - - - -void UW::Terrain::onLoad(){ - -}; - - - -void UW::Terrain::onDestroy(){ - -}; - - - -void UW::Terrain::onUpdate(float delta_time){ - -}; - - - -void UW::Terrain::onFixedUpdate(float fixed_delta_time){ - -}; - - - -void UW::Terrain::render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform){ - if(Resources::get().meshes.validateVersion(mesh_version)){ - mesh_version = Resources::get().meshes.getLatestsVersion(); - mesh_id = Resources::get().meshes.get_id("terrain_chunk"); - }; - - uniform["projection"]->set(render_camera.transformation(renderer)); - uniform["view"]->set(glm::mat4(1.0f)); - uniform["cameraPosition"]->set(culling_camera.position); - uniform["lightCount"]->set(Resources::get().lights.size()); - - uniform["tessBound"]->set(UW::Config::TESS_BOUND); - uniform["mapSize"]->set(map_size); - uniform["maxHeight"]->set(UW::Config::MAX_HEIGHT); - uniform["distanceCoefficient"]->set(UW::Config::TESS_DISTANCE_COFF); - uniform["uTexture"]->set(0); - uniform["material_id"]-> set(Resources::get().materials.translate_material("terrain")); - - Resources::get().getShader("Terrain").getUniforms().emplace_back(&uniform); - Resources::get().getShader("Terrain").getUniforms().emplace_back(&shadows_uniform); - - Resources::get().getTexture("Terrain/heightmap.png").bind(0); - glPatchParameteri(GL_PATCH_VERTICES, 4); - - for (auto& c : chunks){ - glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(c.x * UW::Config::CHUNK_SIZE, 0.0f, c.y * UW::Config::CHUNK_SIZE)); - model = glm::scale(model, glm::vec3(UW::Config::CHUNK_SIZE)); - - if(isVisible(culling_camera.transformation(renderer), model, Resources::get().meshes[mesh_id])){ - uniform["model"]->set(model); - - Resources::get().getShader("Terrain").bind(); - Resources::get().meshes[mesh_id].render(GL_PATCHES); - }; - }; - - Resources::get().getShader("Terrain").unbind(); - Resources::get().getTexture("Terrain/heightmap.png").unbind(); - - Resources::get().getShader("Terrain").getUniforms().clear(); -}; - - - -void UW::Terrain::generateChunks(){ - chunks.clear(); - chunks.reserve((2 * UW::Config::CHUNK_RADIUS + 1) * (2 * UW::Config::CHUNK_RADIUS + 1)); - - int radius = UW::Config::CHUNK_RADIUS; - - for (int x = -radius; x <= radius; x++){ - for (int z = -radius; z <= radius; z++){ - glm::vec2 position = glm::vec2(x, z); - chunks.emplace_back(position); - }; - }; - - map_size = glm::vec2(UW::Config::CHUNK_SIZE * (UW::Config::CHUNK_RADIUS * 2.0f + 1.0f)); -}; - - - -bool UW::Terrain::isVisible(glm::mat4 culling_camera_transform, glm::mat4 model, const CW::Renderer::Mesh& mesh){ - const float epsilonHeight = 1.0f; - - glm::vec3 localMin(0.0f, -epsilonHeight, 0.0f); - glm::vec3 localMax(1.0f, epsilonHeight, 1.0f); - - glm::vec3 corners[8] = { - glm::vec3(model * glm::vec4(localMin.x, localMin.y, localMin.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMin.y, localMin.z, 1.0f)), - glm::vec3(model * glm::vec4(localMin.x, localMax.y, localMin.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMax.y, localMin.z, 1.0f)), - - glm::vec3(model * glm::vec4(localMin.x, localMin.y, localMax.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMin.y, localMax.z, 1.0f)), - glm::vec3(model * glm::vec4(localMin.x, localMax.y, localMax.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMax.y, localMax.z, 1.0f)) - }; - - glm::vec3 aabbMin = corners[0]; - glm::vec3 aabbMax = corners[0]; - - for (int i = 1; i < 8; i++){ - aabbMin = glm::min(aabbMin, corners[i]); - aabbMax = glm::max(aabbMax, corners[i]); - }; - - glm::mat4 m = culling_camera_transform; - - glm::vec4 planes[6]; - - // Left - planes[0] = glm::vec4( - m[0][3] + m[0][0], - m[1][3] + m[1][0], - m[2][3] + m[2][0], - m[3][3] + m[3][0]); - - // Right - planes[1] = glm::vec4( - m[0][3] - m[0][0], - m[1][3] - m[1][0], - m[2][3] - m[2][0], - m[3][3] - m[3][0]); - - // Bottom - planes[2] = glm::vec4( - m[0][3] + m[0][1], - m[1][3] + m[1][1], - m[2][3] + m[2][1], - m[3][3] + m[3][1]); - - // Top - planes[3] = glm::vec4( - m[0][3] - m[0][1], - m[1][3] - m[1][1], - m[2][3] - m[2][1], - m[3][3] - m[3][1]); - - // Near - planes[4] = glm::vec4( - m[0][3] + m[0][2], - m[1][3] + m[1][2], - m[2][3] + m[2][2], - m[3][3] + m[3][2]); - - // Far - planes[5] = glm::vec4( - m[0][3] - m[0][2], - m[1][3] - m[1][2], - m[2][3] - m[2][2], - m[3][3] - m[3][2]); - - for (int i = 0; i < 6; i++){ - float length = glm::length(glm::vec3(planes[i])); - if (length > 0.0f) planes[i] /= length; - }; - - for (int i = 0; i < 6; i++){ - glm::vec3 normal = glm::vec3(planes[i]); - - glm::vec3 positiveVertex; - - positiveVertex.x = (normal.x >= 0.0f) ? aabbMax.x : aabbMin.x; - positiveVertex.y = (normal.y >= 0.0f) ? aabbMax.y : aabbMin.y; - positiveVertex.z = (normal.z >= 0.0f) ? aabbMax.z : aabbMin.z; - - float distance = glm::dot(normal, positiveVertex) + planes[i].w; - - if (distance < 0.0f) return false; - }; - - return true; -}; diff --git a/Engine/Objects/Terrain/Terrain.h b/Engine/Objects/Terrain/Terrain.h deleted file mode 100644 index 88e8a7e..0000000 --- a/Engine/Objects/Terrain/Terrain.h +++ /dev/null @@ -1,46 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#pragma once -#include "Renderer.h" - -#include -#include - -#include "Resources/Resources.h" -#include "Camera/Camera.h" -#include "Utils/utils.h" -#include "config.h" -#include "Objects/Object.h" - - - -namespace UW{ -class Terrain : public Object{ -private: - CW::Renderer::Uniform uniform; - std::vector chunks; - glm::vec2 map_size = glm::vec2(0.0f); - unsigned int mesh_id = -1; - unsigned int mesh_version = -1; - -public: - Terrain(); - ~Terrain(); - - void onLoad() override; - void onDestroy() override; - void onUpdate(float delta_time) override; - void onFixedUpdate(float fixed_delta_time) override; - void render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform) override; - -private: - void generateChunks(); - bool isVisible(glm::mat4 culling_camera_transform, glm::mat4 model, const CW::Renderer::Mesh& mesh); - -}; -}; // namespace UW diff --git a/Engine/Objects/Water/Water.cpp b/Engine/Objects/Water/Water.cpp deleted file mode 100644 index 48a3815..0000000 --- a/Engine/Objects/Water/Water.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Water.h" - - - -UW::Water::Water(){ - generateChunks(); - mesh_id = Resources::get().meshes.get_id("terrain_chunk"); - onLoad(); -}; - - - -UW::Water::~Water(){ - onDestroy(); -}; - - - -void UW::Water::onLoad(){ - -}; - - - -void UW::Water::onDestroy(){ - -}; - - - -void UW::Water::onUpdate(float delta_time){ - elapsed_time += delta_time; -}; - - - -void UW::Water::onFixedUpdate(float fixed_delta_time){ - -}; - - - -void UW::Water::render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform){ - if(Resources::get().meshes.validateVersion(mesh_version)){ - mesh_version = Resources::get().meshes.getLatestsVersion(); - mesh_id = Resources::get().meshes.get_id("terrain_chunk"); - }; - - uniform["projection"]->set(render_camera.transformation(renderer)); - uniform["view"]->set(glm::mat4(1.0f)); - uniform["cameraPosition"]->set(culling_camera.position); - uniform["lightCount"]->set(Resources::get().lights.size()); - - uniform["tessBound"]->set(UW::Config::TESS_BOUND); - uniform["mapSize"]->set(map_size); - uniform["waterHeight"]->set(UW::Config::WATER_HEIGHT); - uniform["distanceCoefficient"]->set(UW::Config::TESS_DISTANCE_COFF); - uniform["time"]->set(elapsed_time); - uniform["material_id"]->set(Resources::get().materials.translate_material("water")); - - - Resources::get().getShader("Water").getUniforms().emplace_back(&uniform); - Resources::get().getShader("Water").getUniforms().emplace_back(&shadows_uniform); - - glPatchParameteri(GL_PATCH_VERTICES, 4); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthMask(GL_FALSE); - - for (auto& c : chunks){ - glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(c.x * UW::Config::CHUNK_SIZE, 0.0f, c.y * UW::Config::CHUNK_SIZE)); - model = glm::scale(model, glm::vec3(UW::Config::CHUNK_SIZE)); - - if(isVisible(culling_camera.transformation(renderer), model, Resources::get().meshes[mesh_id])){ - uniform["model"]->set(model); - - Resources::get().getShader("Water").bind(); - Resources::get().meshes[mesh_id].render(GL_PATCHES); - }; - }; - - Resources::get().getShader("Water").unbind(); - Resources::get().getShader("Water").getUniforms().clear(); - - glDepthMask(GL_TRUE); - glDisable(GL_BLEND); -}; - - - -void UW::Water::generateChunks(){ - chunks.clear(); - chunks.reserve((2 * UW::Config::CHUNK_RADIUS + 1) * (2 * UW::Config::CHUNK_RADIUS + 1)); - - int radius = UW::Config::CHUNK_RADIUS; - - for (int x = -radius; x <= radius; x++){ - for (int z = -radius; z <= radius; z++){ - glm::vec2 position = glm::vec2(x, z); - chunks.emplace_back(position); - }; - }; - - map_size = glm::vec2(UW::Config::CHUNK_SIZE * (UW::Config::CHUNK_RADIUS * 2.0f + 1.0f)); -}; - - - -bool UW::Water::isVisible(glm::mat4 culling_camera_transform, glm::mat4 model, const CW::Renderer::Mesh& mesh){ - const float epsilonHeight = 1.0f; - - glm::vec3 localMin(0.0f, -epsilonHeight, 0.0f); - glm::vec3 localMax(1.0f, epsilonHeight, 1.0f); - - glm::vec3 corners[8] = { - glm::vec3(model * glm::vec4(localMin.x, localMin.y, localMin.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMin.y, localMin.z, 1.0f)), - glm::vec3(model * glm::vec4(localMin.x, localMax.y, localMin.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMax.y, localMin.z, 1.0f)), - - glm::vec3(model * glm::vec4(localMin.x, localMin.y, localMax.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMin.y, localMax.z, 1.0f)), - glm::vec3(model * glm::vec4(localMin.x, localMax.y, localMax.z, 1.0f)), - glm::vec3(model * glm::vec4(localMax.x, localMax.y, localMax.z, 1.0f)) - }; - - glm::vec3 aabbMin = corners[0]; - glm::vec3 aabbMax = corners[0]; - - for (int i = 1; i < 8; i++){ - aabbMin = glm::min(aabbMin, corners[i]); - aabbMax = glm::max(aabbMax, corners[i]); - }; - - glm::mat4 m = culling_camera_transform; - - glm::vec4 planes[6]; - - // Left - planes[0] = glm::vec4( - m[0][3] + m[0][0], - m[1][3] + m[1][0], - m[2][3] + m[2][0], - m[3][3] + m[3][0]); - - // Right - planes[1] = glm::vec4( - m[0][3] - m[0][0], - m[1][3] - m[1][0], - m[2][3] - m[2][0], - m[3][3] - m[3][0]); - - // Bottom - planes[2] = glm::vec4( - m[0][3] + m[0][1], - m[1][3] + m[1][1], - m[2][3] + m[2][1], - m[3][3] + m[3][1]); - - // Top - planes[3] = glm::vec4( - m[0][3] - m[0][1], - m[1][3] - m[1][1], - m[2][3] - m[2][1], - m[3][3] - m[3][1]); - - // Near - planes[4] = glm::vec4( - m[0][3] + m[0][2], - m[1][3] + m[1][2], - m[2][3] + m[2][2], - m[3][3] + m[3][2]); - - // Far - planes[5] = glm::vec4( - m[0][3] - m[0][2], - m[1][3] - m[1][2], - m[2][3] - m[2][2], - m[3][3] - m[3][2]); - - for (int i = 0; i < 6; i++){ - float length = glm::length(glm::vec3(planes[i])); - if (length > 0.0f) planes[i] /= length; - }; - - for (int i = 0; i < 6; i++){ - glm::vec3 normal = glm::vec3(planes[i]); - - glm::vec3 positiveVertex; - - positiveVertex.x = (normal.x >= 0.0f) ? aabbMax.x : aabbMin.x; - positiveVertex.y = (normal.y >= 0.0f) ? aabbMax.y : aabbMin.y; - positiveVertex.z = (normal.z >= 0.0f) ? aabbMax.z : aabbMin.z; - - float distance = glm::dot(normal, positiveVertex) + planes[i].w; - - if (distance < 0.0f) return false; - }; - - return true; -}; diff --git a/Engine/Objects/Water/Water.h b/Engine/Objects/Water/Water.h deleted file mode 100644 index 237e276..0000000 --- a/Engine/Objects/Water/Water.h +++ /dev/null @@ -1,47 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#pragma once -#include "Renderer.h" - -#include -#include - -#include "Resources/Resources.h" -#include "Camera/Camera.h" -#include "Utils/utils.h" -#include "config.h" -#include "Objects/Object.h" - - - -namespace UW{ -class Water : public Object{ -private: - CW::Renderer::Uniform uniform; - std::vector chunks; - glm::vec2 map_size = glm::vec2(0.0f); - float elapsed_time = 0.0f; - unsigned int mesh_id = -1; - unsigned int mesh_version = -1; - -public: - Water(); - ~Water(); - - void onLoad() override; - void onDestroy() override; - void onUpdate(float delta_time) override; - void onFixedUpdate(float fixed_delta_time) override; - void render(CW::Renderer::Renderer* renderer, Camera& culling_camera, Camera& render_camera, CW::Renderer::Uniform& shadows_uniform) override; - -private: - void generateChunks(); - bool isVisible(glm::mat4 culling_camera_transform, glm::mat4 model, const CW::Renderer::Mesh& mesh); - -}; -}; // namespace UW diff --git a/Engine/Resources/Meshes/Meshes.cpp b/Engine/Resources/Meshes/Meshes.cpp deleted file mode 100644 index 4680c57..0000000 --- a/Engine/Resources/Meshes/Meshes.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Meshes.h" - - - -UW::Meshes::Meshes() { -}; - - - -UW::Meshes::~Meshes() { -}; - - - -CW::Renderer::Mesh& UW::Meshes::operator[](unsigned int index) { - return mesh_data[index]; -}; - - - -const CW::Renderer::Mesh& UW::Meshes::operator[](unsigned int index) const { - return mesh_data[index]; -}; - - - -unsigned int UW::Meshes::get_id(const std::string& name) { - auto it = mesh_id.find(name); - if (it == mesh_id.end()) { - return INVALID_ID; - }; - return it->second; -}; - - - -bool UW::Meshes::exists(const std::string& name) const { - return mesh_id.find(name) != mesh_id.end(); -}; - - - -void UW::Meshes::emplace_back(const std::string& name, CW::Renderer::Mesh&& mesh) { - version += 1; - - auto it = mesh_id.find(name); - if (it != mesh_id.end()) { - mesh_data[it->second] = std::move(mesh); - } else { - unsigned int new_id = static_cast(mesh_data.size()); - - mesh_data.emplace_back(std::move(mesh)); - mesh_id[name] = new_id; - id_to_name.push_back(name); - }; -}; - - - -void UW::Meshes::erase(const std::string& name) { - if (!exists(name)) return; - version += 1; - - unsigned int index_to_remove = mesh_id[name]; - unsigned int last_index = static_cast(mesh_data.size() - 1); - - if (index_to_remove != last_index) { - std::swap(mesh_data[index_to_remove], mesh_data[last_index]); - - const std::string& moved_element_name = id_to_name[last_index]; - - mesh_id[moved_element_name] = index_to_remove; - id_to_name[index_to_remove] = moved_element_name; - }; - - mesh_data.pop_back(); - id_to_name.pop_back(); - mesh_id.erase(name); -}; - - - -unsigned int UW::Meshes::size() const{ - return mesh_data.size(); -}; - - - -void UW::Meshes::clear(){ - version += 1; - mesh_data.clear(); - mesh_id.clear(); - id_to_name.clear(); -}; - - - -std::unordered_map& UW::Meshes::getMeshIDs(){ - return mesh_id; -}; - - - -bool UW::Meshes::validateVersion(unsigned int version){ - return version == this->version; -}; - - - -unsigned int UW::Meshes::getLatestsVersion(){ - return version; -}; - - - -void UW::Meshes::compileAll(){ - for(CW::Renderer::Mesh& mesh : mesh_data) mesh.compile(); -}; diff --git a/Engine/Scene.cpp b/Engine/Scene.cpp deleted file mode 100644 index a3a50d4..0000000 --- a/Engine/Scene.cpp +++ /dev/null @@ -1,324 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Scene.h" - - - -UW::Scene::Scene(CW::Renderer::Renderer& window) - : window(window), light_camera(&window), fbo(1920, 1080), shadows_fbo(1920 * 5, 1080 * 5), camera(&window) -#ifndef PRODUCTION - , debug_camera(&window) -#endif -{ - UW::Logger::get().info("Scene", "Scene Initialized"); -}; - - - -UW::Scene::~Scene(){ - UW::Logger::get().info("Scene", "Scene Destroyed"); -}; - - - -void UW::Scene::onLoad(){ - Logger::get().info("Scene", "Loading Scene"); - - Logger::get().info("Scene", "Data Loaded from DataSerializer"); - - - screen_quad_mesh_id = Resources::get().meshes.get_id("screen_quad"); - meshes_version = Resources::get().meshes.getLatestsVersion(); - Logger::get().info("Scene", "Meshes ID's Initialized"); - - - post_uniform["u_water_height"]->set(UW::Config::WATER_HEIGHT); - post_uniform["u_Near"]->set(UW::Config::CAMERA_NEAR_PLANE); - post_uniform["u_Far"]->set(UW::Config::CAMERA_ORTHO_FAR_PLANE); - post_uniform["u_FogDensity"]->set(UW::Config::FOG_DENSITY); - post_uniform["u_FogColor"]->set(UW::Config::FOG_COLOR); - Logger::get().info("Scene", "PostProcessing Uniforms Initialized"); - - - light_camera.setOrthographic(true); - light_camera.fov = 110.0f; - last_light_camera_fov = light_camera.fov; - light_camera.position = Resources::get().lights[0].position; - last_light_camera_pos = light_camera.position; - light_camera.direction = glm::normalize(-Resources::get().lights[0].position); - last_light_camera_dir = light_camera.direction; - light_space_matrix = light_camera.transformation(&window); - - shadows_uniform_off["u_ShadowEnabled"]->set(0); - shadows_uniform_off["u_ShadowDepthTexture"]->set(16); - shadows_uniform_off["u_LightSpaceMatrix"]->set(light_space_matrix); - shadows_uniform_on["u_ShadowEnabled"]->set(1); - shadows_uniform_on["u_ShadowDepthTexture"]->set(16); - shadows_uniform_on["u_LightSpaceMatrix"]->set(light_space_matrix); - Logger::get().info("Scene", "Shadows Camera and Uniform Initialized"); - - - camera.position = {174.780f, 26.939f, -80.027f}; - camera.direction = {-0.847f, -0.466f, -0.256f}; - Logger::get().info("Scene", "Main Camera Initialized"); - - -#ifndef PRODUCTION - debug_camera.position = {453.198f, 250.233f, -26.842f}; - debug_camera.direction = {-0.668f, -0.734f, -0.122f}; - Logger::get().info("Scene", "Debug Camera Initialized"); -#endif - - - for(int i = 0; i < 2; i++){ - meduses.emplace_back(); - meduses[i].genRandom(i, - glm::vec3(-50, -10, -50), glm::vec3(50, 10, 50), glm::vec3(174.780f, 40.939f, -80.027f), - glm::vec3(-glm::radians(10.0f), -glm::radians(10.0f), -glm::radians(10.0f)), glm::vec3(glm::radians(10.0f), glm::radians(10.0f), glm::radians(10.0f)), - 0.4f, 0.7f - ); - }; - - meduses[0].setPath({glm::vec3(117.610, 51.472, -39.445), - glm::vec3(89.665, 25.785, -152.533), - glm::vec3(253.161, 54.430, -68.562), - glm::vec3(282.921, 21.784, 0.884)}); - meduses[0].setOrientation(glm::vec3(0.0f, 0.0f, 0.0f)); - meduses[0].setSpeed(20.0f); - Logger::get().info("Scene", "Meduses SDF Objects Initialized"); - - - compileShadows(); - Logger::get().info("Scene", "Shadows Compiled"); -}; - - - -void UW::Scene::onUpdate(float delta_time){ - camera.event(&window); - - unsigned int size = UW::ObjectManager::get().objects.size(); - for(int i = 0; i < size; i++){ - UW::ObjectManager::get().objects[i].onUpdate(delta_time); - if(size > UW::ObjectManager::get().objects.size()){ - size = UW::ObjectManager::get().objects.size(); - i--; - if(size == 0) break; - }; - }; - - for(UW::Meduse& meduse : meduses) meduse.onUpdate(delta_time); - if(terrain_on) terrain.onUpdate(delta_time); - skybox.onUpdate(delta_time); - if(water_on) water.onUpdate(delta_time); -}; - - - -void UW::Scene::onFixedUpdate(float fixed_delta_time){ -#ifndef PRODUCTION - save_acc += fixed_delta_time; - - if(save_acc >= UW::Config::SAVE_TIMESTAMP){ - save_acc -= UW::Config::SAVE_TIMESTAMP; - DataSerializer::get().saveAll(); - Logger::get().info("Scene", "Auto-Save scene data"); - }; -#endif - - unsigned int size = UW::ObjectManager::get().objects.size(); - for(int i = 0; i < size; i++){ - UW::ObjectManager::get().objects[i].onFixedUpdate(fixed_delta_time); - if(size > UW::ObjectManager::get().objects.size()){ - size = UW::ObjectManager::get().objects.size(); - i--; - if(size == 0) break; - }; - }; - - for(UW::Meduse& meduse : meduses) meduse.onFixedUpdate(fixed_delta_time); - if(terrain_on) terrain.onFixedUpdate(fixed_delta_time); - skybox.onFixedUpdate(fixed_delta_time); - if(water_on) water.onFixedUpdate(fixed_delta_time); -}; - - - -void UW::Scene::onDestroy() { - Logger::get().info("Scene", "Destroying Scene"); - - unsigned int size = UW::ObjectManager::get().objects.size(); - for(int i = 0; i < size; i++){ - UW::ObjectManager::get().objects[i].onDestroy(); - if(size > UW::ObjectManager::get().objects.size()){ - size = UW::ObjectManager::get().objects.size(); - i--; - if(size == 0) break; - }; - }; - Logger::get().info("Scene", "Objects onDestroy"); - - UW::ObjectManager::get().objects.clear(); - Logger::get().info("Scene", "Objects Removed"); - - Logger::get().info("Scene", "Destroyed Scene"); -}; - - - -void UW::Scene::compileShadows(){ - shadows_fbo.bind(); - - if(last_light_camera_pos != light_camera.position){ - light_camera.fov = 110.0f; - last_light_camera_fov = light_camera.fov; - - light_camera.position = Resources::get().lights[0].position; - last_light_camera_pos = light_camera.position; - - light_camera.direction = glm::normalize(-Resources::get().lights[0].position); - last_light_camera_dir = light_camera.direction; - - light_space_matrix = light_camera.transformation(&window); - shadows_uniform_off["u_LightSpaceMatrix"]->set(light_space_matrix); - shadows_uniform_on["u_LightSpaceMatrix"]->set(light_space_matrix); - }; - - window.beginFrame(); - - terrain.render(&window, light_camera, light_camera, shadows_uniform_off); - for(UW::GameObject& object : UW::ObjectManager::get().objects) object.render(&window, light_camera, light_camera, shadows_uniform_off); - - shadows_fbo.unbind(); -}; - - - -void UW::Scene::render(){ - Resources::get().lights.bind(0); - Resources::get().materials.bind(1); - - -#ifndef PRODUCTION - if(!shadows_on){ - shadows_fbo.bind(); - window.beginFrame(); - shadows_fbo.unbind(); - } - else -#endif - compileShadows(); - - - fbo.bind(); - -#ifndef PRODUCTION - if(debug_camera_on) - renderFrame(debug_camera); - else -#endif - renderFrame(camera); - - -#ifndef PRODUCTION - if(debug_camera_on) - renderSFD(debug_camera); - else -#endif - renderSFD(camera); - - fbo.unbind(); - - - Resources::get().materials.unbind(); - Resources::get().lights.unbind(); - - - window.beginFrame(); - - -#ifndef PRODUCTION - if(!post_processing_on) - fbo.blitToScreen(window.getWindowData()->width, window.getWindowData()->height); - else -#endif - postProcessing(); -}; - - - -void UW::Scene::renderFrame(UW::Camera& camera){ - window.beginFrame(); - - glActiveTexture(GL_TEXTURE16); - glBindTexture(GL_TEXTURE_2D, shadows_fbo.getDepthTexture()); - - if(terrain_on) terrain.render(&window, this->camera, camera, shadows_uniform_on); - skybox.render(&window, this->camera, camera, shadows_uniform_off); - if(water_on) water.render(&window, this->camera, camera, shadows_uniform_off); - for(UW::GameObject& object : UW::ObjectManager::get().objects) object.render(&window, this->camera, camera, shadows_uniform_on); - - - glActiveTexture(GL_TEXTURE16); - glBindTexture(GL_TEXTURE_2D, 0); -}; - - - -void UW::Scene::renderSFD(UW::Camera& camera){ - for(UW::Meduse& meduse : meduses) meduse.render(&window, this->camera, camera, shadows_uniform_off); -}; - - - -void UW::Scene::postProcessing(){ - if(meshes_version != Resources::get().meshes.getLatestsVersion()){ - screen_quad_mesh_id = Resources::get().meshes.get_id("screen_quad"); - meshes_version = Resources::get().meshes.getLatestsVersion(); - Logger::get().info("Scene", "Meshes ID's Updated"); - }; - - std::string shader_name = "PostProcessing"; - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, fbo.getColorTexture()); - post_uniform["u_SceneColorTexture"]->set(0); - - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, fbo.getDepthTexture()); - post_uniform["u_SceneDepthTexture"]->set(1); - - -#ifndef PRODUCTION - if(debug_camera_on){ - glm::mat4 invViewProj = glm::inverse(debug_camera.projection(&window) * debug_camera.view(&window)); - post_uniform["u_InvViewProj"]->set(invViewProj); - post_uniform["u_CamPos"]->set(debug_camera.position); - } - else{ -#endif - glm::mat4 invViewProj = glm::inverse(camera.projection(&window) * camera.view(&window)); - post_uniform["u_InvViewProj"]->set(invViewProj); - post_uniform["u_CamPos"]->set(camera.position); -#ifndef PRODUCTION - } -#endif - - - Resources::get().getShader(shader_name).getUniforms().emplace_back(&post_uniform); - Resources::get().getShader(shader_name).bind(); - - Resources::get().meshes[screen_quad_mesh_id].render(); - - Resources::get().getShader(shader_name).unbind(); - Resources::get().getShader(shader_name).getUniforms().clear(); - - - glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); -}; diff --git a/Engine/ScriptShared/ScriptShared/Camera.h b/Engine/ScriptShared/ScriptShared/Camera.h new file mode 100644 index 0000000..e789f75 --- /dev/null +++ b/Engine/ScriptShared/ScriptShared/Camera.h @@ -0,0 +1,75 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once + +#define GLM_ENABLE_EXPERIMENTAL +#ifdef BUILDING_SCRIPT_DLL +#include "glm/glm/glm.hpp" +#include "glm/glm/gtc/quaternion.hpp" +#else +#include "Renderer.h" +#include "../vendor/glm/glm/gtc/quaternion.hpp" +#endif + + + +namespace Engine::ScriptShared{ +enum CameraMode{ + PERSPECTIVE = 0, + ORTHOGONAL = 1 +}; + + + +class ICamera { +public: + virtual glm::mat4 transformation() noexcept = 0; + virtual glm::mat4 view() noexcept = 0; + virtual glm::mat4 projection() noexcept = 0; + + virtual glm::vec3 getPosition() const noexcept = 0; + virtual void setPosition(glm::vec3 position) noexcept = 0; + virtual glm::vec3 getDirection() const noexcept = 0; + virtual void setDirection(glm::vec3 direction) noexcept = 0; + + virtual float getFov() const noexcept = 0; + virtual void setFov(float fov) noexcept = 0; + virtual float getOrthoSize() const noexcept = 0; + virtual void setOrthoSize(float size) noexcept = 0; + virtual float getNearPlane() const noexcept = 0; + virtual void setNearPlane(float near) noexcept = 0; + virtual float getFarPlane() const noexcept = 0; + virtual void setFarPlane(float far) noexcept = 0; + virtual float getNearPerspectivePlane() const noexcept = 0; + virtual void setNearPerspectivePlane(float near) noexcept = 0; + virtual float getFarPerspectivePlane() const noexcept = 0; + virtual void setFarPerspectivePlane(float far) noexcept = 0; + virtual float getNearOrthogonalPlane() const noexcept = 0; + virtual void setNearOrthogonalPlane(float near) noexcept = 0; + virtual float getFarOrthogonalPlane() const noexcept = 0; + virtual void setFarOrthogonalPlane(float far) noexcept = 0; + + + virtual Engine::ScriptShared::CameraMode getCameraMode() const noexcept = 0; + virtual void setCameraMode(Engine::ScriptShared::CameraMode mode) noexcept = 0; + + virtual bool getDefaultMovement() const noexcept = 0; + virtual void setDefaultMovement(bool state) noexcept = 0; + + virtual float getVelocity() const noexcept = 0; + virtual void setVelocity(float velocity) noexcept = 0; + virtual float getSensitivity() const noexcept = 0; + virtual void setSensitivity(float sensitivity) noexcept = 0; + virtual bool getMouseActive() const noexcept = 0; + virtual void setMouseActive(bool active) noexcept = 0; + + virtual void event(float delta_time) = 0; + virtual void resetMouse() = 0; + +}; +}; diff --git a/Engine/ScriptShared/ScriptShared/CameraController.h b/Engine/ScriptShared/ScriptShared/CameraController.h new file mode 100644 index 0000000..3ccf7d6 --- /dev/null +++ b/Engine/ScriptShared/ScriptShared/CameraController.h @@ -0,0 +1,36 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once + +#define GLM_ENABLE_EXPERIMENTAL +#ifdef BUILDING_SCRIPT_DLL +#include "glm/glm/glm.hpp" +#include "glm/glm/gtc/quaternion.hpp" +#else +#include "Renderer.h" +#include "../vendor/glm/glm/gtc/quaternion.hpp" +#endif + +#include "Camera.h" + + + +namespace Engine::ScriptShared { +class ICameraController { +public: + virtual void setActiveCamera(const std::string& name) noexcept = 0; + virtual std::string getActiveCameraName() const noexcept = 0; + virtual Engine::ScriptShared::ICamera& getActiveCamera() = 0; + + virtual void spawnCamera(const std::string& name, glm::vec3 position = {0.0f, 0.0f, 0.0f}, glm::vec3 direction = {0.0f, 0.0f, 1.0f}) noexcept = 0; + virtual void deleteCamera(const std::string& name) noexcept = 0; + + virtual Engine::ScriptShared::ICamera& getCamera(const std::string& name) = 0; + virtual bool cameraExists(const std::string& name) const noexcept = 0; +}; +}; diff --git a/ScriptShared/ScriptShared/GameObjectData.h b/Engine/ScriptShared/ScriptShared/GameObjectData.h similarity index 77% rename from ScriptShared/ScriptShared/GameObjectData.h rename to Engine/ScriptShared/ScriptShared/GameObjectData.h index 6e6a2fa..7223120 100644 --- a/ScriptShared/ScriptShared/GameObjectData.h +++ b/Engine/ScriptShared/ScriptShared/GameObjectData.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -16,6 +16,8 @@ #include "../vendor/glm/glm/gtc/quaternion.hpp" #endif + + #include #include #include @@ -23,7 +25,7 @@ -namespace UW{ +namespace Engine::ScriptShared{ inline constexpr const char* gameObjectParameterTypeName[] = {"int", "float", "bool", "vec2", "vec3", "str"}; using GameObjectParameterType = std::variant; @@ -39,7 +41,14 @@ struct GameObjectData{ glm::vec3 rotation = glm::vec3(0.0f); glm::vec3 scale = glm::vec3(1.0f); bool hidden = false; + bool culling_on = true; + bool dont_write_to_depth_mask = false; + bool gl_depth_lequal = false; + bool gl_draw_patches = false; + bool gl_blend = false; + bool gl_nearest = false; std::unordered_map parameters; + std::unordered_map uniforms; }; }; diff --git a/ScriptShared/ScriptShared/GameObjectScriptInterface.h b/Engine/ScriptShared/ScriptShared/GameObjectScriptInterface.h similarity index 87% rename from ScriptShared/ScriptShared/GameObjectScriptInterface.h rename to Engine/ScriptShared/ScriptShared/GameObjectScriptInterface.h index 3b51263..84e16e4 100644 --- a/ScriptShared/ScriptShared/GameObjectScriptInterface.h +++ b/Engine/ScriptShared/ScriptShared/GameObjectScriptInterface.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,6 +11,8 @@ #include "GameObjectData.h" #include "IObjectManger.h" #include "GlobResource.h" +#include "Camera.h" +#include "CameraController.h" @@ -26,13 +28,14 @@ -namespace UW{ +namespace Engine::ScriptShared{ class GameObjectScriptInterface { public: GameObjectData* game_object_data = nullptr; GlobResource* glob_res = nullptr; ILogger* logger = nullptr; IObjectManager* object_manager = nullptr; + ICameraController* camera_controller = nullptr; virtual ~GameObjectScriptInterface() = default; diff --git a/ScriptShared/ScriptShared/GlobResource.h b/Engine/ScriptShared/ScriptShared/GlobResource.h similarity index 96% rename from ScriptShared/ScriptShared/GlobResource.h rename to Engine/ScriptShared/ScriptShared/GlobResource.h index fb0c90a..957350d 100644 --- a/ScriptShared/ScriptShared/GlobResource.h +++ b/Engine/ScriptShared/ScriptShared/GlobResource.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -37,7 +37,7 @@ class InoutData; -namespace UW{ +namespace Engine::ScriptShared{ inline constexpr const char* globResourceName[] = {"int", "float", "bool", "vec2", "vec3", "str"}; using GlobResourceName = std::variant; diff --git a/ScriptShared/ScriptShared/ILogger.h b/Engine/ScriptShared/ScriptShared/ILogger.h similarity index 90% rename from ScriptShared/ScriptShared/ILogger.h rename to Engine/ScriptShared/ScriptShared/ILogger.h index 9b74a66..afa1a3d 100644 --- a/ScriptShared/ScriptShared/ILogger.h +++ b/Engine/ScriptShared/ScriptShared/ILogger.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,7 +11,7 @@ -namespace UW { +namespace Engine::ScriptShared { class ILogger { public: virtual ~ILogger() = default; diff --git a/ScriptShared/ScriptShared/IObjectManger.h b/Engine/ScriptShared/ScriptShared/IObjectManger.h similarity index 54% rename from ScriptShared/ScriptShared/IObjectManger.h rename to Engine/ScriptShared/ScriptShared/IObjectManger.h index 7d61aac..5458c2e 100644 --- a/ScriptShared/ScriptShared/IObjectManger.h +++ b/Engine/ScriptShared/ScriptShared/IObjectManger.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -12,7 +12,7 @@ #include "GameObjectData.h" -namespace UW { +namespace Engine::ScriptShared { class IObjectManager { public: virtual void emplace_back(const std::string& name) = 0; @@ -21,5 +21,12 @@ class IObjectManager { virtual void addScript(const std::string& object_name, const std::string& path) = 0; virtual void removeScript(const std::string& object_name, const std::string& path) = 0; virtual void saveRuntime(const std::string& object_name) = 0; + + virtual void emplace_backObjectScript(const std::string& name) = 0; + virtual void eraseObjectScript(const std::string& name) = 0; + virtual GameObjectData* getGameObjectDataObjectScript(const std::string& name) = 0; + virtual void addScriptObjectScript(const std::string& object_name, const std::string& path) = 0; + virtual void removeScriptObjectScript(const std::string& object_name, const std::string& path) = 0; + virtual void saveRuntimeObjectScript(const std::string& object_name) = 0; }; }; diff --git a/ScriptShared/ScriptShared/InputData.h b/Engine/ScriptShared/ScriptShared/InputData.h similarity index 100% rename from ScriptShared/ScriptShared/InputData.h rename to Engine/ScriptShared/ScriptShared/InputData.h diff --git a/ScriptShared/ScriptShared/ScriptRegister.h b/Engine/ScriptShared/ScriptShared/ScriptRegister.h similarity index 62% rename from ScriptShared/ScriptShared/ScriptRegister.h rename to Engine/ScriptShared/ScriptShared/ScriptRegister.h index aa91e5f..e103859 100644 --- a/ScriptShared/ScriptShared/ScriptRegister.h +++ b/Engine/ScriptShared/ScriptShared/ScriptRegister.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -11,12 +11,13 @@ #include #include #include +#include #include "GameObjectScriptInterface.h" #include "ILogger.h" -namespace UW { +namespace Engine::ScriptShared { class GameObjectScriptInterface; using ScriptFactory = std::function; @@ -34,6 +35,7 @@ namespace UW { }; void registerScript(const std::string& name, ScriptFactory factory) { + printf("Reg: %s\n", name.c_str()); factories[name] = factory; }; @@ -54,8 +56,8 @@ namespace UW { namespace { \ struct ScriptRegisterer_##ScriptClassName { \ ScriptRegisterer_##ScriptClassName() { \ - UW::ScriptRegistry::get().registerScript(RegKey, []() -> UW::GameObjectScriptInterface* { \ - return new UW::ScriptClassName(); \ + Engine::ScriptShared::ScriptRegistry::get().registerScript(RegKey, []() -> Engine::ScriptShared::GameObjectScriptInterface* { \ + return new Engine::ScriptClassName(); \ }); \ } \ }; \ @@ -64,5 +66,16 @@ namespace UW { #define REGISTER_SCRIPT(RegKey, ScriptClassName) REGISTER_SCRIPT_INTERNAL(RegKey, ScriptClassName) #else - #define REGISTER_SCRIPT(RegKey, ScriptClassName) + #define REGISTER_SCRIPT(RegKey, ScriptClassName) \ + extern "C" Engine::ScriptShared::GameObjectScriptInterface* SCRIPT_API GetScript() { \ + Engine::ScriptClassName* script = new Engine::ScriptClassName(); \ + return (Engine::ScriptShared::GameObjectScriptInterface*)script; \ + }; \ + \ + \ + \ + extern "C" void SCRIPT_API DeleteScript(Engine::ScriptShared::GameObjectScriptInterface* script) { \ + Engine::ScriptClassName* temp_script = (Engine::ScriptClassName*)script; \ + delete temp_script; \ + }; #endif \ No newline at end of file diff --git a/ScriptShared/ScriptShared/glm/copying.txt b/Engine/ScriptShared/ScriptShared/glm/copying.txt similarity index 100% rename from ScriptShared/ScriptShared/glm/copying.txt rename to Engine/ScriptShared/ScriptShared/glm/copying.txt diff --git a/ScriptShared/ScriptShared/glm/glm/CMakeLists.txt b/Engine/ScriptShared/ScriptShared/glm/glm/CMakeLists.txt similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/CMakeLists.txt rename to Engine/ScriptShared/ScriptShared/glm/glm/CMakeLists.txt diff --git a/ScriptShared/ScriptShared/glm/glm/common.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/common.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/common.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/common.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/_features.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/_features.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/_features.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/_features.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/_fixes.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/_fixes.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/_fixes.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/_fixes.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/_noise.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/_noise.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/_noise.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/_noise.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/_swizzle.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/_swizzle.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/_swizzle.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/_swizzle.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/_swizzle_func.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/_swizzle_func.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/_swizzle_func.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/_swizzle_func.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/_vectorize.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/_vectorize.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/_vectorize.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/_vectorize.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/compute_common.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/compute_common.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/compute_common.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/compute_common.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/compute_vector_decl.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/compute_vector_decl.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/compute_vector_decl.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/compute_vector_decl.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/compute_vector_relational.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/compute_vector_relational.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/compute_vector_relational.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/compute_vector_relational.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_common.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_common.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_common.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_common.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_common_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_common_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_common_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_common_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_exponential.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_exponential.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_exponential.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_exponential.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_exponential_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_exponential_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_exponential_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_exponential_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_geometric.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_geometric.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_geometric.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_geometric.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_geometric_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_geometric_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_geometric_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_geometric_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_integer.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_integer.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_integer.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_integer.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_integer_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_integer_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_integer_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_integer_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_matrix.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_matrix.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_matrix.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_matrix.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_matrix_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_matrix_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_matrix_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_matrix_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_packing.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_packing.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_packing.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_packing.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_packing_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_packing_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_packing_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_packing_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_trigonometric_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/func_vector_relational_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/glm.cpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/glm.cpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/glm.cpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/glm.cpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/qualifier.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/qualifier.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/qualifier.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/qualifier.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/setup.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/setup.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/setup.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/setup.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_float.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_float.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_float.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_float.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_half.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_half.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_half.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_half.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_half.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_half.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_half.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_half.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x2.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x3.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat2x4.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x2.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x3.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat3x4.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x2.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x3.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_mat4x4_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_quat.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_quat.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_quat.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_quat.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_quat.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_quat.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_quat.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_quat.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_quat_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_quat_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_quat_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_quat_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec1.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec1.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec1.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec1.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec1.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec1.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec1.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec1.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec2.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec2.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec2.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec2.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec3.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec3.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec3.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec3.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec4.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec4.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec4.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec4.inl diff --git a/ScriptShared/ScriptShared/glm/glm/detail/type_vec_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/detail/type_vec_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/detail/type_vec_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/exponential.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/exponential.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/exponential.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/exponential.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/_matrix_vectorize.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/_matrix_vectorize.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/_matrix_vectorize.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/_matrix_vectorize.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_clip_space.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_common.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_common.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_common.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_common.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_common.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_common.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_common.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_common.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double2x4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double3x4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_double4x4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float2x4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float3x4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_float4x4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int2x4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int3x4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_int4x4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_integer.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_projection.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_relational.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_transform.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint2x4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint3x4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/matrix_uint4x4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_common_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_common_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_double.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_double.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_double.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_double.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_double_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_double_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_double_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_double_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_exponential.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_float.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_float.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_float.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_float.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_float_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_float_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_float_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_float_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_geometric.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_relational.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_transform.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/quaternion_trigonometric.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_common.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_common.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_common.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_common.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_common.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_common.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_common.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_common.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_constants.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_int_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_int_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_int_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_int_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_integer.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_packing.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_reciprocal.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_relational.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_uint_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_uint_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_uint_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_uint_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/scalar_ulp.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool1.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool1.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool1.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool1.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool1_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool1_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool1_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool1_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_bool4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_bool4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_bool4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_common.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_common.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_common.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_common.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_common.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_common.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_common.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_common.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double1.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double1.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double1.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double1.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double1_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double1_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double1_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double1_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_double4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_double4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_double4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float1.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float1.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float1.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float1.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float1_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float1_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float1_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float1_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float2_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float2_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float2_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float2_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float3_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float3_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float3_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float3_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_float4_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float4_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_float4_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_float4_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int1.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int1.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int1.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int1.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int1_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int1_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int1_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int1_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_int4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_int4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_int4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_integer.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_integer.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_integer.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_integer.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_integer.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_integer.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_integer.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_integer.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_packing.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_packing.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_packing.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_packing.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_packing.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_packing.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_packing.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_packing.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_reciprocal.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_relational.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_relational.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_relational.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_relational.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_relational.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_relational.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_relational.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_relational.inl diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint1.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint1.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint1.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint1.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint1_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint1_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint1_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint1_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint2_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint2_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint2_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint2_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint3_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint3_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint3_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint3_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_uint4_sized.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint4_sized.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_uint4_sized.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_uint4_sized.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.inl b/Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/ext/vector_ulp.inl diff --git a/ScriptShared/ScriptShared/glm/glm/fwd.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/fwd.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/fwd.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/fwd.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/geometric.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/geometric.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/geometric.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/geometric.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/glm.cppm b/Engine/ScriptShared/ScriptShared/glm/glm/glm.cppm similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/glm.cppm rename to Engine/ScriptShared/ScriptShared/glm/glm/glm.cppm diff --git a/ScriptShared/ScriptShared/glm/glm/glm.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/glm.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/glm.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/glm.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/bitfield.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/bitfield.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/bitfield.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/bitfield.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/bitfield.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/bitfield.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/bitfield.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/bitfield.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/color_space.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/color_space.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/color_space.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/color_space.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/color_space.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/color_space.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/color_space.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/color_space.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/constants.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/constants.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/constants.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/constants.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/constants.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/constants.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/constants.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/constants.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/epsilon.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/epsilon.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/epsilon.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/epsilon.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/epsilon.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/epsilon.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/epsilon.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/epsilon.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/integer.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/integer.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/integer.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/integer.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/integer.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/integer.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/integer.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/integer.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_access.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/matrix_integer.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_integer.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/matrix_integer.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_integer.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_inverse.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/matrix_transform.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/noise.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/noise.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/noise.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/noise.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/noise.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/noise.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/noise.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/noise.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/packing.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/packing.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/packing.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/packing.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/packing.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/packing.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/packing.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/packing.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/quaternion.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/quaternion.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/quaternion.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/quaternion.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/quaternion.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/quaternion.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/quaternion.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/quaternion.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/quaternion_simd.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/quaternion_simd.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/quaternion_simd.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/quaternion_simd.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/random.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/random.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/random.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/random.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/random.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/random.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/random.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/random.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/reciprocal.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/reciprocal.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/reciprocal.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/reciprocal.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/round.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/round.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/round.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/round.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/round.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/round.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/round.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/round.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/type_aligned.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_aligned.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/type_aligned.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_aligned.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/type_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/type_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/type_precision.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_precision.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/type_precision.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_precision.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/type_ptr.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/ulp.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/ulp.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/ulp.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/ulp.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/ulp.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/ulp.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/ulp.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/ulp.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtc/vec1.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtc/vec1.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtc/vec1.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtc/vec1.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/associated_min_max.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/bit.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/bit.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/bit.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/bit.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/bit.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/bit.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/bit.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/bit.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/closest_point.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/closest_point.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/closest_point.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/closest_point.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/closest_point.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/closest_point.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/closest_point.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/closest_point.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_encoding.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/color_space.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/color_space.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/color_space.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/color_space.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/color_space_YCoCg.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/common.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/common.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/common.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/common.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/common.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/common.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/common.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/common.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/compatibility.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/compatibility.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/compatibility.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/compatibility.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/compatibility.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/compatibility.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/compatibility.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/compatibility.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/component_wise.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/component_wise.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/component_wise.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/component_wise.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/component_wise.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/component_wise.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/component_wise.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/component_wise.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/dual_quaternion.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/easing.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/easing.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/easing.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/easing.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/easing.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/easing.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/easing.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/easing.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/euler_angles.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/extend.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/extend.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/extend.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/extend.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/extend.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/extend.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/extend.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/extend.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/extended_min_max.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/exterior_product.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_exponential.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_square_root.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/fast_trigonometry.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/float_normalize.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/float_normalize.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/float_normalize.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/float_normalize.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/functions.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/functions.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/functions.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/functions.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/functions.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/functions.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/functions.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/functions.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/gradient_paint.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/handed_coordinate_space.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/hash.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/hash.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/hash.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/hash.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/hash.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/hash.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/hash.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/hash.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/integer.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/integer.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/integer.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/integer.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/integer.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/integer.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/integer.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/integer.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/intersect.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/intersect.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/intersect.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/intersect.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/intersect.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/intersect.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/intersect.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/intersect.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/io.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/io.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/io.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/io.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/io.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/io.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/io.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/io.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/iteration.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/iteration.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/iteration.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/iteration.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/iteration.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/iteration.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/iteration.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/iteration.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/log_base.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/log_base.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/log_base.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/log_base.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/log_base.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/log_base.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/log_base.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/log_base.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_cross_product.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_decompose.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_factorisation.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_interpolation.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_major_storage.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_operation.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_query.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/matrix_transform_2d.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/mixed_product.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/norm.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/norm.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/norm.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/norm.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/norm.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/norm.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/norm.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/norm.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/normal.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/normal.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/normal.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/normal.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/normal.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/normal.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/normal.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/normal.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/normalize_dot.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/number_precision.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/number_precision.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/number_precision.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/number_precision.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/optimum_pow.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/orthonormalize.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/pca.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/pca.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/pca.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/pca.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/pca.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/pca.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/pca.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/pca.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/perpendicular.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/polar_coordinates.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/projection.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/projection.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/projection.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/projection.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/projection.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/projection.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/projection.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/projection.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/quaternion.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/quaternion.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/quaternion.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/quaternion.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/quaternion.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/quaternion.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/quaternion.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/quaternion.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/range.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/range.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/range.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/range.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/raw_data.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/raw_data.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/raw_data.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/raw_data.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/raw_data.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/raw_data.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/raw_data.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/raw_data.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_normalized_axis.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/rotate_vector.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/scalar_multiplication.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/scalar_multiplication.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/scalar_multiplication.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/scalar_multiplication.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/scalar_relational.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/spline.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/spline.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/spline.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/spline.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/spline.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/spline.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/spline.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/spline.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/std_based_type.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/string_cast.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/string_cast.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/string_cast.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/string_cast.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/string_cast.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/string_cast.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/string_cast.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/string_cast.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/structured_bindings.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/texture.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/texture.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/texture.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/texture.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/texture.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/texture.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/texture.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/texture.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/transform.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/transform.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/transform.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/transform.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/transform2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/transform2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/transform2.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform2.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/transform2.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/transform2.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_aligned.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/type_trait.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_trait.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/type_trait.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_trait.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/type_trait.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_trait.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/type_trait.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/type_trait.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/vec_swizzle.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/vec_swizzle.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/vec_swizzle.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/vec_swizzle.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_angle.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/vector_query.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_query.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/vector_query.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_query.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/vector_query.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_query.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/vector_query.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/vector_query.inl diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/wrap.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/wrap.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/wrap.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/wrap.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/gtx/wrap.inl b/Engine/ScriptShared/ScriptShared/glm/glm/gtx/wrap.inl similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/gtx/wrap.inl rename to Engine/ScriptShared/ScriptShared/glm/glm/gtx/wrap.inl diff --git a/ScriptShared/ScriptShared/glm/glm/integer.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/integer.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/integer.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/integer.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat2x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat2x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat2x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat2x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat2x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat2x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat2x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat2x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat2x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat2x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat2x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat2x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat3x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat3x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat3x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat3x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat3x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat3x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat3x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat3x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat3x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat3x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat3x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat3x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat4x2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat4x2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat4x2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat4x2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat4x3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat4x3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat4x3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat4x3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/mat4x4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/mat4x4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/mat4x4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/mat4x4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/matrix.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/matrix.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/matrix.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/matrix.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/packing.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/packing.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/packing.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/packing.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/simd/common.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/common.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/common.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/common.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/exponential.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/exponential.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/exponential.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/exponential.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/geometric.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/geometric.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/geometric.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/geometric.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/integer.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/integer.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/integer.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/integer.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/matrix.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/matrix.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/matrix.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/matrix.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/neon.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/neon.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/neon.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/neon.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/packing.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/packing.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/packing.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/packing.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/platform.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/platform.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/platform.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/platform.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/trigonometric.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/trigonometric.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/trigonometric.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/trigonometric.h diff --git a/ScriptShared/ScriptShared/glm/glm/simd/vector_relational.h b/Engine/ScriptShared/ScriptShared/glm/glm/simd/vector_relational.h similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/simd/vector_relational.h rename to Engine/ScriptShared/ScriptShared/glm/glm/simd/vector_relational.h diff --git a/ScriptShared/ScriptShared/glm/glm/trigonometric.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/trigonometric.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/trigonometric.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/trigonometric.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/vec2.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/vec2.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/vec2.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/vec2.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/vec3.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/vec3.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/vec3.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/vec3.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/vec4.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/vec4.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/vec4.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/vec4.hpp diff --git a/ScriptShared/ScriptShared/glm/glm/vector_relational.hpp b/Engine/ScriptShared/ScriptShared/glm/glm/vector_relational.hpp similarity index 100% rename from ScriptShared/ScriptShared/glm/glm/vector_relational.hpp rename to Engine/ScriptShared/ScriptShared/glm/glm/vector_relational.hpp diff --git a/Engine/UI/UI.cpp b/Engine/UI/UI.cpp deleted file mode 100644 index 8a0c89c..0000000 --- a/Engine/UI/UI.cpp +++ /dev/null @@ -1,294 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "UI.h" -#ifndef PRODUCTION - - - -UW::UI::UI(CW::Renderer::Renderer &window, float &fps, UW::Scene& scene) - :window(window), gui(&window), scene(scene), - info_ui(gui, fps, scene), - log_ui(gui), - materials_ui(gui), - objects_ui(gui, window, scene), - lights_ui(gui), - shader_ui(gui), - asset_loader_ui(gui, scene), - scripts_ui(gui){ - Logger::get().info("UI", "Initializing UI"); - - gui.setWorkspace(appWorkspace()); -}; - - - -UW::UI::~UI(){ - onDestroy(); -}; - - - -void UW::UI::onLoad(){ - Logger::get().info("UI", "Loading UI"); - - uiLoad(); - window.setSize(guiSettings.window_width, guiSettings.window_height); - Logger::get().info("UI", "Window Size Setted { "+ std::to_string(guiSettings.window_width) + " x " + std::to_string(guiSettings.window_height) +" }"); -}; - - - -void UW::UI::render(){ - gui.render(); -}; - - - -void UW::UI::onDestroy() { - Logger::get().info("UI", "Destroying UI"); - scripts_ui.saveScriptEditors(); - shader_ui.saveShaderEditors(); -}; - - - -// ========================= // -// ========== GUI ========== // -// ========================= // -void UW::UI::uiLoad(){ - configControl(); - ImGui::LoadIniSettingsFromDisk(ImGui::GetIO().IniFilename); - Logger::get().info("UI", "Loading UI Data from disck"); - - Resources::get().simulation_mode = guiSettings.simulation_mode; - - shader_ui.loadShaderEditors(); - scripts_ui.loadScriptEditors(); - - uiControl(); -}; - - -void UW::UI::configControl(){ - ImGuiSettingsHandler handler; - handler.TypeName = "GuiSettings"; - handler.TypeHash = ImHashStr("GuiSettings"); - - handler.ReadOpenFn = [](ImGuiContext*, ImGuiSettingsHandler*, const char*){ - return (void*)&UW::guiSettings; - }; - - handler.ReadLineFn = [](ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line){ - GuiSettings* s = (GuiSettings*)entry; - - int value; - if (sscanf(line, "InfoWindowOn=%d", &value) == 1) s->infoWindowOn = value; - if (sscanf(line, "LogWindowOn=%d", &value) == 1) s->logWindowOn = value; - if (sscanf(line, "MaterialExplorerOn=%d", &value) == 1) s->materialExplorerOn = value; - if (sscanf(line, "LightsExplorerOn=%d", &value) == 1) s->lightsExplorerOn = value; - if (sscanf(line, "MaterialEditorOn=%d", &value) == 1) s->materialEditorOn = value; - if (sscanf(line, "ShaderExplorerWindowOn=%d", &value) == 1) s->shaderExplorerWindowOn = value; - if (sscanf(line, "ScriptsExplorerWindowOn=%d", &value) == 1) s->scriptsExplorerWindowOn= value; - if (sscanf(line, "ShaderEditorWindowOn=%d", &value) == 1) s->shaderEditorWindowOn = value; - if (sscanf(line, "ScriptEditorWindowOn=%d", &value) == 1) s->scriptEditorWindowOn = value; - if (sscanf(line, "ObjectExplorerWindowOn=%d", &value) == 1) s->objectExplorerWindowOn = value; - if (sscanf(line, "ObjectEditorWindowOn=%d", &value) == 1) s->objectEditorWindowOn = value; - if (sscanf(line, "Object_ID=%d", &value) == 1) s->object_id = value; - if (sscanf(line, "Mesh_Mode_On=%d", &value) == 1) s->mesh_mode_on = value; - if (sscanf(line, "Window_Width=%d", &value) == 1) s->window_width = value; - if (sscanf(line, "Window_Height=%d", &value) == 1) s->window_height = value; - if (sscanf(line, "Simulation_Mode=%d", &value) == 1) s->simulation_mode = value; - - char value_str[256]; - if (sscanf(line, "Material_ID=%255s", &value_str) == 1) s->material_name = std::string(value_str); - - char name[256]; - unsigned int type; - - if (sscanf(line, "ShaderEditor=%255[^,],%u", name, &type) == 2){ - s->shader_editors_reg.emplace_back(name, type); - }; - - if (sscanf(line, "ScriptEditor=%255[^,]", name) == 1){ - s->scripts_editors_reg.emplace_back(name); - }; - }; - - handler.WriteAllFn = [](ImGuiContext*, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf){ - out_buf->appendf("[%s][Main]\n", handler->TypeName); - out_buf->appendf("InfoWindowOn=%d\n", guiSettings.infoWindowOn); - out_buf->appendf("LogWindowOn=%d\n", guiSettings.logWindowOn); - out_buf->appendf("MaterialExplorerOn=%d\n", guiSettings.materialExplorerOn); - out_buf->appendf("LightsExplorerOn=%d\n", guiSettings.lightsExplorerOn); - out_buf->appendf("MaterialEditorOn=%d\n", guiSettings.materialEditorOn); - out_buf->appendf("ShaderExplorerWindowOn=%d\n", guiSettings.shaderExplorerWindowOn); - out_buf->appendf("ScriptsExplorerWindowOn=%d\n", guiSettings.scriptsExplorerWindowOn); - out_buf->appendf("ShaderEditorWindowOn=%d\n", guiSettings.shaderEditorWindowOn); - out_buf->appendf("ScriptEditorWindowOn=%d\n", guiSettings.scriptEditorWindowOn); - out_buf->appendf("ObjectExplorerWindowOn=%d\n", guiSettings.objectExplorerWindowOn); - out_buf->appendf("ObjectEditorWindowOn=%d\n", guiSettings.objectEditorWindowOn); - out_buf->appendf("Object_ID=%d\n", guiSettings.object_id); - out_buf->appendf("Mesh_Mode_On=%d\n", guiSettings.mesh_mode_on); - out_buf->appendf("Window_Width=%d\n", guiSettings.window_width); - out_buf->appendf("Window_Height=%d\n", guiSettings.window_height); - out_buf->appendf("Material_ID=%s\n", guiSettings.material_name.c_str()); - out_buf->appendf("Simulation_Mode=%d\n", guiSettings.simulation_mode); - - out_buf->appendf("ShaderEditorCount=%zu\n", guiSettings.shader_editors_reg.size()); - - for (size_t i = 0; i < guiSettings.shader_editors_reg.size(); ++i){ - out_buf->appendf( - "ShaderEditor=%s,%u\n", - guiSettings.shader_editors_reg[i].first.c_str(), - guiSettings.shader_editors_reg[i].second - ); - }; - - out_buf->appendf("ScriptEditorCount=%zu\n", guiSettings.scripts_editors_reg.size()); - - for (size_t i = 0; i < guiSettings.scripts_editors_reg.size(); ++i){ - out_buf->appendf( - "ScriptEditor=%s\n", - guiSettings.scripts_editors_reg[i].c_str() - ); - }; - - out_buf->append("\n"); - }; - - ImGui::GetCurrentContext()->SettingsHandlers.push_back(handler); -}; - - - -void UW::UI::uiControl(){ - info_ui.uiControl(); - log_ui.uiControl(); - materials_ui.uiControl(); - objects_ui.uiControl(); - lights_ui.uiControl(); - shader_ui.uiControl(); - asset_loader_ui.uiControl(); - scripts_ui.uiControl(); -}; - - - -void UW::UI::menuBarGui(){ - if (ImGui::BeginMenuBar()) { - if (ImGui::BeginMenu("Window")) { - if(ImGui::MenuItem("Info")){ - guiSettings.infoWindowOn = !guiSettings.infoWindowOn; - uiControl(); - }; - if(ImGui::MenuItem("Logs")){ - guiSettings.logWindowOn = !guiSettings.logWindowOn; - uiControl(); - }; - if(ImGui::MenuItem("Material Explorer")){ - guiSettings.materialExplorerOn = !guiSettings.materialExplorerOn; - uiControl(); - }; - if(ImGui::MenuItem("Material Editor")){ - guiSettings.materialEditorOn = !guiSettings.materialEditorOn; - uiControl(); - }; - if(ImGui::MenuItem("Lights Explorer")){ - guiSettings.lightsExplorerOn = !guiSettings.lightsExplorerOn; - uiControl(); - }; - if(ImGui::MenuItem("Shader Explorer")){ - guiSettings.shaderExplorerWindowOn = !guiSettings.shaderExplorerWindowOn; - uiControl(); - }; - if(ImGui::MenuItem("Script Explorer")){ - guiSettings.scriptsExplorerWindowOn = !guiSettings.scriptsExplorerWindowOn; - uiControl(); - }; - if(ImGui::MenuItem("Object Explorer")){ - guiSettings.objectExplorerWindowOn = !guiSettings.objectExplorerWindowOn; - uiControl(); - }; - if(ImGui::MenuItem("Object Editor")){ - guiSettings.objectEditorWindowOn = !guiSettings.objectEditorWindowOn; - uiControl(); - }; - ImGui::EndMenu(); - }; - - if(ImGui::BeginMenu("Assets")){ - if(ImGui::MenuItem("Asset Loader")){ - guiSettings.assetLoaderWindowOn = !guiSettings.assetLoaderWindowOn; - uiControl(); - }; - ImGui::EndMenu(); - }; - - if(ImGui::BeginMenu("Properties")){ - char title_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE] = {}; - memcpy(title_buffer, UW::GlobResource::get().WINDOW_TITLE.data(), UW::GlobResource::get().WINDOW_TITLE.size()); - if(ImGui::InputText("Window Title", title_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - UW::GlobResource::get().WINDOW_TITLE = std::string(title_buffer); - }; - - bool vsync_on = UW::GlobResource::get().VSYNC; - if(ImGui::Checkbox("Vsync", &vsync_on)) UW::GlobResource::get().VSYNC = vsync_on; - - float fixed_hz = UW::GlobResource::get().FIXED_HZ; - if(ImGui::InputFloat("Fixed_HZ", &fixed_hz)){ - UW::GlobResource::get().FIXED_HZ = fixed_hz; - }; - - ImGui::EndMenu(); - }; - - bool new_simulation_mode = Resources::get().simulation_mode; - if(ImGui::Checkbox("Simulation", &new_simulation_mode)){ - Resources::get().simulation_mode = new_simulation_mode; - guiSettings.simulation_mode = new_simulation_mode; - }; - - ImGui::EndMenuBar(); - }; -}; - - -std::function render_windows)> UW::UI::appWorkspace() { - return [this](std::function render_windows){ - ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_MenuBar; - - const ImGuiViewport* viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(viewport->WorkPos); - ImGui::SetNextWindowSize(viewport->WorkSize); - ImGui::SetNextWindowViewport(viewport->ID); - - window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | - ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | - ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus; - - ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); - ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); - - ImGui::Begin("Window DockSpace", nullptr, window_flags); - - ImGui::PopStyleVar(2); - ImGui::PopStyleColor(); - - menuBarGui(); - - ImGuiID docspace_id = ImGui::GetID("MyDockSpace"); - ImGui::DockSpace(docspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode); - - render_windows(); - - ImGui::End(); - }; -}; - -#endif diff --git a/Engine/UI/UI_Info.cpp b/Engine/UI/UI_Info.cpp deleted file mode 100644 index 1042b12..0000000 --- a/Engine/UI/UI_Info.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "UI_Info.h" - -#ifndef PRODUCTION - - - -UW::UI_Info::UI_Info(CW::Gui::Gui& gui, float &fps, UW::Scene& scene) - :gui(gui), fps(fps), scene(scene){}; - - - -UW::UI_Info::~UI_Info(){}; - - - -void UW::UI_Info::uiControl(){ - if(guiSettings.infoWindowOn){ - Logger::get().info("UI", "Opening Info Gui"); - gui.addWindow("Info Gui", ui()); - } - else{ - Logger::get().info("UI", "Closing Info GUI"); - gui.deleteWindow("Info Gui"); - }; -}; - - - -inline void UW::UI_Info::guiInfo(){ - ImGui::SeparatorText("Info"); - ImGui::Text("FPS: %f", fps); - - ImGui::Text("Current camera: %s", scene.debug_camera_on ? "Debug" : "Normal"); - - ImGui::Text("Camera:"); - ImGui::InputFloat3("Camera POS: [%f, %f, %f]", &scene.camera.position[0]); - ImGui::SliderFloat3("Camera DIR: [%f, %f, %f]", &scene.camera.direction[0], -1, 1); - - ImGui::Text("Debug Camera:"); - ImGui::InputFloat3("Debug POS: [%f, %f, %f]", &scene.debug_camera.position[0]); - ImGui::SliderFloat3("Debug DIR: [%f, %f, %f]", &scene.debug_camera.direction[0], -1, 1); - - if(ImGui::Checkbox("Mesh mode", &guiSettings.mesh_mode_on)) mesh_mode_is_updated = false; - if(!mesh_mode_is_updated){ - mesh_mode_is_updated = true; - if(guiSettings.mesh_mode_on){ - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - Logger::get().info("UI", "Changed Draw Mode To Mesh"); - } - else{ - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - Logger::get().info("UI", "Changed Draw Mode To Normal"); - }; - }; - - if(ImGui::Checkbox("Post Processing", &scene.post_processing_on)); - if(ImGui::Checkbox("Shadows", &scene.shadows_on)); - - if(ImGui::Checkbox("Water_on", &scene.water_on)); - if(ImGui::Checkbox("Terrain_on", &scene.terrain_on)); -}; - - - -void UW::UI_Info::guiControlsInfo(){ - ImGui::SeparatorText("Controls Info"); - - ImGui::Text("- Swap Camera: %s", UW::Config::SWAP_CAMERA_BTN.c_str()); - ImGui::Text("- Swap Camera Mode: %s", UW::Config::CAMERA_SWAP_MODE_BTN.c_str()); - ImGui::Text("- Camera Accelerate: %s", UW::Config::CAMERA_ACCELERATE.c_str()); - ImGui::Text("- Camera Decelerate: %s", UW::Config::CAMERA_DECELERATE.c_str()); - ImGui::Text("- Move Forward: %s", UW::Config::CAMERA_MOVE_FORWARD.c_str()); - ImGui::Text("- Move Back: %s", UW::Config::CAMERA_MOVE_BACK.c_str()); - ImGui::Text("- Move Right: %s", UW::Config::CAMERA_MOVE_RIGHT.c_str()); - ImGui::Text("- Move Left: %s", UW::Config::CAMERA_MOVE_LEFT.c_str()); -}; - - - -inline std::function UW::UI_Info::ui(){ -return [this](CW::Renderer::iRenderer *window){ - guiControlsInfo(); - guiInfo(); -}; -}; - -#endif diff --git a/Engine/UI/UI_Materials.cpp b/Engine/UI/UI_Materials.cpp deleted file mode 100644 index 91bdc20..0000000 --- a/Engine/UI/UI_Materials.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "UI_Materials.h" - -#ifndef PRODUCTION - - - -UW::UI_Materials::UI_Materials(CW::Gui::Gui& gui) - :gui(gui){}; - - - -UW::UI_Materials::~UI_Materials(){ -}; - - - -void UW::UI_Materials::uiControl(){ - if(guiSettings.materialExplorerOn){ - Logger::get().info("UI", "Opening Materials Explorer GUI"); - gui.addWindow("Material Explorer", materialExplorerGui()); - } - else{ - Logger::get().info("UI", "Closing Materials Explorer GUI"); - gui.deleteWindow("Material Explorer"); - }; - - if(guiSettings.materialEditorOn){ - Logger::get().info("UI", "Opening Materials Editor GUI"); - gui.addWindow("Material Editor", materialEditorGui()); - } - else{ - Logger::get().info("UI", "Closing Materials Editor GUI"); - gui.deleteWindow("Material Editor"); - }; -}; - - - -inline void UW::UI_Materials::guiMaterialList(){ - ImGui::SeparatorText("Materials List"); - - for (std::pair el : Resources::get().materials.getMaterialReg()) { - std::string button_label = "- " + el.first; - if (ImGui::Button(button_label.c_str())) guiSettings.material_name = el.first; - - button_label = "Delete ##" + el.first; - ImGui::SameLine(); - if (ImGui::Button(button_label.c_str())) { - Resources::get().materials.erase(el.first); - Logger::get().warn("UI", "Deleted Material { " + el.first + " }"); - break; - }; - }; - - std::string button_label = "Add " + std::to_string(Resources::get().materials.size()); - if (ImGui::Button(button_label.c_str())) { - Resources::get().materials.emplace_back("new material", UW::Material()); - Logger::get().info("UI", "Added new Material { new material }"); - }; -}; - - - -inline std::function UW::UI_Materials::materialExplorerGui(){ -return [this](CW::Renderer::iRenderer *window){ - guiMaterialList(); -}; -}; - - - -inline void UW::UI_Materials::guiMaterialParameters(){ - ImGui::SeparatorText("Materials Parameters"); - ImGui::Text("Material id: %s", guiSettings.material_name.c_str()); - - if(!Resources::get().materials.find(guiSettings.material_name)) return; - - Material temp_mat = Resources::get().materials.getMaterial(guiSettings.material_name); - - char name_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE]; - memcpy(name_buffer, guiSettings.material_name.data(), guiSettings.material_name.size()); - name_buffer[guiSettings.material_name.size()] = '\0'; - if(ImGui::InputText("name", name_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - Resources::get().materials.erase(guiSettings.material_name); - guiSettings.material_name = std::string(name_buffer + '\0'); - Resources::get().materials.emplace_back(guiSettings.material_name, temp_mat); - }; - - if(ImGui::ColorEdit3("Albedo: ", &temp_mat.albedo[0])) material_is_updated = true; - if(ImGui::SliderFloat("Roughness: ", &temp_mat.roughness, 0.0f, 1.0f)) material_is_updated = true; - if(ImGui::SliderFloat("Metallic: ", &temp_mat.metallic, 0.0f, 1.0f)) material_is_updated = true; - if(ImGui::ColorEdit3("Emission Color: ", &temp_mat.emission_color[0])) material_is_updated = true; - if(ImGui::SliderFloat("Emission Strength: ", &temp_mat.emission_strength, 0.0f, 1.0f)) material_is_updated = true; - if(ImGui::SliderFloat("Ambient Occlusion: ", &temp_mat.ambient_occlusion, 0.0f, 1.0f)) material_is_updated = true; - - if(material_is_updated){ - Logger::get().info("UI", "Updating Material { " + guiSettings.material_name + " }"); - material_is_updated = false; - Resources::get().materials[guiSettings.material_name] = temp_mat; - Resources::get().materials.compile(); - }; -}; - - - -std::function UW::UI_Materials::materialEditorGui(){ - return [this](CW::Renderer::iRenderer *window){ - guiMaterialParameters(); - }; -}; - -#endif diff --git a/Engine/UI/UI_Objects.cpp b/Engine/UI/UI_Objects.cpp deleted file mode 100644 index 3b42d7c..0000000 --- a/Engine/UI/UI_Objects.cpp +++ /dev/null @@ -1,418 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "UI_Objects.h" - -#ifndef PRODUCTION - - - -UW::UI_Objects::UI_Objects(CW::Gui::Gui& gui, CW::Renderer::Renderer& window, UW::Scene& scene) - :gui(gui), window(window), scene(scene) {}; - - - -UW::UI_Objects::~UI_Objects(){ -}; - - - -void UW::UI_Objects::uiControl(){ - if(guiSettings.objectExplorerWindowOn){ - Logger::get().info("UI", "Opening Object Explorer GUI"); - gui.addWindow("Object Explorer", objectExplorerGui()); - } - else{ - Logger::get().info("UI", "Closing Object Explorer GUI"); - gui.deleteWindow("Object Explorer"); - }; - - if(guiSettings.objectEditorWindowOn){ - Logger::get().info("UI", "Opening Object Editor GUI"); - gui.addWindow("Object Editor", objectEditorGui()); - } - else{ - Logger::get().info("UI", "Closing Object Explorer GUI"); - gui.deleteWindow("Object Editor"); - }; -}; - - - -void UW::UI_Objects::guiObjectList(){ - ImGui::SeparatorText("Object List"); - - for(unsigned int id = 0; id < UW::ObjectManager::get().objects.size(); id++){ - if(UW::ObjectManager::get().objects[id].copy_game_object_data.hidden) continue; - - std::string label = "- " + UW::ObjectManager::get().objects[id].game_object_data.name + "##(" + std::to_string(id) + ")"; - if(ImGui::Button(label.c_str())) guiSettings.object_id = id; - - label = "Delete##" + std::to_string(id); - ImGui::SameLine(); - if(ImGui::Button(label.c_str())) { - UW::ObjectManager::get().objects.erase(UW::ObjectManager::get().objects.begin() + id); - Logger::get().warn("UI", "Deleted Object { " + UW::ObjectManager::get().objects[id].game_object_data.name + " }"); - }; - - label = "Duplicate##" + std::to_string(id); - ImGui::SameLine(); - if(ImGui::Button(label.c_str())) { - UW::ObjectManager::get().objects.emplace_back(GameObject(UW::ObjectManager::get().objects[id].game_object_data.name + "_copy", UW::ObjectManager::get().objects[id])); - Logger::get().warn("UI", "Duplicated Object { " + UW::ObjectManager::get().objects[id].game_object_data.name + " }"); - }; - }; - - if(ImGui::Button("Add new")) { - UW::ObjectManager::get().objects.emplace_back(UW::GameObject("new object", "testing", "testing", {}, {}, {}, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f), glm::vec3(1.0f))); - Logger::get().info("UI", "Added New Object { new object }"); - }; -}; - - - -std::function UW::UI_Objects::objectExplorerGui(){ -return [this](CW::Renderer::iRenderer *window){ - guiObjectList(); -}; -}; - - - -void UW::UI_Objects::guiObjectEditor(){ - ImGui::SeparatorText("Object Editor"); - if(guiSettings.object_id >= UW::ObjectManager::get().objects.size()) return; - - UW::GameObject& object = UW::ObjectManager::get().objects[guiSettings.object_id]; - - char name_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE]; - memcpy(name_buffer, object.game_object_data.name.data(), object.game_object_data.name.size()); - name_buffer[object.game_object_data.name.size()] = '\0'; - if(ImGui::InputText("name", name_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - object.stopScripts(); - object.game_object_data.name = std::string(name_buffer + '\0'); - object.startScripts(); - }; - - char mesh_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE]; - memcpy(mesh_buffer, object.game_object_data.mesh.data(), object.game_object_data.mesh.size()); - mesh_buffer[object.game_object_data.mesh.size()] = '\0'; - if(ImGui::InputText("mesh", mesh_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - if(!Resources::get().meshes.exists(mesh_buffer)) return; - object.stopScripts(); - object.game_object_data.mesh = std::string(mesh_buffer + '\0'); - object.startScripts(); - }; - - char shader_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE]; - memcpy(shader_buffer, object.game_object_data.shader.data(), object.game_object_data.shader.size()); - shader_buffer[object.game_object_data.shader.size()] = '\0'; - if(ImGui::InputText("shader", shader_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - auto its = Resources::get().shaders.find(shader_buffer); - if(its == Resources::get().shaders.end()) return; - object.stopScripts(); - object.game_object_data.shader = std::string(shader_buffer + '\0'); - object.startScripts(); - }; - - - glm::vec3 new_position = object.game_object_data.position; - if(ImGui::InputFloat3("position: ", &new_position[0])) { - object.stopScripts(); - object.game_object_data.position = new_position; - object.startScripts(); - }; - - glm::vec3 position_offset = glm::vec3(0.0f); - if(ImGui::SliderFloat3("position slider: ", &position_offset[0], -10.0f, 10.0f)){ - object.stopScripts(); - object.game_object_data.position += position_offset * window.getWindowData()->delta_time; - object.startScripts(); - }; - - glm::vec3 new_rotation = object.game_object_data.rotation; - if(ImGui::InputFloat3("rotate: ", &new_rotation[0])){ - object.stopScripts(); - object.game_object_data.rotation = new_rotation; - object.startScripts(); - }; - - glm::vec3 rotate_offset = glm::vec3(0.0f); - if(ImGui::SliderFloat3("rotate slider: ", &rotate_offset[0], -1.0f, 1.0f)){ - object.stopScripts(); - object.game_object_data.rotation += rotate_offset * window.getWindowData()->delta_time; - object.startScripts(); - }; - - glm::vec3 new_scale = object.game_object_data.scale; - if(ImGui::InputFloat3("scale: ", &new_scale[0])){ - object.stopScripts(); - object.game_object_data.scale = new_scale; - object.startScripts(); - }; - - glm::vec3 scale_offset = glm::vec3(0.0f); - if(ImGui::SliderFloat3("scale slider: ", &scale_offset[0], -100.0f, 100.0f)){ - object.stopScripts(); - object.game_object_data.scale += scale_offset * window.getWindowData()->delta_time; - object.startScripts(); - }; - - ImGui::SeparatorText("Textures: "); - for(int i = 0; i < object.game_object_data.textures.size(); i++){ - std::string label = "- texture (" + std::to_string(i) + ")"; - char texture_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE]; - memcpy(texture_buffer, object.game_object_data.textures[i].data(), object.game_object_data.textures[i].size()); - texture_buffer[object.game_object_data.textures[i].size()] = '\0'; - if(ImGui::InputText(label.c_str(), texture_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - object.stopScripts(); - object.game_object_data.textures[i] = std::string(texture_buffer + '\0'); - object.startScripts(); - }; - - ImGui::SameLine(); - label = "Delete texture##(" + std::to_string(i) + ")"; - if(ImGui::Button(label.c_str())) { - object.stopScripts(); - object.game_object_data.textures.erase(object.game_object_data.textures.begin() + i); - object.startScripts(); - }; - }; - - std::string label = "Add Texture (" + std::to_string(object.game_object_data.textures.size()) + ")"; - if(ImGui::Button(label.c_str())) { - object.stopScripts(); - object.game_object_data.textures.emplace_back(""); - object.startScripts(); - }; - - - ImGui::SeparatorText("Materials: "); - for(int i = 0; i < object.game_object_data.materials.size(); i++){ - std::string label = "- material (" + std::to_string(i) + ")"; - - char material_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE]; - memcpy(material_buffer, object.game_object_data.materials[i].data(), object.game_object_data.materials[i].size()); - material_buffer[object.game_object_data.materials[i].size()] = '\0'; - if(ImGui::InputText(label.c_str(), material_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - object.stopScripts(); - if(!Resources::get().materials.find(material_buffer)) return; - object.game_object_data.materials[i] = std::string(material_buffer + '\0'); - object.startScripts(); - }; - - ImGui::SameLine(); - label = "Delete material##(" + std::to_string(i) + ")"; - if(ImGui::Button(label.c_str())) { - object.stopScripts(); - object.game_object_data.materials.erase(object.game_object_data.materials.begin() + i); - object.startScripts(); - } - }; - - label = "Add material (" + std::to_string(object.game_object_data.materials.size()) + ")"; - if(ImGui::Button(label.c_str())) { - object.stopScripts(); - object.game_object_data.materials.emplace_back("new material"); - object.startScripts(); - }; - - - ImGui::SeparatorText("Scripts: "); - for(int i = 0; i < object.scripts.size(); i++){ - bool new_script_on = object.scripts[i].script_on; - if(ImGui::Checkbox(std::string("##ScriptOn(" + std::to_string(i) + ")").c_str(), &new_script_on)){ - object.stopScripts(); - object.scripts[i].script_on = new_script_on; - object.startScripts(); - }; - - ImGui::SameLine(); - std::string label = "- script (" + std::to_string(i) + ")"; - - char script_buffer[UW::Config::OBJECT_NAME_BUFFER_SIZE]; - memcpy(script_buffer, object.scripts[i].getPath().data(), object.scripts[i].getPath().size()); - script_buffer[object.scripts[i].getPath().size()] = '\0'; - if(ImGui::InputText(label.c_str(), script_buffer, UW::Config::OBJECT_NAME_BUFFER_SIZE)){ - object.stopScripts(); - object.scripts[i] = UW::GameObjectScriptRecord(std::string(script_buffer + '\0')); - object.scripts[i].script_on = new_script_on; - object.startScripts(); - } - - ImGui::SameLine(); - label = "Delete scripts##(" + std::to_string(i) + ")"; - if(ImGui::Button(label.c_str())) { - object.stopScripts(); - object.scripts.erase(object.scripts.begin() + i); - object.startScripts(); - }; - }; - - label = "Add script (" + std::to_string(object.scripts.size()) + ")"; - if(ImGui::Button(label.c_str())) { - object.stopScripts(); - object.scripts.emplace_back(GameObjectScriptRecord("new script")); - object.startScripts(); - }; - - - ImGui::SeparatorText("Parameters"); - - auto& params = object.game_object_data.parameters; - - for (auto it = params.begin(); it != params.end();) { - const std::string& current_name = it->first; - auto& param_value = it->second; - - ImGui::PushID(current_name.c_str()); - - bool delete_triggered = false; - bool rename_triggered = false; - char name_buffer[128]; - strncpy(name_buffer, current_name.c_str(), sizeof(name_buffer) - 1); - name_buffer[sizeof(name_buffer) - 1] = '\0'; - - ImGui::SetNextItemWidth(120.0f); - if (ImGui::InputText("##ParamName", name_buffer, sizeof(name_buffer), ImGuiInputTextFlags_EnterReturnsTrue)) { - rename_triggered = true; - } - if (ImGui::IsItemDeactivatedAfterEdit()) { - rename_triggered = true; - } - - ImGui::SameLine(); - - int current_type_idx = static_cast(param_value.index()); - ImGui::SetNextItemWidth(70.0f); - if (ImGui::Combo("##ParamType", ¤t_type_idx, UW::gameObjectParameterTypeName, IM_ARRAYSIZE(UW::gameObjectParameterTypeName))) { - object.stopScripts(); - switch (current_type_idx) { - case 0: param_value = 0; break; - case 1: param_value = 0.0f; break; - case 2: param_value = false; break; - case 3: param_value = glm::vec2(0.0f); break; - case 4: param_value = glm::vec3(0.0f); break; - case 5: param_value = std::string(""); break; - } - object.startScripts(); - } - - ImGui::SameLine(); - - std::visit([&object](auto&& arg) { - using T = std::decay_t; - ImGui::SetNextItemWidth(150.0f); - - if constexpr (std::is_same_v) { - int new_arg = arg; - if(ImGui::InputInt("##val", &new_arg)){ - object.stopScripts(); - arg = new_arg; - object.startScripts(); - } - } - else if constexpr (std::is_same_v) { - float new_arg = arg; - if(ImGui::DragFloat("##val", &new_arg, 0.05f)){ - object.stopScripts(); - arg = new_arg; - object.startScripts(); - } - } - else if constexpr (std::is_same_v) { - bool new_arg = arg; - if(ImGui::Checkbox("##val", &new_arg)){ - object.stopScripts(); - arg = new_arg; - object.startScripts(); - } - } - else if constexpr (std::is_same_v) { - glm::vec2 new_arg = arg; - if(ImGui::DragFloat2("##val", &new_arg.x, 0.05f)){ - object.stopScripts(); - arg = new_arg; - object.startScripts(); - } - } - else if constexpr (std::is_same_v) { - glm::vec3 new_arg = arg; - if(ImGui::DragFloat3("##val", &new_arg.x, 0.05f)){ - object.stopScripts(); - arg = new_arg; - object.startScripts(); - } - } - else if constexpr (std::is_same_v) { - char str_buffer[256]; - strncpy(str_buffer, arg.c_str(), sizeof(str_buffer) - 1); - str_buffer[sizeof(str_buffer) - 1] = '\0'; - if (ImGui::InputText("##val", str_buffer, sizeof(str_buffer))) { - object.stopScripts(); - arg = std::string(str_buffer); - object.startScripts(); - } - } - }, param_value); - - ImGui::SameLine(); - - if (ImGui::Button("Delete")) { - delete_triggered = true; - } - - ImGui::PopID(); - - if (delete_triggered) { - object.stopScripts(); - it = params.erase(it); - object.startScripts(); - } - else if (rename_triggered && std::string(name_buffer) != current_name && !std::string(name_buffer).empty()) { - std::string new_key = name_buffer; - - object.stopScripts(); - if (params.find(new_key) == params.end()) { - params[new_key] = std::move(param_value); - it = params.erase(it); - } else { - ++it; - } - object.startScripts(); - } - else { - ++it; - } - } - - ImGui::Spacing(); - - std::string add_label = "Add Parameter (" + std::to_string(params.size()) + ")"; - if (ImGui::Button(add_label.c_str())) { - object.stopScripts(); - std::string unique_new_name = "NewParameter_" + std::to_string(params.size()); - - int safety_counter = 0; - while(params.find(unique_new_name) != params.end()) { - unique_new_name = "NewParameter_" + std::to_string(params.size() + (++safety_counter)); - } - - params[unique_new_name] = 0; - object.startScripts(); - } -}; - - - -std::function UW::UI_Objects::objectEditorGui(){ - return [this](CW::Renderer::iRenderer *window){ - guiObjectEditor(); - }; -}; - -#endif diff --git a/Engine/UI/UI_ShaderEditors.cpp b/Engine/UI/UI_ShaderEditors.cpp deleted file mode 100644 index aedf158..0000000 --- a/Engine/UI/UI_ShaderEditors.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "UI_ShaderEditors.h" -#ifndef PRODUCTION - - - -UW::UI_ShaderEditor::UI_ShaderEditor(CW::Gui::Gui& gui, const std::string& name, GLenum type) - :gui(gui), shader_name(name), shader_type(type){ - - Logger::get().info("UI_ShaderEditor", "Opened { " + shader_name + " : " + UW::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); - gui.addWindow("Shader Editor " + shader_name + " : " + UW::Config::SHADER_TYPE_TO_NAME[shader_type], shaderEditorGui()); -}; - - - -UW::UI_ShaderEditor::~UI_ShaderEditor(){ - gui.deleteWindow("Shader Editor " + shader_name + " : " + UW::Config::SHADER_TYPE_TO_NAME[shader_type]); - Logger::get().info("UI_ShaderEditor", "Closed { " + shader_name + " : " + UW::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); -}; - - - -void UW::UI_ShaderEditor::guiShaderLoad(const std::string& name, GLenum type){ - if(shader_is_loaded) return; - - shader_name = name; - shader_type = type; - memset(buffer, '\0', UW::Config::SHADER_EDITOR_BUFFER_SIZE); - - auto it = Resources::get().shaders.find(name); - if(it == Resources::get().shaders.end()) return; - - const std::unordered_map& reg = Resources::get().getShader(name).getRegisterShader(); - auto ita = reg.find(type); - if(ita == reg.end()) return; - - std::string source = reg.at(type).getSource(); - memcpy(buffer, source.data(), source.size()); - - - Logger::get().info("UI_ShaderEditor", "Loaded { " + shader_name + " : " + UW::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); - shader_is_loaded = true; -}; - - - -void UW::UI_ShaderEditor::guiShaderEditor(){ - float width = ImGui::GetContentRegionAvail().x; - float height = ImGui::GetContentRegionAvail().y - 50.0f; - - ImGui::SeparatorText("Shader Editor"); - ImGui::Text("Shader: %s : %s", shader_name.c_str(), UW::Config::SHADER_TYPE_TO_NAME[shader_type].c_str()); - - ImGui::InputTextMultiline("##Shader Content", buffer, UW::Config::SHADER_EDITOR_BUFFER_SIZE, ImVec2(width, height), ImGuiInputTextFlags_WordWrap); - - auto it = Resources::get().shaders.find(shader_name); - if(it == Resources::get().shaders.end()) return; - - auto& reg = Resources::get().getShader(shader_name).getRegisterShader(); - auto it2 = reg.find(shader_type); - if(it2 == reg.end()) return; - - if(strcmp(buffer, reg.at(shader_type).getSource().c_str()) != 0) shader_is_updated = true; - - if(shader_is_updated){ - shader_is_updated = false; - - Resources::get().getShader(shader_name).destroy(); - Resources::get().getShader(shader_name).removeShaders(shader_type); - Resources::get().getShader(shader_name).setShader(buffer, shader_type); - Resources::get().getShader(shader_name).compile(); - DataSerializer::get().saveShaders(shader_name, shader_type); - - Logger::get().info("UI_ShaderEditor", "Saved { " + shader_name + " : " + UW::Config::SHADER_TYPE_TO_NAME[shader_type] + " }"); - }; -}; - - - -inline std::function UW::UI_ShaderEditor::shaderEditorGui(){ -return [this](CW::Renderer::iRenderer *window){ - guiShaderLoad(shader_name, shader_type); - guiShaderEditor(); -}; -}; - - - -std::string UW::UI_ShaderEditor::getName(){ - return shader_name; -}; - - - -GLenum UW::UI_ShaderEditor::getType(){ - return shader_type; -}; - -#endif diff --git a/Engine/Utils/CMakeLists.txt b/Engine/Utils/CMakeLists.txt new file mode 100644 index 0000000..7d17fc0 --- /dev/null +++ b/Engine/Utils/CMakeLists.txt @@ -0,0 +1,26 @@ +# Engine +# Copyright 2026 Daynlight +# Licensed under the GNU General, Version 3.0. +# See LICENSE file for details. + + + +cmake_minimum_required(VERSION 3.15) + +project(Utils LANGUAGES CXX C) +project(UtilsDev LANGUAGES CXX C) + + +set(src + "Utils/Logger.cpp" +) + + +add_library(Utils STATIC ${src}) +target_link_libraries(Utils CWindow) +target_include_directories(Utils PUBLIC "." "../ScriptShared") +target_compile_definitions(Utils PRIVATE PRODUCTION) + +add_library(UtilsDev STATIC ${src}) +target_link_libraries(UtilsDev CWindow) +target_include_directories(UtilsDev PUBLIC "." "../ScriptShared") diff --git a/Engine/Utils/Logger.cpp b/Engine/Utils/Logger.cpp deleted file mode 100644 index 7cd3965..0000000 --- a/Engine/Utils/Logger.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#include "Logger.h" - - - -UW::Log::Log(UW::LogType type, const std::string& module, const std::string& text) - :type(type), module(module), text(text){}; - - - -std::string UW::Log::getText() const { - return "["+ getTypeText() +"] ("+ module +"): " + text; -}; - - - -std::string UW::Log::getTypeText() const{ - #ifndef PRODUCTION - switch (type){ - case UW::LogType::INFO: - return "INFO"; - case UW::LogType::WARN: - return "WARN"; - case UW::LogType::ERRO: - return "ERRO"; - default: - return "NO TYPE"; - }; - #endif - - return "NO TYPE"; -}; - - - -ImVec4 UW::Log::getLogColor() const{ - #ifndef PRODUCTION - switch(type){ - case UW::LogType::INFO: - return ImVec4(0.0f, 0.0f, 1.0f, 1.0f); - case UW::LogType::WARN: - return ImVec4(1.0f, 1.0f, 0.0f, 1.0f); - case UW::LogType::ERRO: - return ImVec4(1.0f, 0.0f, 0.0f, 1.0f); - default: - return ImVec4(1.0f, 1.0f, 1.0f, 1.0f); - }; - #endif - - return ImVec4(1.0f, 1.0f, 1.0f, 1.0f); -}; - - - - - - -UW::Logger &UW::Logger::get(){ - static Logger instance; - return instance; -}; - - - -UW::Logger::Logger(){ - calculateInitialLineCount(); -}; - - - -void UW::Logger::info(const std::string& module, const std::string& text){ -#ifndef PRODUCTION - data.emplace_back(UW::LogType::INFO, module, text); - log_to_file(data[data.size() - 1]); -#endif -}; - - - -void UW::Logger::warn(const std::string& module, const std::string& text){ -#ifndef PRODUCTION - data.emplace_back(UW::LogType::WARN, module, text); - log_to_file(data[data.size() - 1]); -#endif -}; - - - -void UW::Logger::erro(const std::string& module, const std::string& text){ -#ifndef PRODUCTION - data.emplace_back(UW::LogType::ERRO, module, text); - log_to_file(data[data.size() - 1]); -#endif -}; - - - -const std::vector& UW::Logger::getLogs() const { - return data; -}; - - - -void UW::Logger::checkAndTrimLog() { - std::ifstream infile(UW::Config::LOG_FILE_PATH); - if (!infile.is_open()) return; - - std::vector lines; - std::string line; - while (std::getline(infile, line)) { - lines.push_back(line); - } - infile.close(); - - if (lines.size() >= UW::Config::LOGS_MAX_LINES) { - std::ofstream outfile(UW::Config::LOG_FILE_PATH, std::ios::trunc); - if (outfile.is_open()) { - size_t start_index = lines.size() - UW::Config::LOGS_TARGET_TRIM_LINES; - for (size_t i = start_index; i < lines.size(); ++i) { - outfile << lines[i] << "\n"; - } - current_lines = UW::Config::LOGS_TARGET_TRIM_LINES; - }; - }; -}; - - - -void UW::Logger::calculateInitialLineCount() { - if (!std::filesystem::exists(UW::Config::LOG_FILE_PATH)) return; - std::ifstream infile(UW::Config::LOG_FILE_PATH); - std::string line; - while (std::getline(infile, line)) { - current_lines++; - }; -}; - - - -void UW::Logger::log_to_file(Log log){ - std::ofstream log_file(UW::Config::LOG_FILE_PATH, std::ios::app); - if (log_file.is_open()) { - log_file << log.getText() << "\n"; - current_lines++; - log_file.close(); - - if (current_lines >= UW::Config::LOGS_MAX_LINES) { - checkAndTrimLog(); - }; - }; -}; diff --git a/Engine/Utils/Logger.h b/Engine/Utils/Logger.h deleted file mode 100644 index b62be7a..0000000 --- a/Engine/Utils/Logger.h +++ /dev/null @@ -1,76 +0,0 @@ -// Help me I'am Under The Water -// Copyright 2026 Daynlight -// Licensed under the GNU General, Version 3.0. -// See LICENSE file for details. - - - -#pragma once -#include "Renderer.h" -#include "Gui.h" - -#include -#include -#include -#include - -#include "config.h" - -#include "ScriptShared/ILogger.h" - - - -namespace UW{ -enum LogType{ - INFO = 0, - WARN = 1, - ERRO = 2, -}; - - - -struct Log{ - LogType type; - std::string module; - std::string text; - - Log(LogType type, const std::string& module, const std::string& text); - std::string getText() const; - - std::string getTypeText() const; - ImVec4 getLogColor() const; -}; - - - -class Logger : public ILogger { -private: - std::vector data; - size_t current_lines = 0; - -public: - static Logger& get(); - - Logger(const Logger&) = delete; - Logger& operator=(const Logger&) = delete; - Logger(Logger&&) = delete; - Logger& operator=(Logger&&) = delete; - -private: - Logger(); - ~Logger() = default; - -public: - void info(const std::string& module, const std::string& text); - void warn(const std::string& module, const std::string& text); - void erro(const std::string& module, const std::string& text); - - const std::vector& getLogs() const; - -private: - void checkAndTrimLog(); - void calculateInitialLineCount(); - void log_to_file(Log log); - -}; -}; diff --git a/Engine/Utils/Utils/Logger.cpp b/Engine/Utils/Utils/Logger.cpp new file mode 100644 index 0000000..9acdd62 --- /dev/null +++ b/Engine/Utils/Utils/Logger.cpp @@ -0,0 +1,157 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "Logger.h" + + + +Engine::Utils::Log::Log(Engine::Utils::LogType type, const std::string& module, const std::string& text) noexcept + :type(type), module(module), text(text){}; + + + +std::string Engine::Utils::Log::getText() const noexcept { + return "["+ getTypeText() +"] ("+ module +"): " + text; +}; + + + +std::string Engine::Utils::Log::getTypeText() const noexcept { + #ifndef PRODUCTION + switch (type){ + case Engine::Utils::LogType::INFO: + return "INFO"; + case Engine::Utils::LogType::WARN: + return "WARN"; + case Engine::Utils::LogType::ERRO: + return "ERRO"; + default: + return "NO TYPE"; + }; + #endif + + return "NO TYPE"; +}; + + + +std::array Engine::Utils::Log::getLogColor() const noexcept { + #ifndef PRODUCTION + switch(type){ + case Engine::Utils::LogType::INFO: + return {0.0f, 0.0f, 1.0f, 1.0f}; + case Engine::Utils::LogType::WARN: + return {1.0f, 1.0f, 0.0f, 1.0f}; + case Engine::Utils::LogType::ERRO: + return {1.0f, 0.0f, 0.0f, 1.0f}; + default: + return {1.0f, 1.0f, 1.0f, 1.0f}; + }; + #endif + + return {1.0f, 1.0f, 1.0f, 1.0f}; +}; + + + + + + +Engine::Utils::Logger &Engine::Utils::Logger::get() noexcept { + static Logger instance; + return instance; +}; + + + +Engine::Utils::Logger::Logger() noexcept { + calculateInitialLineCount(); +}; + + + +void Engine::Utils::Logger::info(const std::string& module, const std::string& text) noexcept { +#ifndef PRODUCTION + data.emplace_back(Engine::Utils::LogType::INFO, module, text); + log_to_file(data[data.size() - 1]); +#endif +}; + + + +void Engine::Utils::Logger::warn(const std::string& module, const std::string& text) noexcept { +#ifndef PRODUCTION + data.emplace_back(Engine::Utils::LogType::WARN, module, text); + log_to_file(data[data.size() - 1]); +#endif +}; + + + +void Engine::Utils::Logger::erro(const std::string& module, const std::string& text) noexcept { +#ifndef PRODUCTION + data.emplace_back(Engine::Utils::LogType::ERRO, module, text); + log_to_file(data[data.size() - 1]); +#endif +}; + + + +const std::vector& Engine::Utils::Logger::getLogs() const noexcept { + return data; +}; + + + +void Engine::Utils::Logger::checkAndTrimLog() noexcept { + std::ifstream infile(Engine::Config::TEMP_BIN_FOLDER + Engine::Config::LOG_FILE_PATH); + if (!infile.is_open()) return; + + std::vector lines; + std::string line; + while (std::getline(infile, line)) { + lines.push_back(line); + } + infile.close(); + + if (lines.size() >= Engine::Config::LOGS_MAX_LINES) { + std::ofstream outfile(Engine::Config::TEMP_BIN_FOLDER + Engine::Config::LOG_FILE_PATH, std::ios::trunc); + if (outfile.is_open()) { + size_t start_index = lines.size() - Engine::Config::LOGS_TARGET_TRIM_LINES; + for (size_t i = start_index; i < lines.size(); ++i) { + outfile << lines[i] << "\n"; + } + current_lines = Engine::Config::LOGS_TARGET_TRIM_LINES; + }; + }; +}; + + + +void Engine::Utils::Logger::calculateInitialLineCount() noexcept { + if (!std::filesystem::exists(Engine::Config::TEMP_BIN_FOLDER + Engine::Config::LOG_FILE_PATH)) return; + std::ifstream infile(Engine::Config::TEMP_BIN_FOLDER + Engine::Config::LOG_FILE_PATH); + std::string line; + while (std::getline(infile, line)) { + current_lines++; + }; +}; + + + +void Engine::Utils::Logger::log_to_file(Log log) noexcept { + std::ofstream log_file(Engine::Config::TEMP_BIN_FOLDER + Engine::Config::LOG_FILE_PATH, std::ios::app); + if (log_file.is_open()) { + log_file << log.getText() << "\n"; + current_lines++; + log_file.close(); + + if (current_lines >= Engine::Config::LOGS_MAX_LINES) { + checkAndTrimLog(); + }; + }; +}; diff --git a/Engine/Utils/Utils/Logger.h b/Engine/Utils/Utils/Logger.h new file mode 100644 index 0000000..41159fe --- /dev/null +++ b/Engine/Utils/Utils/Logger.h @@ -0,0 +1,72 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include +#include +#include +#include +#include + +#include "Utils/config.h" +#include "ScriptShared/ILogger.h" + + + +namespace Engine::Utils{ +enum LogType{ + INFO = 0, + WARN = 1, + ERRO = 2, +}; + + + +struct Log{ + LogType type; + std::string module; + std::string text; + + Log(LogType type, const std::string& module, const std::string& text) noexcept; + std::string getText() const noexcept; + + std::string getTypeText() const noexcept; + std::array getLogColor() const noexcept; +}; + + + +class Logger : public Engine::ScriptShared::ILogger { +private: + std::vector data; + size_t current_lines = 0; + +public: + static Logger& get() noexcept; + + Logger(const Logger&) = delete; + Logger& operator=(const Logger&) = delete; + Logger(Logger&&) = delete; + Logger& operator=(Logger&&) = delete; + +private: + Logger() noexcept; + ~Logger() noexcept = default; + +public: + void info(const std::string& module, const std::string& text) noexcept; + void warn(const std::string& module, const std::string& text) noexcept; + void erro(const std::string& module, const std::string& text) noexcept; + + const std::vector& getLogs() const noexcept; + +private: + void checkAndTrimLog() noexcept; + void calculateInitialLineCount() noexcept; + void log_to_file(Log log) noexcept; +}; +}; // namespace Engine::Utils diff --git a/Engine/Utils/Utils/Resource/Resource.h b/Engine/Utils/Utils/Resource/Resource.h new file mode 100644 index 0000000..dee201c --- /dev/null +++ b/Engine/Utils/Utils/Resource/Resource.h @@ -0,0 +1,48 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#pragma once +#include "Renderer.h" +#include "ResourceController.h" + +#include +#include +#include +#include + + + +namespace Engine::Utils { +template +class Resource { +private: + std::string name = ""; + ResourceController* controller = nullptr; + unsigned int version = -1; + unsigned int id = -1; + bool valid = 1; + +public: + Resource() = default; + Resource(const std::string& name, ResourceController* controller); + ~Resource(); + Resource(const Resource& other); + Resource& operator=(const Resource& other); + Resource(Resource&& other) noexcept; + Resource& operator=(Resource&& other) noexcept; + + T* get(); + void setName(const std::string& name); + +private: + bool validate(); +}; +}; + + + +#include "Resource.hpp" diff --git a/Engine/Utils/Utils/Resource/Resource.hpp b/Engine/Utils/Utils/Resource/Resource.hpp new file mode 100644 index 0000000..510ad44 --- /dev/null +++ b/Engine/Utils/Utils/Resource/Resource.hpp @@ -0,0 +1,100 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "Resource.h" + + + +template +Engine::Utils::Resource::Resource(const std::string& name, ResourceController* controller) + :name(name), controller(controller) { + valid = validate(); +}; + + + +template +Engine::Utils::Resource::~Resource() { +}; + + + +template +Engine::Utils::Resource::Resource(const Resource& other) + :name(other.name), controller(other.controller), version(other.version), id(other.id), valid(other.valid){ +}; + + + +template +Engine::Utils::Resource& Engine::Utils::Resource::operator=(const Resource &other){ + name = other.name; + controller = other.controller; + version = other.version; + id = other.id; + valid = other.valid; + + return *this; +}; + + + +template +Engine::Utils::Resource::Resource(Resource &&other) noexcept + : name(std::move(other.name)), controller(std::move(other.controller)), version(std::move(other.version)), id(std::move(other.id)), valid(std::move(other.valid)){ +}; + + + +template +Engine::Utils::Resource& Engine::Utils::Resource::operator=(Resource &&other) noexcept{ + name = std::move(other.name); + controller = std::move(other.controller); + version = std::move(other.version); + id = std::move(other.id); + valid = std::move(other.valid); + + return *this; +}; + + + +template +T* Engine::Utils::Resource::get(){ + // if(!valid) return nullptr; + + valid = validate(); + if(!valid) return nullptr; + + return &((*controller)[id]); +}; + + + +template +void Engine::Utils::Resource::setName(const std::string& name){ + this->name = name; + version = controller->getLatestsVersion() - 1; +}; + + + +template +bool Engine::Utils::Resource::validate(){ + if(!controller) return 0; + + if(!controller->exists(name)) return 0; + + if(!controller->validateVersion(version)){ + id = controller->getID(name); + version = controller->getLatestsVersion(); + }; + + if(id >= controller->size()) return 0; + + return 1; +}; \ No newline at end of file diff --git a/Engine/Resources/Meshes/Meshes.h b/Engine/Utils/Utils/Resource/ResourceController.h similarity index 55% rename from Engine/Resources/Meshes/Meshes.h rename to Engine/Utils/Utils/Resource/ResourceController.h index 8abdf89..82e285a 100644 --- a/Engine/Resources/Meshes/Meshes.h +++ b/Engine/Utils/Utils/Resource/ResourceController.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -15,34 +15,34 @@ -namespace UW { -class Meshes { +namespace Engine::Utils { +template +class ResourceController { private: - std::vector mesh_data; - std::unordered_map mesh_id; + std::vector data; + std::unordered_map name_to_id; std::vector id_to_name; - unsigned int version = 0; public: - Meshes(); - ~Meshes(); + ResourceController(); + ~ResourceController(); - CW::Renderer::Mesh& operator[](unsigned int index); + T& operator[](unsigned int index); - const CW::Renderer::Mesh& operator[](unsigned int index) const; + const T& operator[](unsigned int index) const; static constexpr unsigned int INVALID_ID = -1; - unsigned int get_id(const std::string& name); + unsigned int getID(const std::string& name); void erase(const std::string& name); unsigned int size() const; void clear(); - void emplace_back(const std::string& name, CW::Renderer::Mesh&& mesh); + void emplace_back(const std::string& name, T&& mesh); bool exists(const std::string& name) const; - std::unordered_map& getMeshIDs(); + std::unordered_map& getIDs(); bool validateVersion(unsigned int version); unsigned int getLatestsVersion(); @@ -51,3 +51,7 @@ class Meshes { }; }; + + + +#include "ResourceController.hpp" diff --git a/Engine/Utils/Utils/Resource/ResourceController.hpp b/Engine/Utils/Utils/Resource/ResourceController.hpp new file mode 100644 index 0000000..33e7b83 --- /dev/null +++ b/Engine/Utils/Utils/Resource/ResourceController.hpp @@ -0,0 +1,143 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include "ResourceController.h" + + + +template +Engine::Utils::ResourceController::ResourceController() { +}; + + + +template +Engine::Utils::ResourceController::~ResourceController() { +}; + + + +template +T& Engine::Utils::ResourceController::operator[](unsigned int index) { + return data[index]; +}; + + + +template +const T& Engine::Utils::ResourceController::operator[](unsigned int index) const { + return data[index]; +}; + + + +template +unsigned int Engine::Utils::ResourceController::getID(const std::string& name) { + auto it = name_to_id.find(name); + if (it == name_to_id.end()) { + return INVALID_ID; + }; + return it->second; +}; + + + + +template +bool Engine::Utils::ResourceController::exists(const std::string& name) const { + return name_to_id.find(name) != name_to_id.end(); +}; + + + +template +void Engine::Utils::ResourceController::emplace_back(const std::string& name, T&& mesh) { + version += 1; + + auto it = name_to_id.find(name); + if (it != name_to_id.end()) { + data[it->second] = std::move(mesh); + } else { + unsigned int new_id = static_cast(data.size()); + + data.emplace_back(std::move(mesh)); + name_to_id[name] = new_id; + id_to_name.push_back(name); + }; +}; + + + + +template +void Engine::Utils::ResourceController::erase(const std::string& name) { + if (!exists(name)) return; + version += 1; + + unsigned int index_to_remove = name_to_id[name]; + unsigned int last_index = static_cast(data.size() - 1); + + if (index_to_remove != last_index) { + std::swap(data[index_to_remove], data[last_index]); + + const std::string& moved_element_name = id_to_name[last_index]; + + name_to_id[moved_element_name] = index_to_remove; + id_to_name[index_to_remove] = moved_element_name; + }; + + data.pop_back(); + id_to_name.pop_back(); + name_to_id.erase(name); +}; + + + + +template +unsigned int Engine::Utils::ResourceController::size() const{ + return data.size(); +}; + + + + +template +void Engine::Utils::ResourceController::clear(){ + version += 1; + data.clear(); + name_to_id.clear(); + id_to_name.clear(); +}; + + + +template +std::unordered_map& Engine::Utils::ResourceController::getIDs(){ + return name_to_id; +}; + + + +template +bool Engine::Utils::ResourceController::validateVersion(unsigned int version){ + return version == this->version; +}; + + + +template +unsigned int Engine::Utils::ResourceController::getLatestsVersion(){ + return version; +}; + + + +template +void Engine::Utils::ResourceController::compileAll(){ + for(T& rec : data) rec.compile(); +}; diff --git a/Engine/config.h b/Engine/Utils/Utils/config.h similarity index 94% rename from Engine/config.h rename to Engine/Utils/Utils/config.h index f835bfa..b8bf04c 100644 --- a/Engine/config.h +++ b/Engine/Utils/Utils/config.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -13,7 +13,7 @@ -namespace UW::Config{ +namespace Engine::Config{ // system inline constexpr float PI = 3.14159265358979f; inline constexpr float EPS = 1e-5f; @@ -66,6 +66,7 @@ namespace UW::Config{ // serialization inline const std::string GAME_DATA_FOLDER = "GameData/"; + inline const std::string BACKUP_GAME_DATA_FOLDER = ".GameData_back/"; inline const std::string ASSETS_FOLDER = "Assets/"; inline const std::string SHADERS_FOLDER = "Shaders/"; inline const std::string TEXTURES_FOLDER = "Textures/"; @@ -76,7 +77,9 @@ namespace UW::Config{ inline const std::string OBJECTS_FILENAME = "Objects.obj"; inline const std::string LIGHTS_FILENAME = "Lights.lit"; inline const std::string SCRIPTS_SRC_FOLDER = "Scripts/"; + inline const std::string COMPILATION_FOLDER = "compile_temp/"; inline const std::string SCRIPTS_DLL_FOLDER = "Scripts_DLL/"; + inline const std::string TEMP_BIN_FOLDER = "Engine_Bin/"; inline const std::string RESOURCES_FILENAME = "Resources.res"; inline const std::string LOG_FILE_PATH = "editor.log"; inline const size_t LOGS_MAX_LINES = 10000; @@ -106,5 +109,6 @@ namespace UW::Config{ inline constexpr float CAMERA_NEAR_PLANE = 0.1f; inline constexpr float CAMERA_FAR_PLANE = 1200.0f; inline constexpr float CAMERA_ORTHO_FAR_PLANE = 1200.0f; + inline constexpr float CAMERA_ORTHO_NEAR_PLANE = 0.1f; inline constexpr float CAMERA_ORTHO_SIZE = 1000.0f; }; diff --git a/Engine/Utils/utils.h b/Engine/Utils/Utils/utils.h similarity index 63% rename from Engine/Utils/utils.h rename to Engine/Utils/Utils/utils.h index 91a91af..c158ae0 100644 --- a/Engine/Utils/utils.h +++ b/Engine/Utils/Utils/utils.h @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -8,48 +8,16 @@ #pragma once #include #include - -#if defined(_WIN32) - #define WIN32_LEAN_AND_MEAN - #include -#else - #include - #include -#endif +#include #ifdef PRODUCTION #include #endif -#include - - - -namespace UW::Utils { -inline std::string GetExecutablePath() { -#if defined(_WIN32) - char buffer[MAX_PATH]; - DWORD size = GetModuleFileNameA(NULL, buffer, MAX_PATH); - if (size == 0) return ""; - return std::string(buffer, size); -#else - char result[PATH_MAX]; - ssize_t count = readlink("/proc/self/exe", result, PATH_MAX); - return std::string(result, (count > 0) ? count : 0); -#endif -}; - - - -inline std::string GetExeDir() { - std::string path = GetExecutablePath(); - if (path.empty()) return ""; - return std::filesystem::path(path).parent_path().string(); -}; - -inline uint32_t hash(uint32_t x) { +namespace Engine::Utils { +constexpr inline uint32_t hash(uint32_t x) noexcept { x = ((x >> 16) ^ x) * 0x45d9f3b; x = ((x >> 16) ^ x) * 0x45d9f3b; x = (x >> 16) ^ x; @@ -59,10 +27,9 @@ inline uint32_t hash(uint32_t x) { template -inline void uploadTypedBuffer(CW::Renderer::Mesh& mesh, const std::vector& buffer, unsigned int dimension, unsigned int layout, GLenum type) { +inline void uploadTypedBuffer(CW::Renderer::Mesh& mesh, const std::vector& buffer, unsigned int dimension, unsigned int layout, GLenum type) noexcept { if (buffer.empty()) return; - - if (buffer.size() % sizeof(T) != 0) throw std::runtime_error("Mesh buffer size not aligned with type size"); + if (buffer.size() % sizeof(T) != 0) return; size_t count = buffer.size() / sizeof(T); @@ -75,7 +42,7 @@ inline void uploadTypedBuffer(CW::Renderer::Mesh& mesh, const std::vector& buffer, unsigned int dimension, unsigned int key){ +inline void uploadBufferByType(CW::Renderer::Mesh& engine_mesh, GLenum type, const std::vector& buffer, unsigned int dimension, unsigned int key) noexcept { if (buffer.empty()) return; switch (type){ @@ -89,14 +56,14 @@ inline void uploadBufferByType(CW::Renderer::Mesh& engine_mesh, GLenum type, con uploadTypedBuffer(engine_mesh, buffer, dimension, key, type); break; default: - throw std::runtime_error("Unsupported GL type in mesh data"); + break; }; }; #ifdef PRODUCTION -inline void scanCmrcDirectory(const cmrc::embedded_filesystem& fs, const std::string& current_path, const std::string& pattern_str, std::vector& out_mesh_files){ +inline void scanCmrcDirectory(const cmrc::embedded_filesystem& fs, const std::string& current_path, const std::string& pattern_str, std::vector& out_mesh_files) noexcept { std::regex pattern(pattern_str); for (const auto& entry : fs.iterate_directory(current_path)) { @@ -107,5 +74,4 @@ inline void scanCmrcDirectory(const cmrc::embedded_filesystem& fs, const std::st }; }; #endif - -}; +}; // namespace Engine::Utils diff --git a/Examples/Game/GameData/Assets/Meshes/Default.msh b/Examples/Game/GameData/Assets/Meshes/Default.msh new file mode 100644 index 0000000..fa3567a Binary files /dev/null and b/Examples/Game/GameData/Assets/Meshes/Default.msh differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/empty.msh b/Examples/Game/GameData/Assets/Meshes/empty.msh similarity index 100% rename from Examples/Moutains/GameData/Assets/Meshes/empty.msh rename to Examples/Game/GameData/Assets/Meshes/empty.msh diff --git a/Examples/Moutains/GameData/Assets/Meshes/screen_quad.msh b/Examples/Game/GameData/Assets/Meshes/screen_quad.msh similarity index 100% rename from Examples/Moutains/GameData/Assets/Meshes/screen_quad.msh rename to Examples/Game/GameData/Assets/Meshes/screen_quad.msh diff --git a/Examples/Moutains/GameData/Assets/Meshes/sky_box.msh b/Examples/Game/GameData/Assets/Meshes/sky_box.msh similarity index 100% rename from Examples/Moutains/GameData/Assets/Meshes/sky_box.msh rename to Examples/Game/GameData/Assets/Meshes/sky_box.msh diff --git a/Examples/Moutains/GameData/Assets/Meshes/terrain_chunk.msh b/Examples/Game/GameData/Assets/Meshes/terrain_chunk.msh similarity index 100% rename from Examples/Moutains/GameData/Assets/Meshes/terrain_chunk.msh rename to Examples/Game/GameData/Assets/Meshes/terrain_chunk.msh diff --git a/Examples/Moutains/GameData/Assets/Shaders/BRDF.glsl b/Examples/Game/GameData/Assets/Shaders/BRDF.glsl similarity index 100% rename from Examples/Moutains/GameData/Assets/Shaders/BRDF.glsl rename to Examples/Game/GameData/Assets/Shaders/BRDF.glsl diff --git a/Examples/Game/GameData/Assets/Shaders/Default/fragment.glsl b/Examples/Game/GameData/Assets/Shaders/Default/fragment.glsl new file mode 100644 index 0000000..766fb4a --- /dev/null +++ b/Examples/Game/GameData/Assets/Shaders/Default/fragment.glsl @@ -0,0 +1,62 @@ +#version 430 core + +out vec4 FragColor; + +in vec2 TexCoords; +in vec3 FragPosition; + +uniform int lightCount; +uniform int u_HasNormalMap; + +struct Light { + vec3 position; + vec3 color; + float strength; +}; + +layout(std430, binding = 0) buffer LightsBuffer { + Light lights[]; +}; + +uniform sampler2D texture0; +uniform sampler2D texture1; + +void main() { + vec4 albedo = texture(texture0, TexCoords); + + if (albedo.a <= 0.05) discard; + + vec3 result = vec3(0.0); + + if (u_HasNormalMap == 1) { + vec3 normal = texture(texture1, TexCoords).rgb * 2.0 - 1.0; + normal.x *= -1.0; + normal = normalize(normal); + + for (int i = 0; i < lightCount; ++i) { + vec3 lightPos = lights[i].position; + + vec3 toLight = lightPos - FragPosition; + + toLight.x *= -1.0; + + float distance = length(toLight); + if (distance == 0.0) distance = 0.0001; + + vec3 lightDir = toLight / distance; + + float diff = max(dot(normal, lightDir), 0.0); + + result += albedo.rgb * + lights[i].color * + lights[i].strength * + diff; + } + } else { + result = albedo.rgb; + } + + FragColor = vec4(result, albedo.a); +} + + diff --git a/Examples/Game/GameData/Assets/Shaders/Default/vertex.glsl b/Examples/Game/GameData/Assets/Shaders/Default/vertex.glsl new file mode 100644 index 0000000..3ba456f --- /dev/null +++ b/Examples/Game/GameData/Assets/Shaders/Default/vertex.glsl @@ -0,0 +1,34 @@ +#version 430 core + +layout(location = 0) in vec3 aPos; +layout(location = 1) in vec2 uvs; + +out vec2 TexCoords; +out vec3 Normal; +out vec3 FragPosition; +out vec4 FragPosLightSpace; + +uniform mat4 projection; +uniform mat4 view; +uniform mat4 u_LightSpaceMatrix; +uniform vec2 window_size; +uniform vec2 sizes; + +uniform mat4 model; + +void main(){ + vec3 scaledPos = vec3(aPos.x * sizes.x, aPos.y * sizes.y, aPos.z); + vec4 worldPos = model * vec4(scaledPos, 1.0); + + FragPosLightSpace = u_LightSpaceMatrix * worldPos; + vec4 pos = projection * view * worldPos; + + FragPosition = worldPos.xyz; + TexCoords = uvs; + + gl_Position = pos; +} + + + + diff --git a/Examples/Game/GameData/Assets/Shaders/Enviroment/fragment.glsl b/Examples/Game/GameData/Assets/Shaders/Enviroment/fragment.glsl new file mode 100644 index 0000000..3e41710 --- /dev/null +++ b/Examples/Game/GameData/Assets/Shaders/Enviroment/fragment.glsl @@ -0,0 +1,86 @@ +#version 430 core + +out vec4 FragColor; + +in vec2 TexCoords; +in vec3 FragPosition; +in vec3 v_cameraPos; +in vec2 atlasSizes; + +uniform int lightCount; +uniform int u_HasNormalMap; + +struct Light { + vec3 position; + vec3 color; + float strength; +}; + +layout(std430, binding = 0) buffer LightsBuffer { + Light lights[]; +}; + +uniform sampler2D texture0; // Albedo +uniform sampler2D texture1; // Normals + + +vec2 mat = vec2(0.0, 0.0); + +vec2 hash22(vec2 p) { + vec3 p3 = fract(vec3(p.xyx) * vec3(443.897, 441.423, 437.195)); + p3 += dot(p3, p3.yzx + 19.19); + return fract((p3.xx + p3.yz) * p3.zy); +} + +void main() { + vec2 globalUV = TexCoords + v_cameraPos.xy / (atlasSizes * 2.0f); + + vec2 cellID = floor(globalUV); + vec2 localUV = fract(globalUV); + + vec2 randVal = hash22(cellID); + vec2 mat = floor(randVal * atlasSizes); + + vec2 tex_cord = (mat + localUV) / atlasSizes; + + vec4 albedo = texture(texture0, tex_cord); + + if (albedo.a <= 0.05) discard; + + vec3 result = vec3(0.0); + + if (u_HasNormalMap == 1) { + vec3 normal = texture(texture1, tex_cord).rgb * 2.0 - 1.0; + normal.x *= -1.0; + normal = normalize(normal); + + for (int i = 0; i < lightCount; ++i) { + vec3 lightPos = lights[i].position; + + vec3 toLight = lightPos - FragPosition; + + toLight.x *= -1.0; + + float distance = length(toLight); + if (distance == 0.0) distance = 0.0001; + + vec3 lightDir = toLight / distance; + + float diff = max(dot(normal, lightDir), 0.0); + + result += albedo.rgb * + lights[i].color * + lights[i].strength * + diff; + } + } else { + result = albedo.rgb; + } + + FragColor = vec4(result, albedo.a); +} + + + + + diff --git a/Examples/Game/GameData/Assets/Shaders/Enviroment/vertex.glsl b/Examples/Game/GameData/Assets/Shaders/Enviroment/vertex.glsl new file mode 100644 index 0000000..ba35c77 --- /dev/null +++ b/Examples/Game/GameData/Assets/Shaders/Enviroment/vertex.glsl @@ -0,0 +1,40 @@ +#version 430 core + +layout(location = 0) in vec3 aPos; +layout(location = 1) in vec2 uvs; + +out vec2 TexCoords; +out vec3 FragPosition; +out vec3 v_cameraPos; +out vec2 atlasSizes; + +uniform vec3 cameraPosition; +uniform mat4 projection; +uniform mat4 view; +uniform vec2 window_size; +uniform vec2 sizes; +uniform vec2 repeate; +uniform vec2 atlas_size; + + + +void main(){ + vec3 localCamPos = cameraPosition; + localCamPos.z = -1.0f; + + vec3 worldPos = aPos + localCamPos; + + vec4 pos = projection * view * vec4(worldPos, 1.0f); + + pos.xy *= repeate.xy; + + atlasSizes = atlas_size; + v_cameraPos = cameraPosition; + + FragPosition = worldPos; + TexCoords = (uvs / atlas_size) * repeate; + + gl_Position = pos; +} + + diff --git a/Examples/Game/GameData/Assets/Shaders/PostProcessing/fragment.glsl b/Examples/Game/GameData/Assets/Shaders/PostProcessing/fragment.glsl new file mode 100644 index 0000000..301e52e --- /dev/null +++ b/Examples/Game/GameData/Assets/Shaders/PostProcessing/fragment.glsl @@ -0,0 +1,16 @@ +#version 430 core + +in vec2 TexCoords; +out vec4 FragColor; + +uniform sampler2D u_SceneColorTexture; + +uniform float u_FogDensity; +uniform vec3 u_FogColor; +uniform float u_water_height; +uniform vec3 u_CamPos; +uniform mat4 u_InvViewProj; + +void main() { + FragColor = vec4(texture(u_SceneColorTexture, TexCoords).rgb, 1.0); +} diff --git a/Examples/Moutains/GameData/Assets/Shaders/PostProcessing/vertex.glsl b/Examples/Game/GameData/Assets/Shaders/PostProcessing/vertex.glsl similarity index 100% rename from Examples/Moutains/GameData/Assets/Shaders/PostProcessing/vertex.glsl rename to Examples/Game/GameData/Assets/Shaders/PostProcessing/vertex.glsl diff --git a/Examples/Game/GameData/Assets/Textures/Create/Create.png b/Examples/Game/GameData/Assets/Textures/Create/Create.png new file mode 100644 index 0000000..c92c5e4 Binary files /dev/null and b/Examples/Game/GameData/Assets/Textures/Create/Create.png differ diff --git a/Examples/Game/GameData/Assets/Textures/Farmer/Albedo.png b/Examples/Game/GameData/Assets/Textures/Farmer/Albedo.png new file mode 100644 index 0000000..cd47222 Binary files /dev/null and b/Examples/Game/GameData/Assets/Textures/Farmer/Albedo.png differ diff --git a/Examples/Game/GameData/Assets/Textures/Farmer/Normals.png b/Examples/Game/GameData/Assets/Textures/Farmer/Normals.png new file mode 100644 index 0000000..53d6067 Binary files /dev/null and b/Examples/Game/GameData/Assets/Textures/Farmer/Normals.png differ diff --git a/Examples/Game/GameData/Assets/Textures/Stairs/Albedo.png b/Examples/Game/GameData/Assets/Textures/Stairs/Albedo.png new file mode 100644 index 0000000..b00762f Binary files /dev/null and b/Examples/Game/GameData/Assets/Textures/Stairs/Albedo.png differ diff --git a/Examples/Game/GameData/Assets/Textures/Terrain/Albedo.png b/Examples/Game/GameData/Assets/Textures/Terrain/Albedo.png new file mode 100644 index 0000000..7e45902 Binary files /dev/null and b/Examples/Game/GameData/Assets/Textures/Terrain/Albedo.png differ diff --git a/Examples/Game/GameData/Assets/Textures/Terrain/Normals.png b/Examples/Game/GameData/Assets/Textures/Terrain/Normals.png new file mode 100644 index 0000000..1131205 Binary files /dev/null and b/Examples/Game/GameData/Assets/Textures/Terrain/Normals.png differ diff --git a/Examples/Game/GameData/Lights.lit b/Examples/Game/GameData/Lights.lit new file mode 100644 index 0000000..7352c99 Binary files /dev/null and b/Examples/Game/GameData/Lights.lit differ diff --git a/Examples/Game/GameData/Materials.pbr b/Examples/Game/GameData/Materials.pbr new file mode 100644 index 0000000..1b1cb4d Binary files /dev/null and b/Examples/Game/GameData/Materials.pbr differ diff --git a/Examples/Game/GameData/Objects.obj b/Examples/Game/GameData/Objects.obj new file mode 100644 index 0000000..58cd880 Binary files /dev/null and b/Examples/Game/GameData/Objects.obj differ diff --git a/Examples/Game/GameData/Resources.res b/Examples/Game/GameData/Resources.res new file mode 100644 index 0000000..507d0cb Binary files /dev/null and b/Examples/Game/GameData/Resources.res differ diff --git a/Examples/Game/Scripts/Config.h b/Examples/Game/Scripts/Config.h new file mode 100644 index 0000000..42cd220 --- /dev/null +++ b/Examples/Game/Scripts/Config.h @@ -0,0 +1,13 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + +const inline float DEFAULT_ZOOM = 20.0f; +const inline float DEFAULT_SPRINT_ZOOM = 25.0f; +const inline float DEFAULT_ZOOM_ACCELERATION = 5.0f; + + +const inline float DEFAULT_SPEED = 10.0f; +const inline float DEFAULT_SPRINT_SPEED = 17.0f; diff --git a/Examples/Game/Scripts/Movement.cpp b/Examples/Game/Scripts/Movement.cpp new file mode 100644 index 0000000..7f69b1d --- /dev/null +++ b/Examples/Game/Scripts/Movement.cpp @@ -0,0 +1,101 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#define SCRIPT_NAME Script_Movement +#define SCRIPT_FILE_NAME "Movement" +#define BUILDING_SCRIPT_DLL + +#include "Engine/ScriptShared/ScriptShared/GameObjectScriptInterface.h" +#include +#include +#include +#include "Config.h" + + + +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { +private: + float zoom = DEFAULT_ZOOM; + +public: + ~SCRIPT_NAME() = default; + + void OnLoad(){ + logger->info(SCRIPT_FILE_NAME, "Loaded"); + }; + + void OnUpdate(float delta_time){ + }; + + void OnFixedUpdate(float fixed_delta_time){ + movement(fixed_delta_time); + cameraTracking(); + }; + + void OnRender(){ + }; + + void OnDestroy(){ + logger->info(SCRIPT_FILE_NAME, "Destroyed"); + }; + + + + + float height(){ + glm::vec3 position = game_object_data->position; + Engine::ScriptShared::GameObjectData* collider = object_manager->getGameObjectData("Stairs"); + + if(collider == nullptr) return 0.0f; + if(std::abs(position.x - collider->position.x) < 1.0f + && std::abs(position.y * 2.0f - collider->position.y) < 1.0f) + return 5.0f; + return 0.0f; + }; + + void movement(float delta_time){ + glm::vec3 delta_movement = glm::vec3(0.0f); + bool shift_pressed = glob_res->input_data->is_key_down("LSHIFT"); + + float target_zoom = shift_pressed ? DEFAULT_SPRINT_ZOOM : DEFAULT_ZOOM; + zoom += (target_zoom - zoom) * DEFAULT_ZOOM_ACCELERATION * delta_time; + + if(glob_res->input_data->is_key_down("W")) delta_movement.y += 1; + if(glob_res->input_data->is_key_down("S")) delta_movement.y -= 1; + if(glob_res->input_data->is_key_down("D")) delta_movement.x += 1; + if(glob_res->input_data->is_key_down("A")) delta_movement.x -= 1; + if(delta_movement.x == 0.0f && delta_movement.y == 0.0f) return; + + glm::vec3 move_vector = glm::normalize(delta_movement); + + if(shift_pressed) move_vector = move_vector * DEFAULT_SPRINT_SPEED * delta_time; + else move_vector = move_vector * DEFAULT_SPEED * delta_time; + + game_object_data->position += move_vector; + + // logger->warn(SCRIPT_FILE_NAME, std::to_string(move_vector.x) + ", " + std::to_string(move_vector.y)); + }; + + void cameraTracking(){ + Engine::ScriptShared::ICamera& camera = camera_controller->getActiveCamera(); + + glm::vec3 position = game_object_data->position; + + position.z = 10.0f; + camera.setPosition(position); + + camera.setOrthoSize(zoom + height()); + camera.setDirection(glm::vec3(0.0f, 0.0f, -1.0f)); + camera.setCameraMode(Engine::ScriptShared::CameraMode::ORTHOGONAL); + }; +}; +}; + + + +REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) diff --git a/Examples/Game/Scripts/Template.cpp b/Examples/Game/Scripts/Template.cpp new file mode 100644 index 0000000..692ddf9 --- /dev/null +++ b/Examples/Game/Scripts/Template.cpp @@ -0,0 +1,47 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#define SCRIPT_NAME Script_Template +#define SCRIPT_FILE_NAME "Template" +#define BUILDING_SCRIPT_DLL + +#include "Engine/ScriptShared/ScriptShared/GameObjectScriptInterface.h" +#include +#include +#include + + + +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { +private: + +public: + ~SCRIPT_NAME() = default; + + void OnLoad(){ + logger->info(SCRIPT_FILE_NAME, "Loaded"); + }; + + void OnUpdate(float delta_time){ + }; + + void OnFixedUpdate(float fixed_delta_time){ + }; + + void OnRender(){ + }; + + void OnDestroy(){ + logger->info(SCRIPT_FILE_NAME, "Destroyed"); + }; +}; +}; + + + +REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) diff --git a/Examples/Game/Scripts/Window.cpp b/Examples/Game/Scripts/Window.cpp new file mode 100644 index 0000000..5c562f3 --- /dev/null +++ b/Examples/Game/Scripts/Window.cpp @@ -0,0 +1,63 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#define SCRIPT_NAME Script_Window +#define SCRIPT_FILE_NAME "Window" +#define BUILDING_SCRIPT_DLL + +#include "Engine/ScriptShared/ScriptShared/GameObjectScriptInterface.h" +#include +#include +#include + + + +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { +private: + std::string base_name = "Farm"; + unsigned int samples = 0; + float acc_time = 0.0f; + +public: + ~SCRIPT_NAME() = default; + + void OnLoad(){ + glob_res->WINDOW_TITLE = base_name; + logger->info(SCRIPT_FILE_NAME, "Loaded"); + }; + + void OnUpdate(float delta_time){ + if(samples > 200){ + float fps = samples / acc_time; + glob_res->WINDOW_TITLE = base_name + " | " + std::to_string(floor(fps)) + " fps"; + acc_time = 0.0f; + samples = 0; + } + else{ + acc_time += delta_time; + samples++; + } + }; + + void OnFixedUpdate(float fixed_delta_time){ + + }; + + void OnRender(){ + }; + + void OnDestroy(){ + glob_res->WINDOW_TITLE = base_name; + logger->info(SCRIPT_FILE_NAME, "Destroyed"); + }; +}; +}; + + + +REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) diff --git a/Examples/Mountain/GameData/Assets/Meshes/Default.msh b/Examples/Mountain/GameData/Assets/Meshes/Default.msh new file mode 100644 index 0000000..fa3567a Binary files /dev/null and b/Examples/Mountain/GameData/Assets/Meshes/Default.msh differ diff --git a/Examples/Mountain/GameData/Assets/Meshes/empty.msh b/Examples/Mountain/GameData/Assets/Meshes/empty.msh new file mode 100644 index 0000000..cd46f9d Binary files /dev/null and b/Examples/Mountain/GameData/Assets/Meshes/empty.msh differ diff --git a/Examples/Mountain/GameData/Assets/Meshes/screen_quad.msh b/Examples/Mountain/GameData/Assets/Meshes/screen_quad.msh new file mode 100644 index 0000000..8f71699 Binary files /dev/null and b/Examples/Mountain/GameData/Assets/Meshes/screen_quad.msh differ diff --git a/Examples/Mountain/GameData/Assets/Meshes/sky_box.msh b/Examples/Mountain/GameData/Assets/Meshes/sky_box.msh new file mode 100644 index 0000000..6a222e4 Binary files /dev/null and b/Examples/Mountain/GameData/Assets/Meshes/sky_box.msh differ diff --git a/Examples/Mountain/GameData/Assets/Meshes/terrain_chunk.msh b/Examples/Mountain/GameData/Assets/Meshes/terrain_chunk.msh new file mode 100644 index 0000000..e274ba5 Binary files /dev/null and b/Examples/Mountain/GameData/Assets/Meshes/terrain_chunk.msh differ diff --git a/Examples/Mountain/GameData/Assets/Shaders/BRDF.glsl b/Examples/Mountain/GameData/Assets/Shaders/BRDF.glsl new file mode 100644 index 0000000..a654c46 --- /dev/null +++ b/Examples/Mountain/GameData/Assets/Shaders/BRDF.glsl @@ -0,0 +1,107 @@ +const float PI = 3.14159265359; + +float DistributionGGX(vec3 N, vec3 H, float roughness){ + float a = roughness * roughness; + float a2 = a * a; + + float NdotH = max(dot(N, H), 0.0); + float NdotH2 = NdotH * NdotH; + + float denom = (NdotH2 * (a2 - 1.0) + 1.0); + denom = PI * denom * denom; + + return a2 / max(denom, 0.0001); +} + +float GeometrySchlickGGX(float NdotV, float roughness){ + float r = roughness + 1.0; + float k = (r * r) / 8.0; + + return NdotV / (NdotV * (1.0 - k) + k); +} + +float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness){ + float NdotV = max(dot(N, V), 0.0); + float NdotL = max(dot(N, L), 0.0); + + return GeometrySchlickGGX(NdotV, roughness) * GeometrySchlickGGX(NdotL, roughness); +} + +vec3 FresnelSchlick(vec3 V, vec3 H, vec3 albedo, float metallic){ + float cosTheta = max(dot(V, H), 0.0); + vec3 F0 = vec3(0.04); + F0 = mix(F0, albedo, metallic); + + return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0); +} + +float Calc_D(float NdotH, float roughness){ + float a = roughness * roughness; + float a2 = a * a; + + float denom = NdotH * NdotH * (a2 - 1.0) + 1.0; + float D = a2 / (PI * denom * denom + 0.0001); + return D; +} + +float GGX(float NdotV, float NdotL, float roughness){ + float k = (roughness + 1.0); + k = (k * k) / 8.0; + + float G1 = NdotL / (NdotL * (1.0 - k) + k); + float G2 = NdotV / (NdotV * (1.0 - k) + k); + float G = G1 * G2; + return G; +} + +vec3 Specular(float NdotL, float NdotV, float D, float G, vec3 Fresnel){ + return (D * G * Fresnel) / max(4.0 * NdotL * NdotV, 0.001); +} + +vec3 Diffuse(vec3 Fresnel, vec3 albedo, float metallic){ + vec3 kS = Fresnel; + vec3 kD = (1.0 - kS) * (1.0 - metallic); + + vec3 diffuse = kD * albedo / PI; + return diffuse; +} + + + +vec3 BRDF( + vec3 Normal, + vec3 FragPos, + vec3 cameraPos, + vec3 lightPos, + vec3 lightColor, + vec3 albedo, + float metallic, + float roughness, + vec3 emission_color, + float emission_strength, + float ambient_occlusion +) +{ + vec3 N = normalize(Normal); + vec3 V = normalize(cameraPos - FragPos); + vec3 L = normalize(lightPos - FragPos); + vec3 H = normalize(V + L); + + float NdotL = max(dot(N, L), 0.0); + float NdotV = max(dot(N, V), 0.0); + float NdotH = max(dot(N, H), 0.0); + + vec3 Fresnel = FresnelSchlick(V, H, albedo, metallic); + + float D = Calc_D(NdotH, roughness); + float G = GGX(NdotV, NdotL, roughness); + + vec3 specular = Specular(NdotL, NdotV, D, G, Fresnel); + vec3 diffuse = Diffuse(Fresnel, albedo, metallic); + + vec3 lighting = (diffuse + specular) * lightColor * NdotL; + vec3 ambient = 0.03 * albedo * ambient_occlusion; + vec3 emissiveColor = emission_color * emission_strength; + + return lighting + ambient + emissiveColor; +}; \ No newline at end of file diff --git a/Examples/Moutains/GameData/Assets/Shaders/Default/fragment.glsl b/Examples/Mountain/GameData/Assets/Shaders/Default/fragment.glsl similarity index 100% rename from Examples/Moutains/GameData/Assets/Shaders/Default/fragment.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Default/fragment.glsl diff --git a/Examples/Moutains/GameData/Assets/Shaders/Default/vertex.glsl b/Examples/Mountain/GameData/Assets/Shaders/Default/vertex.glsl similarity index 100% rename from Examples/Moutains/GameData/Assets/Shaders/Default/vertex.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Default/vertex.glsl diff --git a/Examples/Moutains/GameData/Assets/Shaders/PostProcessing/fragment.glsl b/Examples/Mountain/GameData/Assets/Shaders/PostProcessing/fragment.glsl similarity index 98% rename from Examples/Moutains/GameData/Assets/Shaders/PostProcessing/fragment.glsl rename to Examples/Mountain/GameData/Assets/Shaders/PostProcessing/fragment.glsl index 36ffe90..478ba2b 100644 --- a/Examples/Moutains/GameData/Assets/Shaders/PostProcessing/fragment.glsl +++ b/Examples/Mountain/GameData/Assets/Shaders/PostProcessing/fragment.glsl @@ -9,7 +9,7 @@ uniform sampler2D u_SceneDepthTexture; uniform float u_FogDensity; uniform vec3 u_FogColor; -uniform float u_water_height; +float u_water_height = 200; uniform vec3 u_CamPos; uniform mat4 u_InvViewProj; @@ -72,4 +72,4 @@ void main() { vec3 finalColor = mix(u_FogColor, sceneColor, fogFactor); FragColor = vec4(finalColor, 1.0); -} \ No newline at end of file +} diff --git a/Examples/Moutains/GameData/Assets/Shaders/SDF/vertex.glsl b/Examples/Mountain/GameData/Assets/Shaders/PostProcessing/vertex.glsl similarity index 79% rename from Examples/Moutains/GameData/Assets/Shaders/SDF/vertex.glsl rename to Examples/Mountain/GameData/Assets/Shaders/PostProcessing/vertex.glsl index 2706f94..69aab77 100644 --- a/Examples/Moutains/GameData/Assets/Shaders/SDF/vertex.glsl +++ b/Examples/Mountain/GameData/Assets/Shaders/PostProcessing/vertex.glsl @@ -6,6 +6,6 @@ layout (location = 1) in vec2 aTexCoords; out vec2 TexCoords; void main() { + gl_Position = vec4(aPos.xy, 0.0, 1.0); TexCoords = aTexCoords; - gl_Position = vec4(aPos, 1.0); } \ No newline at end of file diff --git a/Examples/Moutains/GameData/Assets/Shaders/Skybox/fragment.glsl b/Examples/Mountain/GameData/Assets/Shaders/Skybox/fragment.glsl similarity index 81% rename from Examples/Moutains/GameData/Assets/Shaders/Skybox/fragment.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Skybox/fragment.glsl index 4e69f70..b8c37b3 100644 --- a/Examples/Moutains/GameData/Assets/Shaders/Skybox/fragment.glsl +++ b/Examples/Mountain/GameData/Assets/Shaders/Skybox/fragment.glsl @@ -4,7 +4,7 @@ out vec4 FragColor; in vec3 LocalPos; -uniform sampler2D skyboxTex; +uniform sampler2D texture0; const vec2 invAtan = vec2(0.1591, 0.3183); @@ -17,6 +17,7 @@ vec2 SampleSphericalMap(vec3 v){ void main(){ vec2 uv = SampleSphericalMap(normalize(LocalPos)); - vec3 color = texture(skyboxTex, uv).rgb; + vec3 color = texture(texture0, uv).rgb; FragColor = vec4(color, 1.0); -} \ No newline at end of file +} + diff --git a/Examples/Moutains/GameData/Assets/Shaders/Skybox/vertex.glsl b/Examples/Mountain/GameData/Assets/Shaders/Skybox/vertex.glsl similarity index 59% rename from Examples/Moutains/GameData/Assets/Shaders/Skybox/vertex.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Skybox/vertex.glsl index b08f2db..7bda7c3 100644 --- a/Examples/Moutains/GameData/Assets/Shaders/Skybox/vertex.glsl +++ b/Examples/Mountain/GameData/Assets/Shaders/Skybox/vertex.glsl @@ -1,6 +1,6 @@ #version 430 core -layout(location = 0) in vec3 aPos; +layout(location = 0) in vec4 aPos; out vec3 LocalPos; @@ -8,10 +8,11 @@ uniform mat4 projection; uniform mat4 view; void main(){ - LocalPos = aPos; + LocalPos = aPos.xyz; mat4 staticView = mat4(mat3(view)); - vec4 pos = projection * staticView * vec4(aPos, 1.0); + vec4 pos = projection * staticView * aPos; gl_Position = pos.xyww; -} \ No newline at end of file +} + diff --git a/Examples/Moutains/GameData/Assets/Shaders/Terrain/fragment.glsl b/Examples/Mountain/GameData/Assets/Shaders/Terrain/fragment.glsl similarity index 98% rename from Examples/Moutains/GameData/Assets/Shaders/Terrain/fragment.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Terrain/fragment.glsl index 22dfcc8..5bac68b 100644 --- a/Examples/Moutains/GameData/Assets/Shaders/Terrain/fragment.glsl +++ b/Examples/Mountain/GameData/Assets/Shaders/Terrain/fragment.glsl @@ -8,7 +8,7 @@ in vec4 FragPosLightSpace; uniform int lightCount; uniform vec3 cameraPosition; -uniform int material_id; +uniform int mat_translate[1]; uniform int u_ShadowEnabled; uniform sampler2D u_ShadowDepthTexture; @@ -129,7 +129,7 @@ void main(){ if(u_ShadowEnabled == 1){ - Material mat = material[material_id]; + Material mat = material[mat_translate[0]]; vec3 N = normalize(Normal); vec3 directLighting = vec3(0.0f); diff --git a/Examples/Moutains/GameData/Assets/Shaders/Terrain/tess_control.glsl b/Examples/Mountain/GameData/Assets/Shaders/Terrain/tess_control.glsl similarity index 100% rename from Examples/Moutains/GameData/Assets/Shaders/Terrain/tess_control.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Terrain/tess_control.glsl diff --git a/Examples/Moutains/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl b/Examples/Mountain/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl similarity index 77% rename from Examples/Moutains/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl index 1a16da9..8b60bdd 100644 --- a/Examples/Moutains/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl +++ b/Examples/Mountain/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl @@ -8,7 +8,7 @@ out vec4 FragPosLightSpace; uniform mat4 projection; uniform mat4 view; -uniform sampler2D uTexture; +uniform sampler2D texture0; uniform vec2 mapSize; uniform float maxHeight; uniform mat4 u_LightSpaceMatrix; @@ -17,16 +17,16 @@ float terrainHeight(vec2 p){ vec2 worldMin = vec2(-mapSize * 0.5); vec2 uv = (p - worldMin) / mapSize; - vec2 texelSize = 1.0 / textureSize(uTexture, 0); + vec2 texelSize = 1.0 / textureSize(texture0, 0); float texelOffset = 1.5; vec2 offset = texelSize * texelOffset; - float center = texture(uTexture, uv).r; - float left = texture(uTexture, uv + vec2(-offset.x, 0.0)).r; - float right = texture(uTexture, uv + vec2(offset.x, 0.0)).r; - float top = texture(uTexture, uv + vec2(0.0, offset.y)).r; - float bottom = texture(uTexture, uv + vec2(0.0, -offset.y)).r; + float center = texture(texture0, uv).r; + float left = texture(texture0, uv + vec2(-offset.x, 0.0)).r; + float right = texture(texture0, uv + vec2(offset.x, 0.0)).r; + float top = texture(texture0, uv + vec2(0.0, offset.y)).r; + float bottom = texture(texture0, uv + vec2(0.0, -offset.y)).r; float height = (center + left + right + top + bottom) / 5.0; @@ -69,3 +69,4 @@ void main(){ } + diff --git a/Examples/Mountain/GameData/Assets/Shaders/Terrain/vertex.glsl b/Examples/Mountain/GameData/Assets/Shaders/Terrain/vertex.glsl new file mode 100644 index 0000000..2178bb8 --- /dev/null +++ b/Examples/Mountain/GameData/Assets/Shaders/Terrain/vertex.glsl @@ -0,0 +1,10 @@ +#version 430 core + +layout(location = 0) in vec4 aPos; + +uniform mat4 model; + +void main(){ + gl_Position = model * aPos; +} + diff --git a/Examples/Moutains/GameData/Assets/Shaders/Water/fragment.glsl b/Examples/Mountain/GameData/Assets/Shaders/Water/fragment.glsl similarity index 89% rename from Examples/Moutains/GameData/Assets/Shaders/Water/fragment.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Water/fragment.glsl index c643472..8cf25d4 100644 --- a/Examples/Moutains/GameData/Assets/Shaders/Water/fragment.glsl +++ b/Examples/Mountain/GameData/Assets/Shaders/Water/fragment.glsl @@ -7,7 +7,7 @@ in vec3 Normal; uniform int lightCount; uniform vec3 cameraPosition; -uniform int material_id; +uniform int mat_translate[1]; struct Light { @@ -148,7 +148,7 @@ void main(){ float fresnel = pow(1.0 - max(dot(N, V), 0.0), 5.0); fresnel = mix(0.05, 1.0, fresnel); - vec3 color = material[material_id].albedo * 0.1f; + vec3 color = material[mat_translate[0]].albedo * 0.1f; for(int i = 0; i < lightCount; i++){ vec3 L = normalize(lights[i].position - FragPosition); @@ -159,16 +159,17 @@ void main(){ cameraPosition, lights[i].position, lights[i].color, - material[material_id].albedo, - material[material_id].metallic, - material[material_id].roughness, - material[material_id].emission_color, - material[material_id].emission_strength, - material[material_id].ambient_occlusion + material[mat_translate[0]].albedo, + material[mat_translate[0]].metallic, + material[mat_translate[0]].roughness, + material[mat_translate[0]].emission_color, + material[mat_translate[0]].emission_strength, + material[mat_translate[0]].ambient_occlusion ) * lights[i].strength; }; - float alpha = clamp(0.2 + fresnel, 0.0, 0.2); + float alpha = clamp(0.2 + fresnel, 0.0, 0.6); FragColor = vec4(color, alpha); -} \ No newline at end of file +} + diff --git a/Examples/Moutains/GameData/Assets/Shaders/Water/tess_control.glsl b/Examples/Mountain/GameData/Assets/Shaders/Water/tess_control.glsl similarity index 100% rename from Examples/Moutains/GameData/Assets/Shaders/Water/tess_control.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Water/tess_control.glsl diff --git a/Examples/Moutains/GameData/Assets/Shaders/Water/tess_evaluation.glsl b/Examples/Mountain/GameData/Assets/Shaders/Water/tess_evaluation.glsl similarity index 100% rename from Examples/Moutains/GameData/Assets/Shaders/Water/tess_evaluation.glsl rename to Examples/Mountain/GameData/Assets/Shaders/Water/tess_evaluation.glsl diff --git a/Examples/Mountain/GameData/Assets/Shaders/Water/vertex.glsl b/Examples/Mountain/GameData/Assets/Shaders/Water/vertex.glsl new file mode 100644 index 0000000..fb3ec62 --- /dev/null +++ b/Examples/Mountain/GameData/Assets/Shaders/Water/vertex.glsl @@ -0,0 +1,12 @@ +#version 430 core + +layout(location = 0) in vec4 aPos; + +uniform mat4 model; + +void main(){ + gl_Position = model * aPos, 1.0; +} + + + diff --git a/Examples/Moutains/GameData/Assets/Textures/Skybox/Skybox.png b/Examples/Mountain/GameData/Assets/Textures/Skybox/Skybox.png similarity index 100% rename from Examples/Moutains/GameData/Assets/Textures/Skybox/Skybox.png rename to Examples/Mountain/GameData/Assets/Textures/Skybox/Skybox.png diff --git a/Examples/Moutains/GameData/Assets/Textures/Terrain/heightmap.png b/Examples/Mountain/GameData/Assets/Textures/Terrain/heightmap.png similarity index 100% rename from Examples/Moutains/GameData/Assets/Textures/Terrain/heightmap.png rename to Examples/Mountain/GameData/Assets/Textures/Terrain/heightmap.png diff --git a/Examples/Moutains/GameData/Lights.lit b/Examples/Mountain/GameData/Lights.lit similarity index 100% rename from Examples/Moutains/GameData/Lights.lit rename to Examples/Mountain/GameData/Lights.lit diff --git a/Examples/Mountain/GameData/Materials.pbr b/Examples/Mountain/GameData/Materials.pbr new file mode 100644 index 0000000..14c4cf1 Binary files /dev/null and b/Examples/Mountain/GameData/Materials.pbr differ diff --git a/Examples/Mountain/GameData/Objects.obj b/Examples/Mountain/GameData/Objects.obj new file mode 100644 index 0000000..e91a298 Binary files /dev/null and b/Examples/Mountain/GameData/Objects.obj differ diff --git a/Examples/Mountain/GameData/Resources.res b/Examples/Mountain/GameData/Resources.res new file mode 100644 index 0000000..d55a0a0 Binary files /dev/null and b/Examples/Mountain/GameData/Resources.res differ diff --git a/Examples/Mountain/Scripts/AnimateWater.cpp b/Examples/Mountain/Scripts/AnimateWater.cpp new file mode 100644 index 0000000..de245ed --- /dev/null +++ b/Examples/Mountain/Scripts/AnimateWater.cpp @@ -0,0 +1,68 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#define SCRIPT_NAME Script_Template +#define SCRIPT_FILE_NAME "Template" +#define BUILDING_SCRIPT_DLL + +#include "ScriptShared/ScriptShared/GameObjectScriptInterface.h" +#include +#include +#include + + + +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { +private: + float elapsed_time = 0.0f; +public: + ~SCRIPT_NAME() = default; + + void OnLoad(){ + logger->info(SCRIPT_FILE_NAME, "Loaded"); + }; + + void OnUpdate(float delta_time){ + elapsed_time += delta_time; + }; + + void OnFixedUpdate(float fixed_delta_time){ + }; + + void OnRender(){ + game_object_data->uniforms["time"] = elapsed_time; + }; + + void OnDestroy(){ + logger->info(SCRIPT_FILE_NAME, "Destroyed"); + }; +}; +}; + + + +#ifndef PRODUCTION + +extern "C" Engine::ScriptShared::GameObjectScriptInterface* SCRIPT_API GetScript() { + Engine::SCRIPT_NAME* script = new Engine::SCRIPT_NAME(); + return (Engine::ScriptShared::GameObjectScriptInterface*)script; +}; + + + +extern "C" void SCRIPT_API DeleteScript(Engine::ScriptShared::GameObjectScriptInterface* script) { + Engine::SCRIPT_NAME* temp_script = (Engine::SCRIPT_NAME*)script; + delete temp_script; +}; + +#else + +REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) + +#endif + diff --git a/Examples/Moutains/Scripts/FishMovement.cpp b/Examples/Mountain/Scripts/FishMovement.cpp similarity index 93% rename from Examples/Moutains/Scripts/FishMovement.cpp rename to Examples/Mountain/Scripts/FishMovement.cpp index f0325ee..88d586c 100644 --- a/Examples/Moutains/Scripts/FishMovement.cpp +++ b/Examples/Mountain/Scripts/FishMovement.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -16,8 +16,8 @@ -namespace UW{ -class SCRIPT_NAME : public GameObjectScriptInterface { +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { private: std::deque path; @@ -216,13 +216,13 @@ class SCRIPT_NAME : public GameObjectScriptInterface { #ifndef PRODUCTION -extern "C" UW::GameObjectScriptInterface* SCRIPT_API GetScript() { - UW::SCRIPT_NAME* script = new UW::SCRIPT_NAME(); - return (UW::GameObjectScriptInterface*)script; +extern "C" Engine::ScriptShared::GameObjectScriptInterface* SCRIPT_API GetScript() { + Engine::SCRIPT_NAME* script = new Engine::SCRIPT_NAME(); + return (Engine::ScriptShared::GameObjectScriptInterface*)script; }; -extern "C" void SCRIPT_API DeleteScript(UW::GameObjectScriptInterface* script) { - UW::SCRIPT_NAME* temp_script = (UW::SCRIPT_NAME*)script; +extern "C" void SCRIPT_API DeleteScript(Engine::ScriptShared::GameObjectScriptInterface* script) { + Engine::SCRIPT_NAME* temp_script = (Engine::SCRIPT_NAME*)script; delete temp_script; }; diff --git a/Examples/Moutains/Scripts/RandomGen.cpp b/Examples/Mountain/Scripts/RandomGen.cpp similarity index 90% rename from Examples/Moutains/Scripts/RandomGen.cpp rename to Examples/Mountain/Scripts/RandomGen.cpp index f26fd34..e08aa20 100644 --- a/Examples/Moutains/Scripts/RandomGen.cpp +++ b/Examples/Mountain/Scripts/RandomGen.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -17,8 +17,8 @@ -namespace UW{ -class SCRIPT_NAME : public GameObjectScriptInterface { +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { private: std::deque path; int interpolate_points_size = 0; @@ -118,7 +118,7 @@ class SCRIPT_NAME : public GameObjectScriptInterface { child_object.emplace_back(new_child); object_manager->emplace_back(new_child); - GameObjectData* child_data = object_manager->getGameObjectData(new_child); + Engine::ScriptShared::GameObjectData* child_data = object_manager->getGameObjectData(new_child); child_data->mesh = mesh; child_data->rotation = game_object_data->rotation; child_data->scale = game_object_data->scale; @@ -193,15 +193,15 @@ class SCRIPT_NAME : public GameObjectScriptInterface { #ifndef PRODUCTION -extern "C" UW::GameObjectScriptInterface* SCRIPT_API GetScript() { - UW::SCRIPT_NAME* script = new UW::SCRIPT_NAME(); - return (UW::GameObjectScriptInterface*)script; +extern "C" Engine::ScriptShared::GameObjectScriptInterface* SCRIPT_API GetScript() { + Engine::SCRIPT_NAME* script = new Engine::SCRIPT_NAME(); + return (Engine::ScriptShared::GameObjectScriptInterface*)script; }; -extern "C" void SCRIPT_API DeleteScript(UW::GameObjectScriptInterface* script) { - UW::SCRIPT_NAME* temp_script = (UW::SCRIPT_NAME*)script; +extern "C" void SCRIPT_API DeleteScript(Engine::ScriptShared::GameObjectScriptInterface* script) { + Engine::SCRIPT_NAME* temp_script = (Engine::SCRIPT_NAME*)script; delete temp_script; }; diff --git a/Examples/Moutains/Scripts/Template.cpp b/Examples/Mountain/Scripts/Template.cpp similarity index 61% rename from Examples/Moutains/Scripts/Template.cpp rename to Examples/Mountain/Scripts/Template.cpp index 67b1540..a2f17a2 100644 --- a/Examples/Moutains/Scripts/Template.cpp +++ b/Examples/Mountain/Scripts/Template.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -16,8 +16,8 @@ -namespace UW{ -class SCRIPT_NAME : public GameObjectScriptInterface { +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { private: public: @@ -46,15 +46,15 @@ class SCRIPT_NAME : public GameObjectScriptInterface { #ifndef PRODUCTION -extern "C" UW::GameObjectScriptInterface* SCRIPT_API GetScript() { - UW::SCRIPT_NAME* script = new UW::SCRIPT_NAME(); - return (UW::GameObjectScriptInterface*)script; +extern "C" Engine::ScriptShared::GameObjectScriptInterface* SCRIPT_API GetScript() { + Engine::SCRIPT_NAME* script = new Engine::SCRIPT_NAME(); + return (Engine::ScriptShared::GameObjectScriptInterface*)script; }; -extern "C" void SCRIPT_API DeleteScript(UW::GameObjectScriptInterface* script) { - UW::SCRIPT_NAME* temp_script = (UW::SCRIPT_NAME*)script; +extern "C" void SCRIPT_API DeleteScript(Engine::ScriptShared::GameObjectScriptInterface* script) { + Engine::SCRIPT_NAME* temp_script = (Engine::SCRIPT_NAME*)script; delete temp_script; }; diff --git a/Examples/Moutains/GameData/Assets/Meshes/Cod.msh b/Examples/Moutains/GameData/Assets/Meshes/Cod.msh deleted file mode 100644 index 1a513b6..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/Cod.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/Default.msh b/Examples/Moutains/GameData/Assets/Meshes/Default.msh deleted file mode 100644 index 976fac0..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/Default.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/House.msh b/Examples/Moutains/GameData/Assets/Meshes/House.msh deleted file mode 100644 index 4d31f08..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/House.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/Manta.msh b/Examples/Moutains/GameData/Assets/Meshes/Manta.msh deleted file mode 100644 index 95a586f..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/Manta.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/Pufferfish.msh b/Examples/Moutains/GameData/Assets/Meshes/Pufferfish.msh deleted file mode 100644 index 2932b9e..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/Pufferfish.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/Road.msh b/Examples/Moutains/GameData/Assets/Meshes/Road.msh deleted file mode 100644 index 3d8a86a..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/Road.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/Rock.msh b/Examples/Moutains/GameData/Assets/Meshes/Rock.msh deleted file mode 100644 index dd8fccc..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/Rock.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/Skyscraper.msh b/Examples/Moutains/GameData/Assets/Meshes/Skyscraper.msh deleted file mode 100644 index 8e37bb7..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/Skyscraper.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Meshes/TelescopeFish.msh b/Examples/Moutains/GameData/Assets/Meshes/TelescopeFish.msh deleted file mode 100644 index 586928f..0000000 Binary files a/Examples/Moutains/GameData/Assets/Meshes/TelescopeFish.msh and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Shaders/Manta/fragment.glsl b/Examples/Moutains/GameData/Assets/Shaders/Manta/fragment.glsl deleted file mode 100644 index cd3810b..0000000 --- a/Examples/Moutains/GameData/Assets/Shaders/Manta/fragment.glsl +++ /dev/null @@ -1,239 +0,0 @@ -#version 430 core - -out vec4 FragColor; - -in vec3 FragPosition; -flat in int material_id; -in vec3 Normal; -in vec2 uv; -in vec4 FragPosLightSpace; - -uniform int lightCount; -uniform vec3 cameraPosition; -uniform sampler2D u_ShadowDepthTexture; -uniform int u_ShadowEnabled; -uniform sampler2D texture0; - -struct Light { - vec3 position; - vec3 color; - float strength; -}; - -struct Material { - vec3 albedo; - float metallic; - float roughness; - vec3 emission_color; - float emission_strength; - float ambient_occlusion; -}; - -layout(std430, binding = 0) buffer LightsBuffer { - Light lights[]; -}; - -layout(std430, binding = 1) buffer MaterialsBuffer { - Material material[]; -}; - - -const float PI = 3.14159265359; - -float DistributionGGX(vec3 N, vec3 H, float roughness){ - float a = roughness * roughness; - float a2 = a * a; - - float NdotH = max(dot(N, H), 0.0); - float NdotH2 = NdotH * NdotH; - - float denom = (NdotH2 * (a2 - 1.0) + 1.0); - denom = PI * denom * denom; - - return a2 / max(denom, 0.0001); -} - -float GeometrySchlickGGX(float NdotV, float roughness){ - float r = roughness + 1.0; - float k = (r * r) / 8.0; - - return NdotV / (NdotV * (1.0 - k) + k); -} - -float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness){ - float NdotV = max(dot(N, V), 0.0); - float NdotL = max(dot(N, L), 0.0); - - return GeometrySchlickGGX(NdotV, roughness) * GeometrySchlickGGX(NdotL, roughness); -} - -vec3 FresnelSchlick(vec3 V, vec3 H, vec3 albedo, float metallic){ - float cosTheta = max(dot(V, H), 0.0); - vec3 F0 = vec3(0.04); - F0 = mix(F0, albedo, metallic); - - return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0); -} - -float Calc_D(float NdotH, float roughness){ - float a = roughness * roughness; - float a2 = a * a; - - float denom = NdotH * NdotH * (a2 - 1.0) + 1.0; - float D = a2 / (PI * denom * denom + 0.0001); - return D; -} - -float GGX(float NdotV, float NdotL, float roughness){ - float k = (roughness + 1.0); - k = (k * k) / 8.0; - - float G1 = NdotL / (NdotL * (1.0 - k) + k); - float G2 = NdotV / (NdotV * (1.0 - k) + k); - float G = G1 * G2; - return G; -} - -vec3 Specular(float NdotL, float NdotV, float D, float G, vec3 Fresnel){ - return (D * G * Fresnel) / max(4.0 * NdotL * NdotV, 0.001); -} - -vec3 Diffuse(vec3 Fresnel, vec3 albedo, float metallic){ - vec3 kS = Fresnel; - vec3 kD = (1.0 - kS) * (1.0 - metallic); - - vec3 diffuse = kD * albedo / PI; - return diffuse; -} - - - -float CalculateShadow(vec4 fragPosLightSpace, vec3 normal, vec3 lightDir) { - vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; - - projCoords = projCoords * 0.5 + 0.5; - - if(projCoords.z > 1.0 || projCoords.x < 0.0 || projCoords.x > 1.0 || projCoords.y < 0.0 || projCoords.y > 1.0) { - return 0.0; - } - - float currentDepth = projCoords.z; - - float bias = max(0.005 * (1.0 - dot(normal, lightDir)), 0.001); - - float shadow = 0.0; - vec2 texelSize = 1.0 / textureSize(u_ShadowDepthTexture, 0); - - int radius = 1; - float samples = 0.0; - - for(int x = -radius; x <= radius; ++x) { - for(int y = -radius; y <= radius; ++y) { - float pcfDepth = texture(u_ShadowDepthTexture, projCoords.xy + vec2(x, y) * texelSize).r; - shadow += (currentDepth - bias > pcfDepth) ? 1.0 : 0.0; - samples += 1.0; - } - } - - return shadow / samples; -} - - -vec3 BRDF( - vec3 Normal, - vec3 FragPos, - vec3 cameraPos, - vec3 lightPos, - vec3 lightColor, - vec3 albedo, - float metallic, - float roughness, - vec3 emission_color, - float emission_strength, - float ambient_occlusion, - bool isFirstLight -) -{ - vec3 N = normalize(Normal); - vec3 V = normalize(cameraPos - FragPos); - vec3 L = normalize(lightPos - FragPos); - vec3 H = normalize(V + L); - - float NdotL = max(dot(N, L), 0.0); - float NdotV = max(dot(N, V), 0.0); - float NdotH = max(dot(N, H), 0.0); - - vec3 Fresnel = FresnelSchlick(V, H, albedo, metallic); - - float D = Calc_D(NdotH, roughness); - float G = GGX(NdotV, NdotL, roughness); - - vec3 specular = Specular(NdotL, NdotV, D, G, Fresnel); - vec3 diffuse = Diffuse(Fresnel, albedo, metallic); - - float shadow = 0.0; - if (isFirstLight && u_ShadowEnabled == 1) { - shadow = CalculateShadow(FragPosLightSpace, N, L); - } - - vec3 lighting = (1 - shadow) * (diffuse + specular) * lightColor * NdotL; - vec3 ambient = 0.03 * albedo * ambient_occlusion; - vec3 emissiveColor = emission_color * emission_strength; - - return lighting + ambient + emissiveColor; -}; - -vec4 sampleMyTexture(sampler2D tex, vec2 uv) { - return texture(tex, uv); -} - -uniform sampler2D sky_box; -uniform int mat_translate[2]; - -void main(){ - vec3 finalColor = vec3(1.0f); - - vec3 texColor = texture(texture0, uv).rgb; - texColor = pow(texColor, vec3(2.2)); - - vec3 baseAlbedo = material[mat_translate[material_id]].albedo * texColor; - - if(u_ShadowEnabled == 1){ - vec3 lighting = vec3(0.0); - - for(int i = 0; i < lightCount; i++){ - bool isFirstLight = (i == 0); - lighting += BRDF( - normalize(Normal), - FragPosition, - cameraPosition, - lights[i].position, - lights[i].color, - baseAlbedo, - // material[mat_translate[material_id]].albedo, - material[mat_translate[material_id]].metallic, - material[mat_translate[material_id]].roughness, - material[mat_translate[material_id]].emission_color, - material[mat_translate[material_id]].emission_strength, - material[mat_translate[material_id]].ambient_occlusion, - isFirstLight - ) * lights[i].strength; - }; - finalColor = lighting; - } - - FragColor = vec4(finalColor, 1.0); -} - - - - - - - - - - - - - diff --git a/Examples/Moutains/GameData/Assets/Shaders/Manta/vertex.glsl b/Examples/Moutains/GameData/Assets/Shaders/Manta/vertex.glsl deleted file mode 100644 index 0819b40..0000000 --- a/Examples/Moutains/GameData/Assets/Shaders/Manta/vertex.glsl +++ /dev/null @@ -1,31 +0,0 @@ -#version 430 core - -layout(location = 0) in vec3 aPos; -layout(location = 1) in vec3 normals; -layout(location = 2) in vec2 uvs; -layout(location = 3) in int mat_id; - -flat out int material_id; -out vec2 uv; -out vec3 Normal; -out vec3 FragPosition; -out vec4 FragPosLightSpace; - -uniform mat4 projection; -uniform mat4 view; -uniform mat4 u_LightSpaceMatrix; - -uniform mat4 model; - -void main(){ - FragPosLightSpace = u_LightSpaceMatrix * model * vec4(aPos, 1.0); - vec4 pos = projection * view * model * vec4(aPos, 1.0); - - material_id = mat_id; - uv = uvs; - Normal = normals; - FragPosition = pos.xyz; - - gl_Position = pos; -} - diff --git a/Examples/Moutains/GameData/Assets/Shaders/SDF/fragment.glsl b/Examples/Moutains/GameData/Assets/Shaders/SDF/fragment.glsl deleted file mode 100644 index 0dc6123..0000000 --- a/Examples/Moutains/GameData/Assets/Shaders/SDF/fragment.glsl +++ /dev/null @@ -1,253 +0,0 @@ -#version 430 core - -in vec2 TexCoords; -out vec4 FragColor; - -uniform mat4 transformation; -uniform int lightCount; -uniform vec3 cameraPosition; -uniform int material_id; -uniform mat4 model; - -struct Light { - vec3 position; - vec3 color; - float strength; -}; - -layout(std430, binding = 0) buffer LightsBuffer { - Light lights[]; -}; - -struct Material { - vec3 albedo; - float metallic; - float roughness; - vec3 emission_color; - float emission_strength; - float ambient_occlusion; -}; - -layout(std430, binding = 1) buffer MaterialsBuffer { - Material material[]; -}; - -const float PI = 3.14159265359; - -float DistributionGGX(vec3 N, vec3 H, float roughness){ - float a = roughness * roughness; - float a2 = a * a; - float NdotH = max(dot(N, H), 0.0); - float NdotH2 = NdotH * NdotH; - float denom = (NdotH2 * (a2 - 1.0) + 1.0); - denom = PI * denom * denom; - return a2 / max(denom, 0.0001); -} - -float GeometrySchlickGGX(float NdotV, float roughness){ - float r = roughness + 1.0; - float k = (r * r) / 8.0; - return NdotV / (NdotV * (1.0 - k) + k); -} - -float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness){ - float NdotV = max(dot(N, V), 0.0); - float NdotL = max(dot(N, L), 0.0); - return GeometrySchlickGGX(NdotV, roughness) * GeometrySchlickGGX(NdotL, roughness); -} - -vec3 FresnelSchlick(vec3 V, vec3 H, vec3 albedo, float metallic){ - float cosTheta = max(dot(V, H), 0.0); - vec3 F0 = vec3(0.04); - F0 = mix(F0, albedo, metallic); - return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0); -} - -float Calc_D(float NdotH, float roughness){ - float a = roughness * roughness; - float a2 = a * a; - float denom = NdotH * NdotH * (a2 - 1.0) + 1.0; - float D = a2 / (PI * denom * denom + 0.0001); - return D; -} - -float GGX(float NdotV, float NdotL, float roughness){ - float k = (roughness + 1.0); - k = (k * k) / 8.0; - float G1 = NdotL / (NdotL * (1.0 - k) + k); - float G2 = NdotV / (NdotV * (1.0 - k) + k); - float G = G1 * G2; - return G; -} - -vec3 Specular(float NdotL, float NdotV, float D, float G, vec3 Fresnel){ - return (D * G * Fresnel) / max(4.0 * NdotL * NdotV, 0.001); -} - -vec3 Diffuse(vec3 Fresnel, vec3 albedo, float metallic){ - vec3 kS = Fresnel; - vec3 kD = (1.0 - kS) * (1.0 - metallic); - return kD * albedo / PI; -} - -vec3 BRDF(vec3 Normal, vec3 FragPos, vec3 cameraPos, vec3 lightPos, vec3 lightColor, vec3 albedo, float metallic, float roughness, vec3 emission_color, float emission_strength, float ambient_occlusion) { - vec3 N = normalize(Normal); - vec3 V = normalize(cameraPos - FragPos); - vec3 L = normalize(lightPos - FragPos); - vec3 H = normalize(V + L); - float NdotL = max(dot(N, L), 0.0); - float NdotV = max(dot(N, V), 0.0); - float NdotH = max(dot(N, H), 0.0); - vec3 Fresnel = FresnelSchlick(V, H, albedo, metallic); - float D = Calc_D(NdotH, roughness); - float G = GGX(NdotV, NdotL, roughness); - vec3 specular = Specular(NdotL, NdotV, D, G, Fresnel); - vec3 diffuse = Diffuse(Fresnel, albedo, metallic); - vec3 lighting = (diffuse + specular) * lightColor * NdotL; - vec3 ambient = 0.03 * albedo * ambient_occlusion; - vec3 emissiveColor = emission_color * emission_strength; - return lighting + ambient + emissiveColor; -} - - - - -float sdElipsolid(vec3 p, vec3 center, vec3 coff, float radius) { - return length((p - center) / coff) - radius; -} - -float sdCone(vec3 p, vec3 center, vec2 c, float h) { - vec3 translatedP = p - center; - float q = length(translatedP.xz); - return max(dot(c.xy, vec2(q, translatedP.y)), -h - translatedP.y); -} - -float sdConeUpsideDown(vec3 p, vec3 center, vec2 c, float h) { - vec3 translatedP = p - center; - - translatedP.y = -translatedP.y; - - float q = length(translatedP.xz); - return max(dot(c.xy, vec2(q, translatedP.y)), -h - translatedP.y); -} - - - -float map(vec3 p) { - float minDist = 100000.0; - - float elipsolidTop = sdElipsolid(p, vec3(0.0, 0.0, 0.0), vec3(1.5, 1, 1.5), 5.0); - float elipsolidBottomCut = sdElipsolid(p, vec3(0.0, -5.0, 0.0), vec3(1.7, 1, 1.7), 5.0); - - minDist = max(elipsolidTop, -elipsolidBottomCut); - - float cone1 = sdConeUpsideDown(p, vec3(0.0, -8, 0), vec2(0.9, 0.5), 9); - - minDist = min(minDist, cone1); - - return minDist; -} - - - - -vec3 calculateNormal(vec3 p) { - vec2 eps = vec2(0.005, 0.0); - return normalize(vec3( - map(p + eps.xyy) - map(p - eps.xyy), - map(p + eps.yxy) - map(p - eps.yxy), - map(p + eps.yyx) - map(p - eps.yyx) - )); -} - -void main() { - vec2 uv = TexCoords * 2.0 - 1.0; - mat4 invTransformation = inverse(transformation); - mat4 invModel = inverse(model); - - vec4 nearTarget = invTransformation * vec4(uv, -1.0, 1.0); - vec4 farTarget = invTransformation * vec4(uv, 1.0, 1.0); - - vec3 world_ro = nearTarget.xyz / nearTarget.w; - vec3 world_rd = normalize((farTarget.xyz / farTarget.w) - world_ro); - - vec3 ro = (invModel * vec4(world_ro, 1.0)).xyz; - vec3 rd = normalize((invModel * vec4(world_rd, 0.0)).xyz); - - float t = 0.0; - float max_t = 4000.0; - bool hit = false; - vec3 hitPosLocal = vec3(0.0); - - for(int i = 0; i < 200; i++) { - vec3 p = ro + rd * t; - float d = map(p); - if(d < 0.005) { - hit = true; - hitPosLocal = p; - break; - } - if(t > max_t) break; - t += d; - } - - if(!hit) { - discard; - } - - - - float insideThickness = 0.0; - float inside_t = t + 0.03; - float max_thickness_dist = t + 20.0; - - for(int i = 0; i < 40; i++) { - vec3 insideP = ro + rd * inside_t; - float d = map(insideP); - - if(d < 0.0) { - insideThickness += abs(d); - inside_t += max(abs(d), 0.1); - } else { - inside_t += max(d, 0.1); - } - - if(inside_t > max_thickness_dist || inside_t > max_t) { - break; - } - } - - float densityCoefficient = 0.15; - float alpha = 1.0 - exp(-insideThickness * densityCoefficient); - - - vec3 hitPosWorld = (model * vec4(hitPosLocal, 1.0)).xyz; - - vec4 clipPos = transformation * vec4(hitPosWorld, 1.0); - float ndcDepth = clipPos.z / clipPos.w; - gl_FragDepth = ndcDepth * 0.5 + 0.5; - - vec3 localNormal = calculateNormal(hitPosLocal); - vec3 normal = normalize(mat3(transpose(invModel)) * localNormal); - vec3 totalLighting = vec3(0.0); - - for(int i = 0; i < lightCount; i++) { - totalLighting += BRDF( - normal, - hitPosWorld, - cameraPosition, - lights[i].position, - lights[i].color, - material[material_id].albedo, - material[material_id].metallic, - material[material_id].roughness, - material[material_id].emission_color, - material[material_id].emission_strength, - material[material_id].ambient_occlusion - ) * lights[i].strength; - } - FragColor = vec4(totalLighting, alpha); -} - - - diff --git a/Examples/Moutains/GameData/Assets/Shaders/Terrain/vertex.glsl b/Examples/Moutains/GameData/Assets/Shaders/Terrain/vertex.glsl deleted file mode 100644 index 533ab63..0000000 --- a/Examples/Moutains/GameData/Assets/Shaders/Terrain/vertex.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 430 core - -layout(location = 0) in vec3 aPos; - -uniform mat4 model; - -void main(){ - gl_Position = model * vec4(aPos, 1.0); -} diff --git a/Examples/Moutains/GameData/Assets/Shaders/Water/vertex.glsl b/Examples/Moutains/GameData/Assets/Shaders/Water/vertex.glsl deleted file mode 100644 index 96295ae..0000000 --- a/Examples/Moutains/GameData/Assets/Shaders/Water/vertex.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#version 430 core - -layout(location = 0) in vec3 aPos; - -uniform mat4 model; - -void main(){ - gl_Position = model * vec4(aPos, 1.0); -} - - diff --git a/Examples/Moutains/GameData/Assets/Textures/Cod/CodAlbedo.png b/Examples/Moutains/GameData/Assets/Textures/Cod/CodAlbedo.png deleted file mode 100644 index 4b03d55..0000000 Binary files a/Examples/Moutains/GameData/Assets/Textures/Cod/CodAlbedo.png and /dev/null differ diff --git a/Examples/Moutains/GameData/Assets/Textures/Manta/Mantaalbedo.png b/Examples/Moutains/GameData/Assets/Textures/Manta/Mantaalbedo.png deleted file mode 100644 index 616f966..0000000 Binary files a/Examples/Moutains/GameData/Assets/Textures/Manta/Mantaalbedo.png and /dev/null differ diff --git a/Examples/Moutains/GameData/Materials.pbr b/Examples/Moutains/GameData/Materials.pbr deleted file mode 100644 index 8200f17..0000000 Binary files a/Examples/Moutains/GameData/Materials.pbr and /dev/null differ diff --git a/Examples/Moutains/GameData/Objects.obj b/Examples/Moutains/GameData/Objects.obj deleted file mode 100644 index 82ca841..0000000 Binary files a/Examples/Moutains/GameData/Objects.obj and /dev/null differ diff --git a/Examples/Moutains/GameData/Resources.res b/Examples/Moutains/GameData/Resources.res deleted file mode 100644 index 9720da7..0000000 Binary files a/Examples/Moutains/GameData/Resources.res and /dev/null differ diff --git a/Assets/Enviroment/House/House.blend b/Examples/UnderTheWater/Assets/Enviroment/House/House.blend similarity index 100% rename from Assets/Enviroment/House/House.blend rename to Examples/UnderTheWater/Assets/Enviroment/House/House.blend diff --git a/Assets/Enviroment/House/House.mtl b/Examples/UnderTheWater/Assets/Enviroment/House/House.mtl similarity index 100% rename from Assets/Enviroment/House/House.mtl rename to Examples/UnderTheWater/Assets/Enviroment/House/House.mtl diff --git a/Assets/Enviroment/House/House.obj b/Examples/UnderTheWater/Assets/Enviroment/House/House.obj similarity index 100% rename from Assets/Enviroment/House/House.obj rename to Examples/UnderTheWater/Assets/Enviroment/House/House.obj diff --git a/Assets/Enviroment/Road/Road.blend b/Examples/UnderTheWater/Assets/Enviroment/Road/Road.blend similarity index 100% rename from Assets/Enviroment/Road/Road.blend rename to Examples/UnderTheWater/Assets/Enviroment/Road/Road.blend diff --git a/Assets/Enviroment/Road/Road.mtl b/Examples/UnderTheWater/Assets/Enviroment/Road/Road.mtl similarity index 100% rename from Assets/Enviroment/Road/Road.mtl rename to Examples/UnderTheWater/Assets/Enviroment/Road/Road.mtl diff --git a/Assets/Enviroment/Road/Road.obj b/Examples/UnderTheWater/Assets/Enviroment/Road/Road.obj similarity index 100% rename from Assets/Enviroment/Road/Road.obj rename to Examples/UnderTheWater/Assets/Enviroment/Road/Road.obj diff --git a/Assets/Enviroment/Rock/Rock.blend b/Examples/UnderTheWater/Assets/Enviroment/Rock/Rock.blend similarity index 100% rename from Assets/Enviroment/Rock/Rock.blend rename to Examples/UnderTheWater/Assets/Enviroment/Rock/Rock.blend diff --git a/Assets/Enviroment/Rock/Rock.mtl b/Examples/UnderTheWater/Assets/Enviroment/Rock/Rock.mtl similarity index 100% rename from Assets/Enviroment/Rock/Rock.mtl rename to Examples/UnderTheWater/Assets/Enviroment/Rock/Rock.mtl diff --git a/Assets/Enviroment/Rock/Rock.obj b/Examples/UnderTheWater/Assets/Enviroment/Rock/Rock.obj similarity index 100% rename from Assets/Enviroment/Rock/Rock.obj rename to Examples/UnderTheWater/Assets/Enviroment/Rock/Rock.obj diff --git a/Assets/Enviroment/Skyscraper/Skyscraper.blend b/Examples/UnderTheWater/Assets/Enviroment/Skyscraper/Skyscraper.blend similarity index 100% rename from Assets/Enviroment/Skyscraper/Skyscraper.blend rename to Examples/UnderTheWater/Assets/Enviroment/Skyscraper/Skyscraper.blend diff --git a/Assets/Enviroment/Skyscraper/Skyscraper.mtl b/Examples/UnderTheWater/Assets/Enviroment/Skyscraper/Skyscraper.mtl similarity index 100% rename from Assets/Enviroment/Skyscraper/Skyscraper.mtl rename to Examples/UnderTheWater/Assets/Enviroment/Skyscraper/Skyscraper.mtl diff --git a/Assets/Enviroment/Skyscraper/Skyscraper.obj b/Examples/UnderTheWater/Assets/Enviroment/Skyscraper/Skyscraper.obj similarity index 100% rename from Assets/Enviroment/Skyscraper/Skyscraper.obj rename to Examples/UnderTheWater/Assets/Enviroment/Skyscraper/Skyscraper.obj diff --git a/Assets/Fishes/Cod/COD.blend b/Examples/UnderTheWater/Assets/Fishes/Cod/COD.blend similarity index 100% rename from Assets/Fishes/Cod/COD.blend rename to Examples/UnderTheWater/Assets/Fishes/Cod/COD.blend diff --git a/Assets/Fishes/Cod/COD.mtl b/Examples/UnderTheWater/Assets/Fishes/Cod/COD.mtl similarity index 100% rename from Assets/Fishes/Cod/COD.mtl rename to Examples/UnderTheWater/Assets/Fishes/Cod/COD.mtl diff --git a/Assets/Fishes/Cod/COD.obj b/Examples/UnderTheWater/Assets/Fishes/Cod/COD.obj similarity index 100% rename from Assets/Fishes/Cod/COD.obj rename to Examples/UnderTheWater/Assets/Fishes/Cod/COD.obj diff --git a/Assets/Fishes/Cod/CodAlbedo.png b/Examples/UnderTheWater/Assets/Fishes/Cod/CodAlbedo.png similarity index 100% rename from Assets/Fishes/Cod/CodAlbedo.png rename to Examples/UnderTheWater/Assets/Fishes/Cod/CodAlbedo.png diff --git a/Assets/Fishes/Manta/Manta.blend b/Examples/UnderTheWater/Assets/Fishes/Manta/Manta.blend similarity index 100% rename from Assets/Fishes/Manta/Manta.blend rename to Examples/UnderTheWater/Assets/Fishes/Manta/Manta.blend diff --git a/Assets/Fishes/Manta/Manta.mtl b/Examples/UnderTheWater/Assets/Fishes/Manta/Manta.mtl similarity index 100% rename from Assets/Fishes/Manta/Manta.mtl rename to Examples/UnderTheWater/Assets/Fishes/Manta/Manta.mtl diff --git a/Assets/Fishes/Manta/Manta.obj b/Examples/UnderTheWater/Assets/Fishes/Manta/Manta.obj similarity index 100% rename from Assets/Fishes/Manta/Manta.obj rename to Examples/UnderTheWater/Assets/Fishes/Manta/Manta.obj diff --git a/Assets/Fishes/Manta/Mantaalbedo.png b/Examples/UnderTheWater/Assets/Fishes/Manta/Mantaalbedo.png similarity index 100% rename from Assets/Fishes/Manta/Mantaalbedo.png rename to Examples/UnderTheWater/Assets/Fishes/Manta/Mantaalbedo.png diff --git a/Assets/Fishes/Pufferfish/Pufferfish.blend b/Examples/UnderTheWater/Assets/Fishes/Pufferfish/Pufferfish.blend similarity index 100% rename from Assets/Fishes/Pufferfish/Pufferfish.blend rename to Examples/UnderTheWater/Assets/Fishes/Pufferfish/Pufferfish.blend diff --git a/Assets/Fishes/Pufferfish/Pufferfish.mtl b/Examples/UnderTheWater/Assets/Fishes/Pufferfish/Pufferfish.mtl similarity index 100% rename from Assets/Fishes/Pufferfish/Pufferfish.mtl rename to Examples/UnderTheWater/Assets/Fishes/Pufferfish/Pufferfish.mtl diff --git a/Assets/Fishes/Pufferfish/Pufferfish.obj b/Examples/UnderTheWater/Assets/Fishes/Pufferfish/Pufferfish.obj similarity index 100% rename from Assets/Fishes/Pufferfish/Pufferfish.obj rename to Examples/UnderTheWater/Assets/Fishes/Pufferfish/Pufferfish.obj diff --git a/Assets/Fishes/Telescopefish/Telescope.blend b/Examples/UnderTheWater/Assets/Fishes/Telescopefish/Telescope.blend similarity index 100% rename from Assets/Fishes/Telescopefish/Telescope.blend rename to Examples/UnderTheWater/Assets/Fishes/Telescopefish/Telescope.blend diff --git a/Assets/Fishes/Telescopefish/Telescope.mtl b/Examples/UnderTheWater/Assets/Fishes/Telescopefish/Telescope.mtl similarity index 100% rename from Assets/Fishes/Telescopefish/Telescope.mtl rename to Examples/UnderTheWater/Assets/Fishes/Telescopefish/Telescope.mtl diff --git a/Assets/Fishes/Telescopefish/Telescope.obj b/Examples/UnderTheWater/Assets/Fishes/Telescopefish/Telescope.obj similarity index 100% rename from Assets/Fishes/Telescopefish/Telescope.obj rename to Examples/UnderTheWater/Assets/Fishes/Telescopefish/Telescope.obj diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/PostProcessing/fragment.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/PostProcessing/fragment.glsl index 36ffe90..790a660 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/PostProcessing/fragment.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/PostProcessing/fragment.glsl @@ -22,7 +22,7 @@ vec3 GetWorldPos(float depth) { float WaterDepthFog(float camY) { float d = max(0.0, u_water_height - camY); - return 1.0 - exp(-d * u_FogDensity * 2.0); + return 1.0 - exp(-d * u_FogDensity * 1.0); } void main() { @@ -72,4 +72,5 @@ void main() { vec3 finalColor = mix(u_FogColor, sceneColor, fogFactor); FragColor = vec4(finalColor, 1.0); -} \ No newline at end of file +} + diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/fragment.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/fragment.glsl index 4e69f70..b8c37b3 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/fragment.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/fragment.glsl @@ -4,7 +4,7 @@ out vec4 FragColor; in vec3 LocalPos; -uniform sampler2D skyboxTex; +uniform sampler2D texture0; const vec2 invAtan = vec2(0.1591, 0.3183); @@ -17,6 +17,7 @@ vec2 SampleSphericalMap(vec3 v){ void main(){ vec2 uv = SampleSphericalMap(normalize(LocalPos)); - vec3 color = texture(skyboxTex, uv).rgb; + vec3 color = texture(texture0, uv).rgb; FragColor = vec4(color, 1.0); -} \ No newline at end of file +} + diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/vertex.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/vertex.glsl index b08f2db..7bda7c3 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/vertex.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/Skybox/vertex.glsl @@ -1,6 +1,6 @@ #version 430 core -layout(location = 0) in vec3 aPos; +layout(location = 0) in vec4 aPos; out vec3 LocalPos; @@ -8,10 +8,11 @@ uniform mat4 projection; uniform mat4 view; void main(){ - LocalPos = aPos; + LocalPos = aPos.xyz; mat4 staticView = mat4(mat3(view)); - vec4 pos = projection * staticView * vec4(aPos, 1.0); + vec4 pos = projection * staticView * aPos; gl_Position = pos.xyww; -} \ No newline at end of file +} + diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/fragment.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/fragment.glsl index 22dfcc8..5bac68b 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/fragment.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/fragment.glsl @@ -8,7 +8,7 @@ in vec4 FragPosLightSpace; uniform int lightCount; uniform vec3 cameraPosition; -uniform int material_id; +uniform int mat_translate[1]; uniform int u_ShadowEnabled; uniform sampler2D u_ShadowDepthTexture; @@ -129,7 +129,7 @@ void main(){ if(u_ShadowEnabled == 1){ - Material mat = material[material_id]; + Material mat = material[mat_translate[0]]; vec3 N = normalize(Normal); vec3 directLighting = vec3(0.0f); diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl index 1a16da9..8b60bdd 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/tess_evaluation.glsl @@ -8,7 +8,7 @@ out vec4 FragPosLightSpace; uniform mat4 projection; uniform mat4 view; -uniform sampler2D uTexture; +uniform sampler2D texture0; uniform vec2 mapSize; uniform float maxHeight; uniform mat4 u_LightSpaceMatrix; @@ -17,16 +17,16 @@ float terrainHeight(vec2 p){ vec2 worldMin = vec2(-mapSize * 0.5); vec2 uv = (p - worldMin) / mapSize; - vec2 texelSize = 1.0 / textureSize(uTexture, 0); + vec2 texelSize = 1.0 / textureSize(texture0, 0); float texelOffset = 1.5; vec2 offset = texelSize * texelOffset; - float center = texture(uTexture, uv).r; - float left = texture(uTexture, uv + vec2(-offset.x, 0.0)).r; - float right = texture(uTexture, uv + vec2(offset.x, 0.0)).r; - float top = texture(uTexture, uv + vec2(0.0, offset.y)).r; - float bottom = texture(uTexture, uv + vec2(0.0, -offset.y)).r; + float center = texture(texture0, uv).r; + float left = texture(texture0, uv + vec2(-offset.x, 0.0)).r; + float right = texture(texture0, uv + vec2(offset.x, 0.0)).r; + float top = texture(texture0, uv + vec2(0.0, offset.y)).r; + float bottom = texture(texture0, uv + vec2(0.0, -offset.y)).r; float height = (center + left + right + top + bottom) / 5.0; @@ -69,3 +69,4 @@ void main(){ } + diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/vertex.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/vertex.glsl index 533ab63..2178bb8 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/vertex.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/Terrain/vertex.glsl @@ -1,9 +1,10 @@ #version 430 core -layout(location = 0) in vec3 aPos; +layout(location = 0) in vec4 aPos; uniform mat4 model; void main(){ - gl_Position = model * vec4(aPos, 1.0); + gl_Position = model * aPos; } + diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/Water/fragment.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/Water/fragment.glsl index c643472..8cf25d4 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/Water/fragment.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/Water/fragment.glsl @@ -7,7 +7,7 @@ in vec3 Normal; uniform int lightCount; uniform vec3 cameraPosition; -uniform int material_id; +uniform int mat_translate[1]; struct Light { @@ -148,7 +148,7 @@ void main(){ float fresnel = pow(1.0 - max(dot(N, V), 0.0), 5.0); fresnel = mix(0.05, 1.0, fresnel); - vec3 color = material[material_id].albedo * 0.1f; + vec3 color = material[mat_translate[0]].albedo * 0.1f; for(int i = 0; i < lightCount; i++){ vec3 L = normalize(lights[i].position - FragPosition); @@ -159,16 +159,17 @@ void main(){ cameraPosition, lights[i].position, lights[i].color, - material[material_id].albedo, - material[material_id].metallic, - material[material_id].roughness, - material[material_id].emission_color, - material[material_id].emission_strength, - material[material_id].ambient_occlusion + material[mat_translate[0]].albedo, + material[mat_translate[0]].metallic, + material[mat_translate[0]].roughness, + material[mat_translate[0]].emission_color, + material[mat_translate[0]].emission_strength, + material[mat_translate[0]].ambient_occlusion ) * lights[i].strength; }; - float alpha = clamp(0.2 + fresnel, 0.0, 0.2); + float alpha = clamp(0.2 + fresnel, 0.0, 0.6); FragColor = vec4(color, alpha); -} \ No newline at end of file +} + diff --git a/Examples/UnderTheWater/GameData/Assets/Shaders/Water/vertex.glsl b/Examples/UnderTheWater/GameData/Assets/Shaders/Water/vertex.glsl index 96295ae..fb3ec62 100644 --- a/Examples/UnderTheWater/GameData/Assets/Shaders/Water/vertex.glsl +++ b/Examples/UnderTheWater/GameData/Assets/Shaders/Water/vertex.glsl @@ -1,11 +1,12 @@ #version 430 core -layout(location = 0) in vec3 aPos; +layout(location = 0) in vec4 aPos; uniform mat4 model; void main(){ - gl_Position = model * vec4(aPos, 1.0); + gl_Position = model * aPos, 1.0; } + diff --git a/Examples/UnderTheWater/GameData/Assets/Textures/Skybox/Skybox.png b/Examples/UnderTheWater/GameData/Assets/Textures/Skybox/Skybox.png index 8f8c975..a01f0e6 100644 Binary files a/Examples/UnderTheWater/GameData/Assets/Textures/Skybox/Skybox.png and b/Examples/UnderTheWater/GameData/Assets/Textures/Skybox/Skybox.png differ diff --git a/Examples/UnderTheWater/GameData/Lights.lit b/Examples/UnderTheWater/GameData/Lights.lit index ba66a66..e14c14e 100644 Binary files a/Examples/UnderTheWater/GameData/Lights.lit and b/Examples/UnderTheWater/GameData/Lights.lit differ diff --git a/Examples/UnderTheWater/GameData/Materials.pbr b/Examples/UnderTheWater/GameData/Materials.pbr index aab46c3..8c16046 100644 Binary files a/Examples/UnderTheWater/GameData/Materials.pbr and b/Examples/UnderTheWater/GameData/Materials.pbr differ diff --git a/Examples/UnderTheWater/GameData/Objects.obj b/Examples/UnderTheWater/GameData/Objects.obj index bca664b..b4f8b07 100644 Binary files a/Examples/UnderTheWater/GameData/Objects.obj and b/Examples/UnderTheWater/GameData/Objects.obj differ diff --git a/Examples/UnderTheWater/GameData/Resources.res b/Examples/UnderTheWater/GameData/Resources.res index 6f6cfc9..157c106 100644 Binary files a/Examples/UnderTheWater/GameData/Resources.res and b/Examples/UnderTheWater/GameData/Resources.res differ diff --git a/Examples/UnderTheWater/Scripts/AnimateWater.cpp b/Examples/UnderTheWater/Scripts/AnimateWater.cpp new file mode 100644 index 0000000..1f44cd3 --- /dev/null +++ b/Examples/UnderTheWater/Scripts/AnimateWater.cpp @@ -0,0 +1,49 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#define SCRIPT_NAME Script_AnimationWater +#define SCRIPT_FILE_NAME "AnimationWater" +#define BUILDING_SCRIPT_DLL + +#include "ScriptShared/ScriptShared/GameObjectScriptInterface.h" +#include +#include +#include + + + +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { +private: + float elapsed_time = 0.0f; +public: + ~SCRIPT_NAME() = default; + + void OnLoad(){ + logger->info(SCRIPT_FILE_NAME, "Loaded"); + }; + + void OnUpdate(float delta_time){ + elapsed_time += delta_time; + }; + + void OnFixedUpdate(float fixed_delta_time){ + }; + + void OnRender(){ + game_object_data->uniforms["time"] = elapsed_time; + }; + + void OnDestroy(){ + logger->info(SCRIPT_FILE_NAME, "Destroyed"); + }; +}; +}; + + + +REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) diff --git a/Examples/UnderTheWater/Scripts/FishMovement.cpp b/Examples/UnderTheWater/Scripts/FishMovement.cpp index f0325ee..37a6be0 100644 --- a/Examples/UnderTheWater/Scripts/FishMovement.cpp +++ b/Examples/UnderTheWater/Scripts/FishMovement.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -16,8 +16,8 @@ -namespace UW{ -class SCRIPT_NAME : public GameObjectScriptInterface { +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { private: std::deque path; @@ -214,20 +214,4 @@ class SCRIPT_NAME : public GameObjectScriptInterface { -#ifndef PRODUCTION - -extern "C" UW::GameObjectScriptInterface* SCRIPT_API GetScript() { - UW::SCRIPT_NAME* script = new UW::SCRIPT_NAME(); - return (UW::GameObjectScriptInterface*)script; -}; - -extern "C" void SCRIPT_API DeleteScript(UW::GameObjectScriptInterface* script) { - UW::SCRIPT_NAME* temp_script = (UW::SCRIPT_NAME*)script; - delete temp_script; -}; - -#else - REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) - -#endif diff --git a/Examples/UnderTheWater/Scripts/RandomGen.cpp b/Examples/UnderTheWater/Scripts/RandomGen.cpp index f26fd34..7d43604 100644 --- a/Examples/UnderTheWater/Scripts/RandomGen.cpp +++ b/Examples/UnderTheWater/Scripts/RandomGen.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -17,8 +17,8 @@ -namespace UW{ -class SCRIPT_NAME : public GameObjectScriptInterface { +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { private: std::deque path; int interpolate_points_size = 0; @@ -116,9 +116,9 @@ class SCRIPT_NAME : public GameObjectScriptInterface { void generateChild(const std::string& new_child, unsigned int i){ child_object.emplace_back(new_child); - object_manager->emplace_back(new_child); + object_manager->emplace_backObjectScript(new_child); - GameObjectData* child_data = object_manager->getGameObjectData(new_child); + Engine::ScriptShared::GameObjectData* child_data = object_manager->getGameObjectDataObjectScript(new_child); child_data->mesh = mesh; child_data->rotation = game_object_data->rotation; child_data->scale = game_object_data->scale; @@ -136,9 +136,9 @@ class SCRIPT_NAME : public GameObjectScriptInterface { if(j == 0) child_data->position = path[0] + randomVec3(unique_seed); } - object_manager->addScript(new_child, "FishMovement"); + object_manager->addScriptObjectScript(new_child, "FishMovement"); - object_manager->saveRuntime(new_child); + object_manager->saveRuntimeObjectScript(new_child); }; @@ -181,7 +181,7 @@ class SCRIPT_NAME : public GameObjectScriptInterface { void OnDestroy(){ for(std::string child : child_object){ - object_manager->erase(child); + object_manager->eraseObjectScript(child); }; logger->info(SCRIPT_FILE_NAME, "Destroyed"); @@ -191,23 +191,4 @@ class SCRIPT_NAME : public GameObjectScriptInterface { -#ifndef PRODUCTION - -extern "C" UW::GameObjectScriptInterface* SCRIPT_API GetScript() { - UW::SCRIPT_NAME* script = new UW::SCRIPT_NAME(); - return (UW::GameObjectScriptInterface*)script; -}; - - - -extern "C" void SCRIPT_API DeleteScript(UW::GameObjectScriptInterface* script) { - UW::SCRIPT_NAME* temp_script = (UW::SCRIPT_NAME*)script; - delete temp_script; -}; - -#else - REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) - -#endif - diff --git a/Examples/UnderTheWater/Scripts/Template.cpp b/Examples/UnderTheWater/Scripts/Template.cpp index 67b1540..5fdf4f7 100644 --- a/Examples/UnderTheWater/Scripts/Template.cpp +++ b/Examples/UnderTheWater/Scripts/Template.cpp @@ -1,4 +1,4 @@ -// Help me I'am Under The Water +// Engine // Copyright 2026 Daynlight // Licensed under the GNU General, Version 3.0. // See LICENSE file for details. @@ -16,8 +16,8 @@ -namespace UW{ -class SCRIPT_NAME : public GameObjectScriptInterface { +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { private: public: @@ -44,23 +44,4 @@ class SCRIPT_NAME : public GameObjectScriptInterface { -#ifndef PRODUCTION - -extern "C" UW::GameObjectScriptInterface* SCRIPT_API GetScript() { - UW::SCRIPT_NAME* script = new UW::SCRIPT_NAME(); - return (UW::GameObjectScriptInterface*)script; -}; - - - -extern "C" void SCRIPT_API DeleteScript(UW::GameObjectScriptInterface* script) { - UW::SCRIPT_NAME* temp_script = (UW::SCRIPT_NAME*)script; - delete temp_script; -}; - -#else - REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) - -#endif - diff --git a/Examples/UnderTheWater/Scripts/Window.cpp b/Examples/UnderTheWater/Scripts/Window.cpp new file mode 100644 index 0000000..99704d9 --- /dev/null +++ b/Examples/UnderTheWater/Scripts/Window.cpp @@ -0,0 +1,66 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#define SCRIPT_NAME Script_Window +#define SCRIPT_FILE_NAME "Window" +#define BUILDING_SCRIPT_DLL + +#include "ScriptShared/ScriptShared/GameObjectScriptInterface.h" +#include +#include +#include + + + +namespace Engine{ +class SCRIPT_NAME : public Engine::ScriptShared::GameObjectScriptInterface { +private: + std::string base_name = "Under The Water"; + unsigned int samples = 0; + float acc_time = 0.0f; + +public: + ~SCRIPT_NAME() = default; + + void OnLoad(){ + glob_res->WINDOW_TITLE = base_name; + logger->info(SCRIPT_FILE_NAME, "Loaded"); + }; + + void OnUpdate(float delta_time){ + if(samples > 200){ + float fps = samples / acc_time; + glob_res->WINDOW_TITLE = base_name + " | " + std::to_string(floor(fps)) + " fps"; + acc_time = 0.0f; + samples = 0; + } + else{ + acc_time += delta_time; + samples++; + } + }; + + void OnFixedUpdate(float fixed_delta_time){ + Engine::ICamera& camera = camera_controller->getActiveCamera(); + glm::vec3 ps = camera.getPosition(); + ps += glm::vec3(0.0, 1.0, 0.0) * fixed_delta_time; + camera.setPosition(ps); + }; + + void OnRender(){ + }; + + void OnDestroy(){ + glob_res->WINDOW_TITLE = base_name; + logger->info(SCRIPT_FILE_NAME, "Destroyed"); + }; +}; +}; + + + +REGISTER_SCRIPT(SCRIPT_FILE_NAME, SCRIPT_NAME) diff --git a/README.md b/README.md index 4e5087e..2c95dc3 100644 --- a/README.md +++ b/README.md @@ -9,25 +9,9 @@ ## Demos - - - - - - - - - - -
- - - -
- - - -
+ + + @@ -52,15 +36,6 @@ Game Engine with editor and production. Build on top of my library [**CWindow**] - [GameObject](#gameobject) - [UI](#ui-1) - [Script Controller and ScriptShared](#script-controller-and-scriptshared) -- [Tasks Presentation](#tasks-presentation) - - [Normal mapping](#normal-mapping) - - [PBR](#pbr) - - [Quaternion camera](#quaternion-camera) - - [Shadow mapping](#shadow-mapping) - - [Parallel Transport Frames](#parallel-transport-frames) - - [Underwater skybox](#underwater-skybox) - - [**A09** Ray-marched SDF object](#a09-ray-marched-sdf-object) - - [**B07** Heightmap-based seabed mesh](#b07-heightmap-based-seabed-mesh) - [Writing scripts](#writing-scripts) - [Supported Platforms](#supported-platforms) - [Prerequisites](#prerequisites) @@ -117,7 +92,7 @@ All in **Editor** mode. **Production** have turn off ui. ## Compiling End Product -Use cmake command with ```PRODUCTION``` FLAG +Use ```Build BTN``` or cmake command with ```PRODUCTION``` FLAG ```bash mkdir -p build-prod @@ -125,7 +100,7 @@ cd build-prod cmake -B . -DPRODUCTION=ON -DCMAKE_BUILD_TYPE=Release .. cmake --build . cd .. -./build-prod/bin/UnderTheWater +./build-prod/bin/App ``` @@ -137,7 +112,7 @@ We use **cmake** for ease of build with **git submodules** for git packages. ### [DataSerializer](UnderTheWater/DataSerializer/) {SINGLETON} Focuses only on reading and saving. For loading data uses ```cmrc``` that **bakes** assets into executable. Data are stored in ```binary``` format for faster access and avoiding parsing. Everything that is baked via ```cmrc``` is save in [GameData](GameData/) folder. In editor we skips ```cmrc``` and use normal ```fstreams``` for faster editing. -* **Meshes**: Faster to read then **Assimp**. Saved as multiple files each for one mesh in [Assets/Meshes](GameData/Assets//Meshes/) folder each with ```.msh``` extension. On load we search for file in this directory with ```.msh``` extension. Loaded to [```Resources```](UnderTheWater/Resources/) saved in ```UW::Meshes``` that controls versioning and allows avoiding ```unordered_map``` for editor. +* **Meshes**: Faster to read then **Assimp**. Saved as multiple files each for one mesh in [Assets/Meshes](GameData/Assets//Meshes/) folder each with ```.msh``` extension. On load we search for file in this directory with ```.msh``` extension. Loaded to [```Resources```](UnderTheWater/Resources/) saved in ```Engine::Meshes``` that controls versioning and allows avoiding ```unordered_map``` for editor. * **Shaders**: Accessible via ```Resources```. Saved as multiple files in [Assets/Shaders](GameData/Assets/Shaders/) folders **each folder is one compiled shader** with ```.glsl``` extension. List of allowed script types is in [config.h](UnderTheWater/config.h). * **Scripts**: In DataSerializer saves and loads ```.cpp``` script to ```UI``` editor. Logic of ```hot-reloading``` and compiling to ```PRODUCTION``` is in [ScriptController](UnderTheWater/ScriptController/) and [ScriptShared](UnderTheWater/ScriptShared/). * **Lights**: World static lights loaded to ```Resources``` and compile as ```SSBO```. Single file [```Lights.lit```](GameData/Lights.lit). @@ -191,32 +166,6 @@ Production is designed to create one executable with no additional files require -## Tasks Presentation -### Normal mapping - - -### PBR - - -### Quaternion camera - - -### Shadow mapping - - -### Parallel Transport Frames - -### Underwater skybox - - -### **A09** Ray-marched SDF object - - -### **B07** Heightmap-based seabed mesh - - - - ## Writing scripts **![ Docs In Future ]!** @@ -363,14 +312,58 @@ Production is designed to create one executable with no additional files require - [x] Scripts on windows. +
+ Iteration 7 (26.07.2026) + +- [x] Shaders uniform parameters ui. +- [x] Skybox as GameObject. +- [x] Terrain as GameObject. +- [x] Terrain fix materials. +- [x] Rm Terrain_on btn. +- [x] Water as GameObject. +- [x] Game data backup. +- [x] Add Texture Serializer. +- [x] Separated register for script objects. +- [x] Multi project structure. +- [x] Separate Project for Add and Dev. +- [x] Src in App Dev. +- [x] Build/Run btn. +- [x] Installer. +
+
-🌟Iteration 7🌟 + 🌟 Iteration 8 🌟 + +- [x] Viewport ui. +- [x] Production BTN. +- [x] Camera full quaternions. +- [x] Minimized Script Shared. +- [ ] Move Rendering to Camera with FBO. +- [ ] Camera Culling check. +- [ ] Camera Tests. +- [ ] CameraController Refactor. +- [ ] CameraController Tests. +- [ ] One Unified Scene Class. +- [ ] Scene Save. +- [ ] SceneController. +- [ ] Access to SceneController and Scene via Scripts. +- [ ] Scene Tests. +- [ ] SceneController Tests. +- [ ] Docs Camera and CameraController. +- [ ] Docs Scene and SceneController. +
-- [ ] Game data backup. -- [ ] Move terrain, water, skybox to object_register vector. -- [ ] Shaders uniform parameters ui. -- [ ] Add Texture Serializer. -- [ ] Last Time Write sync. +
+ Iteration 9 + +- [ ] Entity, Component, System. +- [ ] ScriptController. +- [ ] ScriptController Dependency graf. +- [ ] ScriptController Tests. +- [ ] Offset fixed update. +- [ ] Threads for fixed update. + +- [ ] Fix Issues: - [ ] Fix pre_size size error. ```bash corrupted size vs. prev_size while consolidating @@ -388,24 +381,19 @@ terminate called after throwing an instance of 'std::length_error' what(): basic_string::_M_create Aborted (core dumped) ``` -- [ ] Window Data Serialization move in different file then ```imgui.ini```. -- [ ] Simpler glm in script shared. -- [ ] Clean up. -- [ ] Viewport ui. -- [ ] Rule of 5. -- [ ] Debug Camera and Game Camera. Game Camera as game object specified in GlobConf. -- [ ] Production optimization. -- [ ] Optimization for Compile version (avoid maps). -- [ ] Docs.
Planed in Future -- [ ] Multiple Scenes. +- [ ] Last Time Write sync. +- [ ] Window Size in GlobResources. +- [ ] Script Data Serializer. +- [ ] Camera as GameObject. +- [ ] Editor Camera. +- [ ] GameObject components system. - [ ] Viewport mode for editing and gameplay. - [ ] Optimization for Production. -- [ ] Production BTN. - [ ] Full access to render engine from scripts. - [ ] Components base GameObjects. - [ ] UI Module for games. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt new file mode 100644 index 0000000..3c5961a --- /dev/null +++ b/Tests/CMakeLists.txt @@ -0,0 +1,27 @@ +# Engine +# Copyright 2026 Daynlight +# Licensed under the GNU General, Version 3.0. +# See LICENSE file for details. + + + +cmake_minimum_required(VERSION 3.15) + +set(tests_src + Core/Camera/CameraTests.cpp +) + +add_executable(unit_tests ${tests_src}) + +target_link_libraries(unit_tests PRIVATE + Core + gtest_main + gmock_main +) + +target_include_directories(unit_tests PRIVATE + ${CMAKE_SOURCE_DIR}/Engine/Core +) + +include(GoogleTest) +gtest_discover_tests(unit_tests) \ No newline at end of file diff --git a/Tests/Core/Camera/CameraTests.cpp b/Tests/Core/Camera/CameraTests.cpp new file mode 100644 index 0000000..9e14cc7 --- /dev/null +++ b/Tests/Core/Camera/CameraTests.cpp @@ -0,0 +1,1067 @@ +// Engine +// Copyright 2026 Daynlight +// Licensed under the GNU General, Version 3.0. +// See LICENSE file for details. + + + +#include +#include + +#define GLM_ENABLE_EXPERIMENTAL +#include "../vendor/glm/glm/gtx/euler_angles.hpp" +#include "../vendor/glm/glm/gtx/quaternion.hpp" + +#define private public +#define protected public + +#include "Core/Camera/Camera.h" + +#undef private +#undef protected + + + +//// ======================= ///// +//// ======== Mocks ======== ///// +//// ======================= ///// +namespace Mock{ + +class Renderer : public CW::Renderer::Renderer { +public: + Renderer() {} + + // MOCK_METHOD(const CW::Renderer::WindowData*, getWindowData, (), (override)); + // MOCK_METHOD(const CW::Renderer::InputData*, getInputData, (), (override)); + // MOCK_METHOD(void, setKeyboardBind, (const std::string& action, char key), (override)); + + // MOCK_METHOD(void, createWindow, (), (override)); + // MOCK_METHOD(void, windowLessRenderer, (), (override)); + // MOCK_METHOD(APIWindow*, getWindow, (), (override)); + // void createRenderer() override {}; + + // MOCK_METHOD(void, beginFrame, (), (override)); + // MOCK_METHOD(void, swapBuffer, (), (override)); + // MOCK_METHOD(void, windowEvents, (), (override)); + + // MOCK_METHOD(void, setWindowMode, (CW::Renderer::WindowMode mode), (override)); + // MOCK_METHOD(void, setWindowTitle, (const std::string& title), (override)); + // MOCK_METHOD(void, setIcon, (const std::string& path), (override)); + // MOCK_METHOD(void, setVsync, (bool vsync), (override)); + // MOCK_METHOD(void, minimize, (bool minimize), (override)); + // MOCK_METHOD(void, maximize, (bool maximize), (override)); + // MOCK_METHOD(void, setPosition, (int x, int y), (override)); + // MOCK_METHOD(void, setSize, (int width, int height), (override)); + // MOCK_METHOD(void, setCursorVisibility, (bool visible), (override)); + // MOCK_METHOD(void, setCursorOn, (bool on), (override)); + // MOCK_METHOD(void, close, (), (override)); +}; +}; + + + +//// ==================== //// +//// === Constructors === //// +//// ==================== //// +TEST(CameraDefaultConstructors, HandlesInitialization) { + Engine::Core::Camera camera; + + EXPECT_EQ(camera.renderer, nullptr); + EXPECT_GE(camera.fov, 0); + EXPECT_GE(camera.ortho_size, 0); + EXPECT_GE(camera.sensitivity, 0); + EXPECT_GE(camera.velocity, 0); +}; + +TEST(CameraDefaultConstructorsWithNullptr, HandlesInitialization) { + Mock::Renderer* renderer = nullptr; + + Engine::Core::Camera camera(renderer); + + EXPECT_EQ(camera.renderer, nullptr); + EXPECT_GE(camera.fov, 0); + EXPECT_GE(camera.ortho_size, 0); + EXPECT_GE(camera.sensitivity, 0); + EXPECT_GE(camera.velocity, 0); +}; + +TEST(CameraDefaultParamConstructors, HandlesInitialization) { + Mock::Renderer renderer; + glm::vec3 init_pos = {0.1f, -2.0f, 5.0f}; + glm::vec3 init_dir = glm::normalize(glm::vec3(0.2f, 0.5f, -0.3f)); + + Engine::Core::Camera camera(&renderer, init_pos, init_dir); + + EXPECT_NE(camera.renderer, nullptr); + + glm::vec3 actual_pos = camera.getPosition(); + EXPECT_NEAR(actual_pos.x, init_pos.x, 0.0001f); + EXPECT_NEAR(actual_pos.y, init_pos.y, 0.0001f); + EXPECT_NEAR(actual_pos.z, init_pos.z, 0.0001f); + + glm::vec3 actual_dir = camera.getDirection(); + EXPECT_NEAR(actual_dir.x, init_dir.x, 0.0001f); + EXPECT_NEAR(actual_dir.y, init_dir.y, 0.0001f); + EXPECT_NEAR(actual_dir.z, init_dir.z, 0.0001f); + + EXPECT_GE(camera.fov, 0); + EXPECT_GE(camera.ortho_size, 0); + EXPECT_GE(camera.sensitivity, 0); + EXPECT_GE(camera.velocity, 0); +}; + +TEST(CameraCopyConstructor, HandlesInitialization){ + Mock::Renderer renderer; + glm::vec3 init_pos = {0.1f, -2.0f, 5.0f}; + glm::vec3 init_dir = glm::normalize(glm::vec3(0.2f, 0.5f, -0.3f)); + + Engine::Core::Camera init_camera(&renderer, init_pos, init_dir); + + Engine::Core::Camera construct_copy_camera(init_camera); + + EXPECT_NE(construct_copy_camera.renderer, nullptr); + EXPECT_EQ(init_camera.position, construct_copy_camera.position); + EXPECT_EQ(init_camera.direction, construct_copy_camera.direction); + EXPECT_EQ(init_camera.orientation, construct_copy_camera.orientation); + EXPECT_EQ(init_camera.fov, construct_copy_camera.fov); + EXPECT_EQ(init_camera.ortho_size, construct_copy_camera.ortho_size); + EXPECT_EQ(init_camera.transform_mat_ready, construct_copy_camera.transform_mat_ready); + EXPECT_EQ(init_camera.transform_mat, construct_copy_camera.transform_mat); + EXPECT_EQ(init_camera.view_mat_ready, construct_copy_camera.view_mat_ready); + EXPECT_EQ(init_camera.view_mat, construct_copy_camera.view_mat); + EXPECT_EQ(init_camera.last_aspect_ratio_orthogonal, construct_copy_camera.last_aspect_ratio_orthogonal); + EXPECT_EQ(init_camera.last_aspect_ratio_perspective, construct_copy_camera.last_aspect_ratio_perspective); + EXPECT_EQ(init_camera.perspective_near_plane, construct_copy_camera.perspective_near_plane); + EXPECT_EQ(init_camera.orthogonal_near_plane, construct_copy_camera.orthogonal_near_plane); + EXPECT_EQ(init_camera.perspective_far_plane, construct_copy_camera.perspective_far_plane); + EXPECT_EQ(init_camera.orthogonal_far_plane, construct_copy_camera.orthogonal_far_plane); + EXPECT_EQ(init_camera.perspective_mat_ready, construct_copy_camera.perspective_mat_ready); + EXPECT_EQ(init_camera.orthogonal_mat_ready, construct_copy_camera.orthogonal_mat_ready); + EXPECT_EQ(init_camera.perspective_mat, construct_copy_camera.perspective_mat); + EXPECT_EQ(init_camera.orthogonal_mat, construct_copy_camera.orthogonal_mat); + EXPECT_EQ(init_camera.default_movemement_on, construct_copy_camera.default_movemement_on); + EXPECT_EQ(init_camera.sensitivity, construct_copy_camera.sensitivity); + EXPECT_EQ(init_camera.velocity, construct_copy_camera.velocity); + EXPECT_EQ(init_camera.mouse_is_active, construct_copy_camera.mouse_is_active); + EXPECT_EQ(init_camera.cursor_lock, construct_copy_camera.cursor_lock); + + Engine::Core::Camera construct_copy_assign_camera = init_camera; + + EXPECT_NE(construct_copy_assign_camera.renderer, nullptr); + EXPECT_EQ(init_camera.position, construct_copy_assign_camera.position); + EXPECT_EQ(init_camera.direction, construct_copy_assign_camera.direction); + EXPECT_EQ(init_camera.orientation, construct_copy_assign_camera.orientation); + EXPECT_EQ(init_camera.fov, construct_copy_assign_camera.fov); + EXPECT_EQ(init_camera.ortho_size, construct_copy_assign_camera.ortho_size); + EXPECT_EQ(init_camera.transform_mat_ready, construct_copy_assign_camera.transform_mat_ready); + EXPECT_EQ(init_camera.transform_mat, construct_copy_assign_camera.transform_mat); + EXPECT_EQ(init_camera.view_mat_ready, construct_copy_assign_camera.view_mat_ready); + EXPECT_EQ(init_camera.view_mat, construct_copy_assign_camera.view_mat); + EXPECT_EQ(init_camera.last_aspect_ratio_orthogonal, construct_copy_assign_camera.last_aspect_ratio_orthogonal); + EXPECT_EQ(init_camera.last_aspect_ratio_perspective, construct_copy_assign_camera.last_aspect_ratio_perspective); + EXPECT_EQ(init_camera.perspective_near_plane, construct_copy_assign_camera.perspective_near_plane); + EXPECT_EQ(init_camera.orthogonal_near_plane, construct_copy_assign_camera.orthogonal_near_plane); + EXPECT_EQ(init_camera.perspective_far_plane, construct_copy_assign_camera.perspective_far_plane); + EXPECT_EQ(init_camera.orthogonal_far_plane, construct_copy_assign_camera.orthogonal_far_plane); + EXPECT_EQ(init_camera.perspective_mat_ready, construct_copy_assign_camera.perspective_mat_ready); + EXPECT_EQ(init_camera.orthogonal_mat_ready, construct_copy_assign_camera.orthogonal_mat_ready); + EXPECT_EQ(init_camera.perspective_mat, construct_copy_assign_camera.perspective_mat); + EXPECT_EQ(init_camera.orthogonal_mat, construct_copy_assign_camera.orthogonal_mat); + EXPECT_EQ(init_camera.default_movemement_on, construct_copy_assign_camera.default_movemement_on); + EXPECT_EQ(init_camera.sensitivity, construct_copy_assign_camera.sensitivity); + EXPECT_EQ(init_camera.velocity, construct_copy_assign_camera.velocity); + EXPECT_EQ(init_camera.mouse_is_active, construct_copy_assign_camera.mouse_is_active); + EXPECT_EQ(init_camera.cursor_lock, construct_copy_assign_camera.cursor_lock); + + Engine::Core::Camera construct_copy_self_camera(init_camera); + Engine::Core::Camera* org_camera_ptr = &construct_copy_self_camera; + construct_copy_self_camera = construct_copy_self_camera; + Engine::Core::Camera* new_camera_ptr = &construct_copy_self_camera; + + EXPECT_EQ(org_camera_ptr, new_camera_ptr); + EXPECT_NE(construct_copy_self_camera.renderer, nullptr); + EXPECT_EQ(init_camera.position, construct_copy_self_camera.position); + EXPECT_EQ(init_camera.direction, construct_copy_self_camera.direction); + EXPECT_EQ(init_camera.orientation, construct_copy_self_camera.orientation); + EXPECT_EQ(init_camera.fov, construct_copy_self_camera.fov); + EXPECT_EQ(init_camera.ortho_size, construct_copy_self_camera.ortho_size); + EXPECT_EQ(init_camera.transform_mat_ready, construct_copy_self_camera.transform_mat_ready); + EXPECT_EQ(init_camera.transform_mat, construct_copy_self_camera.transform_mat); + EXPECT_EQ(init_camera.view_mat_ready, construct_copy_self_camera.view_mat_ready); + EXPECT_EQ(init_camera.view_mat, construct_copy_self_camera.view_mat); + EXPECT_EQ(init_camera.last_aspect_ratio_orthogonal, construct_copy_self_camera.last_aspect_ratio_orthogonal); + EXPECT_EQ(init_camera.last_aspect_ratio_perspective, construct_copy_self_camera.last_aspect_ratio_perspective); + EXPECT_EQ(init_camera.perspective_near_plane, construct_copy_self_camera.perspective_near_plane); + EXPECT_EQ(init_camera.orthogonal_near_plane, construct_copy_self_camera.orthogonal_near_plane); + EXPECT_EQ(init_camera.perspective_far_plane, construct_copy_self_camera.perspective_far_plane); + EXPECT_EQ(init_camera.orthogonal_far_plane, construct_copy_self_camera.orthogonal_far_plane); + EXPECT_EQ(init_camera.perspective_mat_ready, construct_copy_self_camera.perspective_mat_ready); + EXPECT_EQ(init_camera.orthogonal_mat_ready, construct_copy_self_camera.orthogonal_mat_ready); + EXPECT_EQ(init_camera.perspective_mat, construct_copy_self_camera.perspective_mat); + EXPECT_EQ(init_camera.orthogonal_mat, construct_copy_self_camera.orthogonal_mat); + EXPECT_EQ(init_camera.default_movemement_on, construct_copy_self_camera.default_movemement_on); + EXPECT_EQ(init_camera.sensitivity, construct_copy_self_camera.sensitivity); + EXPECT_EQ(init_camera.velocity, construct_copy_self_camera.velocity); + EXPECT_EQ(init_camera.mouse_is_active, construct_copy_self_camera.mouse_is_active); + EXPECT_EQ(init_camera.cursor_lock, construct_copy_self_camera.cursor_lock); +}; + +TEST(CameraMoveConstructor, HandlesInitialization){ + Mock::Renderer renderer; + glm::vec3 init_pos = {0.1f, -2.0f, 5.0f}; + glm::vec3 init_dir = glm::normalize(glm::vec3(0.2f, 0.5f, -0.3f)); + + Engine::Core::Camera init_org_camera(&renderer, init_pos, init_dir); + + Engine::Core::Camera init_constructor_move_camera(init_org_camera); + Engine::Core::Camera construct_move_camera(std::move(init_constructor_move_camera)); + + EXPECT_NE(init_constructor_move_camera.renderer, nullptr); + EXPECT_NE(init_org_camera.renderer, nullptr); + EXPECT_EQ(init_org_camera.position, construct_move_camera.position); + EXPECT_EQ(init_org_camera.direction, construct_move_camera.direction); + EXPECT_EQ(init_org_camera.orientation, construct_move_camera.orientation); + EXPECT_EQ(init_org_camera.fov, construct_move_camera.fov); + EXPECT_EQ(init_org_camera.ortho_size, construct_move_camera.ortho_size); + EXPECT_EQ(init_org_camera.transform_mat_ready, construct_move_camera.transform_mat_ready); + EXPECT_EQ(init_org_camera.transform_mat, construct_move_camera.transform_mat); + EXPECT_EQ(init_org_camera.view_mat_ready, construct_move_camera.view_mat_ready); + EXPECT_EQ(init_org_camera.view_mat, construct_move_camera.view_mat); + EXPECT_EQ(init_org_camera.last_aspect_ratio_orthogonal, construct_move_camera.last_aspect_ratio_orthogonal); + EXPECT_EQ(init_org_camera.last_aspect_ratio_perspective, construct_move_camera.last_aspect_ratio_perspective); + EXPECT_EQ(init_org_camera.perspective_near_plane, construct_move_camera.perspective_near_plane); + EXPECT_EQ(init_org_camera.orthogonal_near_plane, construct_move_camera.orthogonal_near_plane); + EXPECT_EQ(init_org_camera.perspective_far_plane, construct_move_camera.perspective_far_plane); + EXPECT_EQ(init_org_camera.orthogonal_far_plane, construct_move_camera.orthogonal_far_plane); + EXPECT_EQ(init_org_camera.perspective_mat_ready, construct_move_camera.perspective_mat_ready); + EXPECT_EQ(init_org_camera.orthogonal_mat_ready, construct_move_camera.orthogonal_mat_ready); + EXPECT_EQ(init_org_camera.perspective_mat, construct_move_camera.perspective_mat); + EXPECT_EQ(init_org_camera.orthogonal_mat, construct_move_camera.orthogonal_mat); + EXPECT_EQ(init_org_camera.default_movemement_on, construct_move_camera.default_movemement_on); + EXPECT_EQ(init_org_camera.sensitivity, construct_move_camera.sensitivity); + EXPECT_EQ(init_org_camera.velocity, construct_move_camera.velocity); + EXPECT_EQ(init_org_camera.mouse_is_active, construct_move_camera.mouse_is_active); + EXPECT_EQ(init_org_camera.cursor_lock, construct_move_camera.cursor_lock); + + Engine::Core::Camera init_construct_move_assign_camera(init_org_camera); + Engine::Core::Camera construct_move_assign_camera = std::move(init_construct_move_assign_camera); + + EXPECT_NE(init_construct_move_assign_camera.renderer, nullptr); + EXPECT_NE(construct_move_assign_camera.renderer, nullptr); + EXPECT_EQ(init_org_camera.position, construct_move_assign_camera.position); + EXPECT_EQ(init_org_camera.direction, construct_move_assign_camera.direction); + EXPECT_EQ(init_org_camera.orientation, construct_move_assign_camera.orientation); + EXPECT_EQ(init_org_camera.fov, construct_move_assign_camera.fov); + EXPECT_EQ(init_org_camera.ortho_size, construct_move_assign_camera.ortho_size); + EXPECT_EQ(init_org_camera.transform_mat_ready, construct_move_assign_camera.transform_mat_ready); + EXPECT_EQ(init_org_camera.transform_mat, construct_move_assign_camera.transform_mat); + EXPECT_EQ(init_org_camera.view_mat_ready, construct_move_assign_camera.view_mat_ready); + EXPECT_EQ(init_org_camera.view_mat, construct_move_assign_camera.view_mat); + EXPECT_EQ(init_org_camera.last_aspect_ratio_orthogonal, construct_move_assign_camera.last_aspect_ratio_orthogonal); + EXPECT_EQ(init_org_camera.last_aspect_ratio_perspective, construct_move_assign_camera.last_aspect_ratio_perspective); + EXPECT_EQ(init_org_camera.perspective_near_plane, construct_move_assign_camera.perspective_near_plane); + EXPECT_EQ(init_org_camera.orthogonal_near_plane, construct_move_assign_camera.orthogonal_near_plane); + EXPECT_EQ(init_org_camera.perspective_far_plane, construct_move_assign_camera.perspective_far_plane); + EXPECT_EQ(init_org_camera.orthogonal_far_plane, construct_move_assign_camera.orthogonal_far_plane); + EXPECT_EQ(init_org_camera.perspective_mat_ready, construct_move_assign_camera.perspective_mat_ready); + EXPECT_EQ(init_org_camera.orthogonal_mat_ready, construct_move_assign_camera.orthogonal_mat_ready); + EXPECT_EQ(init_org_camera.perspective_mat, construct_move_assign_camera.perspective_mat); + EXPECT_EQ(init_org_camera.orthogonal_mat, construct_move_assign_camera.orthogonal_mat); + EXPECT_EQ(init_org_camera.default_movemement_on, construct_move_assign_camera.default_movemement_on); + EXPECT_EQ(init_org_camera.sensitivity, construct_move_assign_camera.sensitivity); + EXPECT_EQ(init_org_camera.velocity, construct_move_assign_camera.velocity); + EXPECT_EQ(init_org_camera.mouse_is_active, construct_move_assign_camera.mouse_is_active); + EXPECT_EQ(init_org_camera.cursor_lock, construct_move_assign_camera.cursor_lock); + + Engine::Core::Camera init_construct_move_self_camera(init_org_camera); + Engine::Core::Camera construct_move_self_camera(std::move(init_construct_move_self_camera)); + Engine::Core::Camera* org_camera_ptr = &construct_move_self_camera; + construct_move_self_camera = std::move(init_construct_move_self_camera); + Engine::Core::Camera* new_camera_ptr = &construct_move_self_camera; + + EXPECT_EQ(org_camera_ptr, new_camera_ptr); + EXPECT_NE(init_construct_move_self_camera.renderer, nullptr); + EXPECT_NE(construct_move_self_camera.renderer, nullptr); + EXPECT_EQ(init_org_camera.position, construct_move_self_camera.position); + EXPECT_EQ(init_org_camera.direction, construct_move_self_camera.direction); + EXPECT_EQ(init_org_camera.orientation, construct_move_self_camera.orientation); + EXPECT_EQ(init_org_camera.fov, construct_move_self_camera.fov); + EXPECT_EQ(init_org_camera.ortho_size, construct_move_self_camera.ortho_size); + EXPECT_EQ(init_org_camera.transform_mat_ready, construct_move_self_camera.transform_mat_ready); + EXPECT_EQ(init_org_camera.transform_mat, construct_move_self_camera.transform_mat); + EXPECT_EQ(init_org_camera.view_mat_ready, construct_move_self_camera.view_mat_ready); + EXPECT_EQ(init_org_camera.view_mat, construct_move_self_camera.view_mat); + EXPECT_EQ(init_org_camera.last_aspect_ratio_orthogonal, construct_move_self_camera.last_aspect_ratio_orthogonal); + EXPECT_EQ(init_org_camera.last_aspect_ratio_perspective, construct_move_self_camera.last_aspect_ratio_perspective); + EXPECT_EQ(init_org_camera.perspective_near_plane, construct_move_self_camera.perspective_near_plane); + EXPECT_EQ(init_org_camera.orthogonal_near_plane, construct_move_self_camera.orthogonal_near_plane); + EXPECT_EQ(init_org_camera.perspective_far_plane, construct_move_self_camera.perspective_far_plane); + EXPECT_EQ(init_org_camera.orthogonal_far_plane, construct_move_self_camera.orthogonal_far_plane); + EXPECT_EQ(init_org_camera.perspective_mat_ready, construct_move_self_camera.perspective_mat_ready); + EXPECT_EQ(init_org_camera.orthogonal_mat_ready, construct_move_self_camera.orthogonal_mat_ready); + EXPECT_EQ(init_org_camera.perspective_mat, construct_move_self_camera.perspective_mat); + EXPECT_EQ(init_org_camera.orthogonal_mat, construct_move_self_camera.orthogonal_mat); + EXPECT_EQ(init_org_camera.default_movemement_on, construct_move_self_camera.default_movemement_on); + EXPECT_EQ(init_org_camera.sensitivity, construct_move_self_camera.sensitivity); + EXPECT_EQ(init_org_camera.velocity, construct_move_self_camera.velocity); + EXPECT_EQ(init_org_camera.mouse_is_active, construct_move_self_camera.mouse_is_active); + EXPECT_EQ(init_org_camera.cursor_lock, construct_move_self_camera.cursor_lock); +}; + + + +//// ==================== //// +//// ==== Projection ==== //// +//// ==================== //// +TEST(CameraPerspectiveProjection, HandlesInitialization){ + Mock::Renderer renderer; + glm::vec3 init_pos = {0.0f, 0.0f, 0.0f}; + glm::vec3 init_dir = {0.0f, 0.0f, 1.0f}; + float init_fov = 60.0f; + float init_near_plane = Engine::Config::CAMERA_NEAR_PLANE; + float init_far_plane = Engine::Config::CAMERA_FAR_PLANE; + + + Engine::Core::Camera camera(&renderer, init_pos, init_dir); + camera.setFov(init_fov); + camera.setNearPlane(init_near_plane); + camera.setFarPlane(init_far_plane); + + float aspectRatio = renderer.getWindowData()->width / (float)renderer.getWindowData()->height; + glm::mat4 expected_mat = glm::perspective(glm::radians(init_fov), aspectRatio, init_near_plane, init_far_plane); + + glm::vec4 testing_point1 = glm::vec4(-3.0f, 2.0f, -10.0f, 1.0f); + glm::vec4 transformed_point1 = camera.perspective_projection() * testing_point1; + glm::vec4 expected1 = expected_mat * testing_point1; + + EXPECT_NEAR(transformed_point1.w, 10.0f, 0.001f); + EXPECT_NEAR(transformed_point1.x, expected1.x, 0.001f); + EXPECT_NEAR(transformed_point1.y, expected1.y, 0.001f); + EXPECT_NEAR(transformed_point1.z, expected1.z, 0.001f); + + glm::vec3 ndc1 = glm::vec3(transformed_point1) / transformed_point1.w; + + EXPECT_GE(ndc1.x, -1.0f); + EXPECT_LE(ndc1.x, 1.0f); + EXPECT_GE(ndc1.y, -1.0f); + EXPECT_LE(ndc1.y, 1.0f); + EXPECT_GE(ndc1.z, -1.0f); + EXPECT_LE(ndc1.z, 1.0f); + + glm::vec4 testing_point2 = {2.0f, 12.0f, -25.0f, 1.0f}; + glm::vec4 transformed_point2 = camera.perspective_projection() * testing_point2; + glm::vec4 expected2 = expected_mat * testing_point2; + + EXPECT_NEAR(transformed_point2.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point2.x, expected2.x, 0.001f); + EXPECT_NEAR(transformed_point2.y, expected2.y, 0.001f); + EXPECT_NEAR(transformed_point2.z, expected2.z, 0.001f); + + glm::vec3 ndc2 = glm::vec3(transformed_point2) / transformed_point2.w; + + EXPECT_GE(ndc2.x, -1.0f); + EXPECT_LE(ndc2.x, 1.0f); + EXPECT_GE(ndc2.y, -1.0f); + EXPECT_LE(ndc2.y, 1.0f); + EXPECT_GE(ndc2.z, -1.0f); + EXPECT_LE(ndc2.z, 1.0f); + + float new_fov = 65.0f; + camera.setFov(new_fov); + glm::vec4 testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + glm::vec4 transformed_point = camera.perspective_projection() * testing_point; + expected_mat = glm::perspective(glm::radians(new_fov), aspectRatio, init_near_plane, init_far_plane); + glm::vec4 expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + glm::vec3 ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + float new_near = 0.5f; + camera.setNearPerspectivePlane(new_near); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.perspective_projection() * testing_point; + expected_mat = glm::perspective(glm::radians(new_fov), aspectRatio, new_near, init_far_plane); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + new_near = 0.001f; + camera.setNearPlane(new_near); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.perspective_projection() * testing_point; + expected_mat = glm::perspective(glm::radians(new_fov), aspectRatio, new_near, init_far_plane); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + float new_far = 200.0f; + camera.setFarPerspectivePlane(new_far); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.perspective_projection() * testing_point; + expected_mat = glm::perspective(glm::radians(new_fov), aspectRatio, new_near, new_far); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + new_far = 2000.0f; + camera.setFarPlane(new_far); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.perspective_projection() * testing_point; + expected_mat = glm::perspective(glm::radians(new_fov), aspectRatio, new_near, new_far); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + renderer.setSize(200, 300); + aspectRatio = renderer.getWindowData()->width / (float)renderer.getWindowData()->height; + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.perspective_projection() * testing_point; + expected_mat = glm::perspective(glm::radians(new_fov), aspectRatio, new_near, new_far); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); +}; + +TEST(CameraOrthogonalProjection, HandlesInitialization){ + Mock::Renderer renderer; + glm::vec3 init_pos = {0.0f, 0.0f, 0.0f}; + glm::vec3 init_dir = {0.0f, 0.0f, 1.0f}; + float init_ortho_size = 60.0f; + float init_near_plane = Engine::Config::CAMERA_ORTHO_NEAR_PLANE; + float init_far_plane = Engine::Config::CAMERA_ORTHO_FAR_PLANE; + + + Engine::Core::Camera camera(&renderer, init_pos, init_dir); + camera.setCameraMode(Engine::ScriptShared::CameraMode::ORTHOGONAL); + camera.setOrthoSize(init_ortho_size); + camera.setNearPlane(init_near_plane); + camera.setFarPlane(init_far_plane); + + float aspectRatio = renderer.getWindowData()->width / (float)renderer.getWindowData()->height; + float half_width = (init_ortho_size * aspectRatio) * 0.5f; + float half_height = init_ortho_size * 0.5f; + glm::mat4 expected_mat = glm::ortho(-half_width, half_width, -half_height, half_height, init_near_plane, init_far_plane); + + glm::vec4 testing_point1 = glm::vec4(-3.0f, 2.0f, -10.0f, 1.0f); + glm::vec4 transformed_point1 = camera.orthogonal_projection() * testing_point1; + glm::vec4 expected1 = expected_mat * testing_point1; + + EXPECT_NEAR(transformed_point1.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point1.x, expected1.x, 0.001f); + EXPECT_NEAR(transformed_point1.y, expected1.y, 0.001f); + EXPECT_NEAR(transformed_point1.z, expected1.z, 0.001f); + + glm::vec3 ndc1 = glm::vec3(transformed_point1) / transformed_point1.w; + + EXPECT_GE(ndc1.x, -1.0f); + EXPECT_LE(ndc1.x, 1.0f); + EXPECT_GE(ndc1.y, -1.0f); + EXPECT_LE(ndc1.y, 1.0f); + EXPECT_GE(ndc1.z, -1.0f); + EXPECT_LE(ndc1.z, 1.0f); + + glm::vec4 testing_point2 = {2.0f, 12.0f, -25.0f, 1.0f}; + glm::vec4 transformed_point2 = camera.orthogonal_projection() * testing_point2; + glm::vec4 expected2 = expected_mat * testing_point2; + + EXPECT_NEAR(transformed_point2.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point2.x, expected2.x, 0.001f); + EXPECT_NEAR(transformed_point2.y, expected2.y, 0.001f); + EXPECT_NEAR(transformed_point2.z, expected2.z, 0.001f); + + glm::vec3 ndc2 = glm::vec3(transformed_point2) / transformed_point2.w; + + EXPECT_GE(ndc2.x, -1.0f); + EXPECT_LE(ndc2.x, 1.0f); + EXPECT_GE(ndc2.y, -1.0f); + EXPECT_LE(ndc2.y, 1.0f); + EXPECT_GE(ndc2.z, -1.0f); + EXPECT_LE(ndc2.z, 1.0f); + + float new_ortho_size = 65.0f; + camera.setOrthoSize(new_ortho_size); + aspectRatio = renderer.getWindowData()->width / (float)renderer.getWindowData()->height; + half_width = (new_ortho_size * aspectRatio) * 0.5f; + half_height = new_ortho_size * 0.5f; + glm::vec4 testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + glm::vec4 transformed_point = camera.orthogonal_projection() * testing_point; + expected_mat = glm::ortho(-half_width, half_width, -half_height, half_height, init_near_plane, init_far_plane); + glm::vec4 expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + glm::vec3 ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + float new_near = 0.5f; + camera.setNearOrthogonalPlane(new_near); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.orthogonal_projection() * testing_point; + expected_mat = glm::ortho(-half_width, half_width, -half_height, half_height, new_near, init_far_plane); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + new_near = 0.001f; + camera.setNearPlane(new_near); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.orthogonal_projection() * testing_point; + expected_mat = glm::ortho(-half_width, half_width, -half_height, half_height, new_near, init_far_plane); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + float new_far = 200.0f; + camera.setFarOrthogonalPlane(new_far); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.orthogonal_projection() * testing_point; + expected_mat = glm::ortho(-half_width, half_width, -half_height, half_height, new_near, new_far); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + new_far = 2000.0f; + camera.setFarPlane(new_far); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.orthogonal_projection() * testing_point; + expected_mat = glm::ortho(-half_width, half_width, -half_height, half_height, new_near, new_far); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + renderer.setSize(200, 300); + aspectRatio = renderer.getWindowData()->width / (float)renderer.getWindowData()->height; + half_width = (new_ortho_size * aspectRatio) * 0.5f; + half_height = new_ortho_size * 0.5f; + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.orthogonal_projection() * testing_point; + expected_mat = glm::ortho(-half_width, half_width, -half_height, half_height, new_near, new_far); + expected = expected_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); +}; + +TEST(CameraProjection, HandlesInitialization){ + Mock::Renderer renderer; + glm::vec3 init_pos = glm::vec3(0.0f, 0.0f, 0.0f); + glm::vec3 init_dir = glm::vec3(0.0f, 0.0f, 1.0f); + + float init_ortho_size = 60.0f; + float init_ortho_near_plane = Engine::Config::CAMERA_ORTHO_NEAR_PLANE; + float init_ortho_far_plane = Engine::Config::CAMERA_ORTHO_FAR_PLANE; + float init_fov = 60.0f; + float init_perspective_near_plane = Engine::Config::CAMERA_NEAR_PLANE; + float init_perspective_far_plane = Engine::Config::CAMERA_FAR_PLANE; + + Engine::Core::Camera camera(&renderer, init_pos, init_dir); + camera.setOrthoSize(init_ortho_size); + camera.setNearOrthogonalPlane(init_ortho_near_plane); + camera.setFarOrthogonalPlane(init_ortho_far_plane); + camera.setFov(init_fov); + camera.setNearPerspectivePlane(init_perspective_near_plane); + camera.setFarPerspectivePlane(init_perspective_far_plane); + + float aspectRatio = renderer.getWindowData()->width / (float)renderer.getWindowData()->height; + float half_width = (init_ortho_size * aspectRatio) * 0.5f; + float half_height = init_ortho_size * 0.5f; + glm::mat4 expected_orthogonal_mat = glm::ortho(-half_width, half_width, -half_height, half_height, init_ortho_near_plane, init_ortho_far_plane); + glm::mat4 expected_perspective_mat = glm::perspective(glm::radians(init_fov), aspectRatio, init_perspective_near_plane, init_perspective_far_plane); + + camera.setCameraMode(Engine::ScriptShared::CameraMode::ORTHOGONAL); + glm::vec4 testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + glm::vec4 transformed_point = camera.projection() * testing_point; + glm::vec4 expected = expected_orthogonal_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 1.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + glm::vec3 ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); + + camera.setCameraMode(Engine::ScriptShared::CameraMode::PERSPECTIVE); + testing_point = {2.0f, 12.0f, -25.0f, 1.0f}; + transformed_point = camera.projection() * testing_point; + expected = expected_perspective_mat * testing_point; + + EXPECT_NEAR(transformed_point.w, 25.0f, 0.001f); + EXPECT_NEAR(transformed_point.x, expected.x, 0.001f); + EXPECT_NEAR(transformed_point.y, expected.y, 0.001f); + EXPECT_NEAR(transformed_point.z, expected.z, 0.001f); + + ndc = glm::vec3(transformed_point) / transformed_point.w; + + EXPECT_GE(ndc.x, -1.0f); + EXPECT_LE(ndc.x, 1.0f); + EXPECT_GE(ndc.y, -1.0f); + EXPECT_LE(ndc.y, 1.0f); + EXPECT_GE(ndc.z, -1.0f); + EXPECT_LE(ndc.z, 1.0f); +}; + +TEST(CameraView, HandlesInitialization){ + Mock::Renderer renderer; + glm::vec3 init_pos = {0.0f, 0.0f, 0.0f}; + glm::vec3 init_dir = {0.0f, 0.0f, 1.0f}; + + Engine::Core::Camera camera(&renderer, init_pos, init_dir); + + glm::vec4 testing_point = glm::vec4(2.0f, 0.0f, 1.0f, 1.0f); + glm::quat orient = glm::quatLookAt(-init_dir, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::vec3 dynamicUp = orient * glm::vec3(0.0f, 1.0f, 0.0f); + glm::mat4 expected_mat = glm::lookAt(init_pos, init_pos + init_dir, dynamicUp); + glm::vec4 expected = expected_mat * testing_point; + + EXPECT_EQ(expected, camera.view() * testing_point); + + testing_point = glm::vec4(22.0f, -14.0f, 32.0f, 1.0f); + orient = glm::quatLookAt(-init_dir, glm::vec3(0.0f, 1.0f, 0.0f)); + dynamicUp = orient * glm::vec3(0.0f, 1.0f, 0.0f); + expected_mat = glm::lookAt(init_pos, init_pos + init_dir, dynamicUp); + expected = expected_mat * testing_point; + + EXPECT_EQ(expected, camera.view() * testing_point); + + glm::vec3 new_dir = {0.25f, 0.45f, 1.0f}; + camera.setDirection(new_dir); + testing_point = glm::vec4(2.0f, 0.0f, 1.0f, 1.0f); + orient = glm::quatLookAt(-new_dir, glm::vec3(0.0f, 1.0f, 0.0f)); + dynamicUp = orient * glm::vec3(0.0f, 1.0f, 0.0f); + expected_mat = glm::lookAt(init_pos, init_pos + new_dir, dynamicUp); + expected = expected_mat * testing_point; + + EXPECT_NEAR(expected.x, (camera.view() * testing_point).x, 0.0001f); + EXPECT_NEAR(expected.y, (camera.view() * testing_point).y, 0.0001f); + EXPECT_NEAR(expected.z, (camera.view() * testing_point).z, 0.0001f); + EXPECT_NEAR(expected.w, (camera.view() * testing_point).w, 0.0001f); + + testing_point = glm::vec4(22.0f, -14.0f, 32.0f, 1.0f); + orient = glm::quatLookAt(-new_dir, glm::vec3(0.0f, 1.0f, 0.0f)); + dynamicUp = orient * glm::vec3(0.0f, 1.0f, 0.0f); + expected_mat = glm::lookAt(init_pos, init_pos + new_dir, dynamicUp); + expected = expected_mat * testing_point; + + EXPECT_NEAR(expected.x, (camera.view() * testing_point).x, 0.0001f); + EXPECT_NEAR(expected.y, (camera.view() * testing_point).y, 0.0001f); + EXPECT_NEAR(expected.z, (camera.view() * testing_point).z, 0.0001f); + EXPECT_NEAR(expected.w, (camera.view() * testing_point).w, 0.0001f); + + glm::vec3 new_pos = {20.0f, 1.45f, -25.0f}; + camera.setPosition(new_pos); + testing_point = glm::vec4(2.0f, 0.0f, 1.0f, 1.0f); + orient = glm::quatLookAt(-new_dir, glm::vec3(0.0f, 1.0f, 0.0f)); + dynamicUp = orient * glm::vec3(0.0f, 1.0f, 0.0f); + expected_mat = glm::lookAt(new_pos, new_pos + new_dir, dynamicUp); + expected = expected_mat * testing_point; + + EXPECT_NEAR(expected.x, (camera.view() * testing_point).x, 0.0001f); + EXPECT_NEAR(expected.y, (camera.view() * testing_point).y, 0.0001f); + EXPECT_NEAR(expected.z, (camera.view() * testing_point).z, 0.0001f); + EXPECT_NEAR(expected.w, (camera.view() * testing_point).w, 0.0001f); + + testing_point = glm::vec4(22.0f, -14.0f, 32.0f, 1.0f); + orient = glm::quatLookAt(-new_dir, glm::vec3(0.0f, 1.0f, 0.0f)); + dynamicUp = orient * glm::vec3(0.0f, 1.0f, 0.0f); + expected_mat = glm::lookAt(new_pos, new_pos + new_dir, dynamicUp); + expected = expected_mat * testing_point; + + EXPECT_NEAR(expected.x, (camera.view() * testing_point).x, 0.0001f); + EXPECT_NEAR(expected.y, (camera.view() * testing_point).y, 0.0001f); + EXPECT_NEAR(expected.z, (camera.view() * testing_point).z, 0.0001f); + EXPECT_NEAR(expected.w, (camera.view() * testing_point).w, 0.0001f); + + float target_blank = 0.0f; + camera.movementButtons(0.0f, target_blank); + EXPECT_EQ(camera.view_mat_ready, false); + + camera.view(); + EXPECT_EQ(camera.view_mat_ready, true); + + camera.rotationButtons(0.0f, target_blank); + EXPECT_EQ(camera.view_mat_ready, false); +}; + +TEST(CameraTransformation, HandlesInitialization){ + Mock::Renderer renderer; + glm::vec3 init_pos = {0.0f, 0.0f, 0.0f}; + glm::vec3 init_dir = {0.0f, 0.0f, 1.0f}; + float init_ortho_size = 60.0f; + float init_fov = 60.0f; + float init_perspective_near_plane = 0.01f; + float init_perspective_far_plane = 1000.0f; + float init_orthogonal_near_plane = 0.01f; + float init_orthogonal_far_plane = 1000.0f; + + Engine::Core::Camera camera(&renderer, init_pos, init_dir); + camera.setFov(init_fov); + camera.setOrthoSize(init_ortho_size); + camera.setNearPerspectivePlane(init_perspective_near_plane); + camera.setFarPerspectivePlane(init_perspective_far_plane); + camera.setNearOrthogonalPlane(init_orthogonal_near_plane); + camera.setFarOrthogonalPlane(init_orthogonal_far_plane); + + float aspectRatio = renderer.getWindowData()->width / (float)renderer.getWindowData()->height; + glm::vec4 testing_point = glm::vec4(2.0f, 0.0f, 1.0f, 1.0f); + glm::quat orient = glm::quatLookAt(-init_dir, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::vec3 dynamicUp = orient * glm::vec3(0.0f, 1.0f, 0.0f); + glm::mat4 expected_view_mat = glm::lookAt(init_pos, init_pos + init_dir, dynamicUp); + glm::mat4 expected_perspective_mat = glm::perspective(glm::radians(init_fov), aspectRatio, init_perspective_near_plane, init_perspective_far_plane); + glm::vec4 expected = expected_perspective_mat * expected_view_mat * testing_point; + + EXPECT_EQ(expected, camera.transformation() * testing_point); + + camera.setPosition({0.0f, 1.0f, 1.0f}); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setDirection({0.0f, 1.0f, 1.0f}); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setCameraMode(Engine::ScriptShared::CameraMode::PERSPECTIVE); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setFov(20.0f); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setCameraMode(Engine::ScriptShared::CameraMode::ORTHOGONAL); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setFov(20.0f); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setOrthoSize(20.0f); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setNearPerspectivePlane(0.1f); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setNearOrthogonalPlane(0.1f); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setFarPerspectivePlane(100.0f); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.setFarOrthogonalPlane(200.0f); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + float target_blank = 0.0f; + camera.movementButtons(0.0f, target_blank); + EXPECT_EQ(camera.transform_mat_ready, false); + + camera.transformation(); + EXPECT_EQ(camera.transform_mat_ready, true); + + camera.rotationButtons(0.0f, target_blank); + EXPECT_EQ(camera.transform_mat_ready, false); +}; + + + +//// ========================= //// +//// ==== Setters/Getters ==== //// +//// ========================= //// +TEST(CameraPositionDirectionSettersGetters, HandlesPositionAndDirection) { + Mock::Renderer renderer; + Engine::Core::Camera camera(&renderer, glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, -1.0f)); + + glm::vec3 newPos(10.0f, -5.0f, 3.14f); + camera.setPosition(newPos); + + EXPECT_FLOAT_EQ(camera.getPosition().x, newPos.x); + EXPECT_FLOAT_EQ(camera.getPosition().y, newPos.y); + EXPECT_FLOAT_EQ(camera.getPosition().z, newPos.z); + + glm::vec3 newDir(1.0f, 1.0f, 0.0f); + camera.setDirection(newDir); + glm::vec3 expectedDir = glm::normalize(newDir); + + EXPECT_NEAR(camera.getDirection().x, expectedDir.x, 0.001f); + EXPECT_NEAR(camera.getDirection().y, expectedDir.y, 0.001f); + EXPECT_NEAR(camera.getDirection().z, expectedDir.z, 0.001f); + + camera.setDirection(glm::vec3(0.0f, 0.0f, 0.0f)); + + EXPECT_NEAR(camera.getDirection().x, 0.0f, 0.001f); + EXPECT_NEAR(camera.getDirection().y, 0.0f, 0.001f); + EXPECT_NEAR(camera.getDirection().z, 1.0f, 0.001f); +}; + +TEST(CameraParametersSettersGetters, HandlesProjectionPropertiesAndClamping) { + Mock::Renderer renderer; + Engine::Core::Camera camera(&renderer, glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, -1.0f)); + + camera.setFov(90.0f); + EXPECT_FLOAT_EQ(camera.getFov(), 90.0f); + camera.setFov(-10.0f); + EXPECT_FLOAT_EQ(camera.getFov(), 0.0f); + + camera.setOrthoSize(25.0f); + EXPECT_FLOAT_EQ(camera.getOrthoSize(), 25.0f); + camera.setOrthoSize(0.0f); + EXPECT_FLOAT_EQ(camera.getOrthoSize(), 0.0f); + + camera.setNearPerspectivePlane(0.1f); + EXPECT_FLOAT_EQ(camera.getNearPerspectivePlane(), 0.1f); + camera.setNearPerspectivePlane(-1.0f); + EXPECT_FLOAT_EQ(camera.getNearPerspectivePlane(), 0.0f); + + camera.setFarPerspectivePlane(1000.0f); + EXPECT_FLOAT_EQ(camera.getFarPerspectivePlane(), 1000.0f); + camera.setFarPerspectivePlane(0.0f); + EXPECT_FLOAT_EQ(camera.getFarPerspectivePlane(), 0.0f); + + camera.setNearOrthogonalPlane(1.0f); + EXPECT_FLOAT_EQ(camera.getNearOrthogonalPlane(), 1.0f); + camera.setNearOrthogonalPlane(-5.0f); + EXPECT_FLOAT_EQ(camera.getNearOrthogonalPlane(), 0.0f); + + camera.setFarOrthogonalPlane(500.0f); + EXPECT_FLOAT_EQ(camera.getFarOrthogonalPlane(), 500.0f); + camera.setFarOrthogonalPlane(-100.0f); + EXPECT_FLOAT_EQ(camera.getFarOrthogonalPlane(), 0.0f); +}; + +TEST(CameraProjectionSettersGetters, HandlesModeSpecificPlanes) { + Mock::Renderer renderer; + Engine::Core::Camera camera(&renderer, glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, -1.0f)); + + camera.setNearPerspectivePlane(0.1f); + camera.setFarPerspectivePlane(100.0f); + camera.setNearOrthogonalPlane(1.0f); + camera.setFarOrthogonalPlane(200.0f); + + camera.setCameraMode(Engine::ScriptShared::CameraMode::PERSPECTIVE); + EXPECT_EQ(camera.getCameraMode(), Engine::ScriptShared::CameraMode::PERSPECTIVE); + EXPECT_FLOAT_EQ(camera.getNearPlane(), 0.1f); + EXPECT_FLOAT_EQ(camera.getFarPlane(), 100.0f); + + camera.setNearPlane(0.5f); + camera.setFarPlane(150.0f); + EXPECT_FLOAT_EQ(camera.getNearPerspectivePlane(), 0.5f); + EXPECT_FLOAT_EQ(camera.getFarPerspectivePlane(), 150.0f); + + EXPECT_FLOAT_EQ(camera.getNearOrthogonalPlane(), 1.0f); + + camera.setCameraMode(Engine::ScriptShared::CameraMode::ORTHOGONAL); + EXPECT_EQ(camera.getCameraMode(), Engine::ScriptShared::CameraMode::ORTHOGONAL); + EXPECT_FLOAT_EQ(camera.getNearPlane(), 1.0f); + EXPECT_FLOAT_EQ(camera.getFarPlane(), 200.0f); + + camera.setNearPlane(2.0f); + camera.setFarPlane(250.0f); + EXPECT_FLOAT_EQ(camera.getNearOrthogonalPlane(), 2.0f); + EXPECT_FLOAT_EQ(camera.getFarOrthogonalPlane(), 250.0f); + + EXPECT_FLOAT_EQ(camera.getNearPerspectivePlane(), 0.5f); +}; + +TEST(CameraMovementSettersGetters, HandlesMovementAndInputFlags) { + Mock::Renderer renderer; + Engine::Core::Camera camera(&renderer, glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, -1.0f)); + + camera.setDefaultMovement(true); + EXPECT_TRUE(camera.getDefaultMovement()); + camera.setDefaultMovement(false); + EXPECT_FALSE(camera.getDefaultMovement()); + + camera.setMouseActive(true); + EXPECT_TRUE(camera.getMouseActive()); + camera.setMouseActive(false); + EXPECT_FALSE(camera.getMouseActive()); + + camera.setVelocity(5.5f); + EXPECT_FLOAT_EQ(camera.getVelocity(), 5.5f); + camera.setVelocity(-2.0f); + EXPECT_FLOAT_EQ(camera.getVelocity(), 0.0f); + + camera.setSensitivity(0.8f); + EXPECT_FLOAT_EQ(camera.getSensitivity(), 0.8f); + camera.setSensitivity(0.0f); + EXPECT_FLOAT_EQ(camera.getSensitivity(), 0.0f); +}; + + + +//// ================== //// +//// ==== Movement ==== //// +//// ================== //// +// Skiped requires MOCKS \ No newline at end of file diff --git a/docs/Engine.drawio b/docs/Engine.drawio new file mode 100644 index 0000000..c355fd0 --- /dev/null +++ b/docs/Engine.drawio @@ -0,0 +1,439 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Engine.png b/docs/Engine.png new file mode 100644 index 0000000..3d76875 Binary files /dev/null and b/docs/Engine.png differ diff --git a/docs/Movement.gif b/docs/Movement.gif deleted file mode 100644 index db20434..0000000 Binary files a/docs/Movement.gif and /dev/null differ diff --git a/docs/Movement.mp4 b/docs/Movement.mp4 deleted file mode 100644 index f9e8e9b..0000000 Binary files a/docs/Movement.mp4 and /dev/null differ diff --git a/docs/Normals.png b/docs/Normals.png deleted file mode 100644 index 92bca3c..0000000 Binary files a/docs/Normals.png and /dev/null differ diff --git a/docs/PBR.gif b/docs/PBR.gif deleted file mode 100644 index d53167d..0000000 Binary files a/docs/PBR.gif and /dev/null differ diff --git a/docs/PBR.mp4 b/docs/PBR.mp4 deleted file mode 100644 index 83cc0a4..0000000 Binary files a/docs/PBR.mp4 and /dev/null differ diff --git a/docs/QuaterionCamera.gif b/docs/QuaterionCamera.gif deleted file mode 100644 index b5019b1..0000000 Binary files a/docs/QuaterionCamera.gif and /dev/null differ diff --git a/docs/QuaterionCamera.mp4 b/docs/QuaterionCamera.mp4 deleted file mode 100644 index cf99958..0000000 Binary files a/docs/QuaterionCamera.mp4 and /dev/null differ diff --git a/docs/SDF.gif b/docs/SDF.gif deleted file mode 100644 index 5076ad4..0000000 Binary files a/docs/SDF.gif and /dev/null differ diff --git a/docs/SDF.mp4 b/docs/SDF.mp4 deleted file mode 100644 index ba4247c..0000000 Binary files a/docs/SDF.mp4 and /dev/null differ diff --git a/docs/Shadows.gif b/docs/Shadows.gif deleted file mode 100644 index 0186b78..0000000 Binary files a/docs/Shadows.gif and /dev/null differ diff --git a/docs/Shadows.mp4 b/docs/Shadows.mp4 deleted file mode 100644 index f40df65..0000000 Binary files a/docs/Shadows.mp4 and /dev/null differ diff --git a/docs/Skybox.gif b/docs/Skybox.gif deleted file mode 100644 index 6c8b3d5..0000000 Binary files a/docs/Skybox.gif and /dev/null differ diff --git a/docs/Skybox.mp4 b/docs/Skybox.mp4 deleted file mode 100644 index c5e112d..0000000 Binary files a/docs/Skybox.mp4 and /dev/null differ diff --git a/docs/Terrain.gif b/docs/Terrain.gif deleted file mode 100644 index 41044df..0000000 Binary files a/docs/Terrain.gif and /dev/null differ diff --git a/docs/Terrain.mp4 b/docs/Terrain.mp4 deleted file mode 100644 index 573a15e..0000000 Binary files a/docs/Terrain.mp4 and /dev/null differ diff --git a/vendor/CWindow b/vendor/CWindow new file mode 160000 index 0000000..42123e3 --- /dev/null +++ b/vendor/CWindow @@ -0,0 +1 @@ +Subproject commit 42123e3e2968feee9de4a994b73137b498ce2902 diff --git a/vendor/cmrc b/vendor/cmrc new file mode 160000 index 0000000..952ffdd --- /dev/null +++ b/vendor/cmrc @@ -0,0 +1 @@ +Subproject commit 952ffddba731fc110bd50409e8d2b8a06abbd237 diff --git a/vendor/googletest b/vendor/googletest new file mode 160000 index 0000000..d89aac5 --- /dev/null +++ b/vendor/googletest @@ -0,0 +1 @@ +Subproject commit d89aac5f0dd4021198d903d39de16f896726de21