diff options
| -rw-r--r-- | src/engine/engine.cpp | 38 | ||||
| -rw-r--r-- | src/engine/engine.h | 94 | ||||
| -rw-r--r-- | src/engine/object.h | 55 | ||||
| -rw-r--r-- | src/engine/scene.h | 47 | ||||
| -rw-r--r-- | src/states/config_state.cpp | 16 | ||||
| -rw-r--r-- | src/states/config_state.h | 16 | ||||
| -rw-r--r-- | src/states/simulation_state.cpp | 12 | ||||
| -rw-r--r-- | src/states/simulation_state.h | 12 | ||||
| -rw-r--r-- | src/states/world_builder_state.cpp | 42 | ||||
| -rw-r--r-- | src/states/world_builder_state.h | 38 |
10 files changed, 187 insertions, 183 deletions
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index d6e2723..87eda62 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -79,12 +79,12 @@ namespace Donut glGenFramebuffers(1, &m_geodesic_fbo); } - void Engine::update_window_dimensions() + auto Engine::update_window_dimensions() -> void { update_compute_dimensions(); } - void Engine::set_window_dimensions(int width, int height) + auto Engine::set_window_dimensions(int width, int height) -> void { int old_width = m_width; int old_height = m_height; @@ -99,18 +99,18 @@ namespace Donut update_compute_dimensions(); } - void Engine::update_performance(float delta_time) + auto Engine::update_performance(float delta_time) -> void { if (delta_time > 0.0f) m_current_fps = 1.0f / delta_time; } - void Engine::update_compute_dimensions() + auto Engine::update_compute_dimensions() -> void { m_texture = Texture2D::create(get_compute_width(), m_compute_height); } - void Engine::draw_full_screen_quad() + auto Engine::draw_full_screen_quad() -> void { RenderCommand::set_viewport(0, 0, m_width, m_height); @@ -125,7 +125,7 @@ namespace Donut RenderCommand::enable_depth_test(); } - void Engine::draw_blur_pass() + auto Engine::draw_blur_pass() -> void { RenderCommand::set_viewport(0, 0, m_width, m_height); @@ -143,7 +143,7 @@ namespace Donut RenderCommand::enable_depth_test(); } - void Engine::draw_geodesic_pass(int cw, int ch) + auto Engine::draw_geodesic_pass(int cw, int ch) -> void { m_quad_vao->bind(); RenderCommand::disable_depth_test(); @@ -170,7 +170,7 @@ namespace Donut RenderCommand::enable_depth_test(); } - void Engine::dispatch_compute(const Camera& cam) + auto Engine::dispatch_compute(const Camera& cam) -> void { auto& hdri_manager = HDRIManager::get(); m_hdri_environment = hdri_manager.get_current_hdri(); @@ -200,7 +200,7 @@ namespace Donut glBindFramebuffer(GL_FRAMEBUFFER, 0); } - void Engine::upload_camera_ubo(const Camera& cam) + auto Engine::upload_camera_ubo(const Camera& cam) -> void { struct UBOData { @@ -231,7 +231,7 @@ namespace Donut m_camera_ubo->bind(1); } - void Engine::upload_objects_ubo(const std::vector<ObjectData>& objs) + auto Engine::upload_objects_ubo(const std::vector<ObjectData>& objs) -> void { struct UBOData { @@ -256,7 +256,7 @@ namespace Donut m_objects_ubo->bind(3); } - void Engine::upload_disk_ubo() + auto Engine::upload_disk_ubo() -> void { float r1 = static_cast<float>(m_sag_a.m_rs * 2.2); float r2 = static_cast<float>(m_sag_a.m_rs * 5.2); @@ -268,7 +268,7 @@ namespace Donut m_disk_ubo->bind(2); } - void Engine::upload_simulation_ubo() + auto Engine::upload_simulation_ubo() -> void { struct UBOData { @@ -292,7 +292,7 @@ namespace Donut m_simulation_ubo->bind(4); } - void Engine::update_physics(float delta_time) + auto Engine::update_physics(float delta_time) -> void { for (auto& obj : m_objects) { @@ -325,7 +325,7 @@ namespace Donut } } - void Engine::render_scene() + auto Engine::render_scene() -> void { RenderCommand::clear(); m_shader_program->bind(); @@ -334,7 +334,7 @@ namespace Donut RenderCommand::draw_arrays(6); } - Ref<Shader> Engine::create_compute_program(const char* path) + auto Engine::create_compute_program(const char* path) -> Ref<Shader> { std::ifstream in(path); if(!in.is_open()) @@ -348,7 +348,7 @@ namespace Donut return Ref<Shader>(Shader::create_compute("ComputeShader", src_str)); } - std::pair<Ref<VertexArray>, Ref<Texture2D>> Engine::quad_vao() + auto Engine::quad_vao() -> std::pair<Ref<VertexArray>, Ref<Texture2D>> { float quad_vertices[] = { @@ -373,7 +373,7 @@ namespace Donut return { vertex_array, texture }; } - void Engine::load_objects_from_scene(const std::vector<Donut::Object>& objects) + auto Engine::load_objects_from_scene(const std::vector<Donut::Object>& objects) -> void { m_objects.clear(); m_objects.push_back( @@ -410,7 +410,7 @@ namespace Donut print_object_info(); } - void Engine::print_object_info() const + auto Engine::print_object_info() const -> void { DONUT_INFO("=== Object Information ==="); DONUT_INFO("Total objects: {}", m_objects.size()); @@ -435,7 +435,7 @@ namespace Donut DONUT_INFO("========================"); } - void Engine::export_high_res_frame(const std::string& filename, int width, int height) + auto Engine::export_high_res_frame(const std::string& filename, int width, int height) -> void { DONUT_INFO("Exporting high-resolution frame: {}x{} to {}", width, height, filename); diff --git a/src/engine/engine.h b/src/engine/engine.h index 1c25466..0451d40 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -65,30 +65,30 @@ namespace Donut Engine(); ~Engine() = default; - void draw_full_screen_quad(); - void draw_blur_pass(); - void dispatch_compute(const Camera& cam); - void upload_camera_ubo(const Camera& cam); - void upload_objects_ubo(const std::vector<ObjectData>& objs); - void upload_disk_ubo(); - void upload_simulation_ubo(); - void render_scene(); - void update_physics(float delta_time); - void update_window_dimensions(); - void set_window_dimensions(int width, int height); + auto draw_full_screen_quad() -> void; + auto draw_blur_pass() -> void; + auto dispatch_compute(const Camera& cam) -> void; + auto upload_camera_ubo(const Camera& cam) -> void; + auto upload_objects_ubo(const std::vector<ObjectData>& objs) -> void; + auto upload_disk_ubo() -> void; + auto upload_simulation_ubo() -> void; + auto render_scene() -> void; + auto update_physics(float delta_time) -> void; + auto update_window_dimensions() -> void; + auto set_window_dimensions(int width, int height) -> void; - int get_width() const { return m_width; } - int get_height() const { return m_height; } + auto get_width() const -> int { return m_width; } + auto get_height() const -> int { return m_height; } - std::vector<ObjectData>& get_objects() { return m_objects; } - BlackHole& get_sag_a() { return m_sag_a; } - Camera& get_camera() { return m_camera; } - bool& get_gravity() { return m_gravity; } + auto get_objects() -> std::vector<ObjectData>& { return m_objects; } + auto get_sag_a() -> BlackHole& { return m_sag_a; } + auto get_camera() -> Camera& { return m_camera; } + auto get_gravity() -> bool& { return m_gravity; } - void update_performance(float delta_time); - void set_target_fps(int fps) { m_target_fps = fps; } - int get_target_fps() const { return m_target_fps; } - float get_current_fps() const { return m_current_fps; } + auto update_performance(float delta_time) -> void; + auto set_target_fps(int fps) -> void { m_target_fps = fps; } + auto get_target_fps() const -> int { return m_target_fps; } + auto get_current_fps() const -> float { return m_current_fps; } void set_compute_height(int height) { #ifdef __APPLE__ @@ -96,43 +96,43 @@ namespace Donut #endif m_compute_height = height; } - int get_compute_height() const { return m_compute_height; } - int get_compute_width() const { return (m_width * m_compute_height) / m_height; } - void update_compute_dimensions(); + auto get_compute_height() const -> int { return m_compute_height; } + auto get_compute_width() const -> int { return (m_width * m_compute_height) / m_height; } + auto update_compute_dimensions() -> void; - int get_max_steps_moving() const { return m_max_steps_moving; } - int get_max_steps_static() const { return m_max_steps_static; } - float get_early_exit_distance() const { return m_early_exit_distance; } - void set_max_steps_moving(int steps) { m_max_steps_moving = steps; } - void set_max_steps_static(int steps) { m_max_steps_static = steps; } - void set_early_exit_distance(float distance) { m_early_exit_distance = distance; } + auto get_max_steps_moving() const -> int { return m_max_steps_moving; } + auto get_max_steps_static() const -> int { return m_max_steps_static; } + auto get_early_exit_distance() const -> float { return m_early_exit_distance; } + auto set_max_steps_moving(int steps) -> void { m_max_steps_moving = steps; } + auto set_max_steps_static(int steps) -> void { m_max_steps_static = steps; } + auto set_early_exit_distance(float distance) -> void { m_early_exit_distance = distance; } - float get_disk_thickness() const { return m_disk_thickness; } - void set_disk_thickness(float thickness) { m_disk_thickness = thickness; } + auto get_disk_thickness() const -> float { return m_disk_thickness; } + auto set_disk_thickness(float thickness) -> void { m_disk_thickness = thickness; } - float get_disk_density() const { return m_disk_density; } - void set_disk_density(float density) { m_disk_density = density; } + auto get_disk_density() const -> float { return m_disk_density; } + auto set_disk_density(float density) -> void { m_disk_density = density; } - float get_rotation_speed() const { return m_rotation_speed; } - void set_rotation_speed(float speed) { m_rotation_speed = speed; } + auto get_rotation_speed() const -> float { return m_rotation_speed; } + auto set_rotation_speed(float speed) -> void { m_rotation_speed = speed; } - float get_blur_strength() const { return m_blur_strength; } - void set_blur_strength(float strength) { m_blur_strength = strength; } + auto get_blur_strength() const -> float { return m_blur_strength; } + auto set_blur_strength(float strength) -> void { m_blur_strength = strength; } - float get_glow_intensity() const { return m_glow_intensity; } - void set_glow_intensity(float intensity) { m_glow_intensity = intensity; } + auto get_glow_intensity() const -> float { return m_glow_intensity; } + auto set_glow_intensity(float intensity) -> void { m_glow_intensity = intensity; } - void load_objects_from_scene(const std::vector<Donut::Object>& objects); - void export_high_res_frame(const std::string& filename, int width = 4096, int height = 3072); - void print_object_info() const; + auto load_objects_from_scene(const std::vector<Donut::Object>& objects) -> void; + auto export_high_res_frame(const std::string& filename, int width = 4096, int height = 3072) -> void; + auto print_object_info() const -> void; - void set_hdri_environment(Ref<CubemapTexture> hdri) { m_hdri_environment = hdri; } - Ref<CubemapTexture> get_hdri_environment() const { return m_hdri_environment; } + auto set_hdri_environment(Ref<CubemapTexture> hdri) -> void { m_hdri_environment = hdri; } + auto get_hdri_environment() const -> Ref<CubemapTexture> { return m_hdri_environment; } private: - Ref<Shader> create_compute_program(const char* path); + auto create_compute_program(const char* path) -> Ref<Shader>; std::pair<Ref<VertexArray>, Ref<Texture2D>> quad_vao(); - void draw_geodesic_pass(int cw, int ch); + auto draw_geodesic_pass(int cw, int ch) -> void; private: Ref<VertexArray> m_quad_vao; Ref<Texture2D> m_texture; diff --git a/src/engine/object.h b/src/engine/object.h index 790fe25..8101540 100644 --- a/src/engine/object.h +++ b/src/engine/object.h @@ -7,67 +7,70 @@ namespace Donut class Ray { public: + Ray(glm::vec3 o, glm::vec3 d) + : m_origin(o), + m_direction(glm::normalize(d)) { } + + public: glm::vec3 m_direction; glm::vec3 m_origin; - - Ray(glm::vec3 o, glm::vec3 d) - : m_origin(o), - m_direction(glm::normalize(d)) { } }; class Material { public: - glm::vec3 m_color; - float m_specular; - float m_emission; - Material() : m_color(1.0f, 1.0f, 1.0f), m_specular(0.5f), m_emission(0.0f) { } Material(glm::vec3 c, float s, float e) - : m_color(c), - m_specular(s), + : m_color(c), + m_specular(s), m_emission(e) { } + + public: + glm::vec3 m_color; + float m_specular; + float m_emission; }; class Object { public: - glm::vec3 m_centre; - float m_radius; - Material m_material; - Object() : m_centre(0.0f, 0.0f, 0.0f), m_radius(1.0f), m_material() { } - Object(glm::vec3 c, float r, Material m) - : m_centre(c), - m_radius(r), + Object(glm::vec3 c, float r, Material m) + : m_centre(c), + m_radius(r), m_material(m) { } - - bool intersect(Ray &ray, float &t) + + auto intersect(Ray& ray, float& t) -> bool { glm::vec3 oc = ray.m_origin - m_centre; - float a = glm::dot(ray.m_direction, ray.m_direction); + float a = glm::dot(ray.m_direction, ray.m_direction); float b = 2.0f * glm::dot(oc, ray.m_direction); float c = glm::dot(oc, oc) - m_radius * m_radius; float discriminant = static_cast<float>(b*b - 4*a*c); - if(discriminant < 0) + if (discriminant < 0) return false; - + float intercept = (-b - sqrt(discriminant)) / (2.0f*a); - if(intercept < 0) + if (intercept < 0) { intercept = (-b + sqrt(discriminant)) / (2.0f*a); - if(intercept<0) + if (intercept < 0) return false; } t = intercept; return true; } - - glm::vec3 get_normal(glm::vec3 &point) const + + auto get_normal(glm::vec3& point) const -> glm::vec3 { return glm::normalize(point - m_centre); } + + public: + glm::vec3 m_centre; + float m_radius; + Material m_material; }; }; diff --git a/src/engine/scene.h b/src/engine/scene.h index 2ac9cd8..4b41203 100644 --- a/src/engine/scene.h +++ b/src/engine/scene.h @@ -7,63 +7,64 @@ namespace Donut { - class Scene + class Scene { public: - std::vector<Object> objs; - glm::vec3 m_light_pos; - - Scene() + Scene() : m_light_pos(5.0f, 5.0f, 5.0f) { } - - glm::vec3 trace(Ray &ray) + + auto trace(Ray& ray) -> glm::vec3 { float closest = std::numeric_limits<float>::infinity(); const Object* hit_obj = nullptr; - - for(auto& obj : objs) + + for (auto& obj : objs) { float t; - if(obj.intersect(ray, t)) - if(t < closest) + if (obj.intersect(ray, t)) + if (t < closest) { closest = t; hit_obj = &obj; } } - - if(hit_obj) + + if (hit_obj) { glm::vec3 hit_point = ray.m_origin + ray.m_direction * closest; glm::vec3 normal = hit_obj->get_normal(hit_point); glm::vec3 light_dir = glm::normalize(m_light_pos - hit_point); - + float diff = std::max(glm::dot(normal, light_dir), 0.0f); - + Ray shadow_ray(hit_point + normal * 0.001f, light_dir); bool in_shadow = false; - - for(auto& obj : objs) + + for (auto& obj : objs) { float t; - if(obj.intersect(shadow_ray, t)) + if (obj.intersect(shadow_ray, t)) { in_shadow = true; break; } } - + glm::vec3 color = hit_obj->m_material.m_color; float ambient = 0.1f; - - if (in_shadow) + + if (in_shadow) return color * ambient; return color * (ambient + diff * 0.9f); } - - return glm::vec3(0.0f, 0.0f, 0.1f); + + return glm::vec3(0.0f, 0.0f, 0.1f); } + + public: + std::vector<Object> objs; + glm::vec3 m_light_pos; }; }; diff --git a/src/states/config_state.cpp b/src/states/config_state.cpp index 4573aab..d5fca87 100644 --- a/src/states/config_state.cpp +++ b/src/states/config_state.cpp @@ -10,7 +10,7 @@ namespace Donut { - void ConfigState::on_enter() + auto ConfigState::on_enter() -> void { DONUT_INFO("Entering Config State"); @@ -32,12 +32,12 @@ namespace Donut m_enable_anti_aliasing = settings.graphics.enable_anti_aliasing; } - void ConfigState::on_exit() + auto ConfigState::on_exit() -> void { DONUT_INFO("Exiting Config State"); } - void ConfigState::on_update(float delta_time) + auto ConfigState::on_update(float delta_time) -> void { if (m_show_restart_message) { @@ -50,17 +50,17 @@ namespace Donut } } - void ConfigState::on_render() + auto ConfigState::on_render() -> void { Renderer::set_clear_color({ 0.1f, 0.1f, 0.1f, 1.0f }); Renderer::clear(); } - void ConfigState::on_event(Event& event) + auto ConfigState::on_event(Event& event) -> void { } - void ConfigState::on_im_ui_render() + auto ConfigState::on_im_ui_render() -> void { ImGui::SetNextWindowSize(ImVec2(900, 700), ImGuiCond_FirstUseEver); ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f, ImGui::GetIO().DisplaySize.y * 0.5f), @@ -258,7 +258,7 @@ namespace Donut ImGui::End(); } - void ConfigState::apply_settings() + auto ConfigState::apply_settings() -> void { SimulationSettings sim_settings; sim_settings.target_fps = m_target_fps; @@ -285,7 +285,7 @@ namespace Donut DONUT_INFO("Settings applied and saved"); } - void ConfigState::reset_to_defaults() + auto ConfigState::reset_to_defaults() -> void { m_selected_api = RendererAPI::API::OpenGL; m_target_fps = 60; diff --git a/src/states/config_state.h b/src/states/config_state.h index 7a31f8c..c723daa 100644 --- a/src/states/config_state.h +++ b/src/states/config_state.h @@ -13,16 +13,16 @@ namespace Donut public: ~ConfigState() = default; - void on_enter() override; - void on_exit() override; - void on_update(float delta_time) override; - void on_render() override; - void on_im_ui_render() override; - void on_event(Event& event) override; + auto on_enter() -> void override; + auto on_exit() -> void override; + auto on_update(float delta_time) -> void override; + auto on_render() -> void override; + auto on_im_ui_render() -> void override; + auto on_event(Event& event) -> void override; private: - void apply_settings(); - void reset_to_defaults(); + auto apply_settings() -> void; + auto reset_to_defaults() -> void; private: RendererAPI::API m_selected_api = RendererAPI::API::OpenGL; diff --git a/src/states/simulation_state.cpp b/src/states/simulation_state.cpp index 540f236..06955ff 100644 --- a/src/states/simulation_state.cpp +++ b/src/states/simulation_state.cpp @@ -15,7 +15,7 @@ namespace Donut { - void SimulationState::on_enter() + auto SimulationState::on_enter() -> void { DONUT_INFO("Entering Simulation State"); @@ -39,12 +39,12 @@ namespace Donut m_initialized = true; } - void SimulationState::on_exit() + auto SimulationState::on_exit() -> void { DONUT_INFO("Exiting Simulation State"); } - void SimulationState::on_update(float delta_time) + auto SimulationState::on_update(float delta_time) -> void { auto& engine = Application::get().get_engine(); engine.update_performance(delta_time); @@ -60,7 +60,7 @@ namespace Donut } } - void SimulationState::on_render() + auto SimulationState::on_render() -> void { auto& engine = Application::get().get_engine(); RenderCommand::set_clear_color(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); @@ -71,7 +71,7 @@ namespace Donut engine.draw_blur_pass(); } - void SimulationState::on_event(Event& event) + auto SimulationState::on_event(Event& event) -> void { auto& engine = Application::get().get_engine(); @@ -112,7 +112,7 @@ namespace Donut } } - void SimulationState::on_im_ui_render() + auto SimulationState::on_im_ui_render() -> void { auto& engine = Application::get().get_engine(); diff --git a/src/states/simulation_state.h b/src/states/simulation_state.h index 9a89fea..625d19e 100644 --- a/src/states/simulation_state.h +++ b/src/states/simulation_state.h @@ -14,12 +14,12 @@ namespace Donut public: ~SimulationState() = default; - void on_enter() override; - void on_exit() override; - void on_update(float delta_time) override; - void on_render() override; - void on_im_ui_render() override; - void on_event(Event& event) override; + auto on_enter() -> void override; + auto on_exit() -> void override; + auto on_update(float delta_time) -> void override; + auto on_render() -> void override; + auto on_im_ui_render() -> void override; + auto on_event(Event& event) -> void override; private: bool m_initialized = false; diff --git a/src/states/world_builder_state.cpp b/src/states/world_builder_state.cpp index ab3e2b3..be74eb6 100644 --- a/src/states/world_builder_state.cpp +++ b/src/states/world_builder_state.cpp @@ -28,7 +28,7 @@ namespace Donut { - void WorldBuilderState::on_enter() + auto WorldBuilderState::on_enter() -> void { DONUT_INFO("Entering World Builder State"); @@ -78,12 +78,12 @@ namespace Donut m_initialized = true; } - void WorldBuilderState::on_exit() + auto WorldBuilderState::on_exit() -> void { DONUT_INFO("Exiting World Builder State"); } - void WorldBuilderState::on_update(float delta_time) + auto WorldBuilderState::on_update(float delta_time) -> void { if (m_camera_dragging && !ImGuizmo::IsUsing()) @@ -112,7 +112,7 @@ namespace Donut } } - void WorldBuilderState::on_render() + auto WorldBuilderState::on_render() -> void { auto& hdri_manager = HDRIManager::get(); m_hdri_environment = hdri_manager.get_current_hdri(); @@ -129,7 +129,7 @@ namespace Donut render_scene(); } - void WorldBuilderState::on_event(Event& event) + auto WorldBuilderState::on_event(Event& event) -> void { EventDispatcher dispatcher(event); @@ -309,7 +309,7 @@ namespace Donut }); } - void WorldBuilderState::on_im_ui_render() + auto WorldBuilderState::on_im_ui_render() -> void { GLFWwindow* window = static_cast<GLFWwindow*>(Application::get().get_window().get_native_window()); int width, height; @@ -376,7 +376,7 @@ namespace Donut ImGui::Spacing(); - if (ImGui::CollapsingHeader("Create Object")) + if (ImGui::CollapsingHeader("create Object")) { ImGui::TextColored(ImVec4(0.9f, 0.9f, 1.0f, 1.0f), "New Sphere"); ImGui::Separator(); @@ -403,12 +403,12 @@ namespace Donut if (m_scene.objs.size() >= 16) { ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f); - ImGui::Button("Add Sphere (Limit Reached)", ImVec2(ImGui::GetWindowWidth() - 20, 30)); + ImGui::Button("add Sphere (Limit Reached)", ImVec2(ImGui::GetWindowWidth() - 20, 30)); ImGui::PopStyleVar(); } else { - if (ImGui::Button("Add Sphere", ImVec2(ImGui::GetWindowWidth() - 20, 30))) + if (ImGui::Button("add Sphere", ImVec2(ImGui::GetWindowWidth() - 20, 30))) add_sphere(); } } @@ -576,7 +576,7 @@ namespace Donut save_scene(); ImGui::SameLine(); - if (ImGui::Button("Load Scene", ImVec2(button_width, 30))) + if (ImGui::Button("load Scene", ImVec2(button_width, 30))) load_scene(); ImGui::Spacing(); @@ -643,7 +643,7 @@ namespace Donut } } - void WorldBuilderState::add_sphere() + auto WorldBuilderState::add_sphere() -> void { if (m_scene.objs.size() >= 16) { @@ -666,7 +666,7 @@ namespace Donut DONUT_INFO("Added sphere to scene and selected it"); } - void WorldBuilderState::remove_selected_object() + auto WorldBuilderState::remove_selected_object() -> void { if (m_selected_object_index >= 0 && m_selected_object_index < static_cast<int>(m_scene.objs.size())) { @@ -676,14 +676,14 @@ namespace Donut } } - void WorldBuilderState::clear_scene() + auto WorldBuilderState::clear_scene() -> void { m_scene.objs.clear(); m_selected_object_index = -1; DONUT_INFO("Cleared scene (black hole remains at center)"); } - void WorldBuilderState::save_scene() + auto WorldBuilderState::save_scene() -> void { nlohmann::json scene_data; scene_data["objects"] = nlohmann::json::array(); @@ -722,7 +722,7 @@ namespace Donut DONUT_ERROR("Failed to save scene"); } - void WorldBuilderState::load_scene() + auto WorldBuilderState::load_scene() -> void { std::ifstream file("Scene.json"); if (file.is_open()) @@ -770,7 +770,7 @@ namespace Donut DONUT_ERROR("Failed to load scene"); } - void WorldBuilderState::initialize_sphere_geometry() + auto WorldBuilderState::initialize_sphere_geometry() -> void { std::vector<float> vertices; std::vector<uint32_t> indices; @@ -837,7 +837,7 @@ namespace Donut m_sphere_vao->set_index_buffer(index_buffer); } - void WorldBuilderState::render_scene() + auto WorldBuilderState::render_scene() -> void { GLFWwindow* window = static_cast<GLFWwindow*>(Application::get().get_window().get_native_window()); int width, height; @@ -920,7 +920,7 @@ namespace Donut - void WorldBuilderState::initialize_skybox_geometry() + auto WorldBuilderState::initialize_skybox_geometry() -> void { float skybox_vertices[] = { @@ -976,7 +976,7 @@ namespace Donut m_skybox_vao->add_vertex_buffer(vertex_buffer); } - void WorldBuilderState::render_skybox() + auto WorldBuilderState::render_skybox() -> void { if (!m_skybox_shader || !m_skybox_vao || !m_hdri_environment) return; @@ -1006,7 +1006,7 @@ namespace Donut RenderCommand::enable_depth_test(); } - void WorldBuilderState::initialize_grid_geometry() + auto WorldBuilderState::initialize_grid_geometry() -> void { if (m_grid_vao) { @@ -1070,7 +1070,7 @@ namespace Donut m_grid_vao->unbind(); } - void WorldBuilderState::render_grid() + auto WorldBuilderState::render_grid() -> void { if (!m_grid_shader || !m_grid_vao) return; diff --git a/src/states/world_builder_state.h b/src/states/world_builder_state.h index 243b750..8b4678a 100644 --- a/src/states/world_builder_state.h +++ b/src/states/world_builder_state.h @@ -26,22 +26,22 @@ namespace Donut public: ~WorldBuilderState() = default; - void on_enter() override; - void on_exit() override; - void on_update(float delta_time) override; - void on_render() override; - void on_im_ui_render() override; - void on_event(Event& event) override; + auto on_enter() -> void override; + auto on_exit() -> void override; + auto on_update(float delta_time) -> void override; + auto on_render() -> void override; + auto on_im_ui_render() -> void override; + auto on_event(Event& event) -> void override; private: - void add_sphere(); - void remove_selected_object(); - void clear_scene(); - void save_scene(); - void load_scene(); - void render_scene(); - void initialize_sphere_geometry(); - void initialize_grid_geometry(); - void render_grid(); + auto add_sphere() -> void; + auto remove_selected_object() -> void; + auto clear_scene() -> void; + auto save_scene() -> void; + auto load_scene() -> void; + auto render_scene() -> void; + auto initialize_sphere_geometry() -> void; + auto initialize_grid_geometry() -> void; + auto render_grid() -> void; private: Scene m_scene; Camera m_camera; @@ -87,10 +87,10 @@ namespace Donut Object m_black_hole; bool m_black_hole_initialized = false; - void set_hdri_environment(Ref<CubemapTexture> hdri) { m_hdri_environment = hdri; } - Ref<CubemapTexture> get_hdri_environment() const { return m_hdri_environment; } + auto set_hdri_environment(Ref<CubemapTexture> hdri) -> void { m_hdri_environment = hdri; } + auto get_hdri_environment() const -> Ref<CubemapTexture> { return m_hdri_environment; } - void initialize_skybox_geometry(); - void render_skybox(); + auto initialize_skybox_geometry() -> void; + auto render_skybox() -> void; }; }; |
