From a3a45db3e43eade57b6d09add8e01a0455837bc9 Mon Sep 17 00:00:00 2001 From: Cracker1000 <39940063+cracker1000@users.noreply.github.com> Date: Thu, 29 Jul 2021 21:20:24 +0530 Subject: [PATCH] Add AMBP and AMBM tools (#778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tamás Bálint Misius --- src/simulation/simtools/AMBM.cpp | 25 +++++++++++++++++++++++++ src/simulation/simtools/AMBP.cpp | 25 +++++++++++++++++++++++++ src/simulation/simtools/meson.build | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 src/simulation/simtools/AMBM.cpp create mode 100644 src/simulation/simtools/AMBP.cpp diff --git a/src/simulation/simtools/AMBM.cpp b/src/simulation/simtools/AMBM.cpp new file mode 100644 index 000000000..692ce36c8 --- /dev/null +++ b/src/simulation/simtools/AMBM.cpp @@ -0,0 +1,25 @@ +#include "simulation/ToolCommon.h" + +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_AMBM() +{ + Identifier = "DEFAULT_TOOL_AMBM"; + Name = "AMBM"; + Colour = PIXPACK(0x00DDFF); + Description = "Decreases ambient air temperature."; + Perform = &perform; +} + +static int perform(Simulation *sim, Particle *cpart, int x, int y, int brushX, int brushY, float strength) +{ + if (!sim->aheat_enable) + { + return 0; + } + + sim->hv[y / CELL][x / CELL] -= strength * 2.0f; + if (sim->hv[y / CELL][x / CELL] > MAX_TEMP) sim->hv[y / CELL][x / CELL] = MAX_TEMP; + if (sim->hv[y / CELL][x / CELL] < MIN_TEMP) sim->hv[y / CELL][x / CELL] = MIN_TEMP; + return 1; +} diff --git a/src/simulation/simtools/AMBP.cpp b/src/simulation/simtools/AMBP.cpp new file mode 100644 index 000000000..2b3b5fb43 --- /dev/null +++ b/src/simulation/simtools/AMBP.cpp @@ -0,0 +1,25 @@ +#include "simulation/ToolCommon.h" + +static int perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength); + +void SimTool::Tool_AMBP() +{ + Identifier = "DEFAULT_TOOL_AMBP"; + Name = "AMBP"; + Colour = PIXPACK(0xFFDD00); + Description = "Increases ambient air temperature."; + Perform = &perform; +} + +static int perform(Simulation *sim, Particle *cpart, int x, int y, int brushX, int brushY, float strength) +{ + if (!sim->aheat_enable) + { + return 0; + } + + sim->hv[y / CELL][x / CELL] += strength * 2.0f; + if (sim->hv[y / CELL][x / CELL] > MAX_TEMP) sim->hv[y / CELL][x / CELL] = MAX_TEMP; + if (sim->hv[y / CELL][x / CELL] < MIN_TEMP) sim->hv[y / CELL][x / CELL] = MIN_TEMP; + return 1; +} diff --git a/src/simulation/simtools/meson.build b/src/simulation/simtools/meson.build index a0c49db1b..68368a169 100644 --- a/src/simulation/simtools/meson.build +++ b/src/simulation/simtools/meson.build @@ -7,6 +7,8 @@ simulation_tool_ids = [ [ 'NGRV', 5 ], [ 'MIX', 6 ], [ 'CYCL', 7 ], + [ 'AMBM', 8 ], + [ 'AMBP', 9 ], ] simulation_tool_src = []