diff --git a/src/conversions/pressure.hpp b/src/conversions/pressure.hpp index b79bdc8..610d8b4 100644 --- a/src/conversions/pressure.hpp +++ b/src/conversions/pressure.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::conversions::pressure +namespace Sim::Conversions::Pressure { constexpr double torr_to_pa(double t) { return t * 133.322; } diff --git a/src/conversions/temperature.hpp b/src/conversions/temperature.hpp index cf3efa8..6cf7aa2 100644 --- a/src/conversions/temperature.hpp +++ b/src/conversions/temperature.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::conversions::temperature +namespace Sim::Conversions::Temperature { constexpr double k_to_c(double k) { return k - 273.15; } diff --git a/src/coolant/condenser.cpp b/src/coolant/condenser.cpp index 737ca0f..d271dc2 100644 --- a/src/coolant/condenser.cpp +++ b/src/coolant/condenser.cpp @@ -4,7 +4,7 @@ #include #include -using namespace sim::coolant; +using namespace Sim::Coolant; constexpr static double calc_cylinder(double h, double d) { diff --git a/src/coolant/condenser.hpp b/src/coolant/condenser.hpp index c568828..d851133 100644 --- a/src/coolant/condenser.hpp +++ b/src/coolant/condenser.hpp @@ -3,7 +3,7 @@ #include "fluid_holder.hpp" -namespace sim::coolant +namespace Sim::Coolant { class Condenser : public FluidHolder diff --git a/src/coolant/condenser_secondary.cpp b/src/coolant/condenser_secondary.cpp index ae658c7..7b78384 100644 --- a/src/coolant/condenser_secondary.cpp +++ b/src/coolant/condenser_secondary.cpp @@ -4,7 +4,7 @@ #include "../util/constants.hpp" #include "../system.hpp" -using namespace sim::coolant; +using namespace Sim::Coolant; CondenserSecondary::CondenserSecondary(Condenser* primary, Evaporator* source, double volume) : primary(primary), source(source), FluidHolder(primary->fluid, volume, 0) diff --git a/src/coolant/condenser_secondary.hpp b/src/coolant/condenser_secondary.hpp index 4227307..2b81a43 100644 --- a/src/coolant/condenser_secondary.hpp +++ b/src/coolant/condenser_secondary.hpp @@ -5,7 +5,7 @@ #include "evaporator.hpp" #include "condenser.hpp" -namespace sim::coolant +namespace Sim::Coolant { class CondenserSecondary : public FluidHolder diff --git a/src/coolant/evaporator.cpp b/src/coolant/evaporator.cpp index 13098ce..5a5b2dd 100644 --- a/src/coolant/evaporator.cpp +++ b/src/coolant/evaporator.cpp @@ -5,7 +5,7 @@ #include #include -using namespace sim::coolant; +using namespace Sim::Coolant; constexpr static double calc_cylinder(double h, double d) { @@ -41,15 +41,15 @@ void Evaporator::update(double dt) steam = 0; double P = 10000; // Pa - double K = conversions::temperature::c_to_k(heat); // K - double R = util::constants::R; // J/K/mol + double K = Conversions::Temperature::c_to_k(heat); // K + double R = Util::Constants::R; // J/K/mol - double n_g = air / util::constants::M_air; // mol + double n_g = air / Util::Constants::M_air; // mol double V_g = (volume - level) * 0.001; // m^3 double n = (P * V_g) / (R * K); // mol - air = n * util::constants::M_air; + air = n * Util::Constants::M_air; update_base(dt); } diff --git a/src/coolant/evaporator.hpp b/src/coolant/evaporator.hpp index 0c6f1f6..148f11a 100644 --- a/src/coolant/evaporator.hpp +++ b/src/coolant/evaporator.hpp @@ -3,7 +3,7 @@ #include "fluid_holder.hpp" -namespace sim::coolant +namespace Sim::Coolant { class Evaporator : public FluidHolder diff --git a/src/coolant/fluid.hpp b/src/coolant/fluid.hpp index eb77551..9f7883b 100644 --- a/src/coolant/fluid.hpp +++ b/src/coolant/fluid.hpp @@ -5,7 +5,7 @@ #include "vapor_pressure.hpp" -namespace sim::coolant +namespace Sim::Coolant { struct Fluid @@ -14,9 +14,9 @@ struct Fluid const double gPmol; // g/mol const double jPg; // J/g latent heat of vaporisation - const coolant::VaporPressure vapor_pressure; + const Coolant::VaporPressure vapor_pressure; - constexpr Fluid(double gPl, double gPmol, double jPg, coolant::VaporPressure vapor_pressure) : + constexpr Fluid(double gPl, double gPmol, double jPg, Coolant::VaporPressure vapor_pressure) : gPl(gPl), gPmol(gPmol), jPg(jPg), vapor_pressure(vapor_pressure) { diff --git a/src/coolant/fluid_holder.cpp b/src/coolant/fluid_holder.cpp index c0501d7..4bfff45 100644 --- a/src/coolant/fluid_holder.cpp +++ b/src/coolant/fluid_holder.cpp @@ -7,7 +7,7 @@ #include #include -using namespace sim::coolant; +using namespace Sim::Coolant; FluidHolder::FluidHolder(Fluid fluid, double volume, double extra_mass) : fluid(fluid), volume(volume), extra_mass(extra_mass) { @@ -98,19 +98,19 @@ double FluidHolder::calc_pressure(double heat, double volume, double mol) { double V = volume * 0.001; - return V == 0 ? 0 : (mol * heat * util::constants::R) / V; + return V == 0 ? 0 : (mol * heat * Util::Constants::R) / V; } double FluidHolder::calc_pressure_mol(double heat, double volume, double pressure) { double V = volume * 0.001; - return (pressure * V) / (util::constants::R * heat); + return (pressure * V) / (Util::Constants::R * heat); } double FluidHolder::get_pressure() const { - return calc_pressure(conversions::temperature::c_to_k(heat), get_gas_volume(), fluid.g_to_mol(steam) + air / util::constants::M_air); + return calc_pressure(Conversions::Temperature::c_to_k(heat), get_gas_volume(), fluid.g_to_mol(steam) + air / Util::Constants::M_air); } double FluidHolder::get_gas_density() const @@ -141,12 +141,12 @@ void FluidHolder::update_base(double secs) if(mass > 0) { - double K = conversions::temperature::c_to_k(heat); // K + double K = Conversions::Temperature::c_to_k(heat); // K double P = fluid.vapor_pressure.calc_p(K); // Pa - double R = util::constants::R; // J/K/mol + double R = Util::Constants::R; // J/K/mol double J_m = fluid.jPg * fluid.gPmol; // J/mol - double n_g = fluid.g_to_mol(steam) + air / util::constants::M_air; // mol + double n_g = fluid.g_to_mol(steam) + air / Util::Constants::M_air; // mol double V_g = (volume - level) * 0.001; // m^3 double n = (P * V_g) / (R * K) - n_g; // mol diff --git a/src/coolant/fluid_holder.hpp b/src/coolant/fluid_holder.hpp index afdba93..91c635e 100644 --- a/src/coolant/fluid_holder.hpp +++ b/src/coolant/fluid_holder.hpp @@ -6,7 +6,7 @@ #include "fluid.hpp" #include "../conversions/temperature.hpp" -namespace sim::coolant +namespace Sim::Coolant { class FluidHolder @@ -36,7 +36,7 @@ public: virtual double get_volume() const { return volume; } // litres virtual double get_level() const { return level; } // litres virtual double get_heat() const { return heat; } // celsius - virtual double get_heat_k() const { return conversions::temperature::c_to_k(get_heat()); } // kelvin + virtual double get_heat_k() const { return Conversions::Temperature::c_to_k(get_heat()); } // kelvin virtual double get_steam() const { return steam; } // grams virtual double get_gas() const { return steam + air; } // grams virtual double get_air() const { return air; } // grams diff --git a/src/coolant/pump.cpp b/src/coolant/pump.cpp index 8d56004..0a7d27e 100644 --- a/src/coolant/pump.cpp +++ b/src/coolant/pump.cpp @@ -6,7 +6,7 @@ #include #include -using namespace sim::coolant; +using namespace Sim::Coolant; Pump::Pump(FluidHolder* src, FluidHolder* dst, double mass, double radius, double power, double l_per_rev, double friction, mode_t mode, double target) : src(src), @@ -71,7 +71,7 @@ void Pump::update(double dt) break; } - velocity += util::calc_work(dt * power * max_power, mass); + velocity += Util::calc_work(dt * power * max_power, mass); } else @@ -90,7 +90,7 @@ void Pump::update(double dt) double p_diff = (p_diff_1 + p_diff_2) / 2; double work = p_diff * dst_volume * 0.001 + get_rpm() / 60 * dt * friction; - velocity = std::max(velocity - util::calc_work(work, mass), 0.0); + velocity = std::max(velocity - Util::calc_work(work, mass), 0.0); flow = dst_volume / dt; } diff --git a/src/coolant/pump.hpp b/src/coolant/pump.hpp index b795d3a..d713a39 100644 --- a/src/coolant/pump.hpp +++ b/src/coolant/pump.hpp @@ -4,7 +4,7 @@ #include "fluid_holder.hpp" #include "../util/pid.hpp" -namespace sim::coolant +namespace Sim::Coolant { class Pump @@ -12,7 +12,7 @@ class Pump FluidHolder* const src; FluidHolder* const dst; - util::PID pid {1, 0, 100, 0, 0}; + Util::PID pid {1, 0, 100, 0, 0}; double flow = 0; // L/s double velocity = 0; // m/s diff --git a/src/coolant/sink.cpp b/src/coolant/sink.cpp index 002abe0..1e81da8 100644 --- a/src/coolant/sink.cpp +++ b/src/coolant/sink.cpp @@ -1,7 +1,7 @@ #include "sink.hpp" -using namespace sim::coolant; +using namespace Sim::Coolant; Sink::Sink(Fluid type, double heat, double pressure, double steam_density) : heat(heat), diff --git a/src/coolant/sink.hpp b/src/coolant/sink.hpp index 4a8a5f4..415d867 100644 --- a/src/coolant/sink.hpp +++ b/src/coolant/sink.hpp @@ -7,7 +7,7 @@ // can kinda just do anything. for example, get rid of steam to the "outside", // or pump in new coolant. -namespace sim::coolant +namespace Sim::Coolant { class Sink : public FluidHolder diff --git a/src/coolant/valve.cpp b/src/coolant/valve.cpp index 4ed9acf..c7b294d 100644 --- a/src/coolant/valve.cpp +++ b/src/coolant/valve.cpp @@ -6,7 +6,7 @@ #include #include -using namespace sim::coolant; +using namespace Sim::Coolant; Valve::Valve(FluidHolder* src, FluidHolder* dst, double state, double max) : src(src), dst(dst), max(max) { @@ -84,7 +84,7 @@ void Valve::update(double dt) mol = FluidHolder::calc_pressure_mol(src->get_heat_k(), src->get_gas_volume(), pressure1 - remove); - mass_a = src->get_air() - mol / util::constants::M_air; + mass_a = src->get_air() - mol / Util::Constants::M_air; mass_s = src->get_steam() - src->fluid.mol_to_g(mol); } @@ -95,7 +95,7 @@ void Valve::update(double dt) mol = FluidHolder::calc_pressure_mol(dst->get_heat_k(), dst->get_gas_volume(), pressure2 - remove); - mass_a = dst->get_air() - mol / util::constants::M_air; + mass_a = dst->get_air() - mol / Util::Constants::M_air; mass_s = dst->get_steam() - dst->fluid.mol_to_g(mol); } diff --git a/src/coolant/valve.hpp b/src/coolant/valve.hpp index 1d18609..6b9ef8c 100644 --- a/src/coolant/valve.hpp +++ b/src/coolant/valve.hpp @@ -4,7 +4,7 @@ #include "fluid_holder.hpp" #include "../util/pid.hpp" -namespace sim::coolant +namespace Sim::Coolant { class Valve @@ -21,7 +21,7 @@ class Valve bool auto_on = false; double auto_th = 0; // C - util::PID pid {1e-3, -1e-3, 100, 0, 0}; + Util::PID pid {1e-3, -1e-3, 100, 0, 0}; public: diff --git a/src/coolant/vapor_pressure.cpp b/src/coolant/vapor_pressure.cpp index 9ad7976..13894ff 100644 --- a/src/coolant/vapor_pressure.cpp +++ b/src/coolant/vapor_pressure.cpp @@ -3,7 +3,7 @@ #include -using namespace sim::coolant; +using namespace Sim::Coolant; double VaporPressure::calc_p(double t) const { diff --git a/src/coolant/vapor_pressure.hpp b/src/coolant/vapor_pressure.hpp index 429fb6d..76ef9a8 100644 --- a/src/coolant/vapor_pressure.hpp +++ b/src/coolant/vapor_pressure.hpp @@ -3,7 +3,7 @@ #include -namespace sim::coolant +namespace Sim::Coolant { struct VaporPressure diff --git a/src/electric/turbine.cpp b/src/electric/turbine.cpp index f23f5ea..09acf08 100644 --- a/src/electric/turbine.cpp +++ b/src/electric/turbine.cpp @@ -6,7 +6,7 @@ #include #include -using namespace sim::electric; +using namespace Sim::Electric; constexpr static double calc_cylinder(double h, double d) { @@ -15,19 +15,19 @@ constexpr static double calc_cylinder(double h, double d) return M_PI * r * r * h * 1000; } -Turbine::Turbine(coolant::Fluid type, coolant::Condenser* condenser, double length, double diameter, double mass) : +Turbine::Turbine(Coolant::Fluid type, Coolant::Condenser* condenser, double length, double diameter, double mass) : length(length), diameter(diameter), condenser(condenser), - sim::coolant::FluidHolder(type, calc_cylinder(length, diameter), mass) + Sim::Coolant::FluidHolder(type, calc_cylinder(length, diameter), mass) { } -Turbine::Turbine(const Json::Value& node, coolant::Condenser* condenser) : +Turbine::Turbine(const Json::Value& node, Coolant::Condenser* condenser) : condenser(condenser), length(node["length"].asDouble()), diameter(node["diameter"].asDouble()), friction(node["friction"].asDouble()), - sim::coolant::FluidHolder(node) + Sim::Coolant::FluidHolder(node) { velocity = node["velocity"].asDouble(); phase = node["phase"].asDouble(); @@ -37,15 +37,15 @@ Turbine::Turbine(const Json::Value& node, coolant::Condenser* condenser) : void Turbine::update(double dt) { double work = get_rpm() / 60 * dt * friction; - phase = std::fmod(phase + util::map( get_rpm(), 0, 60, 0, 2 * M_PI ) * dt, 2 * M_PI); + phase = std::fmod(phase + Util::map( get_rpm(), 0, 60, 0, 2 * M_PI ) * dt, 2 * M_PI); // do energy transfer stuff here if(breaker_closed) { - double r_diff = util::map(get_phase_diff(), -M_PI, M_PI, -30, 30); + double r_diff = Util::map(get_phase_diff(), -M_PI, M_PI, -30, 30); double w = r_diff * 1e6; - double v2 = util::mod((velocity - 3600) / 60 + 30, 60) - 30; + double v2 = Util::mod((velocity - 3600) / 60 + 30, 60) - 30; double w2 = w * w * v2; energy_generated = w2 * extra_mass; @@ -69,13 +69,13 @@ double Turbine::get_rpm() const double Turbine::get_phase_diff() const { double phase_g = std::fmod(System::active.clock * 60, 1) * 2 * M_PI; - return util::mod(phase - phase_g + M_PI, 2*M_PI) - M_PI; + return Util::mod(phase - phase_g + M_PI, 2*M_PI) - M_PI; } void Turbine::add_gas(double steam, double air, double t) { double joules = (steam + air) * fluid.jPg; - velocity = std::max(velocity + util::calc_work(joules, extra_mass), 0.0); + velocity = std::max(velocity + Util::calc_work(joules, extra_mass), 0.0); condenser->add_gas(steam, air, t); } diff --git a/src/electric/turbine.hpp b/src/electric/turbine.hpp index fb2e0e1..dd4a674 100644 --- a/src/electric/turbine.hpp +++ b/src/electric/turbine.hpp @@ -4,12 +4,12 @@ #include "../coolant/fluid_holder.hpp" #include "../coolant/condenser.hpp" -namespace sim::electric +namespace Sim::Electric { -class Turbine : public sim::coolant::FluidHolder +class Turbine : public Sim::Coolant::FluidHolder { - coolant::Condenser* const condenser; + Coolant::Condenser* const condenser; const double length; const double diameter; @@ -23,8 +23,8 @@ public: bool breaker_closed = false; - Turbine(coolant::Fluid type, coolant::Condenser* condenser, double length, double diameter, double mass); - Turbine(const Json::Value& node, coolant::Condenser* condenser); + Turbine(Coolant::Fluid type, Coolant::Condenser* condenser, double length, double diameter, double mass); + Turbine(const Json::Value& node, Coolant::Condenser* condenser); void update(double dt); double get_rpm() const; diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 5675744..1a8ad83 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -13,7 +13,7 @@ #include #include -using namespace sim::graphics; +using namespace Sim::Graphics; static bool on_ground = false; static double yaw = 0, pitch = 0; @@ -22,7 +22,7 @@ static glm::vec<3, double> velocity(0); static Mesh collision_scene; static glm::mat4 camera_mat; -Json::Value camera::serialize() +Json::Value Camera::serialize() { Json::Value node; @@ -39,7 +39,7 @@ Json::Value camera::serialize() return node; } -void camera::load(const Json::Value& node) +void Camera::load(const Json::Value& node) { on_ground = node["on_ground"].asBool(); yaw = node["yaw"].asDouble(); @@ -52,7 +52,7 @@ void camera::load(const Json::Value& node) velocity[2] = node["velocity"]["z"].asDouble(); } -void camera::rotate(double y, double p) +void Camera::rotate(double y, double p) { yaw += y * 0.05; pitch -= p * 0.05; @@ -61,43 +61,43 @@ void camera::rotate(double y, double p) if(pitch > 180) pitch = 180; } -void camera::move(double xoff, double yoff, double zoff) +void Camera::move(double xoff, double yoff, double zoff) { pos.x += xoff; pos.y += yoff; pos.z += zoff; } -glm::vec<3, double> camera::get_normal() +glm::vec<3, double> Camera::get_normal() { glm::mat<3, 3, double> mat(camera_mat); return glm::vec<3, double>(0, 0, -1) * mat; } -glm::vec<3, double> camera::get_pos() +glm::vec<3, double> Camera::get_pos() { return pos; } -void camera::init() +void Camera::init() { collision_scene.load_model("../assets/model", "scene_collisions.stl"); } -void camera::update(double dt) +void Camera::update(double dt) { glm::vec<2, double> off(0, 0); double m = 30; - if(keyboard::is_pressed(GLFW_KEY_W)) + if(Keyboard::is_pressed(GLFW_KEY_W)) off.y += 1; - if(keyboard::is_pressed(GLFW_KEY_S)) + if(Keyboard::is_pressed(GLFW_KEY_S)) off.y -= 1; - if(keyboard::is_pressed(GLFW_KEY_A)) + if(Keyboard::is_pressed(GLFW_KEY_A)) off.x -= 1; - if(keyboard::is_pressed(GLFW_KEY_D)) + if(Keyboard::is_pressed(GLFW_KEY_D)) off.x += 1; - if(keyboard::is_pressed(GLFW_KEY_LEFT_SHIFT)) + if(Keyboard::is_pressed(GLFW_KEY_LEFT_SHIFT)) m *= 1.5; if(off.x != 0 || off.y != 0) off = glm::normalize(off); @@ -118,7 +118,7 @@ void camera::update(double dt) velocity.y += rotated.y * m * dt; } - if(on_ground && keyboard::is_pressed(GLFW_KEY_SPACE)) + if(on_ground && Keyboard::is_pressed(GLFW_KEY_SPACE)) { velocity.z += 3.5; } @@ -139,7 +139,7 @@ void camera::update(double dt) camera_mat = glm::translate(camera_mat, glm::vec3(-pos.x, -pos.y, -pos.z)); } -glm::mat4 camera::get_matrix() +glm::mat4 Camera::get_matrix() { return camera_mat; } diff --git a/src/graphics/camera.hpp b/src/graphics/camera.hpp index 2bb1b28..041b7a4 100644 --- a/src/graphics/camera.hpp +++ b/src/graphics/camera.hpp @@ -6,7 +6,7 @@ #include "../system.hpp" -namespace sim::graphics::camera +namespace Sim::Graphics::Camera { glm::mat4 get_matrix(); diff --git a/src/graphics/input/focus.cpp b/src/graphics/input/focus.cpp index 826f4e7..ee0b17c 100644 --- a/src/graphics/input/focus.cpp +++ b/src/graphics/input/focus.cpp @@ -14,18 +14,18 @@ #include #include -using namespace sim::graphics; +using namespace Sim::Graphics; static glm::vec<3, double> trigger_near; static glm::vec<3, double> trigger_far; -static std::vector> stack; -static std::unique_ptr state = nullptr; +static std::vector> stack; +static std::unique_ptr state = nullptr; static bool mouse_visible = false; static bool mouse_locked = false; static bool triggered = false; -void focus::on_keypress(int key, int sc, int action, int mods) +void Focus::on_keypress(int key, int sc, int action, int mods) { if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { @@ -46,7 +46,7 @@ void focus::on_keypress(int key, int sc, int action, int mods) } } -void focus::on_mouse_button(int button, int action, int mods) +void Focus::on_mouse_button(int button, int action, int mods) { if(state) { @@ -58,27 +58,27 @@ void focus::on_mouse_button(int button, int action, int mods) if(is_mouse_locked() && mouse_visible) { double mx, my; - mouse::get(mx, my); + Mouse::get(mx, my); - glm::vec2 wsize = resize::get_size(); + glm::vec2 wsize = Resize::get_size(); glm::vec4 viewport = glm::vec4(0, 0, wsize); glm::vec2 mouse(mx, wsize.y - my); - trigger_near = glm::unProject(glm::vec3(mouse, -1), camera::get_matrix(), window::projection_matrix, viewport); - trigger_far = glm::unProject(glm::vec3(mouse, 1), camera::get_matrix(), window::projection_matrix, viewport); + trigger_near = glm::unProject(glm::vec3(mouse, -1), Camera::get_matrix(), Window::projection_matrix, viewport); + trigger_far = glm::unProject(glm::vec3(mouse, 1), Camera::get_matrix(), Window::projection_matrix, viewport); triggered = true; } else if(!mouse_visible) { - trigger_near = camera::get_pos(); - trigger_far = trigger_near + camera::get_normal(); + trigger_near = Camera::get_pos(); + trigger_far = trigger_near + Camera::get_normal(); triggered = true; } } } -void focus::on_cursor_pos(double x, double y) +void Focus::on_cursor_pos(double x, double y) { if(state) { @@ -86,7 +86,7 @@ void focus::on_cursor_pos(double x, double y) } } -void focus::on_charcode(unsigned int c) +void Focus::on_charcode(unsigned int c) { if(state) { @@ -94,17 +94,17 @@ void focus::on_charcode(unsigned int c) } } -glm::vec<3, double> focus::get_trigger_near() +glm::vec<3, double> Focus::get_trigger_near() { return trigger_near; } -glm::vec<3, double> focus::get_trigger_far() +glm::vec<3, double> Focus::get_trigger_far() { return trigger_far; } -void focus::update(double dt) +void Focus::update(double dt) { triggered = false; @@ -119,12 +119,12 @@ void focus::update(double dt) { if(c) { - mouse::show_cursor(); + Mouse::show_cursor(); } else { - mouse::hide_cursor(); + Mouse::hide_cursor(); } mouse_visible = c; @@ -136,7 +136,7 @@ void focus::update(double dt) } } -void focus::render_ui() +void Focus::render_ui() { if(state) { @@ -144,7 +144,7 @@ void focus::render_ui() } } -void focus::render() +void Focus::render() { if(state) { @@ -152,12 +152,12 @@ void focus::render() } } -bool focus::is_focused() +bool Focus::is_focused() { return (state != nullptr); } -void focus::clear_focus() +void Focus::clear_focus() { state = nullptr; @@ -168,18 +168,18 @@ void focus::clear_focus() } } -bool focus::is_mouse_locked() +bool Focus::is_mouse_locked() { return is_focused() || mouse_locked; } -void focus::clear_mouse_locked() +void Focus::clear_mouse_locked() { mouse_locked = false; clear_focus(); } -void focus::set(std::unique_ptr f) +void Focus::set(std::unique_ptr f) { if(state != nullptr) { @@ -189,7 +189,7 @@ void focus::set(std::unique_ptr f) state = std::move(f); } -bool focus::is_triggered() +bool Focus::is_triggered() { return triggered; } diff --git a/src/graphics/input/focus.hpp b/src/graphics/input/focus.hpp index 9534e85..381d340 100644 --- a/src/graphics/input/focus.hpp +++ b/src/graphics/input/focus.hpp @@ -5,7 +5,7 @@ #include -namespace sim::graphics::focus +namespace Sim::Graphics::Focus { struct Focus diff --git a/src/graphics/input/keyboard.cpp b/src/graphics/input/keyboard.cpp index fcf8bf6..b8cb9d7 100644 --- a/src/graphics/input/keyboard.cpp +++ b/src/graphics/input/keyboard.cpp @@ -11,7 +11,7 @@ #include "../camera.hpp" #include "../../system.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static std::unordered_map pressed; @@ -19,7 +19,7 @@ static void cb_keypress(GLFWwindow* win, int key, int sc, int action, int mods) { if(key == GLFW_KEY_F11 && action == GLFW_RELEASE) { - resize::toggle_fullscreen(); + Resize::toggle_fullscreen(); } if(action == GLFW_PRESS) @@ -29,28 +29,28 @@ static void cb_keypress(GLFWwindow* win, int key, int sc, int action, int mods) switch(key) { case GLFW_KEY_1: - sim::System::active.speed = 1; // 1 s/s + Sim::System::active.speed = 1; // 1 s/s break; case GLFW_KEY_2: - sim::System::active.speed = 10; // 10 s/s + Sim::System::active.speed = 10; // 10 s/s break; case GLFW_KEY_3: - sim::System::active.speed = 60; // 1 min/s + Sim::System::active.speed = 60; // 1 min/s break; case GLFW_KEY_4: - sim::System::active.speed = 600; // 10 min/s + Sim::System::active.speed = 600; // 10 min/s break; case GLFW_KEY_5: - sim::System::active.speed = 3600; // 1 h/s + Sim::System::active.speed = 3600; // 1 h/s break; case GLFW_KEY_6: - sim::System::active.speed = 43200; // 12 h/s + Sim::System::active.speed = 43200; // 12 h/s break; case GLFW_KEY_O: - sim::System::save(); + Sim::System::save(); break; case GLFW_KEY_L: - sim::System::load(); + Sim::System::load(); break; } } @@ -60,17 +60,17 @@ static void cb_keypress(GLFWwindow* win, int key, int sc, int action, int mods) pressed[key] = false; } - focus::on_keypress(key, sc, action, mods); + Focus::on_keypress(key, sc, action, mods); } static void cb_charcode(GLFWwindow* win, unsigned int code) { - focus::on_charcode(code); + Focus::on_charcode(code); } -bool keyboard::is_pressed(int key) +bool Keyboard::is_pressed(int key) { - if(focus::is_mouse_locked()) + if(Focus::is_mouse_locked()) { return false; } @@ -88,9 +88,9 @@ bool keyboard::is_pressed(int key) } } -void keyboard::init() +void Keyboard::init() { - GLFWwindow* win = window::get_window(); + GLFWwindow* win = Window::get_window(); glfwSetKeyCallback(win, cb_keypress); glfwSetCharCallback(win, cb_charcode); } diff --git a/src/graphics/input/keyboard.hpp b/src/graphics/input/keyboard.hpp index 9762383..44a4e51 100644 --- a/src/graphics/input/keyboard.hpp +++ b/src/graphics/input/keyboard.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::graphics::keyboard +namespace Sim::Graphics::Keyboard { void init(); diff --git a/src/graphics/input/mouse.cpp b/src/graphics/input/mouse.cpp index 4403e11..375a0b9 100644 --- a/src/graphics/input/mouse.cpp +++ b/src/graphics/input/mouse.cpp @@ -7,20 +7,20 @@ #include "../window.hpp" #include "../camera.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static double xpos = 0, ypos = 0; static void cb_cursor_pos(GLFWwindow* win, double x, double y) { - if(focus::is_mouse_locked()) + if(Focus::is_mouse_locked()) { - focus::on_cursor_pos(x - xpos, y - ypos); + Focus::on_cursor_pos(x - xpos, y - ypos); } else { - camera::rotate(x - xpos, y - ypos); + Camera::rotate(x - xpos, y - ypos); } xpos = x; @@ -29,41 +29,41 @@ static void cb_cursor_pos(GLFWwindow* win, double x, double y) void cb_mouse_button(GLFWwindow* window, int button, int action, int mods) { - focus::on_mouse_button(button, action, mods); + Focus::on_mouse_button(button, action, mods); } -void mouse::get(double& x, double& y) +void Mouse::get(double& x, double& y) { x = xpos; y = ypos; } -glm::vec2 mouse::get() +glm::vec2 Mouse::get() { return {xpos, ypos}; } -void mouse::show_cursor() +void Mouse::show_cursor() { double x, y; - GLFWwindow* win = window::get_window(); + GLFWwindow* win = Window::get_window(); glfwSetInputMode(win, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwGetCursorPos(win, &x, &y); cb_cursor_pos(win, x, y); } -void mouse::hide_cursor() +void Mouse::hide_cursor() { double x, y; - GLFWwindow* win = window::get_window(); + GLFWwindow* win = Window::get_window(); glfwSetInputMode(win, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwGetCursorPos(win, &x, &y); cb_cursor_pos(win, x, y); } -void mouse::init() +void Mouse::init() { - GLFWwindow* win = window::get_window(); + GLFWwindow* win = Window::get_window(); glfwSetCursorPosCallback(win, cb_cursor_pos); glfwSetMouseButtonCallback(win, cb_mouse_button); glfwSetInputMode(win, GLFW_CURSOR, GLFW_CURSOR_DISABLED); diff --git a/src/graphics/input/mouse.hpp b/src/graphics/input/mouse.hpp index 8d2dc86..4cf0413 100644 --- a/src/graphics/input/mouse.hpp +++ b/src/graphics/input/mouse.hpp @@ -3,7 +3,7 @@ #include -namespace sim::graphics::mouse +namespace Sim::Graphics::Mouse { void init(); diff --git a/src/graphics/locations.cpp b/src/graphics/locations.cpp index 06b19a3..b049123 100644 --- a/src/graphics/locations.cpp +++ b/src/graphics/locations.cpp @@ -2,9 +2,9 @@ #include "locations.hpp" #include -using namespace sim::graphics; +using namespace Sim::Graphics; -const glm::mat4 locations::monitors[7] = { +const glm::mat4 Locations::monitors[7] = { ( glm::translate(glm::mat4(1), glm::vec3(-2.949, -1.7778 + 0.05, 3 - 0.05)) * glm::rotate(glm::mat4(1), glm::radians(-90), glm::vec3(1, 0, 0)) * diff --git a/src/graphics/locations.hpp b/src/graphics/locations.hpp index 8ad8f46..471a29f 100644 --- a/src/graphics/locations.hpp +++ b/src/graphics/locations.hpp @@ -3,7 +3,7 @@ #include -namespace sim::graphics::locations +namespace Sim::Graphics::Locations { extern const glm::mat4 monitors[7]; diff --git a/src/graphics/mesh/arrays.cpp b/src/graphics/mesh/arrays.cpp index 4d6978f..bb8d7e9 100644 --- a/src/graphics/mesh/arrays.cpp +++ b/src/graphics/mesh/arrays.cpp @@ -8,7 +8,7 @@ #include "arrays.hpp" #include "font.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static unsigned int vao, vbo, ebo; @@ -17,7 +17,7 @@ static void* ptr_diff(void* a, void* b) return (void*)((size_t)a - (size_t)b); } -void arrays::vertex_attrib_pointers() +void Arrays::vertex_attrib_pointers() { vertex v; @@ -34,7 +34,7 @@ void arrays::vertex_attrib_pointers() glEnableVertexAttribArray(3); } -glm::mat4 arrays::colour(glm::vec4 c) +glm::mat4 Arrays::colour(glm::vec4 c) { return glm::mat4({ c.r, c.g, c.b, c.a, diff --git a/src/graphics/mesh/arrays.hpp b/src/graphics/mesh/arrays.hpp index 1b6f41c..d780b0b 100644 --- a/src/graphics/mesh/arrays.hpp +++ b/src/graphics/mesh/arrays.hpp @@ -3,7 +3,7 @@ #include -namespace sim::graphics::arrays +namespace Sim::Graphics::Arrays { struct vertex diff --git a/src/graphics/mesh/font.cpp b/src/graphics/mesh/font.cpp index 3d7560f..97a5646 100644 --- a/src/graphics/mesh/font.cpp +++ b/src/graphics/mesh/font.cpp @@ -13,7 +13,7 @@ #include "arrays.hpp" #include "font.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; struct character { @@ -25,7 +25,7 @@ struct character static character chars[128]; -void font::init() +void Font::init() { FT_Library ft; FT_Face face; @@ -95,7 +95,7 @@ void font::init() void Mesh::load_text(const char* text, double size) { - std::vector vertices; + std::vector vertices; std::vector indices; float x = 0, y = size; @@ -136,10 +136,10 @@ void Mesh::load_text(const char* text, double size) float ex = sx + ch.size.x * size; float ey = sy + ch.size.y * size; - vertices.push_back(arrays::vertex(ch.handle, {0, 0}, {sx, sy, 0, 1}, {0, 0, -1})); - vertices.push_back(arrays::vertex(ch.handle, {0, 1}, {sx, ey, 0, 1}, {0, 0, -1})); - vertices.push_back(arrays::vertex(ch.handle, {1, 0}, {ex, sy, 0, 1}, {0, 0, -1})); - vertices.push_back(arrays::vertex(ch.handle, {1, 1}, {ex, ey, 0, 1}, {0, 0, -1})); + vertices.push_back(Arrays::vertex(ch.handle, {0, 0}, {sx, sy, 0, 1}, {0, 0, -1})); + vertices.push_back(Arrays::vertex(ch.handle, {0, 1}, {sx, ey, 0, 1}, {0, 0, -1})); + vertices.push_back(Arrays::vertex(ch.handle, {1, 0}, {ex, sy, 0, 1}, {0, 0, -1})); + vertices.push_back(Arrays::vertex(ch.handle, {1, 1}, {ex, ey, 0, 1}, {0, 0, -1})); indices.insert(indices.end(), &index[0], &index[6]); at += 4; diff --git a/src/graphics/mesh/font.hpp b/src/graphics/mesh/font.hpp index 52b6ee0..40df8ab 100644 --- a/src/graphics/mesh/font.hpp +++ b/src/graphics/mesh/font.hpp @@ -6,7 +6,7 @@ #include #include -namespace sim::graphics::font +namespace Sim::Graphics::Font { void init(); diff --git a/src/graphics/mesh/glmesh.cpp b/src/graphics/mesh/glmesh.cpp index 8d6476b..06ca8dd 100644 --- a/src/graphics/mesh/glmesh.cpp +++ b/src/graphics/mesh/glmesh.cpp @@ -7,7 +7,7 @@ #include "../shader.hpp" #include "../camera.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; constexpr static void init(GLMesh* m) { @@ -24,7 +24,7 @@ constexpr static void init(GLMesh* m) glBindBuffer(GL_ARRAY_BUFFER, m->vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m->ebo); - arrays::vertex_attrib_pointers(); + Arrays::vertex_attrib_pointers(); } GLMesh::GLMesh(GLMesh&& o) @@ -59,8 +59,8 @@ void GLMesh::bind() void GLMesh::uniform() { - glUniformMatrix4fv(shader::gl_model, 1, false, &model_matrix[0][0]); - glUniformMatrix4fv(shader::gl_tex_mat, 1, false, &colour_matrix[0][0]); + glUniformMatrix4fv(Shader::gl_model, 1, false, &model_matrix[0][0]); + glUniformMatrix4fv(Shader::gl_tex_mat, 1, false, &colour_matrix[0][0]); } void GLMesh::set(const Mesh& m, int mode) diff --git a/src/graphics/mesh/glmesh.hpp b/src/graphics/mesh/glmesh.hpp index 0b016bd..ce8a6bc 100644 --- a/src/graphics/mesh/glmesh.hpp +++ b/src/graphics/mesh/glmesh.hpp @@ -8,7 +8,7 @@ #include -namespace sim::graphics +namespace Sim::Graphics { struct GLMesh diff --git a/src/graphics/mesh/mesh.cpp b/src/graphics/mesh/mesh.cpp index 5e25142..8dc2287 100644 --- a/src/graphics/mesh/mesh.cpp +++ b/src/graphics/mesh/mesh.cpp @@ -8,7 +8,7 @@ #include -using namespace sim::graphics; +using namespace Sim::Graphics; void Mesh::add(const Mesh& o, glm::mat4 mat) { @@ -20,7 +20,7 @@ void Mesh::add(const Mesh& o, glm::mat4 mat) for(unsigned int i = 0; i < o.vertices.size(); i++) { - arrays::vertex v = o.vertices[i]; + Arrays::vertex v = o.vertices[i]; v.normal = mat3 * v.normal; v.pos = mat * v.pos; vertices.push_back(v); @@ -32,7 +32,7 @@ void Mesh::add(const Mesh& o, glm::mat4 mat) } } -void Mesh::set_vertices(const arrays::vertex* data, size_t size) +void Mesh::set_vertices(const Arrays::vertex* data, size_t size) { vertices.clear(); vertices.reserve(size); @@ -98,10 +98,10 @@ bool ray_intersects_triangle(vec3 ray_origin, bool Mesh::check_focus(double len) const { - auto near = focus::get_trigger_near(); - auto far = focus::get_trigger_far(); + auto near = Focus::get_trigger_near(); + auto far = Focus::get_trigger_far(); - return focus::is_triggered() && check_intersect(near, glm::normalize(far - near) * len); + return Focus::is_triggered() && check_intersect(near, glm::normalize(far - near) * len); } bool Mesh::check_focus() const diff --git a/src/graphics/mesh/mesh.hpp b/src/graphics/mesh/mesh.hpp index b3cc6b5..c7bafa4 100644 --- a/src/graphics/mesh/mesh.hpp +++ b/src/graphics/mesh/mesh.hpp @@ -10,17 +10,17 @@ #include "arrays.hpp" -namespace sim::graphics +namespace Sim::Graphics { struct Mesh { - std::vector vertices; + std::vector vertices; std::vector indices; constexpr Mesh() { } - void set_vertices(const arrays::vertex* data, size_t size); + void set_vertices(const Arrays::vertex* data, size_t size); void set_indices(const unsigned int* data, size_t size); void load_model(std::string base, std::string path); void load_model(std::string path) { load_model(".", path); } diff --git a/src/graphics/mesh/model.cpp b/src/graphics/mesh/model.cpp index d8097bc..5926457 100644 --- a/src/graphics/mesh/model.cpp +++ b/src/graphics/mesh/model.cpp @@ -15,14 +15,14 @@ #include "arrays.hpp" #include "texture.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; struct proc_state { unsigned int offset = 0; std::string base; - std::vector vertices; + std::vector vertices; std::vector indices; std::unordered_map handles; }; @@ -53,10 +53,10 @@ static unsigned int proc_texture(const proc_state& state, aiMaterial* mat, const std::string filename(str.C_Str()); std::replace(filename.begin(), filename.end(), '\\', '/'); - return texture::load(state.base + "/" + filename); + return Texture::load(state.base + "/" + filename); } - return texture::handle_white; + return Texture::handle_white; } static void proc_mesh(proc_state& state, glm::mat4 mat, aiMesh* mesh, const aiScene* scene) @@ -68,7 +68,7 @@ static void proc_mesh(proc_state& state, glm::mat4 mat, aiMesh* mesh, const aiSc for(unsigned int i = 0; i < mesh->mNumVertices; i++) { - arrays::vertex vertex; + Arrays::vertex vertex; auto [x, y, z] = mesh->mVertices[i]; vertex.pos = glm::vec4(x, y, z, 1) * mat; @@ -130,7 +130,7 @@ static unsigned int proc_embedded_texture(aiTexture* tex) if(tex->mHeight == 0) { - return texture::load_mem((unsigned char*)tex->pcData, tex->mWidth); + return Texture::load_mem((unsigned char*)tex->pcData, tex->mWidth); } // swizzle each pixel to get RGBA @@ -140,7 +140,7 @@ static unsigned int proc_embedded_texture(aiTexture* tex) tex->pcData[i] = {t.r, t.g, t.b, t.a}; } - return texture::load_mem((unsigned char*)tex->pcData, tex->mWidth, tex->mHeight, 4); + return Texture::load_mem((unsigned char*)tex->pcData, tex->mWidth, tex->mHeight, 4); } void Mesh::load_model(std::string base, std::string filename) diff --git a/src/graphics/mesh/texture.cpp b/src/graphics/mesh/texture.cpp index 77cd633..7ea9392 100644 --- a/src/graphics/mesh/texture.cpp +++ b/src/graphics/mesh/texture.cpp @@ -8,18 +8,18 @@ #include "texture.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static std::unordered_map loaded; -unsigned int texture::handle_white; +unsigned int Texture::handle_white; -void texture::init() +void Texture::init() { unsigned char pixels[] = {255, 255, 255, 255}; handle_white = load_mem(pixels, 1, 1, 4); } -unsigned int texture::load_mem(const unsigned char* data, int width, int height, int channels) +unsigned int Texture::load_mem(const unsigned char* data, int width, int height, int channels) { if(!data) { @@ -64,7 +64,7 @@ unsigned int texture::load_mem(const unsigned char* data, int width, int height, return handle; } -unsigned int texture::load_mem(const unsigned char* filedata, size_t len) +unsigned int Texture::load_mem(const unsigned char* filedata, size_t len) { int width, height, channels; unsigned char* data = stbi_load_from_memory(filedata, len, &width, &height, &channels, 0); @@ -73,7 +73,7 @@ unsigned int texture::load_mem(const unsigned char* filedata, size_t len) return handle; } -unsigned int texture::load(std::string path) +unsigned int Texture::load(std::string path) { const auto it = loaded.find(path); diff --git a/src/graphics/mesh/texture.hpp b/src/graphics/mesh/texture.hpp index 3313fea..686a917 100644 --- a/src/graphics/mesh/texture.hpp +++ b/src/graphics/mesh/texture.hpp @@ -3,7 +3,7 @@ #include -namespace sim::graphics::texture +namespace Sim::Graphics::Texture { extern unsigned int handle_white; diff --git a/src/graphics/monitor/core.cpp b/src/graphics/monitor/core.cpp index 94886d5..1f9e709 100644 --- a/src/graphics/monitor/core.cpp +++ b/src/graphics/monitor/core.cpp @@ -15,14 +15,14 @@ #include #include -using namespace sim::graphics; -using namespace sim::graphics::monitor; +using namespace Sim::Graphics; +using namespace Sim::Graphics::Monitor; static void set_all(bool state) { - for(int i = 0; i < sim::System::active.reactor->rods.size(); i++) + for(int i = 0; i < Sim::System::active.reactor->rods.size(); i++) { - sim::reactor::Rod* r = sim::System::active.reactor->rods[i].get(); + Sim::Reactor::Rod* r = Sim::System::active.reactor->rods[i].get(); if(r->should_select()) { @@ -31,7 +31,7 @@ static void set_all(bool state) } } -struct core_monitor : public focus::Focus +struct core_monitor : public Focus::Focus { virtual void on_keypress(int key, int sc, int action, int mods) { @@ -40,7 +40,7 @@ struct core_monitor : public focus::Focus return; } - sim::System& sys = sim::System::active; + Sim::System& sys = Sim::System::active; switch(key) { @@ -72,23 +72,23 @@ struct core_monitor : public focus::Focus } }; -struct core_joystick : public focus::Focus +struct core_joystick : public Focus::Focus { virtual void on_cursor_pos(double x, double y) { - sim::System::active.reactor->add_rod_speed(y * 1e-6); + Sim::System::active.reactor->add_rod_speed(y * 1e-6); } virtual ~core_joystick() { - sim::System::active.reactor->reset_rod_speed(); + Sim::System::active.reactor->reset_rod_speed(); } virtual void on_mouse_button(int button, int action, int mods) { if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) { - focus::clear_focus(); + Focus::clear_focus(); } } @@ -104,21 +104,21 @@ Core::Core() void Core::init() { - mesh1.model_matrix = locations::monitors[2]; - mesh1.colour_matrix = arrays::colour({1, 1, 1, 1}); + mesh1.model_matrix = Locations::monitors[2]; + mesh1.colour_matrix = Arrays::colour({1, 1, 1, 1}); - sim::graphics::Mesh rmesh; + Sim::Graphics::Mesh rmesh; rmesh.load_text("Reactor Core", 0.04); mesh1.bind(); mesh1.set(rmesh, GL_STATIC_DRAW); unsigned int indices[] = {0, 1, 3, 0, 3, 2}; - arrays::vertex vertices[] = { - {texture::handle_white, {0, 0}, {-0.75, -0.75, 0, 1}, {0, 0, -1}}, - {texture::handle_white, {0, 1}, {-0.75, 0.75, 0, 1}, {0, 0, -1}}, - {texture::handle_white, {1, 0}, { 0.75, -0.75, 0, 1}, {0, 0, -1}}, - {texture::handle_white, {1, 1}, { 0.75, 0.75, 0, 1}, {0, 0, -1}}, + Arrays::vertex vertices[] = { + {Texture::handle_white, {0, 0}, {-0.75, -0.75, 0, 1}, {0, 0, -1}}, + {Texture::handle_white, {0, 1}, {-0.75, 0.75, 0, 1}, {0, 0, -1}}, + {Texture::handle_white, {1, 0}, { 0.75, -0.75, 0, 1}, {0, 0, -1}}, + {Texture::handle_white, {1, 1}, { 0.75, 0.75, 0, 1}, {0, 0, -1}}, }; rmesh.set_indices(indices, 6); @@ -142,12 +142,12 @@ void Core::init() void Core::update(double dt) { - sim::System& sys = sim::System::active; + Sim::System& sys = Sim::System::active; if(m_monitor.check_focus()) - focus::set(std::make_unique()); + Focus::set(std::make_unique()); if(m_joystick.check_focus()) - focus::set(std::make_unique()); + Focus::set(std::make_unique()); if(m_scram.check_focus()) sys.reactor->scram(); if(m_buttons[0].check_focus()) @@ -170,7 +170,7 @@ void Core::update(double dt) void Core::render() { - sim::System& sys = sim::System::active; + Sim::System& sys = Sim::System::active; double step = 1 / (sys.vessel->diameter / sys.reactor->cell_width * 0.8); double sx = 0.5 - (sys.reactor->width - 1) * step / 2.0; @@ -195,7 +195,7 @@ void Core::render() double ox = sx + x * step; double oy = sy + y * step; - reactor::Rod* r = sys.reactor->rods[i].get(); + Reactor::Rod* r = sys.reactor->rods[i].get(); if(!r->should_display()) { @@ -213,14 +213,14 @@ void Core::render() glm::mat4 mat = mesh1.model_matrix * glm::translate(glm::mat4(1), glm::vec3(ox, oy, 0)) * mat_scale; mesh2.model_matrix = mat; - mesh2.colour_matrix = arrays::colour(colour_heat); + mesh2.colour_matrix = Arrays::colour(colour_heat); mesh2.uniform(); mesh2.render(); if(sys.reactor->cursor == i) { mesh2.model_matrix = mat * mat_cursor; - mesh2.colour_matrix = arrays::colour({1, 0, 0, 1}); + mesh2.colour_matrix = Arrays::colour({1, 0, 0, 1}); mesh2.uniform(); mesh2.render(); } @@ -228,7 +228,7 @@ void Core::render() if(r->selected) { mesh2.model_matrix = mat * mat_select; - mesh2.colour_matrix = arrays::colour({1, 1, 0, 1}); + mesh2.colour_matrix = Arrays::colour({1, 1, 0, 1}); mesh2.uniform(); mesh2.render(); } @@ -236,7 +236,7 @@ void Core::render() if(colour_spec[3] != 0) { mesh2.model_matrix = mat * mat_spec; - mesh2.colour_matrix = arrays::colour(colour_spec); + mesh2.colour_matrix = Arrays::colour(colour_spec); mesh2.uniform(); mesh2.render(); } diff --git a/src/graphics/monitor/core.hpp b/src/graphics/monitor/core.hpp index db20a98..902d4ef 100644 --- a/src/graphics/monitor/core.hpp +++ b/src/graphics/monitor/core.hpp @@ -3,17 +3,17 @@ #include "../mesh/glmesh.hpp" -namespace sim::graphics::monitor +namespace Sim::Graphics::monitor { class Core { - sim::graphics::GLMesh mesh1, mesh2; + Sim::Graphics::GLMesh mesh1, mesh2; - sim::graphics::Mesh m_monitor; - sim::graphics::Mesh m_buttons[9]; - sim::graphics::Mesh m_joystick; - sim::graphics::Mesh m_scram; + Sim::Graphics::Mesh m_monitor; + Sim::Graphics::Mesh m_buttons[9]; + Sim::Graphics::Mesh m_joystick; + Sim::Graphics::Mesh m_scram; public: diff --git a/src/graphics/monitor/primary_loop.cpp b/src/graphics/monitor/primary_loop.cpp index 8fd5727..9d74389 100644 --- a/src/graphics/monitor/primary_loop.cpp +++ b/src/graphics/monitor/primary_loop.cpp @@ -12,14 +12,14 @@ #include #include -using namespace sim::graphics; -using namespace sim::graphics::monitor; +using namespace Sim::Graphics; +using namespace Sim::Graphics::Monitor; -struct valve_joystick : public focus::Focus +struct valve_joystick : public Focus::Focus { - sim::coolant::Valve* active; + Sim::Coolant::Valve* active; - valve_joystick(sim::coolant::Valve* v) : active(v) + valve_joystick(Sim::Coolant::Valve* v) : active(v) { } @@ -38,7 +38,7 @@ struct valve_joystick : public focus::Focus { if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) { - focus::clear_focus(); + Focus::clear_focus(); } } @@ -56,7 +56,7 @@ PrimaryLoop::PrimaryLoop() void PrimaryLoop::init() { - mesh1.model_matrix = locations::monitors[3]; + mesh1.model_matrix = Locations::monitors[3]; mesh2.model_matrix = glm::translate(mesh1.model_matrix, glm::vec3(0.5, 0, 0)); mesh1.colour_matrix = mesh2.colour_matrix = { @@ -67,7 +67,7 @@ void PrimaryLoop::init() }; std::stringstream ss; - sim::graphics::Mesh rmesh; + Sim::Graphics::Mesh rmesh; ss << "Turbine Bypass Valve\n\n"; ss << "Opened\nFlow\nSetpoint\n\n"; @@ -106,13 +106,13 @@ void PrimaryLoop::init() void PrimaryLoop::update(double dt) { - System& sys = sim::System::active; + System& sys = Sim::System::active; clock_now += dt; if(clock_at + 1.0/30.0 < clock_now) { std::stringstream ss; - sim::graphics::Mesh rmesh; + Sim::Graphics::Mesh rmesh; clock_at += 1.0/30.0; ss << "\n\n"; @@ -159,9 +159,9 @@ void PrimaryLoop::update(double dt) } if(m_joystick_turbine_bypass.check_focus()) - focus::set(std::make_unique(sys.turbine_bypass_valve.get())); + Focus::set(std::make_unique(sys.turbine_bypass_valve.get())); if(m_joystick_turbine_inlet.check_focus()) - focus::set(std::make_unique(sys.turbine_inlet_valve.get())); + Focus::set(std::make_unique(sys.turbine_inlet_valve.get())); if(m_switch_pump.check_focus()) sys.primary_pump->powered = !sys.primary_pump->powered; if(m_switch_inlet.check_focus()) diff --git a/src/graphics/monitor/primary_loop.hpp b/src/graphics/monitor/primary_loop.hpp index 308d01c..576cb23 100644 --- a/src/graphics/monitor/primary_loop.hpp +++ b/src/graphics/monitor/primary_loop.hpp @@ -3,7 +3,7 @@ #include "../mesh/glmesh.hpp" -namespace sim::graphics::monitor +namespace Sim::Graphics::monitor { class PrimaryLoop diff --git a/src/graphics/monitor/secondary_loop.cpp b/src/graphics/monitor/secondary_loop.cpp index 9eea7bf..d97537f 100644 --- a/src/graphics/monitor/secondary_loop.cpp +++ b/src/graphics/monitor/secondary_loop.cpp @@ -12,8 +12,8 @@ #include #include -using namespace sim::graphics; -using namespace sim::graphics::monitor; +using namespace Sim::Graphics; +using namespace Sim::Graphics::Monitor; SecondaryLoop::SecondaryLoop() { @@ -22,7 +22,7 @@ SecondaryLoop::SecondaryLoop() void SecondaryLoop::init() { - mesh1.model_matrix = locations::monitors[5]; + mesh1.model_matrix = Locations::monitors[5]; mesh2.model_matrix = glm::translate(mesh1.model_matrix, glm::vec3(0.5, 0, 0)); mesh1.colour_matrix = mesh2.colour_matrix = { @@ -33,7 +33,7 @@ void SecondaryLoop::init() }; std::stringstream ss; - sim::graphics::Mesh rmesh; + Sim::Graphics::Mesh rmesh; ss << "Cooling Tower\n\n"; ss << "Heat\nSteam\nPressure\nLevel\n\n"; @@ -62,13 +62,13 @@ void SecondaryLoop::init() void SecondaryLoop::update(double dt) { - System& sys = sim::System::active; + System& sys = Sim::System::active; clock_now += dt; if(clock_at + 1.0/30.0 < clock_now) { std::stringstream ss; - sim::graphics::Mesh rmesh; + Sim::Graphics::Mesh rmesh; clock_at += 1.0/30.0; ss << "\n\n"; diff --git a/src/graphics/monitor/secondary_loop.hpp b/src/graphics/monitor/secondary_loop.hpp index f20563e..9f8a47b 100644 --- a/src/graphics/monitor/secondary_loop.hpp +++ b/src/graphics/monitor/secondary_loop.hpp @@ -3,21 +3,21 @@ #include "../mesh/glmesh.hpp" -namespace sim::graphics::monitor +namespace Sim::Graphics::monitor { class SecondaryLoop { - sim::graphics::GLMesh mesh1, mesh2; + Sim::Graphics::GLMesh mesh1, mesh2; double clock_at = 0, clock_now = 0; - sim::graphics::GLMesh gm_switch_2; - sim::graphics::GLMesh gm_switch_3; + Sim::Graphics::GLMesh gm_switch_2; + Sim::Graphics::GLMesh gm_switch_3; - sim::graphics::Mesh m_joystick_turbine_bypass; - sim::graphics::Mesh m_joystick_turbine_inlet; - sim::graphics::Mesh m_switch_2; - sim::graphics::Mesh m_switch_3; + Sim::Graphics::Mesh m_joystick_turbine_bypass; + Sim::Graphics::Mesh m_joystick_turbine_inlet; + Sim::Graphics::Mesh m_switch_2; + Sim::Graphics::Mesh m_switch_3; public: diff --git a/src/graphics/monitor/turbine.cpp b/src/graphics/monitor/turbine.cpp index 47399fb..7fb8404 100644 --- a/src/graphics/monitor/turbine.cpp +++ b/src/graphics/monitor/turbine.cpp @@ -12,8 +12,8 @@ #include #include -using namespace sim::graphics; -using namespace sim::graphics::monitor; +using namespace Sim::Graphics; +using namespace Sim::Graphics::Monitor; Turbine::Turbine() { @@ -22,7 +22,7 @@ Turbine::Turbine() void Turbine::init() { - mesh1.model_matrix = mesh2.model_matrix = locations::monitors[4]; + mesh1.model_matrix = mesh2.model_matrix = Locations::monitors[4]; mesh1.colour_matrix = mesh2.colour_matrix = { 1, 1, 1, 1, 0, 0, 0, 0, @@ -31,7 +31,7 @@ void Turbine::init() }; std::stringstream ss; - sim::graphics::Mesh rmesh, rmesh2; + Sim::Graphics::Mesh rmesh, rmesh2; ss << "Turbine\n\n"; ss << "Heat\nPressure\nSpeed\n\n"; @@ -56,13 +56,13 @@ void Turbine::init() void Turbine::update(double dt) { - System& sys = sim::System::active; + System& sys = Sim::System::active; clock_now += dt; if(clock_at + 1.0/30.0 < clock_now) { std::stringstream ss; - sim::graphics::Mesh rmesh, rmesh2; + Sim::Graphics::Mesh rmesh, rmesh2; clock_at += 1.0/30.0; ss << "\n\n"; diff --git a/src/graphics/monitor/turbine.hpp b/src/graphics/monitor/turbine.hpp index 9f77cdc..f1ebfea 100644 --- a/src/graphics/monitor/turbine.hpp +++ b/src/graphics/monitor/turbine.hpp @@ -3,17 +3,17 @@ #include "../mesh/glmesh.hpp" -namespace sim::graphics::monitor +namespace Sim::Graphics::monitor { class Turbine { - sim::graphics::GLMesh mesh1, mesh2; + Sim::Graphics::GLMesh mesh1, mesh2; double clock_at = 0, clock_now = 0; - sim::graphics::GLMesh gm_synchroscope_dial; - sim::graphics::GLMesh gm_switch_breaker; - sim::graphics::Mesh m_switch_breaker; + Sim::Graphics::GLMesh gm_synchroscope_dial; + Sim::Graphics::GLMesh gm_switch_breaker; + Sim::Graphics::Mesh m_switch_breaker; public: diff --git a/src/graphics/monitor/vessel.cpp b/src/graphics/monitor/vessel.cpp index 3c2337e..230a109 100644 --- a/src/graphics/monitor/vessel.cpp +++ b/src/graphics/monitor/vessel.cpp @@ -12,7 +12,7 @@ #include #include -using namespace sim::graphics::monitor; +using namespace Sim::Graphics::Monitor; Vessel::Vessel() { @@ -21,7 +21,7 @@ Vessel::Vessel() void Vessel::init() { - mesh1.model_matrix = locations::monitors[1]; + mesh1.model_matrix = Locations::monitors[1]; mesh2.model_matrix = glm::translate(mesh1.model_matrix, glm::vec3(0.5, 0, 0)); mesh1.colour_matrix = mesh2.colour_matrix = { @@ -32,7 +32,7 @@ void Vessel::init() }; std::stringstream ss; - sim::graphics::Mesh rmesh; + Sim::Graphics::Mesh rmesh; ss << "Reactor Vessel\n\n"; ss << "Heat\n"; @@ -54,8 +54,8 @@ void Vessel::init() void Vessel::update(double dt) { std::stringstream ss; - sim::graphics::Mesh rmesh; - sim::System& sys = sim::System::active; + Sim::Graphics::Mesh rmesh; + Sim::System& sys = Sim::System::active; clock_now += dt; if(clock_at + 1.0/30.0 > clock_now) @@ -67,18 +67,18 @@ void Vessel::update(double dt) double crod_min = INFINITY, crod_max = -INFINITY; clock_at += 1.0/30.0; - sys.reactor->get_stats(sim::reactor::Rod::val_t::HEAT, temp_min, temp_max); + sys.reactor->get_stats(Sim::Reactor::Rod::val_t::HEAT, temp_min, temp_max); for(int i = 0; i < sys.reactor->size; i++) { - sim::reactor::Rod* r = sys.reactor->rods[i].get(); + Sim::Reactor::Rod* r = sys.reactor->rods[i].get(); if(r->get_id() != 5) { continue; } - auto br = (sim::reactor::control::BoronRod*)r; + auto br = (Sim::Reactor::control::BoronRod*)r; double v = br->get_inserted(); if(v > crod_max) diff --git a/src/graphics/monitor/vessel.hpp b/src/graphics/monitor/vessel.hpp index 43ffa55..79216e7 100644 --- a/src/graphics/monitor/vessel.hpp +++ b/src/graphics/monitor/vessel.hpp @@ -3,12 +3,12 @@ #include "../mesh/glmesh.hpp" -namespace sim::graphics::monitor +namespace Sim::Graphics::monitor { class Vessel { - sim::graphics::GLMesh mesh1, mesh2; + Sim::Graphics::GLMesh mesh1, mesh2; double clock_at = 0, clock_now = 0; public: diff --git a/src/graphics/resize.cpp b/src/graphics/resize.cpp index c2cead9..ea7fe3d 100644 --- a/src/graphics/resize.cpp +++ b/src/graphics/resize.cpp @@ -5,7 +5,7 @@ #include "resize.hpp" #include "window.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static bool is_fullscreen = false; @@ -17,19 +17,19 @@ static int win_restore_h; static int win_restore_x; static int win_restore_y; -glm::vec<2, int> resize::get_size() +glm::vec<2, int> Resize::get_size() { return {win_w, win_h}; } -float resize::get_aspect() +float Resize::get_aspect() { return (float)win_w / (float)win_h; } -void resize::toggle_fullscreen() +void Resize::toggle_fullscreen() { - GLFWwindow* win = window::get_window(); + GLFWwindow* win = Window::get_window(); is_fullscreen = !is_fullscreen; if(is_fullscreen) @@ -57,9 +57,9 @@ static void cb_framebuffer_size(GLFWwindow* win, int w, int h) glViewport(0, 0, w, h); } -void resize::init() +void Resize::init() { - GLFWwindow* win = window::get_window(); + GLFWwindow* win = Window::get_window(); glfwSetFramebufferSizeCallback(win, cb_framebuffer_size); } diff --git a/src/graphics/resize.hpp b/src/graphics/resize.hpp index ae7c3a8..e2debf5 100644 --- a/src/graphics/resize.hpp +++ b/src/graphics/resize.hpp @@ -3,7 +3,7 @@ #include -namespace sim::graphics::resize +namespace Sim::Graphics::Resize { void init(); diff --git a/src/graphics/shader.cpp b/src/graphics/shader.cpp index 974d941..5626a14 100644 --- a/src/graphics/shader.cpp +++ b/src/graphics/shader.cpp @@ -9,14 +9,14 @@ #include "shader.hpp" #include "window.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static unsigned int prog_id; -int shader::gl_tex_mat; -int shader::gl_model; -int shader::gl_camera; -int shader::gl_projection; +int Shader::gl_tex_mat; +int Shader::gl_model; +int Shader::gl_camera; +int Shader::gl_projection; static int load_shader(const char* src, int type) { @@ -43,7 +43,7 @@ static std::string read_shader(const char* path) return ss.str(); } -unsigned int shader::init_program() +unsigned int Shader::init_program() { std::string shader_vsh = read_shader("../assets/shader/main.vsh"); std::string shader_fsh = read_shader("../assets/shader/main.fsh"); @@ -63,7 +63,7 @@ unsigned int shader::init_program() char infoLog[512]; glGetProgramInfoLog(prog_id, 512, NULL, infoLog); std::cout << "Shader Link Error: " << infoLog << std::endl; - window::close(); + Window::close(); return 0; } diff --git a/src/graphics/shader.hpp b/src/graphics/shader.hpp index b6258ea..98c895d 100644 --- a/src/graphics/shader.hpp +++ b/src/graphics/shader.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::graphics::shader +namespace Sim::Graphics::Shader { extern int gl_tex_mat; diff --git a/src/graphics/ui.cpp b/src/graphics/ui.cpp index af080b8..03b3535 100644 --- a/src/graphics/ui.cpp +++ b/src/graphics/ui.cpp @@ -16,22 +16,22 @@ #include "widget/clock.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static GLMesh StaticMeshData; static widget::Clock WidgetClock; -void ui::init() +void UI::init() { Mesh m; - unsigned int handle = texture::handle_white; + unsigned int handle = Texture::handle_white; const unsigned int indices[] = {0, 1, 3, 0, 3, 2}; - const arrays::vertex vertices[] = { - arrays::vertex(handle, {0, 0}, {-1, -1, 0, 1}, {0, 0, -1}), - arrays::vertex(handle, {0, 1}, {-1, 1, 0, 1}, {0, 0, -1}), - arrays::vertex(handle, {1, 0}, { 1, -1, 0, 1}, {0, 0, -1}), - arrays::vertex(handle, {1, 1}, { 1, 1, 0, 1}, {0, 0, -1}), + const Arrays::vertex vertices[] = { + Arrays::vertex(handle, {0, 0}, {-1, -1, 0, 1}, {0, 0, -1}), + Arrays::vertex(handle, {0, 1}, {-1, 1, 0, 1}, {0, 0, -1}), + Arrays::vertex(handle, {1, 0}, { 1, -1, 0, 1}, {0, 0, -1}), + Arrays::vertex(handle, {1, 1}, { 1, 1, 0, 1}, {0, 0, -1}), }; m.set_indices(indices, 6); @@ -42,21 +42,21 @@ void ui::init() StaticMeshData.colour_matrix = glm::scale(glm::mat4(1), glm::vec3(1) * 0.75f); } -void ui::update(double dt) +void UI::update(double dt) { WidgetClock.update(dt); } -void ui::render() +void UI::render() { glClear(GL_DEPTH_BUFFER_BIT); - glm::vec2 wsize(resize::get_size() / 2); + glm::vec2 wsize(Resize::get_size() / 2); glm::mat4 mat_projection = glm::mat4(1); glm::mat4 mat_camera = glm::scale(glm::mat4(1), glm::vec3(1.0f / wsize * glm::vec2(1, -1), -1)); - glUniformMatrix4fv(shader::gl_projection, 1, false, &mat_projection[0][0]); - glUniformMatrix4fv(shader::gl_camera, 1, false, &mat_camera[0][0]); + glUniformMatrix4fv(Shader::gl_projection, 1, false, &mat_projection[0][0]); + glUniformMatrix4fv(Shader::gl_camera, 1, false, &mat_camera[0][0]); StaticMeshData.bind(); StaticMeshData.uniform(); diff --git a/src/graphics/ui.hpp b/src/graphics/ui.hpp index e606602..f3fa585 100644 --- a/src/graphics/ui.hpp +++ b/src/graphics/ui.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::graphics::ui +namespace Sim::Graphics::UI { void init(); diff --git a/src/graphics/widget/clock.cpp b/src/graphics/widget/clock.cpp index 460fb16..95ad4ec 100644 --- a/src/graphics/widget/clock.cpp +++ b/src/graphics/widget/clock.cpp @@ -16,13 +16,13 @@ #include "../resize.hpp" #include "../../system.hpp" -using namespace sim::graphics::widget; +using namespace Sim::Graphics::Widget; void Clock::update(double dt) { Mesh m; double at = System::active.clock; - glm::vec2 wsize(resize::get_size() / 2); + glm::vec2 wsize(Resize::get_size() / 2); std::stringstream ss; int t_s = std::fmod(at, 60); @@ -38,7 +38,7 @@ void Clock::update(double dt) data.bind(); data.model_matrix = glm::translate(glm::mat4(1), glm::vec3(-wsize + glm::vec2(2, 2), 0)); - data.colour_matrix = arrays::colour({1, 1, 1, 1}); + data.colour_matrix = Arrays::colour({1, 1, 1, 1}); data.set(m, GL_DYNAMIC_DRAW); } diff --git a/src/graphics/widget/clock.hpp b/src/graphics/widget/clock.hpp index eb421b2..503e23f 100644 --- a/src/graphics/widget/clock.hpp +++ b/src/graphics/widget/clock.hpp @@ -3,7 +3,7 @@ #include "../mesh/glmesh.hpp" -namespace sim::graphics::widget +namespace Sim::Graphics::widget { struct Clock diff --git a/src/graphics/window.cpp b/src/graphics/window.cpp index 088e57c..284eed5 100644 --- a/src/graphics/window.cpp +++ b/src/graphics/window.cpp @@ -27,7 +27,7 @@ #include "mesh/texture.hpp" #include "ui.hpp" -using namespace sim::graphics; +using namespace Sim::Graphics; static GLFWwindow* win; static bool win_should_close = false; @@ -39,7 +39,7 @@ static monitor::PrimaryLoop monitor_primary_loop; static monitor::SecondaryLoop monitor_secondary_loop; static monitor::Turbine monitor_turbine; -glm::mat4 window::projection_matrix; +glm::mat4 Window::projection_matrix; void GLAPIENTRY cb_debug_message(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { @@ -49,7 +49,7 @@ void GLAPIENTRY cb_debug_message(GLenum source, GLenum type, GLuint id, GLenum s } } -void window::create() +void Window::create() { glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); @@ -98,17 +98,17 @@ void window::create() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDebugMessageCallback(cb_debug_message, nullptr); - keyboard::init(); - mouse::init(); - resize::init(); - texture::init(); - camera::init(); - font::init(); - ui::init(); + Keyboard::init(); + Mouse::init(); + Resize::init(); + Texture::init(); + Camera::init(); + Font::init(); + UI::init(); - shader::init_program(); + Shader::init_program(); - sim::System& sys = sim::System::active; + Sim::System& sys = Sim::System::active; Mesh m, m2; m.load_model("../assets", "scene-baked.glb"); @@ -128,7 +128,7 @@ void window::create() glViewport(0, 0, 800, 600); } -void window::update(double dt) +void Window::update(double dt) { glfwPollEvents(); @@ -138,15 +138,15 @@ void window::update(double dt) monitor_secondary_loop.update(dt); monitor_turbine.update(dt); - ui::update(dt); + UI::update(dt); } -void window::render() +void Window::render() { - glm::mat4 mat_camera = camera::get_matrix(); - glm::mat4 mat_projection = glm::perspective(glm::radians(90.0f), resize::get_aspect(), 0.01f, 20.f); - glUniformMatrix4fv(shader::gl_projection, 1, false, &mat_projection[0][0]); - glUniformMatrix4fv(shader::gl_camera, 1, false, &mat_camera[0][0]); + glm::mat4 mat_camera = Camera::get_matrix(); + glm::mat4 mat_projection = glm::perspective(glm::radians(90.0f), Resize::get_aspect(), 0.01f, 20.f); + glUniformMatrix4fv(Shader::gl_projection, 1, false, &mat_projection[0][0]); + glUniformMatrix4fv(Shader::gl_camera, 1, false, &mat_camera[0][0]); projection_matrix = mat_projection; glClearColor(0, 0, 0, 1.0f); @@ -162,30 +162,30 @@ void window::render() monitor_secondary_loop.render(); monitor_turbine.render(); - focus::render(); - ui::render(); - focus::render_ui(); + Focus::render(); + UI::render(); + Focus::render_ui(); glfwSwapBuffers(win); } -bool window::should_close() +bool Window::should_close() { return win_should_close || glfwWindowShouldClose(win); } -void window::close() +void Window::close() { win_should_close = true; } -void window::destroy() +void Window::destroy() { glfwDestroyWindow(win); glfwTerminate(); } -GLFWwindow* window::get_window() +GLFWwindow* Window::get_window() { return win; } diff --git a/src/graphics/window.hpp b/src/graphics/window.hpp index f30ae3e..12b44e9 100644 --- a/src/graphics/window.hpp +++ b/src/graphics/window.hpp @@ -6,7 +6,7 @@ #include "../system.hpp" -namespace sim::graphics::window +namespace Sim::Graphics::Window { extern glm::mat4 projection_matrix; diff --git a/src/main.cpp b/src/main.cpp index 075bd34..769d567 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ #include "system.hpp" #include "tests.hpp" -using namespace sim; +using namespace Sim; int main() { @@ -31,27 +31,27 @@ int main() // tests::run(); // return 0; - graphics::window::create(); + Graphics::Window::create(); - long clock = util::time::get_now(); + long clock = Util::Time::get_now(); double at = 0; - while(!graphics::window::should_close()) + while(!Graphics::Window::should_close()) { - long now = util::time::get_now(); + long now = Util::Time::get_now(); long passed = now - clock; double dt = (double)passed / 1e6; clock += passed; - at += dt * sim::System::active.speed; + at += dt * Sim::System::active.speed; - sim::System::active.update(dt); + Sim::System::active.update(dt); - graphics::camera::update(dt); - graphics::window::update(dt); - graphics::focus::update(dt); - graphics::window::render(); + Graphics::Camera::update(dt); + Graphics::Window::update(dt); + Graphics::Focus::update(dt); + Graphics::Window::render(); } - graphics::window::destroy(); + Graphics::Window::destroy(); } diff --git a/src/reactor/builder.cpp b/src/reactor/builder.cpp index af942c1..5be158a 100644 --- a/src/reactor/builder.cpp +++ b/src/reactor/builder.cpp @@ -9,9 +9,9 @@ #include #include -using namespace sim::reactor; +using namespace Sim::Reactor; -sim::reactor::Reactor sim::reactor::builder(const int W, const int H, const double CW, const double CH, fuel::FuelRod fr, coolant::Vessel* v, const char** lines) +Sim::Reactor::Reactor Sim::Reactor::Builder(const int W, const int H, const double CW, const double CH, fuel::FuelRod fr, coolant::Vessel* v, const char** lines) { std::vector> arr(W * H); @@ -49,7 +49,7 @@ sim::reactor::Reactor sim::reactor::builder(const int W, const int H, const doub return Reactor(&arr[0], W, H, CW, CH); } -std::unique_ptr sim::reactor::load_rod(const Json::Value& node, coolant::Vessel* v) +std::unique_ptr Sim::Reactor::load_rod(const Json::Value& node, coolant::Vessel* v) { int id = node["id"].asInt(); diff --git a/src/reactor/builder.hpp b/src/reactor/builder.hpp index b42c08a..bdce4d9 100644 --- a/src/reactor/builder.hpp +++ b/src/reactor/builder.hpp @@ -8,10 +8,10 @@ #include -namespace sim::reactor +namespace Sim::Reactor { -Reactor builder(const int W, const int H, const double CW, const double CH, fuel::FuelRod fr, coolant::Vessel* v, const char** lines); +Reactor Builder(const int W, const int H, const double CW, const double CH, fuel::FuelRod fr, coolant::Vessel* v, const char** lines); std::unique_ptr load_rod(const Json::Value& node, coolant::Vessel* v); }; diff --git a/src/reactor/control/boron_rod.cpp b/src/reactor/control/boron_rod.cpp index 1db6b8e..1af1db3 100644 --- a/src/reactor/control/boron_rod.cpp +++ b/src/reactor/control/boron_rod.cpp @@ -3,7 +3,7 @@ #include -using namespace sim::reactor::control; +using namespace Sim::Reactor::Control; constexpr double boron_density = 2340000; // g/m^3 constexpr double boron_molar_mass = 10; // g/mol diff --git a/src/reactor/control/boron_rod.hpp b/src/reactor/control/boron_rod.hpp index 431397f..7a06729 100644 --- a/src/reactor/control/boron_rod.hpp +++ b/src/reactor/control/boron_rod.hpp @@ -3,7 +3,7 @@ #include "../coolant/pipe.hpp" -namespace sim::reactor::control +namespace Sim::Reactor::control { class BoronRod : public coolant::Pipe diff --git a/src/reactor/control/graphite_rod.cpp b/src/reactor/control/graphite_rod.cpp index 3e870c0..12ed573 100644 --- a/src/reactor/control/graphite_rod.cpp +++ b/src/reactor/control/graphite_rod.cpp @@ -3,7 +3,7 @@ #include -using namespace sim::reactor::control; +using namespace Sim::Reactor::Control; GraphiteRod::GraphiteRod(const Json::Value& node) : Rod(node) { diff --git a/src/reactor/control/graphite_rod.hpp b/src/reactor/control/graphite_rod.hpp index 0b4e65c..038c5b1 100644 --- a/src/reactor/control/graphite_rod.hpp +++ b/src/reactor/control/graphite_rod.hpp @@ -3,10 +3,10 @@ #include "../rod.hpp" -namespace sim::reactor::control +namespace Sim::Reactor::control { -class GraphiteRod : public sim::reactor::Rod +class GraphiteRod : public Sim::Reactor::Rod { double inserted = 0; diff --git a/src/reactor/coolant/heater.cpp b/src/reactor/coolant/heater.cpp index e5bc35c..6f4a6a8 100644 --- a/src/reactor/coolant/heater.cpp +++ b/src/reactor/coolant/heater.cpp @@ -1,7 +1,7 @@ #include "heater.hpp" -using namespace sim::reactor::coolant; +using namespace Sim::Reactor::Coolant; Heater::Heater(const Json::Value& node) : Rod(node) { diff --git a/src/reactor/coolant/heater.hpp b/src/reactor/coolant/heater.hpp index 4a5e369..8acd287 100644 --- a/src/reactor/coolant/heater.hpp +++ b/src/reactor/coolant/heater.hpp @@ -3,10 +3,10 @@ #include "../rod.hpp" -namespace sim::reactor::coolant +namespace Sim::Reactor::coolant { -class Heater : public sim::reactor::Rod +class Heater : public Sim::Reactor::Rod { double rate = 0; diff --git a/src/reactor/coolant/pipe.cpp b/src/reactor/coolant/pipe.cpp index e245a80..1f2c79f 100644 --- a/src/reactor/coolant/pipe.cpp +++ b/src/reactor/coolant/pipe.cpp @@ -2,7 +2,7 @@ #include "pipe.hpp" #include "../reactor.hpp" -using namespace sim::reactor::coolant; +using namespace Sim::Reactor::Coolant; Pipe::Pipe(coolant::Vessel* v) { @@ -35,7 +35,7 @@ void Pipe::update(double secs) void Pipe::update_pipe(double secs) { - sim::reactor::Reactor* r = (sim::reactor::Reactor*)reactor; + Sim::Reactor::Reactor* r = (Sim::Reactor::Reactor*)reactor; double m_heat = r->cell_width * r->cell_width * r->cell_height * 1e6; vals[val_t::HEAT] = vessel->add_heat(m_heat, vals[val_t::HEAT]); diff --git a/src/reactor/coolant/pipe.hpp b/src/reactor/coolant/pipe.hpp index 308dc90..276f8cb 100644 --- a/src/reactor/coolant/pipe.hpp +++ b/src/reactor/coolant/pipe.hpp @@ -4,17 +4,17 @@ #include "vessel.hpp" #include "../rod.hpp" -namespace sim::reactor::coolant +namespace Sim::Reactor::coolant { -class Pipe : public sim::reactor::Rod +class Pipe : public Sim::Reactor::Rod { protected: coolant::Vessel* vessel; double steam; - virtual double get_k(sim::reactor::Rod::val_t type) const; + virtual double get_k(Sim::Reactor::Rod::val_t type) const; virtual const char* get_name() const { return "Coolant"; } virtual int get_id() const { return 2; } diff --git a/src/reactor/coolant/vessel.cpp b/src/reactor/coolant/vessel.cpp index 1d5618b..43891b5 100644 --- a/src/reactor/coolant/vessel.cpp +++ b/src/reactor/coolant/vessel.cpp @@ -7,7 +7,7 @@ #include #include -using namespace sim::reactor::coolant; +using namespace Sim::Reactor::Coolant; constexpr static double calc_cylinder(double h, double d) { @@ -16,15 +16,15 @@ constexpr static double calc_cylinder(double h, double d) return M_PI * r * r * h * 1000; } -Vessel::Vessel(sim::coolant::Fluid fluid, double height, double diameter, double mass, double level, double bubble_hl) : - sim::coolant::FluidHolder(fluid, calc_cylinder(height, diameter), mass), +Vessel::Vessel(Sim::Coolant::Fluid fluid, double height, double diameter, double mass, double level, double bubble_hl) : + Sim::Coolant::FluidHolder(fluid, calc_cylinder(height, diameter), mass), height(height), diameter(diameter), bubble_hl(bubble_hl) { this->level = level; } Vessel::Vessel(const Json::Value& node) : - sim::coolant::FluidHolder(node), + Sim::Coolant::FluidHolder(node), height(node["height"].asDouble()), diameter(node["diameter"].asDouble()), bubble_hl(node["bubble_hl"].asDouble()) @@ -67,7 +67,7 @@ void Vessel::update(double secs) steam_last = steam; steam_suspended += diff; - steam_suspended *= reactor::fuel::half_life::get(secs, bubble_hl); + steam_suspended *= Reactor::fuel::half_life::get(secs, bubble_hl); if(steam_suspended < 0) { diff --git a/src/reactor/coolant/vessel.hpp b/src/reactor/coolant/vessel.hpp index 3b9a57c..a262953 100644 --- a/src/reactor/coolant/vessel.hpp +++ b/src/reactor/coolant/vessel.hpp @@ -5,10 +5,10 @@ #include "../../coolant/fluid_holder.hpp" -namespace sim::reactor::coolant +namespace Sim::Reactor::coolant { -class Vessel : public sim::coolant::FluidHolder +class Vessel : public Sim::Coolant::FluidHolder { public: @@ -18,7 +18,7 @@ public: double steam_suspended = 0; // grams - Vessel(sim::coolant::Fluid fluid, double height, double diameter, double mass, double level, double bubble_hl); + Vessel(Sim::Coolant::Fluid fluid, double height, double diameter, double mass, double level, double bubble_hl); Vessel(const Json::Value& node); double get_steam_suspended() const; // grams diff --git a/src/reactor/fuel/fuel_rod.cpp b/src/reactor/fuel/fuel_rod.cpp index fc63872..f8edaf4 100644 --- a/src/reactor/fuel/fuel_rod.cpp +++ b/src/reactor/fuel/fuel_rod.cpp @@ -3,7 +3,7 @@ #include -using namespace sim::reactor::fuel; +using namespace Sim::Reactor::Fuel; constexpr double fuel_density = 19100000; // g/m^3 constexpr double fuel_molar_mass = 238.029; // g/mol diff --git a/src/reactor/fuel/fuel_rod.hpp b/src/reactor/fuel/fuel_rod.hpp index 12f2fac..604a3ae 100644 --- a/src/reactor/fuel/fuel_rod.hpp +++ b/src/reactor/fuel/fuel_rod.hpp @@ -4,10 +4,10 @@ #include "sample.hpp" #include "../rod.hpp" -namespace sim::reactor::fuel +namespace Sim::Reactor::fuel { -class FuelRod : public sim::reactor::Rod +class FuelRod : public Sim::Reactor::Rod { Sample s; diff --git a/src/reactor/fuel/half_life.hpp b/src/reactor/fuel/half_life.hpp index 3b833c5..daffe5d 100644 --- a/src/reactor/fuel/half_life.hpp +++ b/src/reactor/fuel/half_life.hpp @@ -3,7 +3,7 @@ #include -namespace sim::reactor::fuel::half_life +namespace Sim::Reactor::fuel::half_life { const double Te_135 = 19; diff --git a/src/reactor/fuel/sample.cpp b/src/reactor/fuel/sample.cpp index 0b798c6..4c7621e 100644 --- a/src/reactor/fuel/sample.cpp +++ b/src/reactor/fuel/sample.cpp @@ -4,7 +4,7 @@ #include -using namespace sim::reactor::fuel; +using namespace Sim::Reactor::Fuel; constexpr double NEUTRON_BG = 1e-30; diff --git a/src/reactor/fuel/sample.hpp b/src/reactor/fuel/sample.hpp index 927d768..7cdb4d5 100644 --- a/src/reactor/fuel/sample.hpp +++ b/src/reactor/fuel/sample.hpp @@ -5,14 +5,14 @@ #include -namespace sim::reactor::fuel +namespace Sim::Reactor::fuel { class Sample { constexpr static const double Xe_135_M = 1e6; - sim::reactor::fuel::Waste waste; + Sim::Reactor::fuel::Waste waste; // mol double fuel = 0; diff --git a/src/reactor/fuel/waste.cpp b/src/reactor/fuel/waste.cpp index 11ff9b3..3879332 100644 --- a/src/reactor/fuel/waste.cpp +++ b/src/reactor/fuel/waste.cpp @@ -2,7 +2,7 @@ #include "waste.hpp" #include "half_life.hpp" -using namespace sim::reactor::fuel; +using namespace Sim::Reactor::Fuel; Waste::Waste(const Json::Value& node) { diff --git a/src/reactor/fuel/waste.hpp b/src/reactor/fuel/waste.hpp index bb792da..56f3d24 100644 --- a/src/reactor/fuel/waste.hpp +++ b/src/reactor/fuel/waste.hpp @@ -3,7 +3,7 @@ #include -namespace sim::reactor::fuel +namespace Sim::Reactor::fuel { class Waste diff --git a/src/reactor/reactor.cpp b/src/reactor/reactor.cpp index c618374..ae2344d 100644 --- a/src/reactor/reactor.cpp +++ b/src/reactor/reactor.cpp @@ -5,7 +5,7 @@ #include -using namespace sim::reactor; +using namespace Sim::Reactor; Reactor::Reactor(std::unique_ptr* rods, int w, int h, double cw, double ch) : cell_width(cw), cell_height(ch), width(w), height(h), size(w * h) { @@ -155,7 +155,7 @@ void Reactor::toggle_selected() void Reactor::update_tile(double secs, int i, int x, int y) { int nb_lookup[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; - std::shuffle(nb_lookup, &nb_lookup[3], util::random::gen); + std::shuffle(nb_lookup, &nb_lookup[3], Util::Random::gen); for(int j = 0; j < 4; j++) { @@ -171,7 +171,7 @@ void Reactor::update_tile(double secs, int i, int x, int y) void Reactor::update_interactions(int* rods_lookup, double secs) { - std::shuffle(rods_lookup, &rods_lookup[size - 1], util::random::gen); + std::shuffle(rods_lookup, &rods_lookup[size - 1], Util::Random::gen); for(int id = 0; id < size; id++) { diff --git a/src/reactor/reactor.hpp b/src/reactor/reactor.hpp index 91f00f4..0f69389 100644 --- a/src/reactor/reactor.hpp +++ b/src/reactor/reactor.hpp @@ -8,7 +8,7 @@ #include #include -namespace sim::reactor +namespace Sim::Reactor { struct Reactor diff --git a/src/reactor/rod.cpp b/src/reactor/rod.cpp index 9fc9147..6a253bb 100644 --- a/src/reactor/rod.cpp +++ b/src/reactor/rod.cpp @@ -5,7 +5,7 @@ #include -using namespace sim::reactor; +using namespace Sim::Reactor; // Avogadro's Number static double N_a = 6.02214076e23; @@ -69,22 +69,22 @@ glm::vec4 Rod::get_heat_colour() const if(temp < 120) { - return {0, util::map(temp, 0, 120, 0, 1), 1, 1}; + return {0, Util::map(temp, 0, 120, 0, 1), 1, 1}; } if(temp < 240) { - return {0, 1, util::map(temp, 120, 240, 1, 0), 1}; + return {0, 1, Util::map(temp, 120, 240, 1, 0), 1}; } if(temp < 280) { - return {util::map(temp, 240, 280, 0, 1), 1, 0, 1}; + return {Util::map(temp, 240, 280, 0, 1), 1, 0, 1}; } if(temp < 320) { - return {1, util::map(temp, 280, 320, 1, 0), 0, 1}; + return {1, Util::map(temp, 280, 320, 1, 0), 0, 1}; } return {1, 0, 0, 1}; @@ -97,13 +97,13 @@ double Rod::get_flux() const double Rod::get_volume() const { - auto r = (sim::reactor::Reactor*)reactor; + auto r = (Sim::Reactor::Reactor*)reactor; return r->cell_width * r->cell_width * r->cell_height; } double Rod::get_side_area() const { - auto r = (sim::reactor::Reactor*)reactor; + auto r = (Sim::Reactor::Reactor*)reactor; return r->cell_width * r->cell_height; } diff --git a/src/reactor/rod.hpp b/src/reactor/rod.hpp index 9b711f0..48e19f0 100644 --- a/src/reactor/rod.hpp +++ b/src/reactor/rod.hpp @@ -7,7 +7,7 @@ #include #include -namespace sim::reactor +namespace Sim::Reactor { class Rod diff --git a/src/system.cpp b/src/system.cpp index 9604738..486c616 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -10,9 +10,9 @@ #include "reactor/coolant/heater.hpp" #include "graphics/camera.hpp" -using namespace sim; +using namespace Sim; -sim::System System::active; +Sim::System System::active; System::System() { @@ -38,42 +38,42 @@ System::System() " C C C C " }; - vessel = std::make_unique(sim::coolant::WATER, 8, 10, 6e6, 5e5, 10); - reactor = std::make_unique(sim::reactor::builder(19, 19, 1.0 / 4.0, 4, reactor::fuel::FuelRod(0.2), vessel.get(), layout)); - condenser = std::make_unique(sim::coolant::WATER, 6, 4, 3e6, 30000); - turbine = std::make_unique(sim::coolant::WATER, condenser.get(), 6, 3, 2e6); + vessel = std::make_unique(Sim::Coolant::WATER, 8, 10, 6e6, 5e5, 10); + reactor = std::make_unique(Sim::Reactor::Builder(19, 19, 1.0 / 4.0, 4, Reactor::fuel::FuelRod(0.2), vessel.get(), layout)); + condenser = std::make_unique(Sim::Coolant::WATER, 6, 4, 3e6, 30000); + turbine = std::make_unique(Sim::Coolant::WATER, condenser.get(), 6, 3, 2e6); - sink = std::make_unique(sim::coolant::WATER, 11, 0, 0); - evaporator = std::make_unique(sim::coolant::WATER, 2, 30, 0, 1000); - condenser_secondary = std::make_unique(condenser.get(), evaporator.get(), 1000); + sink = std::make_unique(Sim::Coolant::WATER, 11, 0, 0); + evaporator = std::make_unique(Sim::Coolant::WATER, 2, 30, 0, 1000); + condenser_secondary = std::make_unique(condenser.get(), evaporator.get(), 1000); - turbine_inlet_valve = std::make_unique(vessel.get(), turbine.get(), 0, 0.5); - turbine_bypass_valve = std::make_unique(vessel.get(), condenser.get(), 0, 0.5); + turbine_inlet_valve = std::make_unique(vessel.get(), turbine.get(), 0, 0.5); + turbine_bypass_valve = std::make_unique(vessel.get(), condenser.get(), 0, 0.5); - primary_pump = std::make_unique(condenser.get(), vessel.get(), 1e5, 1, 1e5, 0.1, 10, coolant::Pump::mode_t::SRC, 35000); - secondary_pump = std::make_unique(evaporator.get(), condenser_secondary.get(), 1e5, 1, 1e4, 0.1, 1, coolant::Pump::mode_t::NONE, 0); - freight_pump = std::make_unique(sink.get(), evaporator.get(), 1e5, 1, 1e4, 0.1, 10, coolant::Pump::mode_t::DST, 1e6); + primary_pump = std::make_unique(condenser.get(), vessel.get(), 1e5, 1, 1e5, 0.1, 10, Coolant::Pump::mode_t::SRC, 35000); + secondary_pump = std::make_unique(evaporator.get(), condenser_secondary.get(), 1e5, 1, 1e4, 0.1, 1, Coolant::Pump::mode_t::NONE, 0); + freight_pump = std::make_unique(sink.get(), evaporator.get(), 1e5, 1, 1e4, 0.1, 10, Coolant::Pump::mode_t::DST, 1e6); } System::System(const Json::Value& node) { clock = node["clock"].asDouble(); - vessel = std::make_unique(node["vessel"]); - reactor = std::make_unique(node["reactor"], vessel.get()); - condenser = std::make_unique(node["condenser"]); - turbine = std::make_unique(node["turbine"], condenser.get()); + vessel = std::make_unique(node["vessel"]); + reactor = std::make_unique(node["reactor"], vessel.get()); + condenser = std::make_unique(node["condenser"]); + turbine = std::make_unique(node["turbine"], condenser.get()); - evaporator = std::make_unique(node["evaporator"]); - sink = std::make_unique(evaporator->fluid, 11, 0, 0); - condenser_secondary = std::make_unique(condenser.get(), evaporator.get(), 1000); + evaporator = std::make_unique(node["evaporator"]); + sink = std::make_unique(evaporator->fluid, 11, 0, 0); + condenser_secondary = std::make_unique(condenser.get(), evaporator.get(), 1000); - turbine_inlet_valve = std::make_unique(node["valve"]["turbine"]["inlet"], vessel.get(), turbine.get()); - turbine_bypass_valve = std::make_unique(node["valve"]["turbine"]["bypass"], vessel.get(), condenser.get()); + turbine_inlet_valve = std::make_unique(node["valve"]["turbine"]["inlet"], vessel.get(), turbine.get()); + turbine_bypass_valve = std::make_unique(node["valve"]["turbine"]["bypass"], vessel.get(), condenser.get()); - primary_pump = std::make_unique(node["pump"]["primary"], condenser.get(), vessel.get()); - secondary_pump = std::make_unique(node["pump"]["secondary"], evaporator.get(), condenser_secondary.get()); - freight_pump = std::make_unique(node["pump"]["freight"], sink.get(), evaporator.get()); + primary_pump = std::make_unique(node["pump"]["primary"], condenser.get(), vessel.get()); + secondary_pump = std::make_unique(node["pump"]["secondary"], evaporator.get(), condenser_secondary.get()); + freight_pump = std::make_unique(node["pump"]["freight"], sink.get(), evaporator.get()); } void System::update(double dt) @@ -117,7 +117,7 @@ System::operator Json::Value() const void System::save() { Json::Value root(active); - root["camera"] = graphics::camera::serialize(); + root["camera"] = Graphics::Camera::serialize(); Json::StreamWriterBuilder builder; builder["commentStyle"] = "None"; @@ -137,7 +137,7 @@ void System::load() savefile.close(); System sys(root); - graphics::camera::load(root["camera"]); + Graphics::Camera::load(root["camera"]); active = std::move(sys); } diff --git a/src/system.hpp b/src/system.hpp index 60d81e3..3ff9793 100644 --- a/src/system.hpp +++ b/src/system.hpp @@ -14,28 +14,28 @@ #include "coolant/sink.hpp" #include "electric/turbine.hpp" -namespace sim +namespace Sim { struct System { static System active; - std::unique_ptr reactor; - std::unique_ptr vessel; + std::unique_ptr reactor; + std::unique_ptr vessel; - std::unique_ptr sink; - std::unique_ptr condenser; - std::unique_ptr condenser_secondary; - std::unique_ptr evaporator; - std::unique_ptr turbine; + std::unique_ptr sink; + std::unique_ptr condenser; + std::unique_ptr condenser_secondary; + std::unique_ptr evaporator; + std::unique_ptr turbine; - std::unique_ptr primary_pump; - std::unique_ptr secondary_pump; - std::unique_ptr freight_pump; + std::unique_ptr primary_pump; + std::unique_ptr secondary_pump; + std::unique_ptr freight_pump; - std::unique_ptr turbine_bypass_valve; - std::unique_ptr turbine_inlet_valve; + std::unique_ptr turbine_bypass_valve; + std::unique_ptr turbine_inlet_valve; double speed = 1; double clock = 3600 * 12; diff --git a/src/tests.cpp b/src/tests.cpp index 8ba9626..cf28440 100644 --- a/src/tests.cpp +++ b/src/tests.cpp @@ -4,9 +4,9 @@ #include #include -using namespace sim; +using namespace Sim; -void tests::run() +void Tests::run() { // fluid_system fs(WATER, 1000, 10); diff --git a/src/tests.hpp b/src/tests.hpp index e8b2408..e68e579 100644 --- a/src/tests.hpp +++ b/src/tests.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::tests +namespace Sim::Tests { void run(); diff --git a/src/util/constants.hpp b/src/util/constants.hpp index ed868bb..0d74091 100644 --- a/src/util/constants.hpp +++ b/src/util/constants.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::util::constants +namespace Sim::Util::Constants { constexpr double R = 8.31446261815324; // molar gas constant, J/mol/K constexpr double R_air = 0.2870500676; // specific gas constant of dry air, J/g/K diff --git a/src/util/math.hpp b/src/util/math.hpp index 6f78444..1f47264 100644 --- a/src/util/math.hpp +++ b/src/util/math.hpp @@ -19,7 +19,7 @@ std::ostream& operator<<(std::ostream& o, const glm::vec& v) return o; } -namespace sim::util +namespace Sim::Util { constexpr double calc_work(double j, double mass) diff --git a/src/util/pid.cpp b/src/util/pid.cpp index 1f8adf6..6f1ec8b 100644 --- a/src/util/pid.cpp +++ b/src/util/pid.cpp @@ -25,7 +25,7 @@ #include "pid.hpp" using namespace std; -using namespace sim::util; +using namespace Sim::Util; PID::PID(const Json::Value& node) : _max(node["max"].asDouble()), diff --git a/src/util/pid.hpp b/src/util/pid.hpp index 20ae70b..995832d 100644 --- a/src/util/pid.hpp +++ b/src/util/pid.hpp @@ -24,7 +24,7 @@ #include -namespace sim::util +namespace Sim::Util { class PID diff --git a/src/util/random.cpp b/src/util/random.cpp index 2f7ed98..f62a0aa 100644 --- a/src/util/random.cpp +++ b/src/util/random.cpp @@ -1,11 +1,11 @@ #include "random.hpp" -using namespace sim::util; +using namespace Sim::Util; -std::mt19937 random::gen; +std::mt19937 Random::gen; -void random::init() +void Random::init() { std::random_device rd; gen = std::mt19937(rd()); diff --git a/src/util/random.hpp b/src/util/random.hpp index caf1bc3..841ee3c 100644 --- a/src/util/random.hpp +++ b/src/util/random.hpp @@ -3,7 +3,7 @@ #include -namespace sim::util::random +namespace Sim::Util::Random { extern std::mt19937 gen; diff --git a/src/util/time.cpp b/src/util/time.cpp index 6de245d..4e16181 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -8,10 +8,10 @@ #include "time.hpp" -using namespace sim::util; +using namespace Sim::Util; -unsigned long time::get_now() +unsigned long Time::get_now() { #ifdef _WIN32 FILETIME ft; @@ -27,7 +27,7 @@ unsigned long time::get_now() #endif } -void time::sleep(unsigned long usec) +void Time::sleep(unsigned long usec) { #ifdef _WIN32 Sleep(usec / 1000); diff --git a/src/util/time.hpp b/src/util/time.hpp index 601f89d..5ea9d63 100644 --- a/src/util/time.hpp +++ b/src/util/time.hpp @@ -1,7 +1,7 @@ #pragma once -namespace sim::util::time +namespace Sim::Util::Time { unsigned long get_now();