From f8f13b658ad6dffd784ff3fec0f30c7b93c174c3 Mon Sep 17 00:00:00 2001 From: Bosheng Li Date: Sun, 8 Sep 2024 12:02:35 -0400 Subject: [PATCH] Checkpoint. --- CMakeLists.txt | 50 ++++++++++++++----- EvoEngine_App/Demo/CMakeLists.txt | 3 ++ EvoEngine_App/Demo/Demo.cpp | 27 +++++----- EvoEngine_Plugins/CMakeLists.txt | 2 + EvoEngine_Plugins/EcoSysLab/CMakeLists.txt | 9 +--- EvoEngine_Plugins/RayTracer/CMakeLists.txt | 1 + .../RayTracer/src/GpuRayTracerCamera.cpp | 8 +++ EvoEngine_SDK/CMakeLists.txt | 18 ------- Extern/3rdParty/CMakeLists.txt | 1 - 9 files changed, 67 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05bc721..e805f96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") set(3RDPARTY_INCLUDES "") set(3RDPARTY_DLLS "") +set(3RDPARTY_PDBS "") set(3RDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Extern/3rdParty) add_subdirectory(${3RDPARTY_DIR}) @@ -49,30 +50,53 @@ add_subdirectory(${EVOENGINE_SDK_DIR}) # ------------------------------------------------------------------ # EvoEngine - Plugins # ------------------------------------------------------------------ - set(PLUGINS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/EvoEngine_Plugins) add_subdirectory(${PLUGINS_DIR}) - set(EVOENGINE_DEFS ${EVOENGINE_SDK_DEFS} ${EVOENGINE_PLUGINS_DEFS}) set(EVOENGINE_INCLUDES ${EVOENGINE_SDK_INCLUDES} ${EVOENGINE_PLUGINS_INCLUDES}) set(EVOENGINE_PCHS ${EVOENGINE_SDK_PCH} ${EVOENGINE_PLUGINS_PCHS}) -set(EVOENGINE_DLLS ${EVOENGINE_SDK_DLLS} ${EVOENGINE_PLUGINS_DLLS}) + +set(EVOENGINE_DLLS ${EVOENGINE_SDK_DLLS} ${3RDPARTY_DLLS} ${EVOENGINE_PLUGINS_DLLS}) +set(EVOENGINE_PDBS ${EVOENGINE_SDK_PDBS} ${3RDPARTY_PDBS} ${EVOENGINE_PLUGINS_PDBS}) + +set(EVOENGINE_RESOURCES ${EVOENGINE_SDK_RESOURCES} ${EVOENGINE_PLUGINS_RESOURCES}) # ------------------------------------------------------------------ # EvoEngine SDK - Copy resources # ------------------------------------------------------------------ function(evoengine_copy_resources dst_target dst_dir) + if (WIN32) + foreach (file_i ${EVOENGINE_DLLS}) + string(REPLACE "/" "\\" file_i ${file_i}) + add_custom_command(TARGET ${dst_target} POST_BUILD + COMMAND cmd /c "if exist \"${file_i}\" copy \"${file_i}\" \"${dst_dir}\\\"") + endforeach(file_i) + + foreach(file_i ${EVOENGINE_PDBS}) + string(REPLACE "/" "\\" file_i ${file_i}) + add_custom_command(TARGET ${dst_target} POST_BUILD + COMMAND cmd /c "if exist \"${file_i}\" copy \"${file_i}\" \"${dst_dir}\\\"") + endforeach(file_i) + else() + foreach (file_i ${EVOENGINE_DLLS}) + add_custom_command(TARGET ${dst_target} POST_BUILD + /bin/sh -c "if [ -e \"${file_i}\" ]; then cp \"${file_i}\" \"${dst_dir}\\\"; fi") + endforeach(file_i) + + foreach(file_i ${EVOENGINE_PDBS}) + add_custom_command(TARGET ${dst_target} POST_BUILD + /bin/sh -c "if [ -e \"${file_i}\" ]; then cp \"${file_i}\" \"${dst_dir}\\\"; fi") + endforeach(file_i) + endif() evoengine_sdk_copy_resources(${dst_target} ${dst_dir}) - foreach (EVOENGINE_DLL ${EVOENGINE_DLLS}) - add_custom_command( - TARGET ${dst_target} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${EVOENGINE_DLL} - ${dst_dir} - ) - endforeach () + foreach(folder_i ${EVOENGINE_RESOURCES}) + add_custom_command(TARGET ${dst_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${folder_i} ${dst_dir} + VERBATIM) + endforeach(folder_i) + endfunction() # ------------------------------------------------------------------ @@ -110,5 +134,7 @@ if (NOT ${CMAKE_BINARY_DIR} STREQUAL ${PROJECT_BINARY_DIR}) set(EVOENGINE_DLLS ${EVOENGINE_DLLS} PARENT_SCOPE) set(EVOENGINE_SDK_DIR ${EVOENGINE_SDK_DIR} PARENT_SCOPE) + set(EVOENGINE_RESOURCES ${EVOENGINE_RESOURCES} PARENT_SCOPE) + set(EvoEngine_Plugins ${EvoEngine_Plugins} PARENT_SCOPE) endif () \ No newline at end of file diff --git a/EvoEngine_App/Demo/CMakeLists.txt b/EvoEngine_App/Demo/CMakeLists.txt index c044fe8..7a54af2 100644 --- a/EvoEngine_App/Demo/CMakeLists.txt +++ b/EvoEngine_App/Demo/CMakeLists.txt @@ -25,5 +25,8 @@ if (${CMAKE_BINARY_DIR} STREQUAL ${PROJECT_BINARY_DIR}) ) file(COPY imgui.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) evoengine_copy_resources(DemoApp ${CMAKE_CURRENT_BINARY_DIR}) + + + endif () endif () \ No newline at end of file diff --git a/EvoEngine_App/Demo/Demo.cpp b/EvoEngine_App/Demo/Demo.cpp index 17a3c9d..425cec9 100644 --- a/EvoEngine_App/Demo/Demo.cpp +++ b/EvoEngine_App/Demo/Demo.cpp @@ -13,9 +13,9 @@ #include "WindowLayer.hpp" #ifdef UNIVERSE_PLUGIN -#include "PerlinNoiseStage.hpp" -#include "PlanetTerrainSystem.hpp" -#include "StarClusterSystem.hpp" +# include "PerlinNoiseStage.hpp" +# include "PlanetTerrainSystem.hpp" +# include "StarClusterSystem.hpp" #endif #include "PostProcessingStack.hpp" @@ -30,10 +30,10 @@ #endif #ifdef RAY_TRACER_PLUGIN # include "CpuRayTracerCamera.hpp" +# include "GpuRayTracerCamera.hpp" #endif using namespace evo_engine; using namespace Universe; -using namespace Universe; #pragma region Helpers #ifdef PHYSICS_PLUGIN Entity CreateDynamicCube(const float& mass, const glm::vec3& color, const glm::vec3& position, @@ -81,6 +81,7 @@ int main() { #ifdef RAY_TRACER_PLUGIN PrivateComponentRegistration("CpuRayTracerCamera"); + PrivateComponentRegistration("GpuRayTracerCamera"); #endif ApplicationInfo application_info; SetupDemoScene(demo_setup, application_info); @@ -331,7 +332,7 @@ void SetupDemoScene(DemoSetup demo_setup, ApplicationInfo& application_info) { } break; case DemoSetup::Galaxy: { application_info.application_name = "Universe Demo"; - + application_info.project_path = resource_folder_path / "Example Projects/Universe/Universe.eveproj"; #ifdef UNIVERSE_PLUGIN ProjectManager::SetActionAfterNewScene([&](const std::shared_ptr& scene) { @@ -339,9 +340,9 @@ void SetupDemoScene(DemoSetup demo_setup, ApplicationInfo& application_info) { main_camera->Resize({640, 480}); const auto main_camera_entity = main_camera->GetOwner(); scene->GetOrSetPrivateComponent(main_camera_entity); -#pragma region Star System +# pragma region Star System auto star_cluster_system = scene->GetOrCreateSystem(SystemGroup::SimulationSystemGroup); -#pragma endregion +# pragma endregion main_camera->use_clear_color = true; }); #endif @@ -351,7 +352,7 @@ void SetupDemoScene(DemoSetup demo_setup, ApplicationInfo& application_info) { application_info.project_path = resource_folder_path / "Example Projects/Planet/Planet.eveproj"; #ifdef UNIVERSE_PLUGIN ProjectManager::SetActionAfterNewScene([&](const std::shared_ptr& scene) { -#pragma region Preparations +# pragma region Preparations const auto main_camera = scene->main_camera.Get(); main_camera->Resize({640, 480}); const auto main_camera_entity = main_camera->GetOwner(); @@ -411,9 +412,9 @@ void SetupDemoScene(DemoSetup demo_setup, ApplicationInfo& application_info) { planet_terrain3->surface_material = surface_material; planet_terrain3->SetPlanetInfo(pi); scene->SetDataComponent(planet3, planet_transform); -#pragma endregion +# pragma endregion -#pragma region Lights +# pragma region Lights const auto shared_mat = ProjectManager::CreateTemporaryAsset(); Transform ltw; @@ -449,12 +450,12 @@ void SetupDemoScene(DemoSetup demo_setup, ApplicationInfo& application_info) { plmmc2->mesh = Resources::GetResource("PRIMITIVE_SPHERE"); plmmc2->material.Set(shared_mat); -#pragma endregion +# pragma endregion Application::RegisterLateUpdateFunction([=]() { auto scene = Application::GetActiveScene(); Transform ltw; ltw.SetScale(glm::vec3(0.5f)); -#pragma region LightsPosition +# pragma region LightsPosition ltw.SetPosition(glm::vec4( glm::vec3(0.0f, 20.0f * glm::sin(Times::Now() / 2.0f), -20.0f * glm::cos(Times::Now() / 2.0f)), 0.0f)); scene->SetDataComponent(dle, ltw); @@ -464,7 +465,7 @@ void SetupDemoScene(DemoSetup demo_setup, ApplicationInfo& application_info) { ltw.SetPosition(glm::vec4( glm::vec3(20.0f * glm::cos(Times::Now() / 2.0f), 15.0f, 20.0f * glm::sin(Times::Now() / 2.0f)), 0.0f)); scene->SetDataComponent(ple2, ltw); -#pragma endregion +# pragma endregion #endif }); }); diff --git a/EvoEngine_Plugins/CMakeLists.txt b/EvoEngine_Plugins/CMakeLists.txt index 278962b..7b4f5d5 100644 --- a/EvoEngine_Plugins/CMakeLists.txt +++ b/EvoEngine_Plugins/CMakeLists.txt @@ -4,6 +4,7 @@ set(EVOENGINE_PLUGINS_INCLUDES "") set(EVOENGINE_PLUGINS_PCHS "") set(EVOENGINE_PLUGINS_DEFS "") set(EVOENGINE_PLUGINS_DLLS "") +set(EVOENGINE_PLUGINS_RESOURCES "") #if (WIN32) # option(EVOENGINE_PLUGIN_PHYSICS "Build the physics plugin" ON) @@ -72,3 +73,4 @@ set(EVOENGINE_PLUGINS_INCLUDES ${EVOENGINE_PLUGINS_INCLUDES} PARENT_SCOPE) set(EVOENGINE_PLUGINS_PCHS ${EVOENGINE_PLUGINS_PCHS} PARENT_SCOPE) set(EVOENGINE_PLUGINS_DEFS ${EVOENGINE_PLUGINS_DEFS} PARENT_SCOPE) set(EVOENGINE_PLUGINS_DLLS ${EVOENGINE_PLUGINS_DLLS} PARENT_SCOPE) +set(EVOENGINE_PLUGINS_RESOURCES ${EVOENGINE_PLUGINS_RESOURCES} PARENT_SCOPE) diff --git a/EvoEngine_Plugins/EcoSysLab/CMakeLists.txt b/EvoEngine_Plugins/EcoSysLab/CMakeLists.txt index 985880b..0a52413 100644 --- a/EvoEngine_Plugins/EcoSysLab/CMakeLists.txt +++ b/EvoEngine_Plugins/EcoSysLab/CMakeLists.txt @@ -54,15 +54,8 @@ target_precompile_headers(EcoSysLabPlugin set(EVOENGINE_PLUGINS_INCLUDES ${EVOENGINE_PLUGINS_INCLUDES} ${ECOSYSLAB_INCLUDES} PARENT_SCOPE) set(EVOENGINE_PLUGINS_PCHS ${EVOENGINE_PLUGINS_PCHS} ${ECOSYSLAB_PCH} PARENT_SCOPE) set(EVOENGINE_PLUGINS_DEFS ${EVOENGINE_PLUGINS_DEFS} ECOSYSLAB_PLUGIN PARENT_SCOPE) +set(EVOENGINE_PLUGINS_RESOURCES ${EVOENGINE_PLUGINS_RESOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/Internals PARENT_SCOPE) set(EvoEngine_Plugins ${EvoEngine_Plugins} EcoSysLabPlugin PARENT_SCOPE) -# ------------------------------------------------------------------ -# Copy Internal resources -# ------------------------------------------------------------------ -add_custom_command(TARGET EcoSysLabPlugin POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/Internals - ${CMAKE_BINARY_DIR}) - set_target_properties(EcoSysLabPlugin PROPERTIES FOLDER "Plugins") \ No newline at end of file diff --git a/EvoEngine_Plugins/RayTracer/CMakeLists.txt b/EvoEngine_Plugins/RayTracer/CMakeLists.txt index 0c1f4a5..d30d75d 100644 --- a/EvoEngine_Plugins/RayTracer/CMakeLists.txt +++ b/EvoEngine_Plugins/RayTracer/CMakeLists.txt @@ -35,6 +35,7 @@ target_precompile_headers(RayTracerPlugin set(EVOENGINE_PLUGINS_INCLUDES ${EVOENGINE_PLUGINS_INCLUDES} ${RAY_TRACER_INCLUDES} PARENT_SCOPE) set(EVOENGINE_PLUGINS_PCHS ${EVOENGINE_PLUGINS_PCHS} ${RAY_TRACER_PCH} PARENT_SCOPE) set(EVOENGINE_PLUGINS_DEFS ${EVOENGINE_PLUGINS_DEFS} RAY_TRACER_PLUGIN PARENT_SCOPE) +set(EVOENGINE_PLUGINS_RESOURCES ${EVOENGINE_PLUGINS_RESOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/Internals PARENT_SCOPE) set(EvoEngine_Plugins ${EvoEngine_Plugins} RayTracerPlugin PARENT_SCOPE) diff --git a/EvoEngine_Plugins/RayTracer/src/GpuRayTracerCamera.cpp b/EvoEngine_Plugins/RayTracer/src/GpuRayTracerCamera.cpp index 8902303..5f90f85 100644 --- a/EvoEngine_Plugins/RayTracer/src/GpuRayTracerCamera.cpp +++ b/EvoEngine_Plugins/RayTracer/src/GpuRayTracerCamera.cpp @@ -27,7 +27,15 @@ void GpuRayTracerCamera::UpdateCameraInfoBlock(CameraInfoBlock& camera_info_bloc glm::vec4(near_distance, far_distance, glm::tan(glm::radians(fov * 0.5f)), glm::tan(glm::radians(fov * 0.25f))); } +std::shared_ptr trace_shader; + void GpuRayTracerCamera::OnCreate() { + if (!trace_shader) { + trace_shader = ProjectManager::CreateTemporaryAsset(); + const auto shader_code = FileUtils::LoadFileAsString(std::filesystem::path("./RayTracerResources") / + "Shaders/Compute/Trace.comp"); + trace_shader->Set(ShaderType::Compute, shader_code); + } } void GpuRayTracerCamera::Capture(const CaptureParameters& capture_parameters, diff --git a/EvoEngine_SDK/CMakeLists.txt b/EvoEngine_SDK/CMakeLists.txt index a66e25d..56a5e5f 100644 --- a/EvoEngine_SDK/CMakeLists.txt +++ b/EvoEngine_SDK/CMakeLists.txt @@ -130,22 +130,4 @@ function(evoengine_sdk_copy_resources dst_target dst_dir) COMMAND ${CMAKE_COMMAND} -E copy_directory ${EVOENGINE_SDK_DIR}/Internals ${dst_dir} VERBATIM) - foreach(file_i ${EVOENGINE_SDK_DLLS}) - add_custom_command(TARGET ${dst_target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${file_i} ${dst_dir} || (exit 0) - VERBATIM) - endforeach(file_i) - foreach(file_i ${3RDPARTY_DLLS}) - add_custom_command(TARGET ${dst_target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${file_i} ${dst_dir} || (exit 0) - VERBATIM) - endforeach(file_i) - foreach(file_i ${3RDPARTY_PDBS}) - add_custom_command(TARGET ${dst_target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${file_i} ${dst_dir} || (exit 0) - VERBATIM) - endforeach(file_i) endfunction() \ No newline at end of file diff --git a/Extern/3rdParty/CMakeLists.txt b/Extern/3rdParty/CMakeLists.txt index a55554d..c25675f 100644 --- a/Extern/3rdParty/CMakeLists.txt +++ b/Extern/3rdParty/CMakeLists.txt @@ -85,7 +85,6 @@ foreach(target ${all_targets}) endif() endforeach() - set(3RDPARTY_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${3RDPARTY_INCLUDES}