From: Ketmar Dark Date: Fri, 18 Aug 2017 19:13:09 +0000 (+0300) Subject: added small speedup trick to gird (tree already has it) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=4b95088afdbc806bdcb9b681e2abf0e3fcf11f40;p=d2df-sdl.git added small speedup trick to gird (tree already has it) --- diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas index 56d8ecb..0fbbae7 100644 --- a/src/game/g_grid.pas +++ b/src/game/g_grid.pas @@ -102,7 +102,7 @@ type 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): Boolean; + function forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB; tagmask: Integer=-1): Boolean; function getProxyForBody (aObj: TObject; x, y, w, h: Integer): TBodyProxy; @@ -401,7 +401,7 @@ begin end; -function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB): Boolean; +function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB; tagmask: Integer=-1): Boolean; function iterator (grida: Integer): Boolean; var idx: Integer; @@ -414,7 +414,7 @@ function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: GridQueryCB): Boolean if (mCells[idx].body <> -1) then begin px := @mProxies[mCells[idx].body]; - if (px.mQueryMark <> mLastQuery) then + if (px.mQueryMark <> mLastQuery) and ((px.mTag and tagmask) <> 0) then 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; diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 7334c3e..0e5dd09 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -1957,7 +1957,7 @@ begin end else begin - gMapGrid.forEachInAABB(x0, y0, wdt, hgt, checker); + gMapGrid.forEachInAABB(x0, y0, wdt, hgt, checker, ptag); end; // sort and draw the list (we need to sort it, or rendering is fucked) while gDrawPanelList.count > 0 do @@ -2003,7 +2003,7 @@ begin end else begin - gMapGrid.forEachInAABB(lightX-radius, lightY-radius, radius*2, radius*2, checker); + gMapGrid.forEachInAABB(lightX-radius, lightY-radius, radius*2, radius*2, checker, GridTagWallDoor); end; end; @@ -2277,7 +2277,7 @@ begin end else begin - result := gMapGrid.forEachInAABB(X, Y, Width, Height, checker); + result := gMapGrid.forEachInAABB(X, Y, Width, Height, checker, (GridTagWallDoor or GridTagWater or GridTagAcid1 or GridTagAcid2 or GridTagStep or GridTagLift or GridTagBlockMon)); end; end else @@ -2349,7 +2349,7 @@ begin texid := TEXTURE_NONE; if gdbg_map_use_tree_coldet then begin - mapTree.aabbQuery(X, Y, Width, Height, checker); + mapTree.aabbQuery(X, Y, Width, Height, checker, (GridTagWater or GridTagAcid1 or GridTagAcid2)); { cctype1 := cctype; texid1 := texid; @@ -2363,7 +2363,7 @@ begin end else begin - gMapGrid.forEachInAABB(X, Y, Width, Height, checker); + gMapGrid.forEachInAABB(X, Y, Width, Height, checker, (GridTagWater or GridTagAcid1 or GridTagAcid2)); end; result := texid; end