Skip to content

Commit

Permalink
Checkpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
edisonlee0212 committed Sep 8, 2024
1 parent 186a89c commit f8f13b6
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 52 deletions.
50 changes: 38 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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()

# ------------------------------------------------------------------
Expand Down Expand Up @@ -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 ()
3 changes: 3 additions & 0 deletions EvoEngine_App/Demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
27 changes: 14 additions & 13 deletions EvoEngine_App/Demo/Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -81,6 +81,7 @@ int main() {

#ifdef RAY_TRACER_PLUGIN
PrivateComponentRegistration<CpuRayTracerCamera>("CpuRayTracerCamera");
PrivateComponentRegistration<GpuRayTracerCamera>("GpuRayTracerCamera");
#endif
ApplicationInfo application_info;
SetupDemoScene(demo_setup, application_info);
Expand Down Expand Up @@ -331,17 +332,17 @@ 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>& scene) {
const auto main_camera = scene->main_camera.Get<Camera>();
main_camera->Resize({640, 480});
const auto main_camera_entity = main_camera->GetOwner();
scene->GetOrSetPrivateComponent<PlayerController>(main_camera_entity);
#pragma region Star System
# pragma region Star System
auto star_cluster_system = scene->GetOrCreateSystem<StarClusterSystem>(SystemGroup::SimulationSystemGroup);
#pragma endregion
# pragma endregion
main_camera->use_clear_color = true;
});
#endif
Expand All @@ -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>& scene) {
#pragma region Preparations
# pragma region Preparations
const auto main_camera = scene->main_camera.Get<Camera>();
main_camera->Resize({640, 480});
const auto main_camera_entity = main_camera->GetOwner();
Expand Down Expand Up @@ -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<Material>();
Transform ltw;

Expand Down Expand Up @@ -449,12 +450,12 @@ void SetupDemoScene(DemoSetup demo_setup, ApplicationInfo& application_info) {
plmmc2->mesh = Resources::GetResource<Mesh>("PRIMITIVE_SPHERE");
plmmc2->material.Set<Material>(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);
Expand All @@ -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
});
});
Expand Down
2 changes: 2 additions & 0 deletions EvoEngine_Plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
9 changes: 1 addition & 8 deletions EvoEngine_Plugins/EcoSysLab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 1 addition & 0 deletions EvoEngine_Plugins/RayTracer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions EvoEngine_Plugins/RayTracer/src/GpuRayTracerCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Shader> trace_shader;

void GpuRayTracerCamera::OnCreate() {
if (!trace_shader) {
trace_shader = ProjectManager::CreateTemporaryAsset<Shader>();
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,
Expand Down
18 changes: 0 additions & 18 deletions EvoEngine_SDK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion Extern/3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ foreach(target ${all_targets})
endif()
endforeach()


set(3RDPARTY_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}
${3RDPARTY_INCLUDES}
Expand Down

0 comments on commit f8f13b6

Please sign in to comment.