--- a/hedgewars/uLandGraphics.pas Tue Mar 31 00:15:00 2015 +0200
+++ b/hedgewars/uLandGraphics.pas Tue Mar 31 02:30:29 2015 +0200
@@ -920,7 +920,68 @@
Despeckle:= false
end;
+// a bit of AA for explosions
procedure Smooth(X, Y: LongInt);
+var c, r, g, b, a, i: integer;
+ nx, ny: LongInt;
+ pixel: LongWord;
+begin
+
+// only AA inwards
+if (Land[Y, X] and lfDamaged) = 0 then
+ exit;
+
+// check location
+if (Y <= LongInt(topY) + 1) or (Y >= LAND_HEIGHT-2)
+or (X <= LongInt(leftX) + 1) or (X >= LongInt(rightX) - 1) then
+ exit;
+
+// counter for neighbor pixels that are not known to be undamaged
+c:= 8;
+
+// accumalating rgba value of relevant pixels here
+r:= 0;
+g:= 0;
+b:= 0;
+a:= 0;
+
+// iterate over all neighbor pixels (also itself, will be skipped anyway)
+for nx:= X-1 to X+1 do
+ for ny:= Y-1 to Y+1 do
+ // only consider undamaged neighbors (also leads to skipping itself)
+ if (Land[ny, nx] and lfDamaged) = 0 then
+ begin
+ pixel:= LandPixels[ny, nx];
+ inc(r, (pixel and RMask) shr RShift);
+ inc(g, (pixel and GMask) shr GShift);
+ inc(b, (pixel and BMask) shr BShift);
+ inc(a, (pixel and AMask) shr AShift);
+ dec(c);
+ end;
+
+// nothing do to if all neighbors damaged
+if c < 1 then
+ exit;
+
+// use explosion color for damaged pixels
+for i:= 1 to c do
+ begin
+ inc(r, ExplosionBorderColorR);
+ inc(g, ExplosionBorderColorG);
+ inc(b, ExplosionBorderColorB);
+ inc(a, 255);
+ end;
+
+// set resulting color value based on average of all neighbors
+r:= r div 8;
+g:= g div 8;
+b:= b div 8;
+a:= a div 8;
+LandPixels[y,x]:= (r shl RShift) or (g shl GShift) or (b shl BShift) or (a shl AShift);
+
+end;
+
+procedure Smooth_oldImpl(X, Y: LongInt);
begin
// a bit of AA for explosions
if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and
@@ -1064,16 +1125,18 @@
end;
end;
-for y:= 0 to LAND_HEIGHT div 32 - 1 do
- for x:= 0 to LAND_WIDTH div 32 - 1 do
- if LandDirty[y, x] <> 0 then
- begin
- ty:= y * 32;
- tx:= x * 32;
- for yy:= ty to ty + 31 do
- for xx:= tx to tx + 31 do
- Smooth(xx,yy)
- end;
+// smooth explosion borders (except if land is blurry)
+if (cReducedQuality and rqBlurryLand) = 0 then
+ for y:= 0 to LAND_HEIGHT div 32 - 1 do
+ for x:= 0 to LAND_WIDTH div 32 - 1 do
+ if LandDirty[y, x] <> 0 then
+ begin
+ ty:= y * 32;
+ tx:= x * 32;
+ for yy:= ty to ty + 31 do
+ for xx:= tx to tx + 31 do
+ Smooth(xx,yy)
+ end;
for y:= 0 to LAND_HEIGHT div 32 - 1 do
for x:= 0 to LAND_WIDTH div 32 - 1 do
--- a/hedgewars/uLandObjects.pas Tue Mar 31 00:15:00 2015 +0200
+++ b/hedgewars/uLandObjects.pas Tue Mar 31 02:30:29 2015 +0200
@@ -553,6 +553,9 @@
c2.g:= t;
c2.b:= t
end;
+ ExplosionBorderColorR:= c2.r;
+ ExplosionBorderColorG:= c2.g;
+ ExplosionBorderColorB:= c2.b;
ExplosionBorderColor:= (c2.r shl RShift) or (c2.g shl GShift) or (c2.b shl BShift) or AMask;
end
else if key = 'water-top' then
--- a/hedgewars/uVariables.pas Tue Mar 31 00:15:00 2015 +0200
+++ b/hedgewars/uVariables.pas Tue Mar 31 02:30:29 2015 +0200
@@ -126,7 +126,10 @@
isAudioMuted : boolean;
// originally typed consts
- ExplosionBorderColor: LongWord;
+ ExplosionBorderColorR,
+ ExplosionBorderColorG,
+ ExplosionBorderColorB,
+ ExplosionBorderColor: LongWord;
IceColor : LongWord;
IceEdgeColor : LongWord;
WaterOpacity: byte;
@@ -2542,6 +2545,9 @@
SDWaterOpacity:= $80;
SDTint:= $80;
+ ExplosionBorderColorR:= 80;
+ ExplosionBorderColorG:= 80;
+ ExplosionBorderColorB:= 80;
ExplosionBorderColor:= $FF808080;
IceColor:= ($44 shl RShift) or ($97 shl GShift) or ($A9 shl BShift) or ($A0 shl AShift);
IceEdgeColor:= ($8A shl RShift) or ($AF shl GShift) or ($B2 shl BShift) or ($FF shl AShift);