From d22259983632849bb66db0eaa9586897b25797f4 Mon Sep 17 00:00:00 2001 From: Jay Robson Date: Sat, 3 Feb 2024 02:27:08 +1100 Subject: [PATCH] added clickable buttons :D --- assets/model/reactor_core_button1.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button2.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button3.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button4.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button5.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button6.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button7.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button8.stl | Bin 0 -> 184 bytes assets/model/reactor_core_button9.stl | Bin 0 -> 184 bytes assets/model/reactor_core_joystick.stl | Bin 0 -> 2384 bytes assets/model/reactor_core_scram.stl | Bin 6284 -> 1584 bytes assets/unbaked/scene.blend | 4 +- src/graphics/input/focus.cpp | 65 ++++++++++--- src/graphics/input/focus.hpp | 5 + src/graphics/input/mouse.cpp | 5 + src/graphics/input/mouse.hpp | 3 + src/graphics/mesh/mesh.cpp | 5 +- src/graphics/monitor/core.cpp | 125 +++++++++++-------------- src/graphics/monitor/core.hpp | 5 +- src/graphics/window.cpp | 3 + src/graphics/window.hpp | 3 + src/reactor/control/boron_rod.cpp | 2 +- src/reactor/reactor.cpp | 2 +- 23 files changed, 138 insertions(+), 89 deletions(-) create mode 100644 assets/model/reactor_core_button1.stl create mode 100644 assets/model/reactor_core_button2.stl create mode 100644 assets/model/reactor_core_button3.stl create mode 100644 assets/model/reactor_core_button4.stl create mode 100644 assets/model/reactor_core_button5.stl create mode 100644 assets/model/reactor_core_button6.stl create mode 100644 assets/model/reactor_core_button7.stl create mode 100644 assets/model/reactor_core_button8.stl create mode 100644 assets/model/reactor_core_button9.stl create mode 100644 assets/model/reactor_core_joystick.stl diff --git a/assets/model/reactor_core_button1.stl b/assets/model/reactor_core_button1.stl new file mode 100644 index 0000000000000000000000000000000000000000..7e26a5c17871439f124dc94ecea2fbaf12d503d3 GIT binary patch literal 184 zcmZ>*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_u=lR}Xn)Hg-C>=(BA8t* ak_TpUU4Lv3V*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_u)mPW>~PB=-C>=(BA8t* ak_Tod==`*Yv5~c)>OfWnV#7>gU;qF=#U)b! literal 0 HcmV?d00001 diff --git a/assets/model/reactor_core_button3.stl b/assets/model/reactor_core_button3.stl new file mode 100644 index 0000000000000000000000000000000000000000..1cb9d8411646a85ba573fe252fb094fd96f34c34 GIT binary patch literal 184 zcmZ>*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_u&);3bGYS@?y$~X5zMX@ a$pf=*Ij}px*vMK?bs(z(v0)}LFaQ9cEFw(+ literal 0 HcmV?d00001 diff --git a/assets/model/reactor_core_button4.stl b/assets/model/reactor_core_button4.stl new file mode 100644 index 0000000000000000000000000000000000000000..7b94757f9f16dab1bb282baaf7988940ea52b5f5 GIT binary patch literal 184 zcmZ>*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_u=lR}Xm2nr#$lbiBA9(4 aGa1b0y8hT6#zxkHssmXShz&D|fdK&HVJJrc literal 0 HcmV?d00001 diff --git a/assets/model/reactor_core_button5.stl b/assets/model/reactor_core_button5.stl new file mode 100644 index 0000000000000000000000000000000000000000..a3539e2ac1ea6bb5d278faed3bd1b930d3e80360 GIT binary patch literal 184 zcmZ>*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_uustWX@4Oz**D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_u)pQN?rOfWnV#7>gU;qI0`6CSg literal 0 HcmV?d00001 diff --git a/assets/model/reactor_core_button7.stl b/assets/model/reactor_core_button7.stl new file mode 100644 index 0000000000000000000000000000000000000000..d0f5dc501c875186e79b5bebcf150f446611789e GIT binary patch literal 184 zcmZ>*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_u;;q|*j{aagu^;_MKHVd abs(7SUH8!*#zxkHssmXShz&D|fdK#si75vF literal 0 HcmV?d00001 diff --git a/assets/model/reactor_core_button8.stl b/assets/model/reactor_core_button8.stl new file mode 100644 index 0000000000000000000000000000000000000000..7ce133016fe31ae38ec8e38532cd9f41d1af882e GIT binary patch literal 184 zcmZ>*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_uustWX|J|F!eO1eBADI! aIuOjhkjd--V*D9A4=Nlj5mE6UGRaLP%|OGz!#HPJKBGh!eIFrjE_u)pQN?x40m!eO1eBADI! aIuOjR7U6S%v5~c)>OfWnV#7>gU;qFku_Mg@ literal 0 HcmV?d00001 diff --git a/assets/model/reactor_core_joystick.stl b/assets/model/reactor_core_joystick.stl new file mode 100644 index 0000000000000000000000000000000000000000..94a9008ff5683d03a2048bd87a013a32791da9a5 GIT binary patch literal 2384 zcmbVOJ!q6c5FJpg)Jg=cQiz4<5sU~n`3^zSq!DcViHO`?rA9t1G&b6#i`XVru(T0W z0wUaJNEF0NC8V*{LWzx734${_`@Vh4o*-WJjyG@L&g{(aox6K`zP{7%O$_S!n-gbm z^l$b0^@&rR$<9gnpI=8s_1l^0jRW^9*T1O-gF$y?`H=p1yfvDwetp@jo_+0i4U0Tf z#rhZpM*;gu&(G|yWU;zRqMS+R?m7IL@=%YV&PSo(C}2NHGjDW0 zf`S=f%j4&dwYJhCTHQwHqfl@ZuzToyG&&za!3?l@JURZd?HCcAk4ERCP;eBmduX>e zIv=4EnE^JBsi_xLHXmaZ90i6G$J?i&;O%T(0tGzmh9bKkZMPoGa2{MYk*7;Z z!Hg-eOY9`fyh!)kYI`eYxOXu(ek=B1hNqUdM98D{V21Y<@5hiwt6;_ycyl`mZ{u}E zb#o@Y0oO2BFvE4@ij;~}#k5N}zg)o#=akP l6p0(IP;eBm&xh`I+q*%*46yf7dYkZFVtcnx@T>s4#~+`5az_9F literal 0 HcmV?d00001 diff --git a/assets/model/reactor_core_scram.stl b/assets/model/reactor_core_scram.stl index ddfcefd888539ce75a94d9518fc1633ec7c47da2..35f8899f989bbead8ae260f098eb7766fff649bd 100644 GIT binary patch literal 1584 zcmbVLJxc>Y6kOEC11lj#q9I=v7M?~$4JmFBf?%yE@mq6(pizQ_m7YJr-x07>e}LFU z#9D0B&i2w6IrHxB?apfFRSUDT^WMx{1ESuept}X?wz+6#x0s zUDC>8Vm9J>PNzR7?a!LLUdTErD=S+iH#`fGkv&U%?lNwffyjrSR*b&(uzCq6^BhDb ztzns~M|xg)NP72svEIRUVvaQsdA&->mcJX`dLB&4um0#PL}fj3#|%WK9+EO??Szc) zW>N;hR;=+>jTk|2;UGeccYjl9^tLx*22Mp9jL=j?E4oF~o|o5S2JcQ9h|uOQS8L%d za^z_+I)`~EcM&0Xix1WK-Hhxs`HTrt9*j_e%%Eho22O>@qn}e#UEb$mkM8EmT}1Nr zg4%riv!EOiVry9^h{$7UM7i6$Gy-{KS2Y6>VsL`=lFl5bLWHK`me91iSG>6po`VQ& z&P~L>K;I{ZiRga4MNDyg%Bf6BE}|7z-nSBq0$mRbRiTM z5ke(h*g`=eRd@a@%r{t)khQMFWreJ&WRZe(5$~BhXXZR69|XHP&ADgJd+*+N@B0QX z&CSkVoSN)7KR^3k$Ez2n-k+SB?|Sj{bEjVj|L5No6P;;n^}oBmSaW?x^2YE~a((5P z{onC-LnmtEttXPU-l+sQgbP1!^?$IBLZgWNOMid4Jka;xV&GAC5MD5O-RfR?oyT>z@y|Xu#GY@5m;c=|@R5IQ=k?-SqQ*`g6 z&?sW}7_%z;_m{1H>_Zu1cnlApNOf5W@p~{`M+8{#nbWK}8WqxxzhceyrL2$P|onru^=$-6v%qHb2&EepD11 zMeJX)`O&cXktviR#y&pYJudmM`O&cXQBi0Vv3pns8#X^Og)+qOSZFyeb=6FvQN-?H zm6+Q6$UKxGhR0IR6LLSADKv`MJ%;T2L-~zTh8P~}OYL&cle>fIr}?dA6uzZV#O`68 zA!TP!h8P|zN7{={6oPf1l--9>_?AWyyN7kSls!=yVt8z?w-p^Vgk}njB6bg(2C2=D ztWzsP43FEZZAmmgQkx$Yg+>ua9{uQv$`ErO6@)v+I#PC37%Xi6$RmmUuD}zz^mPQe~hrMJ{zGRdk zh6gINd|%mXDdlU4QTUcd5xYlzqiV>9GQ{w}eJtOJ%@i6%>>hb%$UKxGh6nme`QB}& z&?sW}*gSmnN9-Yldh~WiZ!h2KFszelTfh%kuuW(h$K*9GFzQlJ>yeeg|D!zBH+VWjeYU)u(#?JY&z=@PE06kr0 zbVhML7W*hNsEkf$eGQarV$SKV?-G3n#R_HgMW!#n5EdRi`jhMG*>3=zqP|7-?HhY2 z0|omPJlI!ag)&$b`v+EA-t$sZkA7ic=e(&ntMW#vB4)}vp*3B`<8+nLI@Sse;n3x_ zB7@3kRcgIKas3B(sz;eE9PKTqWO<=Zu=-YgEE>;%~Q6Im$?sRG;8sx zmph63m7cVoVF=&++EsWcqbGW>v(od?{e{r^TUU_}Wpqym+lQ|3V5?HU*u#DsH0-xQ z)`59G==#LyAKJA;u-^s^`)yEBXcV!}5BqJfX1@(Gg)+q6qsqGyg8eqYOTVJfSwid{ zlJk_`b;iF7%z5R1AA0y2Z&a!b&j(Sw^R7@2Wmt)bVqd8$lwr;h#okp_D8u_f1*Xsb z3Np+&qS%97v3d9!?_jD7Z!MzO=Ut&^r3|YbQJf{N(6fq}@)sTQgx{QnN3kkpSmB7` zOmv0qqsX8#>~M(U+;xSnN*UgBL~*uP70R&hQi18Szk&>JEu#2FsVbD=G(Z&JL9VcT z6lbLjZ!MzYTcA5vMk`-yx{S9Ol`5lktQDHgsA5&h0JAE!-t5a)+OnRwxA#$0iCSZE z^_1(XXSbI1qZOmIP{v~)%4q&Iv(cufpHBTXY@nIY1N2-kGMo&Fnl`?wLdWM)$ t-+u49da8_`=)ulPPeJz=uSyx+ldd*|?Y+ld;;NL<6&`F=>Ze}{;Xh4Ry{G^H diff --git a/assets/unbaked/scene.blend b/assets/unbaked/scene.blend index b894166..e58cc31 100644 --- a/assets/unbaked/scene.blend +++ b/assets/unbaked/scene.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:de45f07d6afa36e19985970817efc827b060d18a7166350dfd27d2df8d1b120f -size 80493828 +oid sha256:66f728c728db0905aadf7f0052cb42cbaf72308100e3088e271af70d22ab3ec4 +size 80123820 diff --git a/src/graphics/input/focus.cpp b/src/graphics/input/focus.cpp index 4b58b12..d7674a2 100644 --- a/src/graphics/input/focus.cpp +++ b/src/graphics/input/focus.cpp @@ -1,16 +1,23 @@ -#include "focus.hpp" -#include "../camera.hpp" -#include "../../util/math.hpp" -#include "mouse.hpp" - -#include - #include #include +#include "focus.hpp" +#include "../../util/math.hpp" +#include "../window.hpp" +#include "../camera.hpp" +#include "../resize.hpp" +#include "mouse.hpp" + +#include + +#include + using namespace sim::graphics; +static glm::vec<3, double> trigger_near; +static glm::vec<3, double> trigger_far; + static std::unique_ptr state = nullptr; static bool mouse_visible = false; static bool mouse_locked = false; @@ -44,9 +51,28 @@ void focus::on_mouse_button(int button, int action, int mods) state->on_mouse_button(button, action, mods); } - else if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) + else if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { triggered = true; + + if(is_mouse_locked()) + { + double mx, my; + mouse::get(mx, my); + + 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); + } + + else + { + trigger_near = camera::get_pos(); + trigger_far = trigger_near + camera::get_normal(); + } } } @@ -66,15 +92,30 @@ void focus::on_charcode(unsigned int c) } } +glm::vec<3, double> focus::get_trigger_near() +{ + return trigger_near; +} + +glm::vec<3, double> focus::get_trigger_far() +{ + return trigger_far; +} + void focus::update() { triggered = false; - bool locked = is_mouse_locked(); + bool c = is_mouse_locked(); - if(locked != mouse_visible) + if(state && !state->cursor_is_visible()) { - if(locked) + c = false; + } + + if(c != mouse_visible) + { + if(c) { mouse::show_cursor(); } @@ -84,7 +125,7 @@ void focus::update() mouse::hide_cursor(); } - mouse_visible = locked; + mouse_visible = c; } if(state) diff --git a/src/graphics/input/focus.hpp b/src/graphics/input/focus.hpp index b641f30..a586f0f 100644 --- a/src/graphics/input/focus.hpp +++ b/src/graphics/input/focus.hpp @@ -1,6 +1,8 @@ #pragma once +#include + #include namespace sim::graphics::focus @@ -9,6 +11,7 @@ namespace sim::graphics::focus struct focus_t { virtual ~focus_t() { } + virtual bool cursor_is_visible() { return true; } virtual void on_keypress(int key, int sc, int action, int mods) { } virtual void on_mouse_button(int button, int action, int mods) { } virtual void on_cursor_pos(double x, double y) { } @@ -21,6 +24,8 @@ void clear_focus(); bool is_triggered(); bool is_mouse_locked(); void clear_mouse_locked(); +glm::vec<3, double> get_trigger_near(); +glm::vec<3, double> get_trigger_far(); void set(std::unique_ptr f); void on_keypress(int key, int sc, int action, int mods); void on_mouse_button(int button, int action, int mods); diff --git a/src/graphics/input/mouse.cpp b/src/graphics/input/mouse.cpp index 5059b6a..4403e11 100644 --- a/src/graphics/input/mouse.cpp +++ b/src/graphics/input/mouse.cpp @@ -38,6 +38,11 @@ void mouse::get(double& x, double& y) y = ypos; } +glm::vec2 mouse::get() +{ + return {xpos, ypos}; +} + void mouse::show_cursor() { double x, y; diff --git a/src/graphics/input/mouse.hpp b/src/graphics/input/mouse.hpp index 0534ead..8d2dc86 100644 --- a/src/graphics/input/mouse.hpp +++ b/src/graphics/input/mouse.hpp @@ -1,10 +1,13 @@ #pragma once +#include + namespace sim::graphics::mouse { void init(); +glm::vec2 get(); void get(double& x, double& y); void show_cursor(); void hide_cursor(); diff --git a/src/graphics/mesh/mesh.cpp b/src/graphics/mesh/mesh.cpp index db7fde6..bf9644e 100644 --- a/src/graphics/mesh/mesh.cpp +++ b/src/graphics/mesh/mesh.cpp @@ -98,7 +98,10 @@ bool ray_intersects_triangle(vec3 ray_origin, bool mesh::check_focus(double len) const { - return focus::is_triggered() && check_intersect(camera::get_pos(), camera::get_normal() * len); + auto near = focus::get_trigger_near(); + auto far = focus::get_trigger_far(); + + return focus::is_triggered() && check_intersect(near, glm::normalize(far - near) * len); } bool mesh::check_focus() const diff --git a/src/graphics/monitor/core.cpp b/src/graphics/monitor/core.cpp index 6b2a0fe..3a04381 100644 --- a/src/graphics/monitor/core.cpp +++ b/src/graphics/monitor/core.cpp @@ -15,83 +15,42 @@ using namespace sim::graphics; using namespace sim::graphics::monitor; -struct core_focus_t : public focus::focus_t +struct core_joystick : public focus::focus_t { 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); } - void set_all(bool state) + virtual void on_mouse_button(int button, int action, int mods) { - for(int i = 0; i < sim::system::active.reactor->rods.size(); i++) + if(button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) { - sim::reactor::rod* r = sim::system::active.reactor->rods[i].get(); - - if(r->should_select()) - { - r->selected = state; - } + focus::clear_focus(); } } - void toggle_auto() + virtual bool cursor_is_visible() { - //TODO - } - - virtual void on_charcode(unsigned int c) - { - sim::system& sys = sim::system::active; - - switch(c) - { - case 'a': case 'A': - sys.reactor->move_cursor(-1); - break; - case 'd': case 'D': - sys.reactor->move_cursor(1); - break; - case 'w': case 'W': - sys.reactor->move_cursor(-sim::system::active.reactor->height); - break; - case 's': case 'S': - sys.reactor->move_cursor(sim::system::active.reactor->height); - break; - } - } - - virtual void on_keypress(int key, int sc, int action, int mods) - { - if(action != GLFW_PRESS) - { - return; - } - - switch(key) - { - case GLFW_KEY_Z: - sim::system::active.reactor->toggle_selected(); - break; - case GLFW_KEY_C: - toggle_auto(); - break; - case GLFW_KEY_X: - sim::system::active.reactor->reset_rod_speed(); - break; - case GLFW_KEY_Q: - set_all(true); - break; - case GLFW_KEY_E: - set_all(false); - break; - } + return false; } }; core::core() { +} +static void set_all(bool state) +{ + for(int i = 0; i < sim::system::active.reactor->rods.size(); i++) + { + sim::reactor::rod* r = sim::system::active.reactor->rods[i].get(); + + if(r->should_select()) + { + r->selected = state; + } + } } void core::init() @@ -110,22 +69,46 @@ void core::init() rmesh2.load_model("../assets/model/", "reactor_core_interface_cell.stl"); mesh2.bind(); mesh2.set(rmesh2, GL_STATIC_DRAW); - - mesh_click.load_model("../assets/model/", "reactor_core_input.stl"); - mesh_scram.load_model("../assets/model/", "reactor_core_scram.stl"); + + m_buttons[0].load_model("../assets/model/", "reactor_core_button1.stl"); + m_buttons[1].load_model("../assets/model/", "reactor_core_button2.stl"); + m_buttons[2].load_model("../assets/model/", "reactor_core_button3.stl"); + m_buttons[3].load_model("../assets/model/", "reactor_core_button4.stl"); + m_buttons[4].load_model("../assets/model/", "reactor_core_button5.stl"); + m_buttons[5].load_model("../assets/model/", "reactor_core_button6.stl"); + m_buttons[6].load_model("../assets/model/", "reactor_core_button7.stl"); + m_buttons[7].load_model("../assets/model/", "reactor_core_button8.stl"); + m_buttons[8].load_model("../assets/model/", "reactor_core_button9.stl"); + m_joystick.load_model("../assets/model/", "reactor_core_joystick.stl"); + m_scram.load_model("../assets/model/", "reactor_core_scram.stl"); } void core::update() { - if(mesh_click.check_focus()) - { - focus::set(std::make_unique()); - } - - if(mesh_scram.check_focus()) - { + sim::system& sys = sim::system::active; + + if(m_joystick.check_focus()) + focus::set(std::make_unique()); + if(m_scram.check_focus()) sim::system::active.reactor->scram(); - } + if(m_buttons[0].check_focus()) + set_all(true); + if(m_buttons[1].check_focus()) + sys.reactor->move_cursor(-sim::system::active.reactor->height); + if(m_buttons[2].check_focus()) + set_all(false); + if(m_buttons[3].check_focus()) + sys.reactor->move_cursor(-1); + if(m_buttons[4].check_focus()) + sys.reactor->move_cursor(sim::system::active.reactor->height); + if(m_buttons[5].check_focus()) + sys.reactor->move_cursor(1); + if(m_buttons[6].check_focus()) + sim::system::active.reactor->toggle_selected(); + if(m_buttons[7].check_focus()) + sim::system::active.reactor->reset_rod_speed(); +// if(m_buttons[8].check_focus()) +// } void core::render() diff --git a/src/graphics/monitor/core.hpp b/src/graphics/monitor/core.hpp index 677bc31..71653dd 100644 --- a/src/graphics/monitor/core.hpp +++ b/src/graphics/monitor/core.hpp @@ -9,8 +9,11 @@ namespace sim::graphics::monitor class core { - sim::graphics::mesh mesh_click, mesh_scram; sim::graphics::glmesh mesh1, mesh2; + + sim::graphics::mesh m_buttons[9]; + sim::graphics::mesh m_joystick; + sim::graphics::mesh m_scram; public: diff --git a/src/graphics/window.cpp b/src/graphics/window.cpp index 8c9843d..abbfc1d 100644 --- a/src/graphics/window.cpp +++ b/src/graphics/window.cpp @@ -32,6 +32,8 @@ static glmesh MeshScene; static monitor::vessel MonitorVessel; static monitor::core MonitorCore; +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) { if(severity != GL_DEBUG_SEVERITY_NOTIFICATION) @@ -132,6 +134,7 @@ void window::render() 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); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/src/graphics/window.hpp b/src/graphics/window.hpp index 8626cce..f30ae3e 100644 --- a/src/graphics/window.hpp +++ b/src/graphics/window.hpp @@ -2,12 +2,15 @@ #pragma once #include +#include #include "../system.hpp" namespace sim::graphics::window { +extern glm::mat4 projection_matrix; + bool should_close(); void create(); void update(double dt); diff --git a/src/reactor/control/boron_rod.cpp b/src/reactor/control/boron_rod.cpp index 12d893d..f7196ad 100644 --- a/src/reactor/control/boron_rod.cpp +++ b/src/reactor/control/boron_rod.cpp @@ -50,7 +50,7 @@ void boron_rod::update(double secs) void boron_rod::update_selected(double a) { - inserted += a; + inserted -= a; if(inserted > 1) inserted = 1; if(inserted < 0) inserted = 0; diff --git a/src/reactor/reactor.cpp b/src/reactor/reactor.cpp index 809dd02..ced8e84 100644 --- a/src/reactor/reactor.cpp +++ b/src/reactor/reactor.cpp @@ -58,7 +58,7 @@ void reactor::add_rod_speed(double a) void reactor::scram() { - rod_speed = 0.2; + rod_speed = -0.2; for(int i = 0; i < size; i++) {