summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: af2154f)
raw | patch | inline | side by side (parent: af2154f)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 22 Aug 2017 18:55:55 +0000 (21:55 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 23 Aug 2017 18:23:55 +0000 (21:23 +0300) |
src/game/g_grid.pas | patch | blob | history |
diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 9424278d0dcbc14e55d6c7f8a582ebe8594f6c46..579e5f8dbe90e0b2ba781707e90a54727c58555c 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
// returns `true` if there is an intersection, and enter coords
// enter coords will be equal to (x0, y0) if starting point is inside the box
// if result is `false`, `inx` and `iny` are undefined
-function lineAABBIntersects (x0, y0, x1, y1: Integer; bx, by, bw, bh: Integer; out inx, iny: Integer; log: Boolean=false): Boolean;
-
+function lineAABBIntersects (x0, y0, x1, y1: Integer; bx, by, bw, bh: Integer; out inx, iny: Integer): Boolean;
procedure swapInt (var a: Integer; var b: Integer); inline;
function distanceSq (x0, y0, x1, y1: Integer): Integer; inline;
// returns `true` if there is an intersection, and enter coords
// enter coords will be equal to (x0, y0) if starting point is inside the box
// if result is `false`, `inx` and `iny` are undefined
-function lineAABBIntersects (x0, y0, x1, y1: Integer; bx, by, bw, bh: Integer; out inx, iny: Integer; log: Boolean=false): Boolean;
+function lineAABBIntersects (x0, y0, x1, y1: Integer; bx, by, bw, bh: Integer; out inx, iny: Integer): Boolean;
var
wx0, wy0, wx1, wy1: Integer; // window coordinates
stx, sty: Integer; // "steps" for x and y axes
wx1 := bx+bw-1;
wy1 := by+bh-1;
- if log then e_WriteLog('lineAABBIntersects: 0', MSG_NOTIFY);
// horizontal setup
if (x0 < x1) then
begin
swapInt(wx0, wx1);
end;
- if log then e_WriteLog('lineAABBIntersects: 1', MSG_NOTIFY);
// vertical setup
if (y0 < y1) then
begin
e := 2*dsy-dsx;
term := x1;
- if log then e_WriteLog('lineAABBIntersects: 2', MSG_NOTIFY);
xfixed := false;
if (y0 < wy0) then
begin
end;
end;
- if log then e_WriteLog('lineAABBIntersects: 3', MSG_NOTIFY);
if (not xfixed) and (x0 < wx0) then
begin
// clip at left
if (rem >= dsx) then begin Inc(yd); e -= dx2; end;
end;
- if log then e_WriteLog('lineAABBIntersects: 4', MSG_NOTIFY);
if (y1 > wy1) then
begin
// clip at bottom
if (stx = -1) then begin xd := -xd; term := -term; end;
dx2 -= dy2;
- if log then e_WriteLog('lineAABBIntersects: 5', MSG_NOTIFY);
inx := d0^;
iny := d1^;
result := true;