TPT: Added smudge tool afbe8cf38e

This commit is contained in:
Simon Robertshaw 2012-04-18 16:40:43 +01:00
parent a761fa5cbc
commit 43ae47ba77
4 changed files with 25 additions and 1 deletions

View File

@ -7,7 +7,7 @@
class DecorationTool: public Tool
{
public:
enum ToolType { BlendAdd = DECO_ADD, BlendRemove = DECO_SUBTRACT, BlendMultiply = DECO_MULTIPLY, BlendDivide = DECO_DIVIDE, BlendSet = DECO_DRAW };
enum ToolType { BlendAdd = DECO_ADD, BlendRemove = DECO_SUBTRACT, BlendMultiply = DECO_MULTIPLY, BlendDivide = DECO_DIVIDE, BlendSet = DECO_DRAW, BlendSmudge = DECO_SMUDGE };
ToolType decoMode;

View File

@ -97,6 +97,7 @@ GameModel::GameModel():
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendRemove, "SUB", 0, 0, 0));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendMultiply, "MUL", 0, 0, 0));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", 0, 0, 0));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", 0, 0, 0));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", 0, 0, 0));
//Set default brush palette

View File

@ -371,6 +371,28 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_,
tg /= 1.0f+(colG*0.1f)*colA;
tb /= 1.0f+(colB*0.1f)*colA;
}
else if (mode == DECO_SMUDGE)
{
int rx, ry, num = 0;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
{
if ((pmap[y+ry][x+rx]&0xFF) && parts[pmap[y+ry][x+rx]>>8].dcolour)
{
num++;
ta += float((parts[pmap[y+ry][x+rx]>>8].dcolour>>24)&0xFF)/255.0f;
tr += float((parts[pmap[y+ry][x+rx]>>8].dcolour>>16)&0xFF)/255.0f;
tg += float((parts[pmap[y+ry][x+rx]>>8].dcolour>>8)&0xFF)/255.0f;
tb += float((parts[pmap[y+ry][x+rx]>>8].dcolour)&0xFF)/255.0f;
}
}
if (num == 0)
return;
ta = ta/float(num)+0.5f;
tr = tr/float(num)+0.5f;
tg = tg/float(num)+0.5f;
tb = tb/float(num)+0.5f;
}
colA_ = ta*255.0f;
colR_ = tr*255.0f;

View File

@ -61,6 +61,7 @@
#define DECO_SUBTRACT 2
#define DECO_MULTIPLY 3
#define DECO_DIVIDE 4
#define DECO_SMUDGE 5
//Old IDs for GOL types
#define GT_GOL 78