hedgewars/uGearsHandlersMess.pas
changeset 10112 275ad81e4718
parent 10110 a7aed2eea727
child 10118 788703011d20
equal deleted inserted replaced
10110:a7aed2eea727 10112:275ad81e4718
  3321     trueAngle: Longword;
  3321     trueAngle: Longword;
  3322     t: PGear;
  3322     t: PGear;
  3323 begin
  3323 begin
  3324     if WorldWrap(Gear) then
  3324     if WorldWrap(Gear) then
  3325         begin
  3325         begin
  3326             if (WorldEdge = weBounce) then // mirror
  3326         if (WorldEdge = weBounce) then // mirror
  3327                 Gear^.Angle:= 4096 - Gear^.Angle
  3327             Gear^.Angle:= 4096 - Gear^.Angle
  3328             else if (WorldEdge = weSea) then // rotate 90 degree
  3328         else if (WorldEdge = weSea) then // rotate 90 degree
  3329                 begin
  3329             begin
  3330                 // sea-wrapped gears move upwards, so let's mirror angle if needed
  3330             // sea-wrapped gears move upwards, so let's mirror angle if needed
  3331                 if Gear^.Angle < 2048 then
  3331             if Gear^.Angle < 2048 then
  3332                     Gear^.Angle:= 4096 - Gear^.Angle;
  3332                 Gear^.Angle:= 4096 - Gear^.Angle;
  3333                 Gear^.Angle:= (Gear^.Angle + 1024) mod 4096;
  3333             Gear^.Angle:= (Gear^.Angle + 1024) mod 4096;
  3334                 end;
  3334             end;
  3335         end;
  3335         end;
  3336     AllInactive := false;
  3336     AllInactive := false;
  3337 
  3337 
  3338     HHGear := Gear^.Hedgehog^.Gear;
  3338     HHGear := Gear^.Hedgehog^.Gear;
  3339     FollowGear := Gear;
  3339     FollowGear := Gear;
  4169             end;
  4169             end;
  4170 
  4170 
  4171         // is it worth adding an arcsin table?  Just how often would we end up doing something like this?
  4171         // is it worth adding an arcsin table?  Just how often would we end up doing something like this?
  4172         // SYNCED ANGLE UPDATE
  4172         // SYNCED ANGLE UPDATE
  4173         if iterator^.Kind = gtRCPlane then
  4173         if iterator^.Kind = gtRCPlane then
  4174             begin
  4174             iterator^.Angle:= (1024 + vector2Angle(iterator^.dX, iterator^.dY) mod 4096)
  4175             // recycling as temp vars
       
  4176             resety.isNegative:= false;
       
  4177             resety.QWordValue:= 4294967296 * 112;
       
  4178             resetx.isNegative:= false;
       
  4179             resetx.QWordValue:= 4294967296 * 35;
       
  4180             resetdx.isNegative:= false;
       
  4181             resetdx.QWordValue:= 4294967296 * 1152;
       
  4182 
       
  4183             resetdy:=hwAbs(iterator^.dX*4);
       
  4184             resetdy:= resetdy + hwPow(resetdy,3)/_6 + _3 * hwPow(resetdy,5) / _40 + _5 * hwPow(resetdy,7) / resety + resetx * hwPow(resetdy,9) / resetdx;
       
  4185             iterator^.Angle:= hwRound(resetdy*_2048 / _PI);
       
  4186             if not iterator^.dY.isNegative then iterator^.Angle:= 2048-iterator^.Angle;
       
  4187             if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle;
       
  4188             end
       
  4189         // VISUAL USE OF ANGLE ONLY
  4175         // VISUAL USE OF ANGLE ONLY
  4190         else if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtKamikaze) and (CurAmmoGear^.Hedgehog = iterator^.Hedgehog) then
  4176         else if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtKamikaze) and (CurAmmoGear^.Hedgehog = iterator^.Hedgehog) then
  4191             begin
  4177             begin
  4192             iterator^.Angle:= DxDy2AttackAngle(iterator^.dX, iterator^.dY);
  4178             iterator^.Angle:= DxDy2AttackAngle(iterator^.dX, iterator^.dY);
  4193             iterator^.Angle:= 2048-iterator^.Angle;
  4179             iterator^.Angle:= 2048-iterator^.Angle;