# HG changeset patch # User unc0rr # Date 1391719671 -14400 # Node ID 794af93397269fe96d2738f24111b9e8c40aa7f3 # Parent b26c2772e754d143189b544a814850a412e29184# Parent 68a72af636c305bcb1986e498ef92ba26fb588a7 Merge diff -r b26c2772e754 -r 794af9339726 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Fri Feb 07 00:46:49 2014 +0400 +++ b/hedgewars/uFloat.pas Fri Feb 07 00:47:51 2014 +0400 @@ -84,7 +84,6 @@ function hwRound(const t: hwFloat): LongInt; inline; // Does NOT really round but returns the integer representation of the hwFloat without fractional digits. (-_0_9 -> -0, _1_5 -> _1) function hwAbs(const t: hwFloat): hwFloat; inline; // Returns the value of t with positive sign. function hwSqr(const t: hwFloat): hwFloat; inline; // Returns the square value of parameter t. -function hwPow(const t: hwFloat; p: LongWord): hwFloat; inline; // Returns the power of the value function hwSqrt1(const t: hwFloat): hwFloat; inline; // Returns the the positive square root of parameter t. function hwSqrt(const x: hwFloat): hwFloat; inline; // Returns the the positive square root of parameter t. function Distance(const dx, dy: hwFloat): hwFloat; // Returns the distance between two points in 2-dimensional space, of which the parameters are the horizontal and vertical distance. @@ -369,18 +368,6 @@ hwSqr.QWordValue:= ((QWord(t.Round) * t.Round) shl 32) + QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32); end; -function hwPow(const t: hwFloat;p: LongWord): hwFloat; -begin - hwPow:= t; - if p mod 2 = 0 then hwPow.isNegative:= false; - - while p > 0 do - begin - hwPow.QWordValue:= QWord(hwPow.Round) * t.Frac + QWord(hwPow.Frac) * t.Round + ((QWord(hwPow.Frac) * t.Frac) shr 32); - dec(p) - end -end; - function hwSqrt1(const t: hwFloat): hwFloat; const pwr = 8; // even value, feel free to adjust rThreshold = 1 shl (pwr + 32); diff -r b26c2772e754 -r 794af9339726 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Fri Feb 07 00:46:49 2014 +0400 +++ b/hedgewars/uGearsHandlersMess.pas Fri Feb 07 00:47:51 2014 +0400 @@ -3323,15 +3323,15 @@ begin if WorldWrap(Gear) then begin - if (WorldEdge = weBounce) then // mirror - Gear^.Angle:= 4096 - Gear^.Angle - else if (WorldEdge = weSea) then // rotate 90 degree - begin - // sea-wrapped gears move upwards, so let's mirror angle if needed - if Gear^.Angle < 2048 then - Gear^.Angle:= 4096 - Gear^.Angle; - Gear^.Angle:= (Gear^.Angle + 1024) mod 4096; - end; + if (WorldEdge = weBounce) then // mirror + Gear^.Angle:= 4096 - Gear^.Angle + else if (WorldEdge = weSea) then // rotate 90 degree + begin + // sea-wrapped gears move upwards, so let's mirror angle if needed + if Gear^.Angle < 2048 then + Gear^.Angle:= 4096 - Gear^.Angle; + Gear^.Angle:= (Gear^.Angle + 1024) mod 4096; + end; end; AllInactive := false; @@ -4171,21 +4171,7 @@ // is it worth adding an arcsin table? Just how often would we end up doing something like this? // SYNCED ANGLE UPDATE if iterator^.Kind = gtRCPlane then - begin - // recycling as temp vars - resety.isNegative:= false; - resety.QWordValue:= 4294967296 * 112; - resetx.isNegative:= false; - resetx.QWordValue:= 4294967296 * 35; - resetdx.isNegative:= false; - resetdx.QWordValue:= 4294967296 * 1152; - - resetdy:=hwAbs(iterator^.dX*4); - resetdy:= resetdy + hwPow(resetdy,3)/_6 + _3 * hwPow(resetdy,5) / _40 + _5 * hwPow(resetdy,7) / resety + resetx * hwPow(resetdy,9) / resetdx; - iterator^.Angle:= hwRound(resetdy*_2048 / _PI); - if not iterator^.dY.isNegative then iterator^.Angle:= 2048-iterator^.Angle; - if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle; - end + iterator^.Angle:= (1024 + vector2Angle(iterator^.dX, iterator^.dY) mod 4096) // VISUAL USE OF ANGLE ONLY else if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtKamikaze) and (CurAmmoGear^.Hedgehog = iterator^.Hedgehog) then begin