summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 10658b9)
raw | patch | inline | side by side (parent: 10658b9)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 19 Aug 2017 12:20:45 +0000 (15:20 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 19 Aug 2017 13:28:00 +0000 (16:28 +0300) |
src/game/g_grid.pas | patch | blob | history | |
src/game/g_map.pas | patch | blob | history | |
src/game/z_aabbtree.pas | patch | blob | history |
diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 3ed66124c29bdcf9d725e8812fa0f634895e3ba1..5b2f8b135d27583c5a849aaec6ab3e46f5d4ef7e 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
GridCellBucketSize = 8; // WARNING! can't be less than 2!
type
- GridQueryCB = function (obj: TObject; var proxy: PBodyProxyRec; tag: Integer): Boolean is nested; // return `true` to stop
+ TGridQueryCB = function (obj: TObject; objx, objy, objw, objh: Integer; tag: Integer): Boolean is nested; // return `true` to stop
type
TBodyGrid = class;
procedure resizeBody (body: TBodyProxy; sx, sy: Integer);
procedure moveResizeBody (body: TBodyProxy; dx, dy, sx, sy: Integer);
- function forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB; tagmask: Integer=-1): Boolean;
+ function forEachInAABB (x, y, w, h: Integer; cb: TGridQueryCB; tagmask: Integer=-1): Boolean;
//function getProxyForBody (aObj: TObject; x, y, w, h: Integer): TBodyProxy;
end;
-function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB; tagmask: Integer=-1): Boolean;
+function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: TGridQueryCB; tagmask: Integer=-1): Boolean;
function iterator (grida: Integer): Boolean;
var
idx: Integer;
@@ -474,7 +474,7 @@ function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB; tagmask:
begin
//e_WriteLog(Format(' query #%d body hit: (%d,%d)-(%dx%d) tag:%d', [mLastQuery, mCells[idx].body.mX, mCells[idx].body.mY, mCells[idx].body.mWidth, mCells[idx].body.mHeight, mCells[idx].body.mTag]), MSG_NOTIFY);
px.mQueryMark := mLastQuery;
- if (cb(px.mObj, px.mTag)) then begin result := true; exit; end;
+ if (cb(px.mObj, px.mX, px.mY, px.mWidth, px.mHeight, px.mTag)) then begin result := true; exit; end;
end;
end;
idx := pi.next;
@@ -486,7 +486,7 @@ function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB; tagmask:
begin
//e_WriteLog(Format(' query #%d body hit: (%d,%d)-(%dx%d) tag:%d', [mLastQuery, mCells[idx].body.mX, mCells[idx].body.mY, mCells[idx].body.mWidth, mCells[idx].body.mHeight, mCells[idx].body.mTag]), MSG_NOTIFY);
px.mQueryMark := mLastQuery;
- if (cb(px.mObj, px.mTag)) then begin result := true; exit; end;
+ if (cb(px.mObj, px.mX, px.mY, px.mWidth, px.mHeight, px.mTag)) then begin result := true; exit; end;
end;
end;
idx := mCells[idx].next;
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index dd2f455ec38d17a4e668c4fed1339083710f4da2..85d551047d36f4b5d0bb2980e4e18f91f5a7da72 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
// new algo
procedure g_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer);
- function checker (obj: TObject; ; var proxy: PBodyProxyRectag: Integer): Boolean;
+ function checker (obj: TObject; objx, objy, objw, objh: Integer; tag: Integer): Boolean;
var
pan: TPanel;
begin
procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer);
- function checker (obj: TObject; ; var proxy: PBodyProxyRectag: Integer): Boolean;
+ function checker (obj: TObject; objx, objy, objw, objh: Integer; tag: Integer): Boolean;
var
pan: TPanel;
begin
function g_Map_CollidePanel(X, Y: Integer; Width, Height: Word; PanelType: Word; b1x3: Boolean): Boolean;
- function checker (obj: TObject; ; var proxy: PBodyProxyRectag: Integer): Boolean;
+ function checker (obj: TObject; objx, objy, objwidth, objheight: Integer; tag: Integer): Boolean;
var
pan: TPanel;
begin
@@ -2159,16 +2159,16 @@ function g_Map_CollidePanel(X, Y: Integer; Width, Height: Word; PanelType: Word;
(WordBool(PanelType and (PANEL_LIFTDOWN)) and (pan.LiftType = 1)) or
(WordBool(PanelType and (PANEL_LIFTLEFT)) and (pan.LiftType = 2)) or
(WordBool(PanelType and (PANEL_LIFTRIGHT)) and (pan.LiftType = 3))) and
- g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height) then
+ g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight) then
begin
result := true;
exit;
end;
end;
- if ((pan.tag and GridTagBlockMon) <> 0) then
+ if ((tag and GridTagBlockMon) <> 0) then
begin
- if ((not b1x3) or (pan.Width+pan.Height >= 64)) and g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height) then
+ if ((not b1x3) or (objwidth+objheight >= 64)) and g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight) then
begin
result := True;
exit;
@@ -2176,7 +2176,7 @@ function g_Map_CollidePanel(X, Y: Integer; Width, Height: Word; PanelType: Word;
end;
// other shit
- result := g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height);
+ result := g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight);
end;
var
texid: DWORD;
// slightly different from the old code, but meh...
- function checker (obj: TObject; tag: Integer): Boolean;
- var
- pan: TPanel;
+ function checker (obj: TObject; objx, objy, objwidth, objheight: Integer; tag: Integer): Boolean;
+ //var pan: TPanel;
begin
result := false; // don't stop, ever
if ((tag and (GridTagWater or GridTagAcid1 or GridTagAcid2)) = 0) then exit;
- //pan := (obj as TPanel);
- pan := TPanel(obj);
// check priorities
case cctype of
0: if ((tag and GridTagWater) = 0) then exit; // only water
//2: if ((tag and (GridTagWater or GridTagAcid1 or GridTagAcid2) = 0) then exit; // water, acid1, acid2
end;
// collision?
- if not g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height) then exit;
+ if not g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight) then exit;
// yeah
- texid := pan.GetTextureID();
+ //pan := (obj as TPanel);
+ texid := TPanel(obj).GetTextureID();
// water? water has the highest priority, so stop right here
if ((tag and GridTagWater) <> 0) then begin cctype := 0; result := true; exit; end;
// acid2
index 7d346de06fce48d5c5529bc6dd478c7fccf06b15..31b6dd41969aff815aa266d296d7142154251dc2 100644 (file)
--- a/src/game/z_aabbtree.pas
+++ b/src/game/z_aabbtree.pas
interface
-uses e_log;
+uses
+ e_log, g_grid;
// ////////////////////////////////////////////////////////////////////////// //
public
// called when a overlapping node has been found during the call to forEachAABBOverlap()
// return `true` to stop
- type TQueryOverlapCB = function (abody: TTreeFlesh; atag: Integer): Boolean is nested;
+ type TQueryOverlapCB = function (abody: TTreeFlesh; objx, objy, objw, objh: Integer; atag: Integer): Boolean is nested;
type TSegQueryCallback = function (abody: TTreeFlesh; ax, ay, bx, by: Single): Single is nested; // return dist from (ax,ay) to abody
TSegmentQueryResult = record
{$IFDEF aabbtree_query_count}Inc(mNodesDeepVisited);{$ENDIF}
if ((node.tag and tagmask) <> 0) then
begin
- if (visitor(node.flesh, node.tag)) then begin result := nodeId; bigstack := nil; exit; end;
+ if (visitor(node.flesh, node.aabb.minX, node.aabb.minY, node.aabb.maxX, node.aabb.maxY, node.tag)) then begin result := nodeId; bigstack := nil; exit; end;
end;
end
else
@@ -1457,7 +1458,7 @@ function TDynAABBTree.pointQuery (ax, ay: TreeNumber; cb: TQueryOverlapCB): TTre
begin
result := node.aabb.contains(ax, ay);
end;
- function dummycb (abody: TTreeFlesh; atag: Integer): Boolean; begin result := false; end;
+ function dummycb (abody: TTreeFlesh; objx, objy, objw, objh: Integer; atag: Integer): Boolean; begin result := false; end;
var
nid: Integer;
caabb: AABB2D;
result := node.aabb.intersects(curax, curay, curbx, curby);
end;
- function visitor (flesh: TTreeFlesh; tag: Integer): Boolean;
+ function visitor (flesh: TTreeFlesh; objx, objy, objw, objh: Integer; tag: Integer): Boolean;
var
hitFraction: Single;
begin