mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-10 22:23:35 +00:00
improving render distance
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include <Utils.h>
|
||||
#include <NoiseCollection.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -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::FirstPerson3D>(Scop::Vec3f{ 0.0f, 20.0f, 0.0f }, 80.f);
|
||||
main_scene_desc.camera = std::make_shared<Scop::FirstPerson3D>(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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<float>() / 180);
|
||||
m_direction.z = std::cos(m_phi * Pi<float>() / 180) * std::sin(-m_theta * Pi<float>() / 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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user