Digitization (PSNS) and Application of Digitized Pressure (PUMP) (#532)

This commit is contained in:
Novocain1 2018-03-03 23:04:51 -05:00 committed by jacob1
parent c3ff761288
commit 68efe49a5b
2 changed files with 43 additions and 1 deletions

View File

@ -48,6 +48,8 @@ Element_PSNS::Element_PSNS()
int Element_PSNS::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
float photonWl = 0.0f;
bool setFilt = false;
if (sim->pv[y/CELL][x/CELL] > parts[i].temp-273.15f)
{
parts[i].life = 0;
@ -70,6 +72,35 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS)
}
}
}
if (parts[i].tmp == 1)
{
parts[i].life = 0;
setFilt = true;
photonWl = sim->pv[y / CELL][x / CELL];
if (setFilt)
{
int nx, ny;
for (rx = -1; rx < 2; rx++)
for (ry = -1; ry < 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y + ry][x + rx];
if (!r)
continue;
nx = x + rx;
ny = y + ry;
while (TYP(r) == PT_FILT)
{
parts[ID(r)].ctype = 0x10000000 + roundl(photonWl) + 256;
nx += rx;
ny += ry;
if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES)
break;
r = pmap[ny][nx];
}
}
}
}
return 0;
}

View File

@ -63,7 +63,7 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (!(rx && ry))
if (parts[i].tmp != 1 && (!(rx && ry)))
{
sim->pv[(y/CELL)+ry][(x/CELL)+rx] += 0.1f*((parts[i].temp-273.15)-sim->pv[(y/CELL)+ry][(x/CELL)+rx]);
}
@ -81,6 +81,17 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS)
else if (parts[ID(r)].life==0)
parts[ID(r)].life = 10;
}
if (parts[i].tmp == 1 && (TYP(r) == PT_FILT || TYP(r) == PT_PHOT || TYP(r) == PT_BRAY))
{
if (parts[ID(r)].ctype >= 0x10000000 && parts[ID(r)].ctype <= 0x10000000 + 512)
{
sim->pv[(y / CELL) + ry][(x / CELL) + rx] = (parts[ID(r)].ctype - 0x10000000) - 256;
}
else
{
sim->pv[(y / CELL) + ry][(x / CELL) + rx] = 0.0f;
}
}
}
}
return 0;