equal
deleted
inserted
replaced
1055 end; |
1055 end; |
1056 |
1056 |
1057 function CheckGearNearImpl(Kind: TGearType; X, Y: hwFloat; rX, rY: LongInt, exclude: PGear): PGear; |
1057 function CheckGearNearImpl(Kind: TGearType; X, Y: hwFloat; rX, rY: LongInt, exclude: PGear): PGear; |
1058 begin |
1058 begin |
1059 var t: PGear; |
1059 var t: PGear; |
1060 halfWidth, dX, dY: hwFloat; |
1060 width, halfWidth, dX, dY: hwFloat; |
1061 isHit: Boolean; |
1061 isHit: Boolean; |
1062 begin |
1062 begin |
1063 t:= GearsList; |
1063 t:= GearsList; |
1064 rX:= sqr(rX); |
1064 rX:= sqr(rX); |
1065 rY:= sqr(rY); |
1065 rY:= sqr(rY); |
1066 halfWidth:= int2hwFloat(RightX - LeftX) / _2; |
1066 width:= int2hwFloat(RightX - LeftX); |
|
1067 halfWidth:= width / _2; |
1067 |
1068 |
1068 while t <> nil do |
1069 while t <> nil do |
1069 begin |
1070 begin |
1070 if (t <> exclude) and (t^.Kind = Kind) then |
1071 if (t <> exclude) and (t^.Kind = Kind) then |
1071 begin |
1072 begin |
1073 dY := Y - t^.Y; |
1074 dY := Y - t^.Y; |
1074 isHit := not ((hwSqr(dX) / rX + hwSqr(dY) / rY) > _1); |
1075 isHit := not ((hwSqr(dX) / rX + hwSqr(dY) / rY) > _1); |
1075 |
1076 |
1076 if (not isHit) and (WorldEdge = weWrap) then |
1077 if (not isHit) and (WorldEdge = weWrap) then |
1077 begin |
1078 begin |
1078 if (dX > halfWidth) and (not ((hwSqr(dX - halfWidth) / rX + hwSqr(dY) / rY) > _1)) then |
1079 if (dX > halfWidth) and (not ((hwSqr(dX - width) / rX + hwSqr(dY) / rY) > _1)) then |
1079 isHit := true |
1080 isHit := true |
1080 else if (dX < -halfWidth) and (not ((hwSqr(dX + halfWidth) / rX + hwSqr(dY) / rY) > _1)) then |
1081 else if (dX < -halfWidth) and (not ((hwSqr(dX + width) / rX + hwSqr(dY) / rY) > _1)) then |
1081 isHit := true |
1082 isHit := true |
1082 end; |
1083 end; |
1083 |
1084 |
1084 if isHit then |
1085 if isHit then |
1085 begin |
1086 begin |