Particle/powder mixing tool
This commit is contained in:
parent
1171c308e1
commit
e7b0e3f90d
60
src/simulation/simtools/Mix.cpp
Executable file
60
src/simulation/simtools/Mix.cpp
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#include "ToolClasses.h"
|
||||||
|
//#TPT-Directive ToolClass Tool_Mix TOOL_MIX 6
|
||||||
|
Tool_Mix::Tool_Mix()
|
||||||
|
{
|
||||||
|
Identifier = "DEFAULT_TOOL_MIX";
|
||||||
|
Name = "MIX";
|
||||||
|
Colour = PIXPACK(0xFFD090);
|
||||||
|
Description = "Mixes particles.";
|
||||||
|
}
|
||||||
|
|
||||||
|
int Tool_Mix::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength)
|
||||||
|
{
|
||||||
|
int thisPart = sim->pmap[y][x];
|
||||||
|
if(!thisPart)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(rand() % 100 != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int distance = strength * 10;
|
||||||
|
|
||||||
|
if(!(sim->elements[thisPart&0xFF].Properties & TYPE_PART))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int newX = x + (rand() % distance) - (distance/2);
|
||||||
|
int newY = y + (rand() % distance) - (distance/2);
|
||||||
|
|
||||||
|
if(newX < 0 || newY < 0 || newX >= XRES || newY >= YRES)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int thatPart = sim->pmap[newY][newX];
|
||||||
|
if(!thatPart)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(!(sim->elements[thatPart&0xFF].Properties & TYPE_PART))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
sim->pmap[y][x] = thatPart;
|
||||||
|
sim->parts[thatPart>>8].x = x;
|
||||||
|
sim->parts[thatPart>>8].y = y;
|
||||||
|
|
||||||
|
sim->pmap[newY][newX] = thisPart;
|
||||||
|
sim->parts[thisPart>>8].x = newX;
|
||||||
|
sim->parts[thisPart>>8].y = newY;
|
||||||
|
|
||||||
|
/*if(!cpart)
|
||||||
|
return 0;
|
||||||
|
if (cpart->type == PT_PUMP || cpart->type == PT_GPMP)
|
||||||
|
cpart->temp += strength*.1f;
|
||||||
|
else
|
||||||
|
cpart->temp += strength*2.0f;
|
||||||
|
|
||||||
|
if (cpart->temp > MAX_TEMP)
|
||||||
|
cpart->temp = MAX_TEMP;
|
||||||
|
else if (cpart->temp < 0)
|
||||||
|
cpart->temp = 0;
|
||||||
|
return 1;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
Tool_Mix::~Tool_Mix() {}
|
Loading…
Reference in New Issue
Block a user