mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-29 19:00:33 +02:00
Move Simulation::platent to Element::LatentHeat
Also put the feature gated by the macro REALISTIC behind the constexpr LATENTHEAT in SimulationConfig.h.
This commit is contained in:
@@ -61,3 +61,5 @@ constexpr float GLASS_IOR = 1.9f;
|
|||||||
constexpr float GLASS_DISP = 0.07f;
|
constexpr float GLASS_DISP = 0.07f;
|
||||||
|
|
||||||
constexpr float R_TEMP = 22;
|
constexpr float R_TEMP = 22;
|
||||||
|
|
||||||
|
constexpr bool LATENTHEAT = false;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "SimulationConfig.h"
|
||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
|
|
||||||
inline ByteString VersionInfo()
|
inline ByteString VersionInfo()
|
||||||
@@ -23,9 +24,10 @@ inline ByteString VersionInfo()
|
|||||||
{
|
{
|
||||||
sb << " LUACONSOLE";
|
sb << " LUACONSOLE";
|
||||||
}
|
}
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
sb << " REALISTIC";
|
{
|
||||||
#endif
|
sb << " LATENTHEAT";
|
||||||
|
}
|
||||||
if constexpr (NOHTTP)
|
if constexpr (NOHTTP)
|
||||||
{
|
{
|
||||||
sb << " NOHTTP";
|
sb << " NOHTTP";
|
||||||
|
@@ -26,12 +26,15 @@ void initLegacyProps()
|
|||||||
std::vector<StructProperty> properties = Element::GetProperties();
|
std::vector<StructProperty> properties = Element::GetProperties();
|
||||||
for (auto prop : properties)
|
for (auto prop : properties)
|
||||||
{
|
{
|
||||||
|
// TODO: move aliases to the property table in Element.cpp?
|
||||||
if (prop.Name == "MenuVisible")
|
if (prop.Name == "MenuVisible")
|
||||||
legacyPropNames.insert(std::pair<ByteString, StructProperty>("menu", prop));
|
legacyPropNames.insert(std::pair<ByteString, StructProperty>("menu", prop));
|
||||||
else if (prop.Name == "PhotonReflectWavelengths")
|
else if (prop.Name == "PhotonReflectWavelengths")
|
||||||
continue;
|
continue;
|
||||||
else if (prop.Name == "CarriesTypeIn")
|
else if (prop.Name == "CarriesTypeIn")
|
||||||
continue;
|
continue;
|
||||||
|
else if (prop.Name == "LatentHeat")
|
||||||
|
continue;
|
||||||
else if (prop.Name == "Temperature")
|
else if (prop.Name == "Temperature")
|
||||||
legacyPropNames.insert(std::pair<ByteString, StructProperty>("heat", prop));
|
legacyPropNames.insert(std::pair<ByteString, StructProperty>("heat", prop));
|
||||||
else if (prop.Name == "HeatConduct")
|
else if (prop.Name == "HeatConduct")
|
||||||
|
@@ -29,6 +29,7 @@ Element::Element():
|
|||||||
Weight(50),
|
Weight(50),
|
||||||
|
|
||||||
HeatConduct(128),
|
HeatConduct(128),
|
||||||
|
LatentHeat(0),
|
||||||
Description("No description"),
|
Description("No description"),
|
||||||
|
|
||||||
Properties(TYPE_SOLID),
|
Properties(TYPE_SOLID),
|
||||||
@@ -80,6 +81,7 @@ std::vector<StructProperty> const &Element::GetProperties()
|
|||||||
{ "Weight", StructProperty::Integer, offsetof(Element, Weight ) },
|
{ "Weight", StructProperty::Integer, offsetof(Element, Weight ) },
|
||||||
{ "Temperature", StructProperty::Float, offsetof(Element, DefaultProperties.temp ) },
|
{ "Temperature", StructProperty::Float, offsetof(Element, DefaultProperties.temp ) },
|
||||||
{ "HeatConduct", StructProperty::UChar, offsetof(Element, HeatConduct ) },
|
{ "HeatConduct", StructProperty::UChar, offsetof(Element, HeatConduct ) },
|
||||||
|
{ "LatentHeat", StructProperty::UInteger, offsetof(Element, LatentHeat ) },
|
||||||
{ "Description", StructProperty::String, offsetof(Element, Description ) },
|
{ "Description", StructProperty::String, offsetof(Element, Description ) },
|
||||||
{ "State", StructProperty::Removed, 0 },
|
{ "State", StructProperty::Removed, 0 },
|
||||||
{ "Properties", StructProperty::Integer, offsetof(Element, Properties ) },
|
{ "Properties", StructProperty::Integer, offsetof(Element, Properties ) },
|
||||||
|
@@ -38,6 +38,7 @@ public:
|
|||||||
unsigned int PhotonReflectWavelengths;
|
unsigned int PhotonReflectWavelengths;
|
||||||
int Weight;
|
int Weight;
|
||||||
unsigned char HeatConduct;
|
unsigned char HeatConduct;
|
||||||
|
unsigned int LatentHeat;
|
||||||
String Description;
|
String Description;
|
||||||
unsigned int Properties;
|
unsigned int Properties;
|
||||||
unsigned int CarriesTypeIn;
|
unsigned int CarriesTypeIn;
|
||||||
|
@@ -2376,14 +2376,17 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
|
|
||||||
if (elements[t].Diffusion)//the random diffusion that gasses have
|
if (elements[t].Diffusion)//the random diffusion that gasses have
|
||||||
{
|
{
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
//The magic number controls diffusion speed
|
{
|
||||||
parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
//The magic number controls diffusion speed
|
||||||
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||||
#else
|
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||||
parts[i].vx += elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
}
|
||||||
parts[i].vy += elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
else
|
||||||
#endif
|
{
|
||||||
|
parts[i].vx += elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||||
|
parts[i].vy += elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto transitionOccurred = false;
|
auto transitionOccurred = false;
|
||||||
@@ -2434,35 +2437,41 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//heat transfer code
|
//heat transfer code
|
||||||
#ifdef REALISTIC
|
|
||||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale))
|
|
||||||
#else
|
|
||||||
auto h_count = 0;
|
auto h_count = 0;
|
||||||
if (t && (t!=PT_HSWC||parts[i].life==10) && rng.chance(int(elements[t].HeatConduct*gel_scale), 250))
|
bool cond;
|
||||||
#endif
|
if constexpr (LATENTHEAT)
|
||||||
|
{
|
||||||
|
cond = t && (t!=PT_HSWC||parts[i].life==10) && elements[t].HeatConduct*gel_scale > 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cond = t && (t!=PT_HSWC||parts[i].life==10) && rng.chance(int(elements[t].HeatConduct*gel_scale), 250);
|
||||||
|
}
|
||||||
|
if (cond)
|
||||||
{
|
{
|
||||||
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
||||||
{
|
{
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
auto c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]-MIN_PRESSURE)/(MAX_PRESSURE-MIN_PRESSURE)*2;
|
{
|
||||||
float c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]-MIN_PRESSURE)/(MAX_PRESSURE-MIN_PRESSURE)*2;
|
auto c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*std::fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]-MIN_PRESSURE)/(MAX_PRESSURE-MIN_PRESSURE)*2;
|
||||||
auto pt = c_heat/c_Cm;
|
float c_Cm = 96.645/elements[t].HeatConduct*gel_scale*std::fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]-MIN_PRESSURE)/(MAX_PRESSURE-MIN_PRESSURE)*2;
|
||||||
pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
auto pt = c_heat/c_Cm;
|
||||||
parts[i].temp = pt;
|
pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
||||||
//Pressure increase from heat (temporary)
|
parts[i].temp = pt;
|
||||||
pv[y/CELL][x/CELL] += (pt-hv[y/CELL][x/CELL])*0.004;
|
//Pressure increase from heat (temporary)
|
||||||
hv[y/CELL][x/CELL] = pt;
|
pv[y/CELL][x/CELL] += (pt-hv[y/CELL][x/CELL])*0.004;
|
||||||
#else
|
hv[y/CELL][x/CELL] = pt;
|
||||||
auto c_heat = (hv[y/CELL][x/CELL]-parts[i].temp)*0.04;
|
}
|
||||||
c_heat = restrict_flt(c_heat, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
else
|
||||||
parts[i].temp += c_heat;
|
{
|
||||||
hv[y/CELL][x/CELL] -= c_heat;
|
auto c_heat = (hv[y/CELL][x/CELL]-parts[i].temp)*0.04;
|
||||||
#endif
|
c_heat = restrict_flt(c_heat, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
||||||
|
parts[i].temp += c_heat;
|
||||||
|
hv[y/CELL][x/CELL] -= c_heat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto c_heat = 0.0f;
|
auto c_heat = 0.0f;
|
||||||
#ifdef REALISTIC
|
|
||||||
float c_Cm = 0.0f;
|
float c_Cm = 0.0f;
|
||||||
#endif
|
|
||||||
int surround_hconduct[8];
|
int surround_hconduct[8];
|
||||||
for (auto j=0; j<8; j++)
|
for (auto j=0; j<8; j++)
|
||||||
{
|
{
|
||||||
@@ -2480,41 +2489,47 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
&& (t!=PT_FILT || rt!=PT_HSWC || parts[ID(r)].tmp != 1))
|
&& (t!=PT_FILT || rt!=PT_HSWC || parts[ID(r)].tmp != 1))
|
||||||
{
|
{
|
||||||
surround_hconduct[j] = ID(r);
|
surround_hconduct[j] = ID(r);
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
if (rt==PT_GEL)
|
{
|
||||||
gel_scale = parts[ID(r)].tmp*2.55f;
|
if (rt==PT_GEL)
|
||||||
else gel_scale = 1.0f;
|
gel_scale = parts[ID(r)].tmp*2.55f;
|
||||||
|
else gel_scale = 1.0f;
|
||||||
|
|
||||||
c_heat += parts[ID(r)].temp*96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight);
|
c_heat += parts[ID(r)].temp*96.645/elements[rt].HeatConduct*gel_scale*std::fabs(elements[rt].Weight);
|
||||||
c_Cm += 96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight);
|
c_Cm += 96.645/elements[rt].HeatConduct*gel_scale*std::fabs(elements[rt].Weight);
|
||||||
#else
|
}
|
||||||
c_heat += parts[ID(r)].temp;
|
else
|
||||||
#endif
|
{
|
||||||
|
c_heat += parts[ID(r)].temp;
|
||||||
|
}
|
||||||
h_count++;
|
h_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float pt = R_TEMP;
|
float pt = R_TEMP;
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
if (t==PT_GEL)
|
|
||||||
gel_scale = parts[i].tmp*2.55f;
|
|
||||||
else gel_scale = 1.0f;
|
|
||||||
|
|
||||||
if (t == PT_PHOT)
|
|
||||||
pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645);
|
|
||||||
else
|
|
||||||
pt = (c_heat+parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight))/(c_Cm+96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight));
|
|
||||||
|
|
||||||
c_heat += parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight);
|
|
||||||
c_Cm += 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight);
|
|
||||||
parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
|
||||||
#else
|
|
||||||
pt = (c_heat+parts[i].temp)/(h_count+1);
|
|
||||||
pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
|
||||||
for (auto j=0; j<8; j++)
|
|
||||||
{
|
{
|
||||||
parts[surround_hconduct[j]].temp = pt;
|
if (t==PT_GEL)
|
||||||
|
gel_scale = parts[i].tmp*2.55f;
|
||||||
|
else gel_scale = 1.0f;
|
||||||
|
|
||||||
|
if (t == PT_PHOT)
|
||||||
|
pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645);
|
||||||
|
else
|
||||||
|
pt = (c_heat+parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*std::fabs(elements[t].Weight))/(c_Cm+96.645/elements[t].HeatConduct*gel_scale*std::fabs(elements[t].Weight));
|
||||||
|
|
||||||
|
c_heat += parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*std::fabs(elements[t].Weight);
|
||||||
|
c_Cm += 96.645/elements[t].HeatConduct*gel_scale*std::fabs(elements[t].Weight);
|
||||||
|
parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pt = (c_heat+parts[i].temp)/(h_count+1);
|
||||||
|
pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
||||||
|
for (auto j=0; j<8; j++)
|
||||||
|
{
|
||||||
|
parts[surround_hconduct[j]].temp = pt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
auto ctemph = pt;
|
auto ctemph = pt;
|
||||||
auto ctempl = pt;
|
auto ctempl = pt;
|
||||||
@@ -2534,25 +2549,27 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
if (elements[t].HighTemperatureTransition>-1 && ctemph>=elements[t].HighTemperature)
|
if (elements[t].HighTemperatureTransition>-1 && ctemph>=elements[t].HighTemperature)
|
||||||
{
|
{
|
||||||
// particle type change due to high temperature
|
// particle type change due to high temperature
|
||||||
#ifdef REALISTIC
|
|
||||||
float dbt = ctempl - pt;
|
float dbt = ctempl - pt;
|
||||||
if (elements[t].HighTemperatureTransition != PT_NUM)
|
if (elements[t].HighTemperatureTransition != PT_NUM)
|
||||||
{
|
{
|
||||||
if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
if constexpr (LATENTHEAT)
|
||||||
{
|
{
|
||||||
pt = (c_heat - platent[t])/c_Cm;
|
if (elements[t].LatentHeat <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
||||||
t = elements[t].HighTemperatureTransition;
|
{
|
||||||
|
pt = (c_heat - elements[t].LatentHeat)/c_Cm;
|
||||||
|
t = elements[t].HighTemperatureTransition;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
||||||
|
s = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
t = elements[t].HighTemperatureTransition;
|
||||||
s = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (elements[t].HighTemperatureTransition != PT_NUM)
|
|
||||||
t = elements[t].HighTemperatureTransition;
|
|
||||||
#endif
|
|
||||||
else if (t == PT_ICEI || t == PT_SNOW)
|
else if (t == PT_ICEI || t == PT_SNOW)
|
||||||
{
|
{
|
||||||
if (parts[i].ctype > 0 && parts[i].ctype < PT_NUM && parts[i].ctype != t)
|
if (parts[i].ctype > 0 && parts[i].ctype < PT_NUM && parts[i].ctype != t)
|
||||||
@@ -2567,25 +2584,28 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
//One ice table value for all it's kinds
|
{
|
||||||
if (platent[t] <= (c_heat - (elements[parts[i].ctype].LowTemperature - dbt)*c_Cm))
|
//One ice table value for all it's kinds
|
||||||
|
if (elements[t].LatentHeat <= (c_heat - (elements[parts[i].ctype].LowTemperature - dbt)*c_Cm))
|
||||||
|
{
|
||||||
|
pt = (c_heat - elements[t].LatentHeat)/c_Cm;
|
||||||
|
t = parts[i].ctype;
|
||||||
|
parts[i].ctype = PT_NONE;
|
||||||
|
parts[i].life = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parts[i].temp = restrict_flt(elements[parts[i].ctype].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
||||||
|
s = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
pt = (c_heat - platent[t])/c_Cm;
|
|
||||||
t = parts[i].ctype;
|
t = parts[i].ctype;
|
||||||
parts[i].ctype = PT_NONE;
|
parts[i].ctype = PT_NONE;
|
||||||
parts[i].life = 0;
|
parts[i].life = 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
parts[i].temp = restrict_flt(elements[parts[i].ctype].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
|
||||||
s = 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
t = parts[i].ctype;
|
|
||||||
parts[i].ctype = PT_NONE;
|
|
||||||
parts[i].life = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2593,21 +2613,24 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
}
|
}
|
||||||
else if (t == PT_SLTW)
|
else if (t == PT_SLTW)
|
||||||
{
|
{
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
|
||||||
{
|
{
|
||||||
pt = (c_heat - platent[t])/c_Cm;
|
if (elements[t].LatentHeat <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
||||||
|
{
|
||||||
|
pt = (c_heat - elements[t].LatentHeat)/c_Cm;
|
||||||
|
|
||||||
t = rng.chance(1, 4) ? PT_SALT : PT_WTRV;
|
t = rng.chance(1, 4) ? PT_SALT : PT_WTRV;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
||||||
|
s = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
t = rng.chance(1, 4) ? PT_SALT : PT_WTRV;
|
||||||
s = 0;
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
t = rng.chance(1, 4) ? PT_SALT : PT_WTRV;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (t == PT_BRMT)
|
else if (t == PT_BRMT)
|
||||||
{
|
{
|
||||||
@@ -2640,25 +2663,27 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
else if (elements[t].LowTemperatureTransition > -1 && ctempl<elements[t].LowTemperature)
|
else if (elements[t].LowTemperatureTransition > -1 && ctempl<elements[t].LowTemperature)
|
||||||
{
|
{
|
||||||
// particle type change due to low temperature
|
// particle type change due to low temperature
|
||||||
#ifdef REALISTIC
|
|
||||||
float dbt = ctempl - pt;
|
float dbt = ctempl - pt;
|
||||||
if (elements[t].LowTemperatureTransition != PT_NUM)
|
if (elements[t].LowTemperatureTransition != PT_NUM)
|
||||||
{
|
{
|
||||||
if (platent[elements[t].LowTemperatureTransition] >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm))
|
if constexpr (LATENTHEAT)
|
||||||
{
|
{
|
||||||
pt = (c_heat + platent[elements[t].LowTemperatureTransition])/c_Cm;
|
if (elements[elements[t].LowTemperatureTransition].LatentHeat >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm))
|
||||||
t = elements[t].LowTemperatureTransition;
|
{
|
||||||
|
pt = (c_heat + elements[elements[t].LowTemperatureTransition].LatentHeat)/c_Cm;
|
||||||
|
t = elements[t].LowTemperatureTransition;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parts[i].temp = restrict_flt(elements[t].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
||||||
|
s = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parts[i].temp = restrict_flt(elements[t].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
t = elements[t].LowTemperatureTransition;
|
||||||
s = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (elements[t].LowTemperatureTransition != PT_NUM)
|
|
||||||
t = elements[t].LowTemperatureTransition;
|
|
||||||
#endif
|
|
||||||
else if (t == PT_WTRV)
|
else if (t == PT_WTRV)
|
||||||
{
|
{
|
||||||
t = (pt < 273.0f) ? PT_RIME : PT_DSTW;
|
t = (pt < 273.0f) ? PT_RIME : PT_DSTW;
|
||||||
@@ -2717,13 +2742,14 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = 0;
|
s = 0;
|
||||||
#ifdef REALISTIC
|
if constexpr (LATENTHEAT)
|
||||||
pt = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
|
||||||
for (auto j=0; j<8; j++)
|
|
||||||
{
|
{
|
||||||
parts[surround_hconduct[j]].temp = pt;
|
pt = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
||||||
|
for (auto j=0; j<8; j++)
|
||||||
|
{
|
||||||
|
parts[surround_hconduct[j]].temp = pt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (s) // particle type change occurred
|
if (s) // particle type change occurred
|
||||||
{
|
{
|
||||||
if (t==PT_ICEI || t==PT_LAVA || t==PT_SNOW)
|
if (t==PT_ICEI || t==PT_LAVA || t==PT_SNOW)
|
||||||
|
@@ -98,174 +98,6 @@ static std::vector<menu_section> LoadMenus()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<unsigned int> LoadLatent()
|
|
||||||
{
|
|
||||||
return
|
|
||||||
std::vector<unsigned int>{
|
|
||||||
/* NONE */ 0,
|
|
||||||
/* DUST */ 0,
|
|
||||||
/* WATR */ 7500,
|
|
||||||
/* OIL */ 0,
|
|
||||||
/* FIRE */ 0,
|
|
||||||
/* STNE */ 0,
|
|
||||||
/* LAVA */ 0,
|
|
||||||
/* GUN */ 0,
|
|
||||||
/* NITR */ 0,
|
|
||||||
/* CLNE */ 0,
|
|
||||||
/* GAS */ 0,
|
|
||||||
/* C-4 */ 0,
|
|
||||||
/* GOO */ 0,
|
|
||||||
/* ICE */ 1095,
|
|
||||||
/* METL */ 919,
|
|
||||||
/* SPRK */ 0,
|
|
||||||
/* SNOW */ 1095,
|
|
||||||
/* WOOD */ 0,
|
|
||||||
/* NEUT */ 0,
|
|
||||||
/* PLUT */ 0,
|
|
||||||
/* PLNT */ 0,
|
|
||||||
/* ACID */ 0,
|
|
||||||
/* VOID */ 0,
|
|
||||||
/* WTRV */ 0,
|
|
||||||
/* CNCT */ 0,
|
|
||||||
/* DSTW */ 7500,
|
|
||||||
/* SALT */ 0,
|
|
||||||
/* SLTW */ 7500,
|
|
||||||
/* DMND */ 0,
|
|
||||||
/* BMTL */ 0,
|
|
||||||
/* BRMT */ 0,
|
|
||||||
/* PHOT */ 0,
|
|
||||||
/* URAN */ 0,
|
|
||||||
/* WAX */ 0,
|
|
||||||
/* MWAX */ 0,
|
|
||||||
/* PSCN */ 0,
|
|
||||||
/* NSCN */ 0,
|
|
||||||
/* LN2 */ 0,
|
|
||||||
/* INSL */ 0,
|
|
||||||
/* VACU */ 0,
|
|
||||||
/* VENT */ 0,
|
|
||||||
/* RBDM */ 0,
|
|
||||||
/* LRBD */ 0,
|
|
||||||
/* NTCT */ 0,
|
|
||||||
/* SAND */ 0,
|
|
||||||
/* GLAS */ 0,
|
|
||||||
/* PTCT */ 0,
|
|
||||||
/* BGLA */ 0,
|
|
||||||
/* THDR */ 0,
|
|
||||||
/* PLSM */ 0,
|
|
||||||
/* ETRD */ 0,
|
|
||||||
/* NICE */ 0,
|
|
||||||
/* NBLE */ 0,
|
|
||||||
/* BTRY */ 0,
|
|
||||||
/* LCRY */ 0,
|
|
||||||
/* STKM */ 0,
|
|
||||||
/* SWCH */ 0,
|
|
||||||
/* SMKE */ 0,
|
|
||||||
/* DESL */ 0,
|
|
||||||
/* COAL */ 0,
|
|
||||||
/* LO2 */ 0,
|
|
||||||
/* O2 */ 0,
|
|
||||||
/* INWR */ 0,
|
|
||||||
/* YEST */ 0,
|
|
||||||
/* DYST */ 0,
|
|
||||||
/* THRM */ 0,
|
|
||||||
/* GLOW */ 0,
|
|
||||||
/* BRCK */ 0,
|
|
||||||
/* CFLM */ 0,
|
|
||||||
/* FIRW */ 0,
|
|
||||||
/* FUSE */ 0,
|
|
||||||
/* FSEP */ 0,
|
|
||||||
/* AMTR */ 0,
|
|
||||||
/* BCOL */ 0,
|
|
||||||
/* PCLN */ 0,
|
|
||||||
/* HSWC */ 0,
|
|
||||||
/* IRON */ 0,
|
|
||||||
/* MORT */ 0,
|
|
||||||
/* LIFE */ 0,
|
|
||||||
/* DLAY */ 0,
|
|
||||||
/* CO2 */ 0,
|
|
||||||
/* DRIC */ 0,
|
|
||||||
/* CBNW */ 7500,
|
|
||||||
/* STOR */ 0,
|
|
||||||
/* STOR */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* SPNG */ 0,
|
|
||||||
/* RIME */ 0,
|
|
||||||
/* FOG */ 0,
|
|
||||||
/* BCLN */ 0,
|
|
||||||
/* LOVE */ 0,
|
|
||||||
/* DEUT */ 0,
|
|
||||||
/* WARP */ 0,
|
|
||||||
/* PUMP */ 0,
|
|
||||||
/* FWRK */ 0,
|
|
||||||
/* PIPE */ 0,
|
|
||||||
/* FRZZ */ 0,
|
|
||||||
/* FRZW */ 0,
|
|
||||||
/* GRAV */ 0,
|
|
||||||
/* BIZR */ 0,
|
|
||||||
/* BIZRG*/ 0,
|
|
||||||
/* BIZRS*/ 0,
|
|
||||||
/* INST */ 0,
|
|
||||||
/* ISOZ */ 0,
|
|
||||||
/* ISZS */ 0,
|
|
||||||
/* PRTI */ 0,
|
|
||||||
/* PRTO */ 0,
|
|
||||||
/* PSTE */ 0,
|
|
||||||
/* PSTS */ 0,
|
|
||||||
/* ANAR */ 0,
|
|
||||||
/* VINE */ 0,
|
|
||||||
/* INVS */ 0,
|
|
||||||
/* EQVE */ 0,
|
|
||||||
/* SPWN2*/ 0,
|
|
||||||
/* SPAWN*/ 0,
|
|
||||||
/* SHLD1*/ 0,
|
|
||||||
/* SHLD2*/ 0,
|
|
||||||
/* SHLD3*/ 0,
|
|
||||||
/* SHLD4*/ 0,
|
|
||||||
/* LOlZ */ 0,
|
|
||||||
/* WIFI */ 0,
|
|
||||||
/* FILT */ 0,
|
|
||||||
/* ARAY */ 0,
|
|
||||||
/* BRAY */ 0,
|
|
||||||
/* STKM2*/ 0,
|
|
||||||
/* BOMB */ 0,
|
|
||||||
/* C-5 */ 0,
|
|
||||||
/* SING */ 0,
|
|
||||||
/* QRTZ */ 0,
|
|
||||||
/* PQRT */ 0,
|
|
||||||
/* EMP */ 0,
|
|
||||||
/* BREL */ 0,
|
|
||||||
/* ELEC */ 0,
|
|
||||||
/* ACEL */ 0,
|
|
||||||
/* DCEL */ 0,
|
|
||||||
/* TNT */ 0,
|
|
||||||
/* IGNP */ 0,
|
|
||||||
/* BOYL */ 0,
|
|
||||||
/* GEL */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* FREE */ 0,
|
|
||||||
/* WIND */ 0,
|
|
||||||
/* H2 */ 0,
|
|
||||||
/* SOAP */ 0,
|
|
||||||
/* NBHL */ 0,
|
|
||||||
/* NWHL */ 0,
|
|
||||||
/* MERC */ 0,
|
|
||||||
/* PBCN */ 0,
|
|
||||||
/* GPMP */ 0,
|
|
||||||
/* CLST */ 0,
|
|
||||||
/* WIRE */ 0,
|
|
||||||
/* GBMB */ 0,
|
|
||||||
/* FIGH */ 0,
|
|
||||||
/* FRAY */ 0,
|
|
||||||
/* REPL */ 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulationData::init_can_move()
|
void SimulationData::init_can_move()
|
||||||
{
|
{
|
||||||
int movingType, destinationType;
|
int movingType, destinationType;
|
||||||
@@ -504,7 +336,6 @@ SimulationData::SimulationData()
|
|||||||
init_can_move();
|
init_can_move();
|
||||||
msections = LoadMenus();
|
msections = LoadMenus();
|
||||||
wtypes = LoadWalls();
|
wtypes = LoadWalls();
|
||||||
platent = LoadLatent();
|
|
||||||
elements = GetElements();
|
elements = GetElements();
|
||||||
tools = GetTools();
|
tools = GetTools();
|
||||||
}
|
}
|
||||||
|
@@ -174,7 +174,6 @@ class SimulationData : public ExplicitSingleton<SimulationData>
|
|||||||
public:
|
public:
|
||||||
std::array<Element, PT_NUM> elements;
|
std::array<Element, PT_NUM> elements;
|
||||||
std::vector<SimTool> tools;
|
std::vector<SimTool> tools;
|
||||||
std::vector<unsigned int> platent;
|
|
||||||
std::vector<wall_type> wtypes;
|
std::vector<wall_type> wtypes;
|
||||||
std::vector<menu_section> msections;
|
std::vector<menu_section> msections;
|
||||||
char can_move[PT_NUM][PT_NUM];
|
char can_move[PT_NUM][PT_NUM];
|
||||||
|
@@ -31,6 +31,7 @@ void Element::Element_CBNW()
|
|||||||
|
|
||||||
DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
|
DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
|
||||||
HeatConduct = 29;
|
HeatConduct = 29;
|
||||||
|
LatentHeat = 7500;
|
||||||
Description = "Carbonated water. Slowly releases CO2.";
|
Description = "Carbonated water. Slowly releases CO2.";
|
||||||
|
|
||||||
Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE;
|
Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE;
|
||||||
|
@@ -30,6 +30,7 @@ void Element::Element_DSTW()
|
|||||||
|
|
||||||
DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
|
DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
|
||||||
HeatConduct = 23;
|
HeatConduct = 23;
|
||||||
|
LatentHeat = 7500;
|
||||||
Description = "Distilled water, does not conduct electricity.";
|
Description = "Distilled water, does not conduct electricity.";
|
||||||
|
|
||||||
Properties = TYPE_LIQUID|PROP_NEUTPASS;
|
Properties = TYPE_LIQUID|PROP_NEUTPASS;
|
||||||
|
@@ -30,6 +30,7 @@ void Element::Element_ICEI()
|
|||||||
|
|
||||||
DefaultProperties.temp = R_TEMP - 50.0f + 273.15f;
|
DefaultProperties.temp = R_TEMP - 50.0f + 273.15f;
|
||||||
HeatConduct = 46;
|
HeatConduct = 46;
|
||||||
|
LatentHeat = 1095;
|
||||||
Description = "Crushes under pressure. Cools down air.";
|
Description = "Crushes under pressure. Cools down air.";
|
||||||
|
|
||||||
Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_NEUTPASS;
|
Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_NEUTPASS;
|
||||||
|
@@ -27,6 +27,7 @@ void Element::Element_METL()
|
|||||||
Weight = 100;
|
Weight = 100;
|
||||||
|
|
||||||
HeatConduct = 251;
|
HeatConduct = 251;
|
||||||
|
LatentHeat = 919;
|
||||||
Description = "The basic conductor. Meltable.";
|
Description = "The basic conductor. Meltable.";
|
||||||
|
|
||||||
Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW;
|
Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW;
|
||||||
|
@@ -29,6 +29,7 @@ void Element::Element_SLTW()
|
|||||||
Weight = 35;
|
Weight = 35;
|
||||||
|
|
||||||
HeatConduct = 75;
|
HeatConduct = 75;
|
||||||
|
LatentHeat = 7500;
|
||||||
Description = "Saltwater, conducts electricity, difficult to freeze.";
|
Description = "Saltwater, conducts electricity, difficult to freeze.";
|
||||||
|
|
||||||
Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE;
|
Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE;
|
||||||
|
@@ -31,6 +31,7 @@ void Element::Element_SNOW()
|
|||||||
|
|
||||||
DefaultProperties.temp = R_TEMP - 30.0f + 273.15f;
|
DefaultProperties.temp = R_TEMP - 30.0f + 273.15f;
|
||||||
HeatConduct = 46;
|
HeatConduct = 46;
|
||||||
|
LatentHeat = 1095;
|
||||||
Description = "Light particles. Created when ICE breaks under pressure.";
|
Description = "Light particles. Created when ICE breaks under pressure.";
|
||||||
|
|
||||||
Properties = TYPE_PART|PROP_NEUTPASS;
|
Properties = TYPE_PART|PROP_NEUTPASS;
|
||||||
|
@@ -30,6 +30,7 @@ void Element::Element_WATR()
|
|||||||
|
|
||||||
DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
|
DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
|
||||||
HeatConduct = 29;
|
HeatConduct = 29;
|
||||||
|
LatentHeat = 7500;
|
||||||
Description = "Water. Conducts electricity, freezes, and extinguishes fires.";
|
Description = "Water. Conducts electricity, freezes, and extinguishes fires.";
|
||||||
|
|
||||||
Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPASS;
|
Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPASS;
|
||||||
|
Reference in New Issue
Block a user