diff --git a/src/simulation/ElementCommon.h b/src/simulation/ElementCommon.h index 6aa2a8c8c..0b8878f81 100644 --- a/src/simulation/ElementCommon.h +++ b/src/simulation/ElementCommon.h @@ -3,23 +3,12 @@ #include "Misc.h" #include "common/tpt-rand.h" #include "common/tpt-compat.h" -#include "ElementDefs.h" #include "ElementClasses.h" #include "Particle.h" #include "ElementGraphics.h" #include "Simulation.h" #include "SimulationData.h" #include "graphics/Renderer.h" +#include "TransitionConstants.h" #include #include - -constexpr float IPL = MIN_PRESSURE - 1; -constexpr float IPH = MAX_PRESSURE + 1; -constexpr float ITL = MIN_TEMP - 1; -constexpr float ITH = MAX_TEMP + 1; - -// no transition (PT_NONE means kill part) -constexpr int NT = -1; - -// special transition - lava ctypes etc need extra code, which is only found and run if ST is given -constexpr int ST = PT_NUM; diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index e5bc6000a..5597942ac 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1,6 +1,7 @@ #include "Simulation.h" #include "Air.h" #include "ElementClasses.h" +#include "TransitionConstants.h" #include "gravity/Gravity.h" #include "ToolClasses.h" #include "SimulationData.h" @@ -2467,11 +2468,11 @@ void Simulation::UpdateParticles(int start, int end) if ((t==PT_ICEI || t==PT_SNOW) && (!sd.IsElement(parts[i].ctype) || parts[i].ctype==PT_ICEI || parts[i].ctype==PT_SNOW)) parts[i].ctype = PT_WATR; - if (elements[t].HighTemperatureTransition>-1 && ctemph>=elements[t].HighTemperature) + if (elements[t].HighTemperatureTransition != NT && ctemph>=elements[t].HighTemperature) { // particle type change due to high temperature float dbt = ctempl - pt; - if (elements[t].HighTemperatureTransition != PT_NUM) + if (elements[t].HighTemperatureTransition != ST) { if constexpr (LATENTHEAT) { @@ -2581,11 +2582,11 @@ void Simulation::UpdateParticles(int start, int end) else s = 0; } - else if (elements[t].LowTemperatureTransition > -1 && ctempl-1 && pv[y/CELL][x/CELL]>elements[t].HighPressure) { + if (elements[t].HighPressureTransition != NT && pv[y/CELL][x/CELL]>elements[t].HighPressure) { // particle type change due to high pressure - if (elements[t].HighPressureTransition!=PT_NUM) + if (elements[t].HighPressureTransition != ST) t = elements[t].HighPressureTransition; else if (t==PT_BMTL) { if (pv[y/CELL][x/CELL]>2.5f) @@ -2803,14 +2804,14 @@ void Simulation::UpdateParticles(int start, int end) else s = 0; } else s = 0; - } else if (elements[t].LowPressureTransition>-1 && pv[y/CELL][x/CELL]-1 && gravtot>(elements[t].HighPressure/4.0f)) { + } else if (elements[t].HighPressureTransition != NT && gravtot>(elements[t].HighPressure/4.0f)) { // particle type change due to high gravity - if (elements[t].HighPressureTransition!=PT_NUM) + if (elements[t].HighPressureTransition != ST) t = elements[t].HighPressureTransition; else if (t==PT_BMTL) { if (gravtot>0.625f) diff --git a/src/simulation/TransitionConstants.h b/src/simulation/TransitionConstants.h new file mode 100644 index 000000000..968f6c245 --- /dev/null +++ b/src/simulation/TransitionConstants.h @@ -0,0 +1,13 @@ +#pragma once +#include "ElementDefs.h" + +constexpr float IPL = MIN_PRESSURE - 1; +constexpr float IPH = MAX_PRESSURE + 1; +constexpr float ITL = MIN_TEMP - 1; +constexpr float ITH = MAX_TEMP + 1; + +// no transition (PT_NONE means kill part) +constexpr int NT = -1; + +// special transition - lava ctypes etc need extra code, which is only found and run if ST is given +constexpr int ST = PT_NUM;