diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d6ddcc..cd5e6d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ option(ENGINE_BUILD_TEST "Compile the test program" ON) SET(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo") +# enable link time code generation for all targets in the solution +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) + project(engine LANGUAGES CXX C VERSION "0.2.0" ) @@ -53,6 +56,7 @@ set(SRC_FILES "src/systems/ui_render_system.cpp" "src/systems/transform.cpp" "src/util/files.cpp" + "src/util/gen_tangents.cpp" "src/util/gltf_loader.cpp" "src/vulkan/device.cpp" "src/vulkan/device.h" @@ -99,6 +103,7 @@ set(INCLUDE_FILES "include/systems/transform.h" "include/util.h" "include/util/files.h" + "include/util/gen_tangents.h" "include/util/gltf_loader.h" "include/window.h" ) diff --git a/include/util/gen_tangents.h b/include/util/gen_tangents.h new file mode 100644 index 0000000..7b9637e --- /dev/null +++ b/include/util/gen_tangents.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/src/scene.cpp b/src/scene.cpp index 3952c54..f6a1d9b 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -50,6 +50,7 @@ Entity Scene::CreateEntity(const std::string& tag, Entity parent, t->tag = tag; t->parent = parent; + t->is_static = false; return id; } diff --git a/src/util/gen_tangents.cpp b/src/util/gen_tangents.cpp new file mode 100644 index 0000000..0d00346 --- /dev/null +++ b/src/util/gen_tangents.cpp @@ -0,0 +1 @@ +#include "util/gen_tangents.h" \ No newline at end of file diff --git a/src/util/gltf_loader.cpp b/src/util/gltf_loader.cpp index 93a7e81..d5a85c6 100644 --- a/src/util/gltf_loader.cpp +++ b/src/util/gltf_loader.cpp @@ -435,6 +435,7 @@ engine::Entity LoadGLTF(Scene& scene, const std::string& path, bool isStatic) LOG_DEBUG("Generating tangents..."); LOG_TRACE("Tangent gen: vtx count before = {} idx count before = {}", original_num_vertices, num_indices); // generate tangents if they're not in the file + // manually generating tangents directly with MikkTSpace instead of util::GenTangents() in order to directly access glTF vertex attributes struct MeshData { Attribute* positions; Attribute* normals; diff --git a/test/src/camera_controller.hpp b/test/src/camera_controller.hpp index e8e1a2b..54c274c 100644 --- a/test/src/camera_controller.hpp +++ b/test/src/camera_controller.hpp @@ -8,7 +8,7 @@ struct CameraControllerComponent { // looking - static constexpr float kCameraSensitivity = 0.001f; + static constexpr float kCameraSensitivity = 0.003f; static constexpr float kMaxPitch = glm::pi(); static constexpr float kMinPitch = 0.0f; diff --git a/test/src/game.cpp b/test/src/game.cpp index 71372e6..56f70ac 100644 --- a/test/src/game.cpp +++ b/test/src/game.cpp @@ -78,9 +78,11 @@ void PlayGame(GameSettings settings) /* create camera */ engine::Entity camera = main_scene->CreateEntity("camera"); - auto camren = main_scene->AddComponent(camera); + engine::Entity camera_child = main_scene->CreateEntity("camera_child", camera, glm::vec3{0.0f, 0.0f, -3.0f}); + main_scene->GetTransform(camera_child)->is_static = false; + auto camren = main_scene->AddComponent(camera_child); camren->visible = true; - camren->mesh = GenSphereMesh(app.renderer()->GetDevice(), 0.2f, 10); + camren->mesh = GenSphereMesh(app.renderer()->GetDevice(), 1.0f, 16); camren->material = app.GetResource("builtin.default"); /* as of right now, the entity with tag 'camera' is used to build the view @@ -88,6 +90,7 @@ void PlayGame(GameSettings settings) auto camera_transform = main_scene->GetComponent(camera); camera_transform->position = {0.0f, 0.0f, 100.0f}; + camera_transform->is_static = false; main_scene->RegisterComponent(); main_scene->RegisterSystem(); @@ -128,8 +131,13 @@ void PlayGame(GameSettings settings) main_scene->GetPosition(bottle).z += 2.5f; main_scene->GetScale(bottle) *= 25.0f; - engine::Entity cube = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/cube.glb"), false); - main_scene->GetPosition(cube) += glm::vec3{-5.0f, -17.0f, 0.0f}; + //engine::Entity cube = engine::util::LoadGLTF(*main_scene, app.GetResourcePath("models/cube.glb"), false); + engine::Entity cube = main_scene->CreateEntity("cube", 0, glm::vec3{ 4.0f, -17.0f, 0.0f }); + main_scene->GetTransform(cube)->is_static = false; + auto cube_ren = main_scene->AddComponent(cube); + cube_ren->material = app.GetResource("builtin.default"); + cube_ren->mesh = GenCuboidMesh(app.renderer()->GetDevice(), 1.0f, 1.0f, 1.0f); + cube_ren->visible = true; auto cubeCustom = main_scene->AddComponent(cube); cubeCustom->onInit = [] {}; cubeCustom->onUpdate = [&main_scene, cube](float dt) { diff --git a/test/src/meshgen.cpp b/test/src/meshgen.cpp index 21b630b..ebabcb4 100644 --- a/test/src/meshgen.cpp +++ b/test/src/meshgen.cpp @@ -66,7 +66,7 @@ std::unique_ptr GenSphereMesh(engine::GFXDevice* gfx, float r, int if (j == (detail / 2) - 1) norm = -norm; - for (auto it = vertices.end() - 6; it != vertices.end(); it++) { + for (auto it = vertices.end() - 6; it != vertices.end(); ++it) { it->norm = norm; } }