summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 28bf5df)
raw | patch | inline | side by side (parent: 28bf5df)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 18 Aug 2017 17:07:08 +0000 (20:07 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 18 Aug 2017 18:29:44 +0000 (21:29 +0300) |
src/game/g_game.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_game.pas b/src/game/g_game.pas
index a40f7da9c871b521aa31623d194307c86ee83d83..27be5565fddf4ec4b0bd7b49729757dba8c46b1b 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
if (cmd = 'sq_use_grid') or (cmd = 'sq_use_tree') then
begin
- case getBool(1) of
- -1: begin end;
- 0: gdbg_map_use_tree_coldet := (cmd = 'sq_use_grid');
- 1: gdbg_map_use_tree_coldet := (cmd = 'sq_use_tree');
- end;
+ gdbg_map_use_tree_coldet := (cmd = 'sq_use_tree');
if gdbg_map_use_tree_coldet then g_Console_Add('coldet: tree') else g_Console_Add('coldet: grid');
exit;
end;
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index eabf89645796ad273a1a78531c031497a40b3772..b448103ab23601f6630d783d284ddf516f54675a 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
if gdbg_map_use_tree_coldet then
begin
result := mapTree.aabbQuery(X, Y, Width, Height, checkerTree);
+ {
+ if (mapTree.nodesVisited <> 0) then
+ begin
+ e_WriteLog(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited]), MSG_NOTIFY);
+ end;
+ }
end
else
begin
index 852ae85907aef43276c003fe6b74bfbb9aa20ab7..4f3e9938c0fe9c5f5acb617621a6242e890a5983 100644 (file)
--- a/src/game/z_aabbtree.pas
+++ b/src/game/z_aabbtree.pas
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
{$INCLUDE ../shared/a_modes.inc}
-{$DEFINE aabbtree_many_asserts}
-{$DEFINE aabbtree_query_count}
+{.$DEFINE aabbtree_many_asserts}
+{.$DEFINE aabbtree_query_count}
unit z_aabbtree;
interface
public
{$IFDEF aabbtree_query_count}
- nodesVisited, nodesDeepVisited: Integer;
+ mNodesVisited, mNodesDeepVisited: Integer;
{$ENDIF}
public
property extraGap: Float read mExtraGap write mExtraGap;
property nodeCount: Integer read mNodeCount;
property nodeAlloced: Integer read mAllocCount;
+ {$IFDEF aabbtree_query_count}
+ property nodesVisited: Integer read mNodesVisited;
+ property nodesDeepVisited: Integer read mNodesDeepVisited;
+ {$ELSE}
+ const nodesVisited = 0;
+ const nodesDeepVisited = 0;
+ {$ENDIF}
end;
bigstack: array of Integer = nil;
sp: Integer = 0;
- procedure spush (id: Integer);
+ procedure spush (id: Integer); inline;
var
xsp: Integer;
begin
end;
end;
- function spop (): Integer;
+ (*
+ function spop (): Integer; inline;
begin
- assert(sp > 0);
+ {$IFDEF aabbtree_many_asserts}assert(sp > 0);{$ENDIF}
if (sp <= length(stack)) then
begin
// use "small stack"
result := bigstack[sp-length(stack)];
end;
end;
+ *)
var
nodeId: Integer;
//if not assigned(visitor) then begin result := -1; exit; end;
try
{$IFDEF aabbtree_query_count}
- nodesVisited := 0;
- nodesDeepVisited := 0;
+ mNodesVisited := 0;
+ mNodesDeepVisited := 0;
{$ENDIF}
// start from root node
while (sp > 0) do
begin
// get the next node id to visit
- nodeId := spop();
+ //nodeId := spop();
+ {$IFDEF aabbtree_many_asserts}assert(sp > 0);{$ENDIF}
+ if (sp <= length(stack)) then
+ begin
+ // use "small stack"
+ Dec(sp);
+ nodeId := stack[sp];
+ end
+ else
+ begin
+ // use "big stack"
+ Dec(sp);
+ nodeId := bigstack[sp-length(stack)];
+ end;
+
// skip it if it is a nil node
if (nodeId = TTreeNode.NullTreeNode) then continue;
- {$IFDEF aabbtree_query_count}Inc(nodesVisited);{$ENDIF}
+ {$IFDEF aabbtree_query_count}Inc(mNodesVisited);{$ENDIF}
// get the corresponding node
node := @mNodes[nodeId];
// should we investigate this node?
if (node.leaf) then
begin
// call visitor on it
- {$IFDEF aabbtree_query_count}Inc(nodesDeepVisited);{$ENDIF}
+ {$IFDEF aabbtree_query_count}Inc(mNodesDeepVisited);{$ENDIF}
if assigned(visitor) then
begin
if (visitor(node.flesh)) then begin result := nodeId; exit; end;