X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=blobdiff_plain;f=src%2Fgame%2Fg_map.pas;h=b2e35c0eb0b3044abc5308cd98354f286651a9c8;hp=730812cdd2e16113909fb57d2e888277aef0a807;hb=422b1bad780adc75cee9edc8ef16092f29181951;hpb=93a1d67a1cb34cb02937559cd0d15194ca80728c diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 730812c..b2e35c0 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -89,8 +89,6 @@ function g_Map_PanelForPID(PanelID: Integer; var PanelArrayID: Integer): PPanel; procedure g_Map_SaveState(Var Mem: TBinMemoryWriter); procedure g_Map_LoadState(Var Mem: TBinMemoryReader); -// build "possibly lit panels" index, so we can avoid looping over all level panels again and again -function g_Map_BuildPLP (ltminx, ltminy, ltmaxx, ltmaxy: Integer): Boolean; // returns `false` if no patels lit procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer); const @@ -1912,67 +1910,23 @@ begin end; end; -var - plpset: array of Integer = nil; // potentially lit panels - plpcount: Integer; // to avoid constant reallocations - -function g_Map_BuildPLP (ltminx, ltminy, ltmaxx, ltmaxy: Integer): Boolean; -var - idx: Integer; - panels: TPanelArray; -begin - panels := gWalls; - plpcount := 0; - if (ltminx < ltmaxx) and (ltminy < ltmaxy) then - begin - if panels <> nil then - begin - for idx := 0 to High(panels) do - begin - if (panels[idx].Width < 1) or (panels[idx].Height < 1) then continue; - if (panels[idx].X+panels[idx].Width <= ltminx) then continue; - if (panels[idx].Y+panels[idx].Height <= ltminy) then continue; - if (panels[idx].X > ltmaxx) then continue; - if (panels[idx].Y > ltmaxy) then continue; - if plpcount = length(plpset) then SetLength(plpset, plpcount+32768); - plpset[plpcount] := idx; - Inc(plpcount); - end; - //e_WriteLog(Format('%d panels left out of %d', [plpcount, Length(panels)]), MSG_NOTIFY); - end; - end; - result := (plpcount > 0); -end; procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer); - - (* old - procedure drawPanels (var panels: TPanelArray); + function qq (obj: TObject; tag: Integer): Boolean; var - a: Integer; + pan: TPanel; begin - if panels <> nil then - begin - for a := 0 to High(panels) do - begin - panels[a].DrawShadowVolume(lightX, lightY, radius); - end; - end; + result := false; // don't stop, ever + if (tag <> PANEL_WALL) then exit; // only walls + pan := (obj as TPanel); + pan.DrawShadowVolume(lightX, lightY, radius); end; - *) -var - idx: Integer; + begin - (* - drawPanels(gWalls); - //drawPanels(gRenderForegrounds); - *) - for idx := 0 to plpcount-1 do - begin - gWalls[plpset[idx]].DrawShadowVolume(lightX, lightY, radius); - end; + gMapGrid.forEachInAABB(lightX-radius, lightY-radius, radius*2, radius*2, qq); end; + procedure g_Map_DrawBack(dx, dy: Integer); begin if gDrawBackGround and (BackID <> DWORD(-1)) then