diff options
Diffstat (limited to 'src/simulation/tools/SolidTool.cpp')
| -rw-r--r-- | src/simulation/tools/SolidTool.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/simulation/tools/SolidTool.cpp b/src/simulation/tools/SolidTool.cpp new file mode 100644 index 0000000..b147820 --- /dev/null +++ b/src/simulation/tools/SolidTool.cpp @@ -0,0 +1,65 @@ +#include "ToolClasses.h" +//#TPT-Directive ToolClass Tool_Solid TOOL_SOLID 6 +//#TPT-Directive ToolHeader Tool_Solid int LastSolid +//#TPT-Directive ToolHeader Tool_Solid virtual int Start(Simulation * sim, Particle * cpart, int x, int y) +Tool_Solid::Tool_Solid() +{ + Identifier = "DEFAULT_TOOL_SOLID"; + Name = "SLD"; + Colour = PIXPACK(0xA0A080); + Description = "Makes affected particles into a solid."; + LastSolid = -1; +} + +int Tool_Solid::Start(Simulation * sim, Particle * cpart, int x, int y) { + if(cpart && cpart->sld) + LastSolid = cpart->sld - 1; + else + LastSolid = -1; + return 1; +} + +int Tool_Solid::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + int solid_index = LastSolid, i; + + if(!cpart || cpart->sld || + !(sim->elements[cpart->type].Properties & TYPE_SOLID)) + return 0; + + if(solid_index == -1) + for(i=0; i<NSOLID; i++) + if(sim->solids[i].first == -1) { + solid_index = i; + break; + } + if(solid_index == -1) + return 0; + LastSolid = solid_index; + + Solid *sld = sim->solids + solid_index; + + cpart->sld = solid_index + 1; + if(sld->first == -1) { + sld->vx = sld->vy = sld->vrot = 0.0f; + sld->cx = x; + sld->cy = y; + sld->ax = sld->ay = sld->arot = 0.0f; + sld->an = 0; + sld->bf = 0; + sld->bpx[0] = -10000; + sld->bpx[1] = 10000; + sld->bpy[2] = -10000; + sld->bpy[3] = 10000; + sld->first = cpart - sim->parts; + } + + cpart->snext = -1; + cpart->sprev = sld->last; + if(sld->last != -1) + sim->parts[sld->last].snext = cpart - sim->parts; + sld->last = cpart - sim->parts; + return 1; +} + +Tool_Solid::~Tool_Solid() {} |
