mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-17 21:51:20 +02:00
Remove old latent heat code, but leave LATENTHEAT switch and element
property in case if we do a proper implementation later.
This commit is contained in:
@@ -2291,19 +2291,10 @@ 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
|
||||||
{
|
|
||||||
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);
|
|
||||||
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
parts[i].vx += 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);
|
parts[i].vy += elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
auto transitionOccurred = false;
|
auto transitionOccurred = false;
|
||||||
|
|
||||||
@@ -2355,39 +2346,18 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
//heat transfer code
|
//heat transfer code
|
||||||
auto h_count = 0;
|
auto h_count = 0;
|
||||||
bool cond;
|
bool cond;
|
||||||
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);
|
cond = t && (t!=PT_HSWC||parts[i].life==10) && rng.chance(int(elements[t].HeatConduct*gel_scale), 250);
|
||||||
}
|
|
||||||
if (cond)
|
if (cond)
|
||||||
{
|
{
|
||||||
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
||||||
{
|
|
||||||
if constexpr (LATENTHEAT)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
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;
|
|
||||||
auto pt = c_heat/c_Cm;
|
|
||||||
pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
|
||||||
parts[i].temp = pt;
|
|
||||||
//Pressure increase from heat (temporary)
|
|
||||||
pv[y/CELL][x/CELL] += (pt-hv[y/CELL][x/CELL])*0.004;
|
|
||||||
hv[y/CELL][x/CELL] = pt;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
auto c_heat = (hv[y/CELL][x/CELL]-parts[i].temp)*0.04;
|
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);
|
c_heat = restrict_flt(c_heat, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
||||||
parts[i].temp += c_heat;
|
parts[i].temp += c_heat;
|
||||||
hv[y/CELL][x/CELL] -= c_heat;
|
hv[y/CELL][x/CELL] -= c_heat;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
auto c_heat = 0.0f;
|
auto c_heat = 0.0f;
|
||||||
float c_Cm = 0.0f;
|
|
||||||
int surround_hconduct[8];
|
int surround_hconduct[8];
|
||||||
for (auto j=0; j<8; j++)
|
for (auto j=0; j<8; j++)
|
||||||
{
|
{
|
||||||
@@ -2405,47 +2375,17 @@ 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);
|
||||||
if constexpr (LATENTHEAT)
|
|
||||||
{
|
|
||||||
if (rt==PT_GEL)
|
|
||||||
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*std::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;
|
c_heat += parts[ID(r)].temp;
|
||||||
}
|
|
||||||
h_count++;
|
h_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float pt = R_TEMP;
|
float pt = R_TEMP;
|
||||||
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*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 = (c_heat+parts[i].temp)/(h_count+1);
|
||||||
pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
||||||
for (auto j=0; j<8; j++)
|
for (auto j=0; j<8; j++)
|
||||||
{
|
{
|
||||||
parts[surround_hconduct[j]].temp = pt;
|
parts[surround_hconduct[j]].temp = pt;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
auto ctemph = pt;
|
auto ctemph = pt;
|
||||||
auto ctempl = pt;
|
auto ctempl = pt;
|
||||||
@@ -2465,27 +2405,10 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
if (elements[t].HighTemperatureTransition != NT && ctemph>=elements[t].HighTemperature)
|
if (elements[t].HighTemperatureTransition != NT && ctemph>=elements[t].HighTemperature)
|
||||||
{
|
{
|
||||||
// particle type change due to high temperature
|
// particle type change due to high temperature
|
||||||
float dbt = ctempl - pt;
|
|
||||||
if (elements[t].HighTemperatureTransition != ST)
|
if (elements[t].HighTemperatureTransition != ST)
|
||||||
{
|
{
|
||||||
if constexpr (LATENTHEAT)
|
|
||||||
{
|
|
||||||
if (elements[t].LatentHeat <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
|
||||||
{
|
|
||||||
pt = (c_heat - elements[t].LatentHeat)/c_Cm;
|
|
||||||
t = elements[t].HighTemperatureTransition;
|
t = elements[t].HighTemperatureTransition;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
|
||||||
s = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
t = elements[t].HighTemperatureTransition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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)
|
||||||
@@ -2500,54 +2423,18 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
if constexpr (LATENTHEAT)
|
|
||||||
{
|
|
||||||
//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;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = 0;
|
s = 0;
|
||||||
}
|
}
|
||||||
else if (t == PT_SLTW)
|
else if (t == PT_SLTW)
|
||||||
{
|
{
|
||||||
if constexpr (LATENTHEAT)
|
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
|
||||||
t = rng.chance(1, 4) ? PT_SALT : PT_WTRV;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (t == PT_BRMT)
|
else if (t == PT_BRMT)
|
||||||
{
|
{
|
||||||
if (parts[i].ctype == PT_TUNG)
|
if (parts[i].ctype == PT_TUNG)
|
||||||
@@ -2579,27 +2466,10 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
else if (elements[t].LowTemperatureTransition != NT && ctempl<elements[t].LowTemperature)
|
else if (elements[t].LowTemperatureTransition != NT && ctempl<elements[t].LowTemperature)
|
||||||
{
|
{
|
||||||
// particle type change due to low temperature
|
// particle type change due to low temperature
|
||||||
float dbt = ctempl - pt;
|
|
||||||
if (elements[t].LowTemperatureTransition != ST)
|
if (elements[t].LowTemperatureTransition != ST)
|
||||||
{
|
{
|
||||||
if constexpr (LATENTHEAT)
|
|
||||||
{
|
|
||||||
if (elements[elements[t].LowTemperatureTransition].LatentHeat >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm))
|
|
||||||
{
|
|
||||||
pt = (c_heat + elements[elements[t].LowTemperatureTransition].LatentHeat)/c_Cm;
|
|
||||||
t = elements[t].LowTemperatureTransition;
|
t = elements[t].LowTemperatureTransition;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
parts[i].temp = restrict_flt(elements[t].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
|
||||||
s = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
t = elements[t].LowTemperatureTransition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
||||||
@@ -2658,14 +2528,7 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = 0;
|
s = 0;
|
||||||
if constexpr (LATENTHEAT)
|
|
||||||
{
|
|
||||||
pt = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
|
||||||
for (auto j=0; j<8; j++)
|
|
||||||
{
|
|
||||||
parts[surround_hconduct[j]].temp = pt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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)
|
||||||
|
Reference in New Issue
Block a user