Stop PIPE graphics from creating a particle every frame.

Remove temperature setting, this feature is beyond useless now, PROP+Lua are better ways to manually set pipe.
This commit is contained in:
cracker64
2014-12-06 01:16:04 -05:00
parent 9fdcc28dac
commit 783b2c1736

View File

@@ -1,4 +1,7 @@
#include "simulation/Elements.h" #include "simulation/Elements.h"
//Temp particle used for graphics
Particle tpart;
//#TPT-Directive ElementClass Element_PIPE PT_PIPE 99 //#TPT-Directive ElementClass Element_PIPE PT_PIPE 99
Element_PIPE::Element_PIPE() Element_PIPE::Element_PIPE()
{ {
@@ -44,6 +47,8 @@ Element_PIPE::Element_PIPE()
Update = &Element_PIPE::update; Update = &Element_PIPE::update;
Graphics = &Element_PIPE::graphics; Graphics = &Element_PIPE::graphics;
memset(&tpart, 0, sizeof(Particle));
} }
#define PFLAG_NORMALSPEED 0x00010000 #define PFLAG_NORMALSPEED 0x00010000
@@ -215,18 +220,6 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
} }
} }
else if (!parts[i].ctype && parts[i].life<=10) else if (!parts[i].ctype && parts[i].life<=10)
{
if (parts[i].temp<272.15)//manual pipe colors
{
if (parts[i].temp>173.25)
parts[i].ctype = 2;
else if (parts[i].temp>73.25)
parts[i].ctype = 3;
else if (parts[i].temp>=0)
parts[i].ctype = 4;
parts[i].life = 0;
}
else
{ {
// make a border // make a border
for (rx=-2; rx<3; rx++) for (rx=-2; rx<3; rx++)
@@ -246,7 +239,6 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
if (parts[i].life<=1) if (parts[i].life<=1)
parts[i].ctype = 1; parts[i].ctype = 1;
} }
}
else if (parts[i].ctype==1)//wait for empty space before starting to generate automatic pipe pattern else if (parts[i].ctype==1)//wait for empty space before starting to generate automatic pipe pattern
{ {
if (!parts[i].life) if (!parts[i].life)
@@ -287,20 +279,9 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
//#TPT-Directive ElementHeader Element_PIPE static int graphics(GRAPHICS_FUNC_ARGS) //#TPT-Directive ElementHeader Element_PIPE static int graphics(GRAPHICS_FUNC_ARGS)
int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS) int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS)
{ {
if ((cpart->tmp&0xFF)>0 && (cpart->tmp&0xFF)<PT_NUM && ren->sim->elements[(cpart->tmp&0xFF)].Enabled) int t = cpart->tmp & 0xFF;;
if (t>0 && t<PT_NUM && ren->sim->elements[t].Enabled)
{ {
//Create a temp. particle and do a subcall.
Particle tpart;
int t;
memset(&tpart, 0, sizeof(Particle));
tpart.type = cpart->tmp&0xFF;
tpart.temp = cpart->temp;
tpart.life = cpart->tmp2;
tpart.tmp = cpart->pavg[0];
tpart.ctype = cpart->pavg[1];
if (tpart.type == PT_PHOT && tpart.ctype == 0x40000000)
tpart.ctype = 0x3FFFFFFF;
t = tpart.type;
if (ren->graphicscache[t].isready) if (ren->graphicscache[t].isready)
{ {
*pixel_mode = ren->graphicscache[t].pixel_mode; *pixel_mode = ren->graphicscache[t].pixel_mode;
@@ -315,6 +296,15 @@ int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS)
} }
else else
{ {
//Emulate the graphics of stored particle
tpart.type = t;
tpart.temp = cpart->temp;
tpart.life = cpart->tmp2;
tpart.tmp = cpart->pavg[0];
tpart.ctype = cpart->pavg[1];
if (t == PT_PHOT && tpart.ctype == 0x40000000)
tpart.ctype = 0x3FFFFFFF;
*colr = PIXR(ren->sim->elements[t].Colour); *colr = PIXR(ren->sim->elements[t].Colour);
*colg = PIXG(ren->sim->elements[t].Colour); *colg = PIXG(ren->sim->elements[t].Colour);
*colb = PIXB(ren->sim->elements[t].Colour); *colb = PIXB(ren->sim->elements[t].Colour);
@@ -333,44 +323,24 @@ int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS)
} }
else else
{ {
if (cpart->ctype==2) switch (cpart->ctype){
{ case 2:
*colr = 50; *colr = 50;
*colg = 1; *colg = 1;
*colb = 1; *colb = 1;
} break;
else if (cpart->ctype==3) case 3:
{
*colr = 1; *colr = 1;
*colg = 50; *colg = 50;
*colb = 1; *colb = 1;
} break;
else if (cpart->ctype==4) case 4:
{
*colr = 1; *colr = 1;
*colg = 1; *colg = 1;
*colb = 50; *colb = 50;
} break;
else if (cpart->temp<272.15&&cpart->ctype!=1) default:
{ break;
if (cpart->temp>173.25&&cpart->temp<273.15)
{
*colr = 50;
*colg = 1;
*colb = 1;
}
if (cpart->temp>73.25&&cpart->temp<=173.15)
{
*colr = 1;
*colg = 50;
*colb = 1;
}
if (cpart->temp>=0&&cpart->temp<=73.15)
{
*colr = 1;
*colg = 1;
*colb = 50;
}
} }
} }
return 0; return 0;
@@ -439,7 +409,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
rndstore = rndstore>>3; rndstore = rndstore>>3;
rx = pos_1_rx[rnd]; rx = pos_1_rx[rnd];
ry = pos_1_ry[rnd]; ry = pos_1_ry[rnd];
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) if (BOUNDS_CHECK)
{ {
r = sim->pmap[y+ry][x+rx]; r = sim->pmap[y+ry][x+rx];
if (!r) if (!r)