From 92ea24c3137e92adf53427c647f432c8cb73ab37 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Sat, 31 May 2025 22:13:27 +0200 Subject: [PATCH] improving render distance --- Application/World.h | 2 +- Application/main.cpp | 2 +- .../Includes/Graphics/Cameras/FirstPerson3D.h | 10 +++++----- .../Graphics/Cameras/FirstPerson3D.cpp | 20 +++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Application/World.h b/Application/World.h index 74e77db..6ad91be 100644 --- a/Application/World.h +++ b/Application/World.h @@ -10,7 +10,7 @@ #include #include -constexpr std::uint8_t RENDER_DISTANCE = 10; +constexpr std::uint8_t RENDER_DISTANCE = 15; constexpr std::uint8_t CHUNKS_UPLOAD_PER_FRAME = 3; enum class GenerationState: std::uint8_t diff --git a/Application/main.cpp b/Application/main.cpp index c99c09b..cfbedcb 100644 --- a/Application/main.cpp +++ b/Application/main.cpp @@ -17,7 +17,7 @@ int main(int ac, char** av) main_scene_desc.post_process_shader = post_process_shader; main_scene_desc.post_process_data_size = sizeof(std::int32_t); main_scene_desc.render_post_process_enabled = true; - main_scene_desc.camera = std::make_shared(Scop::Vec3f{ 0.0f, 20.0f, 0.0f }, 80.f); + main_scene_desc.camera = std::make_shared(Scop::Vec3f{ 0.0f, 100.0f, 0.0f }, 80.f, 1.0f); main_scene_desc.culling = Scop::CullMode::Front; Scop::Scene& main_scene = splash_scene.AddChildScene("main", std::move(main_scene_desc)); diff --git a/ScopEngine/Runtime/Includes/Graphics/Cameras/FirstPerson3D.h b/ScopEngine/Runtime/Includes/Graphics/Cameras/FirstPerson3D.h index f62d899..aab7260 100644 --- a/ScopEngine/Runtime/Includes/Graphics/Cameras/FirstPerson3D.h +++ b/ScopEngine/Runtime/Includes/Graphics/Cameras/FirstPerson3D.h @@ -10,13 +10,13 @@ namespace Scop { public: FirstPerson3D(); - FirstPerson3D(Vec3f position, float fov = 90.0f); + FirstPerson3D(Vec3f position, float fov = 90.0f, float speed = 50.0f); void Update(class Inputs& input, float aspect, float timestep) override; [[nodiscard]] inline constexpr std::string GetCameraType() override { return "FirstPerson3D"; } [[nodiscard]] const Vec3f& GetPosition() const noexcept override { return m_position; } - [[nodiscard]] const Vec3f& GetUp() const noexcept { return m_up; } + [[nodiscard]] const Vec3f& GetUp() const noexcept { return c_up; } [[nodiscard]] const Vec3f& GetLeft() const noexcept { return m_left; } [[nodiscard]] const Vec3f& GetTarget() const noexcept { return m_target; } [[nodiscard]] const Vec3f& GetDirection() const noexcept { return m_direction; } @@ -27,7 +27,7 @@ namespace Scop void UpdateView(); private: - const Vec3f m_up; + const Vec3f c_up; Vec3f m_position; Vec3f m_left; Vec3f m_forward; @@ -38,8 +38,8 @@ namespace Scop float m_theta = 0.0; float m_phi = 0.0; - const float m_speed = 50.0f; - const float m_sensivity = 0.7f; + const float c_speed = 50.0f; + const float c_sensivity = 0.7f; float m_speed_factor = 1.0f; float m_fov = 90.0f; diff --git a/ScopEngine/Runtime/Sources/Graphics/Cameras/FirstPerson3D.cpp b/ScopEngine/Runtime/Sources/Graphics/Cameras/FirstPerson3D.cpp index 42c5d6c..fb94381 100644 --- a/ScopEngine/Runtime/Sources/Graphics/Cameras/FirstPerson3D.cpp +++ b/ScopEngine/Runtime/Sources/Graphics/Cameras/FirstPerson3D.cpp @@ -3,17 +3,17 @@ namespace Scop { - FirstPerson3D::FirstPerson3D() : BaseCamera(), m_up(0, 1, 0), m_position(0.0, 0.0, 0.0) + FirstPerson3D::FirstPerson3D() : BaseCamera(), c_up(0, 1, 0), m_position(0.0, 0.0, 0.0) {} - FirstPerson3D::FirstPerson3D(Vec3f position, float fov) : BaseCamera(), m_position(std::move(position)), m_up(0, 1, 0), m_fov(fov) + FirstPerson3D::FirstPerson3D(Vec3f position, float fov, float speed) : BaseCamera(), m_position(std::move(position)), c_up(0, 1, 0), c_speed(speed), m_fov(fov) {} void FirstPerson3D::Update(class Inputs& input, float aspect, float timestep) { UpdateView(); m_target = m_position + m_direction; - m_view = Mat4f::LookAt(m_position, m_target, m_up); + m_view = Mat4f::LookAt(m_position, m_target, c_up); m_proj = Mat4f::Perspective(RadianAnglef(m_fov), aspect, 0.1f, 100'000.f); if(input.IsKeyPressed(SDL_SCANCODE_F1)) @@ -32,8 +32,8 @@ namespace Scop if(input.IsMouseGrabbed()) { - m_theta -= input.GetXRel() * m_sensivity; - m_phi -= input.GetYRel() * m_sensivity; + m_theta -= input.GetXRel() * c_sensivity; + m_phi -= input.GetYRel() * c_sensivity; } if(input.IsKeyPressed(SDL_SCANCODE_ESCAPE)) @@ -52,15 +52,15 @@ namespace Scop if(input.IsKeyPressed(SDL_SCANCODE_A) || input.IsKeyPressed(SDL_SCANCODE_LEFT)) m_mov += m_left; if(input.IsKeyPressed(SDL_SCANCODE_LSHIFT) || input.IsKeyPressed(SDL_SCANCODE_RSHIFT)) - m_mov -= m_up; + m_mov -= c_up; if(input.IsKeyPressed(SDL_SCANCODE_SPACE)) - m_mov += m_up; + m_mov += c_up; if(input.IsMouseWheelUp()) m_speed_factor *= 1.5f; if(input.IsMouseWheelDown()) m_speed_factor /= 1.5f; - m_position += m_mov * m_speed * m_speed_factor * timestep; + m_position += m_mov * c_speed * m_speed_factor * timestep; } void FirstPerson3D::UpdateView() @@ -73,10 +73,10 @@ namespace Scop m_direction.y = std::sin(m_phi * Pi() / 180); m_direction.z = std::cos(m_phi * Pi() / 180) * std::sin(-m_theta * Pi() / 180); - m_left = m_up.CrossProduct(m_direction); + m_left = c_up.CrossProduct(m_direction); m_left.Normalize(); - m_forward = m_up.CrossProduct(m_left); + m_forward = c_up.CrossProduct(m_left); m_forward.Normalize(); } }