X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_map.pas;h=b5e457cdc197ecdde00cc5731d2090aaa2968e96;hb=5f3074c27e9576753fe1099858cd0a4e022e6f54;hp=3a97ef4586b2b6572e1a68dff275d0d00f34114d;hpb=46bfd9c48fe4cb640e507ceb88116eb2396579fa;p=d2df-sdl.git diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 3a97ef4..b5e457c 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -134,10 +134,11 @@ var BackID: DWORD = DWORD(-1); gExternalResources: TStringList; - gdbg_map_use_grid_render: Boolean = true; - gdbg_map_use_grid_coldet: Boolean = true; - gdbg_map_use_tree_draw: Boolean = true; + gdbg_map_use_accel_render: Boolean = true; + gdbg_map_use_accel_coldet: Boolean = true; + gdbg_map_use_tree_draw: Boolean = false; gdbg_map_use_tree_coldet: Boolean = false; + gdbg_map_dump_coldet_tree_queries: Boolean = false; profMapCollision: TProfiler = nil; //WARNING: FOR DEBUGGING ONLY! implementation @@ -200,10 +201,14 @@ function TDynAABBTreeMap.getFleshAABB (var aabb: AABB2D; flesh: TTreeFlesh): Boo var pan: TPanel; begin - if (flesh = nil) then begin result := false; exit; end; + result := false; + if (flesh = nil) then begin aabb := AABB2D.Create(0, 0, 0, 0); exit; end; pan := (flesh as TPanel); aabb := AABB2D.Create(pan.X, pan.Y, pan.X+pan.Width, pan.Y+pan.Height); - //e_WriteLog(Format('getFleshAABB(%d;%d) AABB:(%f,%f)-(%f,%f); valid=%d; volume=%f; x=%d; y=%d; w=%d; h=%d', [pan.tag, pan.ArrIdx, aabb.minX, aabb.minY, aabb.maxX, aabb.maxY, Integer(aabb.valid), aabb.volume, pan.X, pan.Y, pan.Width, pan.Height]), MSG_NOTIFY); + if (pan.Width < 1) or (pan.Height < 1) then exit; + //if (pan.Width = 1) then aabb.maxX += 1; + //if (pan.Height = 1) then aabb.maxY += 1; + if not aabb.valid then raise Exception.Create('wutafuuuuuuu?!'); result := aabb.valid; end; @@ -1944,7 +1949,7 @@ begin dplClear(); ptag := panelTypeToTag(PanelType); - if gdbg_map_use_grid_render then + if gdbg_map_use_accel_render then begin if gdbg_map_use_tree_draw then begin @@ -1952,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 @@ -1998,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; @@ -2259,21 +2264,20 @@ begin //TODO: detailed profile if (profMapCollision <> nil) then profMapCollision.sectionBeginAccum('wall coldet'); try - if gdbg_map_use_grid_coldet then + if gdbg_map_use_accel_coldet then begin if gdbg_map_use_tree_coldet then begin result := (mapTree.aabbQuery(X, Y, Width, Height, checker, (GridTagWallDoor or GridTagWater or GridTagAcid1 or GridTagAcid2 or GridTagStep or GridTagLift or GridTagBlockMon)) <> nil); - { - if (mapTree.nodesVisited <> 0) then + if (gdbg_map_dump_coldet_tree_queries) and (mapTree.nodesVisited <> 0) then begin - e_WriteLog(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited]), MSG_NOTIFY); + //e_WriteLog(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited]), MSG_NOTIFY); + g_Console_Add(Format('map collision: %d nodes visited (%d deep)', [mapTree.nodesVisited, mapTree.nodesDeepVisited])); end; - } 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 @@ -2333,33 +2337,20 @@ var end; end; -{var - cctype1: Integer = 3; // priority: 0: water, 1: acid1, 2: acid2; 3: others (nothing) - texid1: DWORD;} begin //TODO: detailed profile? if (profMapCollision <> nil) then profMapCollision.sectionBeginAccum('liquid coldet'); try - if gdbg_map_use_grid_coldet then + if gdbg_map_use_accel_coldet then begin texid := TEXTURE_NONE; if gdbg_map_use_tree_coldet then begin - mapTree.aabbQuery(X, Y, Width, Height, checker); - { - cctype1 := cctype; - texid1 := texid; - cctype := 3; - texid := TEXTURE_NONE; - gMapGrid.forEachInAABB(X, Y, Width, Height, checker); - if (cctype1 <> cctype) or (texid1 <> texid) then - begin - e_WriteLog(Format('g_Map_CollideLiquid_Texture(%d, %d, %u, %u): tree(cctype:%d;texid:%u); grid(cctype:%d;texid:%u)', [X, Y, Width, Height, cctype1, texid1, cctype, texid]), MSG_WARNING); - end;} + mapTree.aabbQuery(X, Y, Width, Height, checker, (GridTagWater or GridTagAcid1 or GridTagAcid2)); 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