some more splash code tweaking/fixing
authorsheepluva
Thu, 02 Oct 2014 00:06:59 +0200
changeset 10419 e19a864e2fab
parent 10417 8f66bb4dbf80
child 10421 87e47843018e
some more splash code tweaking/fixing
hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsUtils.pas	Wed Oct 01 22:46:58 2014 +0200
+++ b/hedgewars/uGearsUtils.pas	Thu Oct 02 00:06:59 2014 +0200
@@ -364,16 +364,12 @@
     speed, hwTmp: hwFloat;
     vi, vs, tmp: real; // impact speed and sideways speed
     isImpactH, isImpactRight: boolean;
-const dist2surf = 6;
+const dist2surf = 4;
 begin
 x:= hwRound(Gear^.X);
 y:= hwRound(Gear^.Y);
 
-splash:= AddVisualGear(x, y, vgtSplash);
-if splash = nil then
-    exit;
-
-// correct position and angle
+// find position for splash and impact speed
 
 distB:= cWaterline - y;
 
@@ -391,30 +387,18 @@
 if not isImpactH then
     begin
     y:= cWaterline - dist2surf;
-    splash^.Y:= y;
     speed:= hwAbs(Gear^.dY);
-    vs:= abs(hwFloat2Float(Gear^.dX));
     end
 else
     begin
     isImpactRight := minDist = distR;
     if isImpactRight then
-        begin
-        x := rightX - dist2surf;;
-        splash^.Angle:= -90;
-        end
+        x:= rightX - dist2surf
     else
-        begin
-        x := leftX + dist2surf;;
-        splash^.Angle:=  90;
-        end;
-    splash^.X:= x;
+        x:= leftX + dist2surf;
     speed:= hwAbs(Gear^.dX);
-    vs:= abs(hwFloat2Float(Gear^.dY));
     end;
 
-vi:= hwFloat2Float(speed);
-
 // splash sound
 
 if justSkipping then
@@ -432,6 +416,30 @@
         PlaySound(sndDroplet2);
     end;
 
+
+// splash visuals
+
+if ((cReducedQuality and rqPlainSplash) <> 0) then
+    exit;
+
+splash:= AddVisualGear(x, y, vgtSplash);
+if splash = nil then
+    exit;
+
+if not isImpactH then
+    vs:= abs(hwFloat2Float(Gear^.dX))
+else
+    begin
+    if isImpactRight then
+        splash^.Angle:= -90
+    else
+        splash^.Angle:=  90;
+    vs:= abs(hwFloat2Float(Gear^.dY));
+    end;
+
+
+vi:= hwFloat2Float(speed);
+
 with splash^ do
     begin
     Scale:= abs(hwFloat2Float(Gear^.Density / _3 * speed));
@@ -596,7 +604,7 @@
                         end
                     else
                         DrownGear(Gear);
-                    if (dist2Water < -1) or (Gear^.Kind = gtFlake) then
+                    if Gear^.Kind = gtFlake then
                         exit(true); // skip splashes
                 end
             else // submersible
@@ -629,8 +637,8 @@
                         tmp:= abs(cWaterLine - tmp);
                         end;
 
-                    // there was an impact if distance was same as radius
-                    isImpact:= (tmp = Gear^.Radius)
+                    // there was an impact if distance was >= radius
+                    isImpact:= (tmp >= Gear^.Radius)
                     end;
                 end; // end of submersible
             end; // end of not skipping