diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-05 20:49:34 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-05 20:49:34 (GMT) |
| commit | b0158e2f60cffb654e9805f66dca055955769290 (patch) | |
| tree | f46f70056be8acfc3af6878962ea5f33eb0f99cd /src/simulation/Simulation.cpp | |
| parent | 3d0ce2ac37dcfad0b311991e73bc2311d5d67277 (diff) | |
| download | powder-b0158e2f60cffb654e9805f66dca055955769290.zip powder-b0158e2f60cffb654e9805f66dca055955769290.tar.gz | |
Changes to Smudge and blending modes (make them a little slower and easier to handle)
Diffstat (limited to 'src/simulation/Simulation.cpp')
| -rw-r--r-- | src/simulation/Simulation.cpp | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index faa8552..1437912 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -848,6 +848,7 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_, { int rp; float tr, tg, tb, ta, colR = colR_, colG = colG_, colB = colB_, colA = colA_; + float strength = 0.01f; rp = pmap[y][x]; if (!rp) return; @@ -873,52 +874,54 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_, } else if (mode == DECO_ADD) { - ta += (colA*0.1f)*colA; - tr += (colR*0.1f)*colA; - tg += (colG*0.1f)*colA; - tb += (colB*0.1f)*colA; + ta += (colA*strength)*colA; + tr += (colR*strength)*colA; + tg += (colG*strength)*colA; + tb += (colB*strength)*colA; } else if (mode == DECO_SUBTRACT) { - ta -= (colA*0.1f)*colA; - tr -= (colR*0.1f)*colA; - tg -= (colG*0.1f)*colA; - tb -= (colB*0.1f)*colA; + ta -= (colA*strength)*colA; + tr -= (colR*strength)*colA; + tg -= (colG*strength)*colA; + tb -= (colB*strength)*colA; } else if (mode == DECO_MULTIPLY) { - tr *= 1.0f+(colR*0.1f)*colA; - tg *= 1.0f+(colG*0.1f)*colA; - tb *= 1.0f+(colB*0.1f)*colA; + tr *= 1.0f+(colR*strength)*colA; + tg *= 1.0f+(colG*strength)*colA; + tb *= 1.0f+(colB*strength)*colA; } else if (mode == DECO_DIVIDE) { - tr /= 1.0f+(colR*0.1f)*colA; - tg /= 1.0f+(colG*0.1f)*colA; - tb /= 1.0f+(colB*0.1f)*colA; + tr /= 1.0f+(colR*strength)*colA; + tg /= 1.0f+(colG*strength)*colA; + tb /= 1.0f+(colB*strength)*colA; } else if (mode == DECO_SMUDGE) { - int rx, ry, num = 0; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) + float tas = ta, trs = tr, tgs = tg, tbs = tb; + int rx, ry; + float num = 1.0f; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) { if ((pmap[y+ry][x+rx]&0xFF) && parts[pmap[y+ry][x+rx]>>8].dcolour) { Particle part = parts[pmap[y+ry][x+rx]>>8]; num++; - ta += float((part.dcolour>>24)&0xFF)/255.0f; - tr += float((part.dcolour>>16)&0xFF)/255.0f; - tg += float((part.dcolour>>8)&0xFF)/255.0f; - tb += float((part.dcolour)&0xFF)/255.0f; + tas += ((float)((part.dcolour>>24)&0xFF))/255.0f; + trs += ((float)((part.dcolour>>16)&0xFF))/255.0f; + tgs += ((float)((part.dcolour>>8)&0xFF))/255.0f; + tbs += ((float)((part.dcolour)&0xFF))/255.0f; } } if (num == 0) return; - ta = ta/float(num+1); - tr = tr/float(num+1); - tg = tg/float(num+1); - tb = tb/float(num+1); + ta = ((tas/num)*0.1f) + (ta*0.9f); + tr = ((trs/num)*0.1f) + (tr*0.9f); + tg = ((tgs/num)*0.1f) + (tg*0.9f); + tb = ((tbs/num)*0.1f) + (tb*0.9f); } colA_ = ta*255.0f; |
