trying to eliminate that annoying impact sound for gears that are well under the water and not even exiting it. sheepluva might want to look this over since this is modifying his code and should perhaps be part of the addSplashForGear checks, but hadn't had much luck getting him to examine it past year or so
--- a/hedgewars/uGearsUtils.pas Wed Aug 09 12:22:05 2017 -0400
+++ b/hedgewars/uGearsUtils.pas Wed Aug 09 12:46:52 2017 -0400
@@ -701,7 +701,7 @@
// check if surface was penetrated
// no penetration if center's water distance not smaller than radius
- if abs(dist2Water + Gear^.Radius) >= Gear^.Radius then
+ if ((dist2Water + Gear^.Radius div 2) < 0) or (abs(dist2Water + Gear^.Radius) >= Gear^.Radius) then
isImpact:= false
else
begin
@@ -709,16 +709,19 @@
if isDirH then
begin
tmp:= hwRound(Gear^.X - Gear^.dX);
- tmp:= abs(min(tmp - leftX, rightX - tmp));
+ if abs(tmp - leftX) < abs(tmp - rightX) then // left edge
+ isImpact:= (abs(tmp-leftX) >= Gear^.Radius) and (Gear^.dX.isNegative)
+ else
+ isImpact:= (abs(tmp-rightX) >= Gear^.Radius) and (not Gear^.dX.isNegative);
end
else
begin
tmp:= hwRound(Gear^.Y - Gear^.dY);
tmp:= abs(cWaterLine - tmp);
+ // there was an impact if distance was >= radius
+ isImpact:= (tmp >= Gear^.Radius) and (not Gear^.dY.isNegative);
end;
- // there was an impact if distance was >= radius
- isImpact:= (tmp >= Gear^.Radius)
end;
end; // end of submersible
end; // end of not skipping