From 983a3707e9af7ec7aadd245ed3fda5876c6b04c7 Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Fri, 18 Aug 2017 20:07:08 +0300 Subject: [PATCH] cosmetix --- src/game/g_game.pas | 6 +----- src/game/g_map.pas | 6 ++++++ src/game/z_aabbtree.pas | 45 +++++++++++++++++++++++++++++++---------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/game/g_game.pas b/src/game/g_game.pas index a40f7da..27be556 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -5060,11 +5060,7 @@ begin 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 eabf896..b448103 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -2294,6 +2294,12 @@ begin 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 diff --git a/src/game/z_aabbtree.pas b/src/game/z_aabbtree.pas index 852ae85..4f3e993 100644 --- a/src/game/z_aabbtree.pas +++ b/src/game/z_aabbtree.pas @@ -14,8 +14,8 @@ * along with this program. If not, see . *) {$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 @@ -199,7 +199,7 @@ type public {$IFDEF aabbtree_query_count} - nodesVisited, nodesDeepVisited: Integer; + mNodesVisited, mNodesDeepVisited: Integer; {$ENDIF} public @@ -269,6 +269,13 @@ type 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; @@ -1104,7 +1111,7 @@ var bigstack: array of Integer = nil; sp: Integer = 0; - procedure spush (id: Integer); + procedure spush (id: Integer); inline; var xsp: Integer; begin @@ -1133,9 +1140,10 @@ var 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" @@ -1149,6 +1157,7 @@ var result := bigstack[sp-length(stack)]; end; end; + *) var nodeId: Integer; @@ -1158,8 +1167,8 @@ begin //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 @@ -1169,10 +1178,24 @@ begin 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? @@ -1182,7 +1205,7 @@ begin 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; -- 2.29.2