diff options
| author | Stanislaw Skowronek <skylark@disorder.sko> | 2013-11-13 13:54:46 (GMT) |
|---|---|---|
| committer | Stanislaw Skowronek <skylark@disorder.sko> | 2013-11-13 13:54:46 (GMT) |
| commit | 54769d13eb1b4216b7c6d18e08c3797bf3a48e8a (patch) | |
| tree | b9044f60fc982a75e00eda291be1aa3baaca1656 /src/simulation/tools | |
| parent | f32929128e1d93517f24253ed58801acc32ce814 (diff) | |
| download | powder-54769d13eb1b4216b7c6d18e08c3797bf3a48e8a.zip powder-54769d13eb1b4216b7c6d18e08c3797bf3a48e8a.tar.gz | |
Initial check-in of movable solids. Save/Load/Undo do not work and may crash.
Diffstat (limited to 'src/simulation/tools')
| -rw-r--r-- | src/simulation/tools/SimTool.h | 2 | ||||
| -rw-r--r-- | src/simulation/tools/SolidTool.cpp | 65 |
2 files changed, 67 insertions, 0 deletions
diff --git a/src/simulation/tools/SimTool.h b/src/simulation/tools/SimTool.h index c5a5cb1..17db8f0 100644 --- a/src/simulation/tools/SimTool.h +++ b/src/simulation/tools/SimTool.h @@ -18,6 +18,8 @@ public: SimTool(); virtual ~SimTool() {} virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) { return 0; } + virtual int Start(Simulation * sim, Particle * cpart, int x, int y) { return 0; } + virtual int Click(Simulation * sim, Particle * cpart, int x, int y) { return 0; } }; #endif 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() {} |
